forked from shividhar/Remotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremotify.sh
executable file
·83 lines (69 loc) · 2.11 KB
/
remotify.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
80
81
82
83
##### Initialization ######
trap 'kill $(jobs -p)' EXIT
sh playerData.sh &
if pgrep -x 'Spotify' &> /dev/null; then
currentApp="Spotify"
elif pgrep -x 'iTunes' &> /dev/null; then
currentApp="iTunes"
fi
###########################
function readIn
{
read -e STR < /dev/cu.usbmodem0E2198D1;
}
while true
do
readIn 2> /dev/null
if pgrep -x 'Spotify' &> /dev/null; then
currentApp="Spotify"
elif pgrep -x 'iTunes' &> /dev/null; then
currentApp="iTunes"
fi
case "${STR:0:1}" in
a) #playpause toggle
osascript -e 'tell application "'$currentApp'" to playpause';;
b) #next track
osascript -e 'tell application "'$currentApp'" to play next track';;
c) #previous track
osascript -e 'tell application "'$currentApp'" to play previous track';;
d) #turn repeat on
if [ "$currentApp" = "Spotify" ]
then
osascript -e 'tell application "Spotify" to set repeating to true'
elif [ "$currentApp" = "iTunes" ]
then
osascript -e 'tell application "iTunes" to set song repeat to all'
fi;;
e) #turn repeat off
if [ "$currentApp" = "Spotify" ]
then
osascript -e 'tell application "Spotify" to set repeating to false'
elif [ "$currentApp" = "iTunes" ]
then
osascript -e 'tell application "iTunes" to set song repeat to off'
fi;;
f) #mute
osascript -e 'set volume output muted true';;
g) #unmute
osascript -e 'set volume output muted false';;
h) #turn shuffle on
if [ "$currentApp" = "Spotify" ]
then
osascript -e 'tell application "Spotify" to set shuffling to true'
elif [ "$currentApp" = "iTunes" ]
then
osascript -e 'tell application "iTunes" to set shuffle enabled to true'
fi;;
i) #turn shuffle off
if [ "$currentApp" = "Spotify" ]
then
osascript -e 'tell application "Spotify" to set shuffling to false'
elif [ "$currentApp" = "iTunes" ]
then
osascript -e 'tell application "iTunes" to set shuffle enabled to false'
fi;;
v) #volume
vol=${STR:1:1}${STR:2:1}
osascript -e 'tell application "'$currentApp'" to set sound volume to '$vol''
esac
done