scripts: mprisctl - wrap playerctl in more sensible way
This commit is contained in:
parent
5b3db778c6
commit
a003050383
1 changed files with 49 additions and 0 deletions
49
bin/executable_mprisctl
Normal file
49
bin/executable_mprisctl
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
typeset -a playing
|
||||||
|
typeset -a paused
|
||||||
|
typeset -a all
|
||||||
|
|
||||||
|
process() {
|
||||||
|
local state=$1
|
||||||
|
shift
|
||||||
|
local pl
|
||||||
|
|
||||||
|
if (( ${#${(P)state}} > 1))
|
||||||
|
then
|
||||||
|
pl=$(rofi -dmenu<<<${(FP)state})
|
||||||
|
else
|
||||||
|
pl=${(FP)state}
|
||||||
|
fi
|
||||||
|
[[ -n $pl ]] && playerctl -p $pl $@
|
||||||
|
}
|
||||||
|
|
||||||
|
while read player ps
|
||||||
|
do
|
||||||
|
all+=$player
|
||||||
|
case $ps in
|
||||||
|
Playing) playing+=$player ;;
|
||||||
|
Paused) paused+=$player ;;
|
||||||
|
esac
|
||||||
|
done < <(playerctl -a status --format '{{playerName}} {{status}}')
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
toggle)
|
||||||
|
if (( ${#playing} ))
|
||||||
|
then
|
||||||
|
xargs -n1 playerctl pause -p <<<${playing}
|
||||||
|
else
|
||||||
|
process paused play
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
next)
|
||||||
|
process playing next
|
||||||
|
;;
|
||||||
|
prev)
|
||||||
|
process playing previous
|
||||||
|
;;
|
||||||
|
open)
|
||||||
|
shift
|
||||||
|
process all open "$@"
|
||||||
|
esac
|
Loading…
Add table
Reference in a new issue