blob: 3701cbf4dc124cd744f0e6ddd7d6006f27e53a02 (
plain)
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
|
#!/bin/sh
show_panel (){
# Needs to send to /dev/null for the actual else case.
player_status=$(playerctl status 2> /dev/null)
if [ "$player_status" = "Playing" ]; then
echo " $(playerctl metadata artist) - $(playerctl metadata title)"
elif [ "$player_status" = "Paused" ]; then
echo "%{F$(xresource color8)} $(playerctl metadata artist) - $(playerctl metadata title)%{F-}"
else
echo "%{F$(xresource color8)} (nothing playing)"
fi
}
send_notification (){
player_status=$(playerctl status 2> /dev/null)
if [ "$player_status" = "Playing" ]; then
artist="$(playerctl metadata artist)"
album="$(playerctl metadata album)"
title="$(playerctl metadata title)"
if [ $album = "\n"]; then
notify-send " $artist - $album" "$title"
else
notify-send " $artist" "$title"
fi
elif [ "$player_status" = "Paused" ]; then
artist="$(playerctl metadata artist)"
album="$(playerctl metadata album)"
title="$(playerctl metadata title)"
if [ $album = "\n"]; then
notify-send " (Paused) $artist - $album" "$title"
else
notify-send " (Paused) $artist" "$title"
fi
else
notify-send " Nothing playing"
fi
}
case $1 in
show)
show_panel
;;
notify)
send_notification
;;
esac
|