1
0
Fork 0

scripts: add mpristoggle

This commit is contained in:
Vladimír Dudr 2022-12-16 22:30:42 +01:00
parent c3cfae6ceb
commit 1b0f8a325c

View file

@ -0,0 +1,26 @@
#!/bin/zsh
declare -i count=0
declare -i playing=0
while read player ps
do
count+=1
[[ "$ps" == Playing ]] && playing+=1
done < <(playerctl -a status --format '{{playerName}} {{status}}')
case $count in
0) notify-send -t 800 -a "Player toggle" "No player running" ;;
1) playerctl play-pause ;;
*)
if ((playing > 0))
then
playerctl pause -a
else
player=$(playerctl status -a --format '{{playerName}} ({{status}})' | rofi -dmenu -p "Play: ")
# pouzit prvni slovo, podle shell pravidel...
# jsou vsechny prehravace se jednoslovnym nazvem?
[[ -n "$player" ]] && playerctl -p "${${(z)player}[1]}" play
fi
esac