2021-07-20 23:48:41 +02:00
|
|
|
#!/bin/bash
|
2021-07-20 22:27:49 +02:00
|
|
|
|
|
|
|
# Media player menu with rofi
|
|
|
|
|
2021-07-20 23:48:41 +02:00
|
|
|
mediaplayer=$1
|
|
|
|
status=$(playerctl -p $mediaplayer status)
|
|
|
|
case $status in
|
|
|
|
Playing|Paused)
|
|
|
|
title="$(playerctl -p $mediaplayer metadata xesam:title)"
|
|
|
|
artist="$(playerctl -p $mediaplayer metadata xesam:artist)"
|
|
|
|
status="$status <span weight='light'><i>${title} (${artist})</i></span>"
|
|
|
|
;;
|
|
|
|
esac
|
2021-07-20 22:27:49 +02:00
|
|
|
choice=$(
|
2021-07-20 23:00:48 +02:00
|
|
|
while read icon description
|
|
|
|
do
|
|
|
|
printf "$description\00icon\37$icon\n"
|
2021-07-20 23:48:41 +02:00
|
|
|
done <<EOF | rofi -dmenu -show-icons -no-custom -i -p "media player action" -mesg "$status" \
|
2021-07-20 22:27:49 +02:00
|
|
|
-kb-select-1 Super+z \
|
|
|
|
-kb-select-2 Super+x \
|
|
|
|
-kb-select-3 Super+c \
|
|
|
|
-kb-select-4 Super+v \
|
|
|
|
-kb-select-5 Super+b \
|
|
|
|
-kb-select-6 Super+m \
|
2021-07-20 23:00:48 +02:00
|
|
|
-kb-select-7 Super+s
|
|
|
|
go-previous Previous track
|
|
|
|
media-playback-start Play
|
|
|
|
media-playback-pause Pause
|
|
|
|
media-playback-stop Stop
|
|
|
|
go-next Next track
|
|
|
|
multimedia-volume-control Open mixer panel
|
2021-07-20 23:48:41 +02:00
|
|
|
com.spotify.Client Open ${mediaplayer^}
|
2021-07-20 23:00:48 +02:00
|
|
|
EOF
|
2021-07-20 22:27:49 +02:00
|
|
|
)
|
|
|
|
case $choice in
|
|
|
|
Previous*) xdotool key --clearmodifiers XF86AudioPrev ;;
|
2021-07-20 23:00:48 +02:00
|
|
|
Next*) xdotool key --clearmodifiers XF86AudioNext ;;
|
|
|
|
Play) xdotool key --clearmodifiers XF86AudioPlay ;;
|
|
|
|
Pause) xdotool key --clearmodifiers XF86AudioPause ;;
|
|
|
|
Stop) xdotool key --clearmodifiers XF86AudioStop ;;
|
|
|
|
*mixer*) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;;
|
2021-07-20 23:48:41 +02:00
|
|
|
*Spotify*) i3-msg '[class="'${mediaplayer^}'"] focus' || i3-msg exec exec spotify ;;
|
2021-07-20 22:27:49 +02:00
|
|
|
esac
|