26 lines
723 B
Bash
26 lines
723 B
Bash
#!/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
|