2021-07-21 07:31:27 +02:00
|
|
|
#!/bin/sh
|
2021-07-20 22:27:49 +02:00
|
|
|
|
|
|
|
# Media player menu with rofi
|
|
|
|
|
2021-07-21 02:17:04 +02:00
|
|
|
if [ -z "${ROFI_OUTSIDE}" ]; then
|
|
|
|
export mediaplayer=$1
|
2021-07-21 07:31:27 +02:00
|
|
|
export Mediaplayer=$(echo $1 | sed -E 's/(.)/\U\1/')
|
2021-07-21 02:17:04 +02:00
|
|
|
exec rofi -show-icons -no-custom -modi m:$0 -show m \
|
|
|
|
-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 \
|
|
|
|
-kb-select-7 Super+s
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $ROFI_RETV in
|
|
|
|
0)
|
|
|
|
# Prompt
|
2021-07-21 07:31:27 +02:00
|
|
|
printf "\00prompt\037media player\n"
|
|
|
|
printf "\00message\037$...\n"
|
2021-07-21 02:17:04 +02:00
|
|
|
|
2021-07-21 01:44:23 +02:00
|
|
|
# Available actions
|
2021-07-21 02:17:04 +02:00
|
|
|
i=0
|
2021-07-21 01:44:23 +02:00
|
|
|
while read icon description
|
|
|
|
do
|
2021-07-21 02:17:04 +02:00
|
|
|
i=$((i+1))
|
2021-07-21 07:31:27 +02:00
|
|
|
printf "$description\00icon\037$icon\037info\037$i\n"
|
2021-07-21 01:44:23 +02:00
|
|
|
done <<EOF
|
2021-07-20 23:00:48 +02:00
|
|
|
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-21 07:31:27 +02:00
|
|
|
com.spotify.Client Open ${Mediaplayer}
|
2021-07-20 23:00:48 +02:00
|
|
|
EOF
|
2021-07-21 01:44:23 +02:00
|
|
|
|
|
|
|
# Player status
|
|
|
|
status=$(playerctl -p $mediaplayer status)
|
|
|
|
case $status in
|
|
|
|
Playing|Paused)
|
2021-07-21 09:55:50 +02:00
|
|
|
title="$(playerctl -p $mediaplayer metadata xesam:title | sed -e 's/&/\&/g' -e 's/</\</g')"
|
|
|
|
artist="$(playerctl -p $mediaplayer metadata xesam:artist | sed -e 's/&/\&/g' -e 's/</\</g')"
|
2021-07-21 01:44:23 +02:00
|
|
|
status="$status <span weight='light'><i>${title} (${artist})</i></span>"
|
|
|
|
;;
|
|
|
|
esac
|
2021-07-21 07:31:27 +02:00
|
|
|
printf "\00message\037${status}\n"
|
2021-07-21 02:17:04 +02:00
|
|
|
;;
|
|
|
|
1)
|
|
|
|
case $ROFI_INFO in
|
2021-07-21 09:52:36 +02:00
|
|
|
1) playerctl -p $mediaplayer previous ;;
|
|
|
|
2) playerctl -p $mediaplayer play-pause ;;
|
|
|
|
3) playerctl -p $mediaplayer pause ;;
|
|
|
|
4) playerctl -p $mediaplayer stop ;;
|
|
|
|
5) playerctl -p $mediaplayer next ;;
|
2021-07-21 02:17:04 +02:00
|
|
|
6) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;;
|
2021-07-21 07:31:27 +02:00
|
|
|
7) i3-msg '[class="'${Mediaplayer}'"] focus' || i3-msg exec exec spotify ;;
|
2021-07-21 02:17:04 +02:00
|
|
|
esac >&2
|
|
|
|
;;
|
2021-07-20 22:27:49 +02:00
|
|
|
esac
|