mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-15 04:34:21 +02:00
rofi-mediaplayer: tentative to be more snappy when querying playerctl
This commit is contained in:
parent
ef77d239b1
commit
cab4f6b8fd
1 changed files with 32 additions and 26 deletions
|
@ -3,26 +3,13 @@
|
|||
# Media player menu with rofi
|
||||
|
||||
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
|
||||
choice=$(
|
||||
{
|
||||
# Available actions
|
||||
while read icon description
|
||||
do
|
||||
printf "$description\00icon\37$icon\n"
|
||||
done <<EOF | rofi -dmenu -show-icons -no-custom -i -p "media player action" -mesg "$status" \
|
||||
-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
|
||||
done <<EOF
|
||||
go-previous Previous track
|
||||
media-playback-start Play
|
||||
media-playback-pause Pause
|
||||
|
@ -31,13 +18,32 @@ go-next Next track
|
|||
multimedia-volume-control Open mixer panel
|
||||
com.spotify.Client Open ${mediaplayer^}
|
||||
EOF
|
||||
|
||||
# Player status
|
||||
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
|
||||
printf "\00message\x1f${status}\n"
|
||||
} | rofi -dmenu -show-icons -no-custom -i -p "media player action" -format d -async-pre-read 0 -mesg "..." \
|
||||
-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
|
||||
)
|
||||
case $choice in
|
||||
Previous*) xdotool key --clearmodifiers XF86AudioPrev ;;
|
||||
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 ;;
|
||||
*Spotify*) i3-msg '[class="'${mediaplayer^}'"] focus' || i3-msg exec exec spotify ;;
|
||||
1) xdotool key --clearmodifiers XF86AudioPrev ;;
|
||||
2) xdotool key --clearmodifiers XF86AudioPlay ;;
|
||||
3) xdotool key --clearmodifiers XF86AudioPause ;;
|
||||
4) xdotool key --clearmodifiers XF86AudioStop ;;
|
||||
5) xdotool key --clearmodifiers XF86AudioNext ;;
|
||||
6) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;;
|
||||
7) i3-msg '[class="'${mediaplayer^}'"] focus' || i3-msg exec exec spotify ;;
|
||||
esac
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue