2022-10-30 16:07:52 +01:00
|
|
|
#!/bin/bash
|
2022-06-19 20:02:26 +02:00
|
|
|
|
|
|
|
# script to run a menu prompt when having more than 2 players since
|
|
|
|
# playerctl is bad at managing more than one player at the same time
|
|
|
|
|
2022-07-17 11:03:13 +02:00
|
|
|
source $HOME/.config/dmenu/config
|
|
|
|
|
2022-06-19 20:02:26 +02:00
|
|
|
command="$@"
|
2022-08-01 17:51:43 +02:00
|
|
|
[ -z "$command" ] && exit
|
2022-06-19 20:02:26 +02:00
|
|
|
instances=$(playerctl -l | wc -l)
|
|
|
|
|
2022-08-01 17:51:43 +02:00
|
|
|
slock=$(ps -C slock | sed -n '1!p' | awk '{ print $4 }' | sed 's/slock/running/')
|
|
|
|
|
2022-06-19 20:02:26 +02:00
|
|
|
if [ "$instances" = "0" ]; then
|
|
|
|
exit
|
|
|
|
elif [ "$instances" -lt "2" ]; then
|
|
|
|
playerctl $command
|
2022-10-30 16:07:52 +01:00
|
|
|
elif [ "$slock" = "running" ]; then
|
|
|
|
if [ "$command" = "play-pause" ]; then
|
2022-08-01 17:51:43 +02:00
|
|
|
if playerctl status -a | grep -i "Playing" > /dev/null; then
|
|
|
|
playerctl pause -a
|
|
|
|
else
|
|
|
|
playerctl -p mpd $command
|
|
|
|
fi
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
players=$(paste <(playerctl -l) <(playerctl status -a) | grep -v -i mpd | awk '{print $1}')
|
|
|
|
if [ ! -z "$players" ]; then
|
|
|
|
for player in $players; do
|
|
|
|
playerctl -p $player pause
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
playerctl -p mpd $command
|
2022-06-19 20:02:26 +02:00
|
|
|
else
|
2022-07-17 11:03:13 +02:00
|
|
|
choice=$(playerctl -l | $DMENU -p 'Manage:')
|
2022-08-01 17:51:43 +02:00
|
|
|
[ -z "$choice" ] && exit
|
2022-06-19 20:02:26 +02:00
|
|
|
playerctl -p $choice $command
|
|
|
|
fi
|