mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-15 12:44: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
|
# Media player menu with rofi
|
||||||
|
|
||||||
mediaplayer=$1
|
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=$(
|
choice=$(
|
||||||
while read icon description
|
{
|
||||||
do
|
# Available actions
|
||||||
printf "$description\00icon\37$icon\n"
|
while read icon description
|
||||||
done <<EOF | rofi -dmenu -show-icons -no-custom -i -p "media player action" -mesg "$status" \
|
do
|
||||||
-kb-select-1 Super+z \
|
printf "$description\00icon\37$icon\n"
|
||||||
-kb-select-2 Super+x \
|
done <<EOF
|
||||||
-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
|
|
||||||
go-previous Previous track
|
go-previous Previous track
|
||||||
media-playback-start Play
|
media-playback-start Play
|
||||||
media-playback-pause Pause
|
media-playback-pause Pause
|
||||||
|
@ -31,13 +18,32 @@ go-next Next track
|
||||||
multimedia-volume-control Open mixer panel
|
multimedia-volume-control Open mixer panel
|
||||||
com.spotify.Client Open ${mediaplayer^}
|
com.spotify.Client Open ${mediaplayer^}
|
||||||
EOF
|
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
|
case $choice in
|
||||||
Previous*) xdotool key --clearmodifiers XF86AudioPrev ;;
|
1) xdotool key --clearmodifiers XF86AudioPrev ;;
|
||||||
Next*) xdotool key --clearmodifiers XF86AudioNext ;;
|
2) xdotool key --clearmodifiers XF86AudioPlay ;;
|
||||||
Play) xdotool key --clearmodifiers XF86AudioPlay ;;
|
3) xdotool key --clearmodifiers XF86AudioPause ;;
|
||||||
Pause) xdotool key --clearmodifiers XF86AudioPause ;;
|
4) xdotool key --clearmodifiers XF86AudioStop ;;
|
||||||
Stop) xdotool key --clearmodifiers XF86AudioStop ;;
|
5) xdotool key --clearmodifiers XF86AudioNext ;;
|
||||||
*mixer*) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;;
|
6) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;;
|
||||||
*Spotify*) i3-msg '[class="'${mediaplayer^}'"] focus' || i3-msg exec exec spotify ;;
|
7) i3-msg '[class="'${mediaplayer^}'"] focus' || i3-msg exec exec spotify ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue