scripts: add mpristoggle
This commit is contained in:
parent
c3cfae6ceb
commit
1b0f8a325c
1 changed files with 26 additions and 0 deletions
26
bin/executable_mpristoggle
Normal file
26
bin/executable_mpristoggle
Normal 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
|
Loading…
Add table
Reference in a new issue