/
rofi-mediaplayer
executable file
·74 lines (67 loc) · 2.31 KB
/
rofi-mediaplayer
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
#!/bin/sh
# Media player menu with rofi
if [ -z "${ROFI_OUTSIDE}" ]; then
export mediaplayer=$1
export Mediaplayer=$(echo $1 | sed -E 's/(.)/\U\1/')
exec rofi -no-lazy-grab -show-icons -no-custom -modi m:$0 -show m \
-kb-custom-1 Super+z \
-kb-custom-2 Super+x \
-kb-custom-3 Super+c \
-kb-custom-4 Super+v \
-kb-custom-5 Super+b \
-kb-custom-6 Super+n \
-kb-custom-7 Super+m \
-kb-custom-8 Super+s \
-kb-cancel Escape,Control+g,Super+Escape
fi
if [ $ROFI_RETV -ge 10 ] && [ $ROFI_RETV -le 28 ]; then
ROFI_INFO=$((ROFI_RETV-9))
ROFI_RETV=1
fi
playerctl="playerctl -p $mediaplayer"
case $ROFI_RETV in
0)
# Prompt
printf "\00prompt\037media player\n"
printf "\00message\037$...\n"
printf "\00use-hot-keys\037true\n"
# Available actions
i=0
while read icon description
do
i=$((i+1))
printf "$description\00icon\037$icon\037info\037$i\n"
done <<EOF
go-previous Previous track
media-playback-start Play
media-playback-pause Pause
media-playback-stop Stop
go-next Next track
audio-input-microphone Toggle microphone
multimedia-volume-control Open mixer panel
dev.aunetx.deezer Open Deezer
EOF
# Player status
status=$($playerctl status)
case $status in
Playing|Paused)
title="$($playerctl metadata xesam:title | sed -e 's/&/\&/g' -e 's/</\</g')"
artist="$($playerctl metadata xesam:artist | sed -e 's/&/\&/g' -e 's/</\</g')"
status="$status <span weight='light'><i>${title} (${artist})</i></span>"
;;
esac
printf "\00message\037${status}\n"
;;
1)
case $ROFI_INFO in
1) $playerctl previous ;;
2) $playerctl play ;;
3) $playerctl pause ;;
4) $playerctl stop ;;
5) $playerctl next ;;
6) ~/.config/i3/bin/toggle-mute source ;;
7) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;;
8) i3-msg '[class="Deezer"] focus' || i3-msg exec gtk-launch dev.aunetx.deezer ;;
esac >&2
;;
esac