diff --git a/bin/executable_mpristoggle b/bin/executable_mpristoggle new file mode 100644 index 0000000..cf3ebed --- /dev/null +++ b/bin/executable_mpristoggle @@ -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