forked from KLIM8D/checkRunning-bash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckRunning.sh
executable file
·79 lines (71 loc) · 1.76 KB
/
checkRunning.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
# Author: Morten Klim Sørensen
# Created: 2011 Oct 12
# Filename: checkRunning.sh
# Description: Check if SERVICE or SERVICE 2 are running and fire some commands if one of them are.
# It was made for using the same mediakeys for spotify and banshee.
SERVICE='spotify'
SERVICE2='Banshee.exe'
function quit_message
{
echo "Usage: `basename $0` {play|pause|playpause|next|previous|stop}"
exit 1
}
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
case "$1" in
play)
sh ~/Scripts/spotify-remote.sh play
;;
pause)
sh ~/Scripts/spotify-remote.sh pause
;;
playpause)
sh ~/Scripts/spotify-remote.sh playpause
;;
next)
sh ~/Scripts/spotify-remote.sh next
;;
previous)
sh ~/Scripts/spotify-remote.sh previous
;;
stop)
sh ~/Scripts/spotify-remote.sh stop
;;
*)
echo -e "Bad argument.\n"
quit_message
;;
esac
else
echo "$SERVICE is not running"
if ps ax | grep -v grep | grep $SERVICE2 > /dev/null
then
case "$1" in
play)
banshee --play
;;
pause)
banshee --pause
;;
playpause)
banshee --toggle-playing
;;
next)
banshee --next
;;
previous)
banshee --restart-or-previous
;;
stop)
banshee --stop
;;
*)
echo -e "Bad argument.\n"
quit_message
;;
esac
else
echo "$SERVICE2 is not running"
fi
fi