forked from matryer/xbar-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvox.30s.sh
executable file
·71 lines (60 loc) · 1.96 KB
/
vox.30s.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
#!/bin/bash
# <bitbar.title>Vox</bitbar.title>
# <bitbar.author>Daniel Kay</bitbar.author>
# <bitbar.author.github>jessor</bitbar.author.github>
# <bitbar.desc>Get current track info from Vox status with play/pause button</bitbar.desc>
# <bitbar.image>https://cloud.githubusercontent.com/assets/480451/12141683/ee53ea2a-b471-11e5-8429-ada2ef579883.png</bitbar.image>
# <bitbar.version>1.0</bitbar.version>
#
# Get current Vox status with play/pause button
#
# by Daniel Kay ([email protected])
# inspired by Jason Tokoph ([email protected])
#
# Shows current track information from vox
if [ "$1" = 'launch' ]; then
osascript -e 'tell application "Vox" to activate'
exit
fi
if [ "$(osascript -e 'application "Vox" is running')" = "false" ]; then
echo "♫"
echo "---"
echo "Vox is not running"
echo "Launch Vox| bash='$0' param1=launch terminal=false"
exit
fi
if [ "$1" = 'playpause' ]; then
osascript -e 'tell application "Vox" to playpause'
exit
fi
state=$(osascript -e 'tell application "Vox" to set state to player state');
if [ "$state" = "1" ]; then
state_icon="🎵"
else
state_icon="⚫"
fi
track=$(osascript -e 'tell application "Vox" to set trackname to track');
track=${track//|/-}
artist=$(osascript -e 'tell application "Vox" to set artistname to artist');
album=$(osascript -e 'tell application "Vox" to set albumname to album');
trackURL=$(osascript -e 'tell application "Vox" to set state to trackURL');
if [[ $trackURL =~ soundcloud ]]
then
echo "$state_icon $track"
else
echo "$state_icon $artist - $track [$album]"
fi
echo "---"
case "$0" in
*\ * )
echo "Your script path | color=#ff0000"
echo "($0) | color=#ff0000"
echo "has a space in it, which BitBar does not support. | color=#ff0000"
echo "Play/Pause/Next/Previous buttons will not work. | color=#ff0000"
;;
esac
if [ "$state" = "1" ]; then
echo "❚❚ Pause | bash='$0' param1=playpause terminal=false"
else
echo "▶ Play | bash='$0' param1=playpause terminal=false"
fi