dmenu-scripts/dmenu-playerctl

29 lines
593 B
Plaintext
Raw Normal View History

#!/bin/env bash
# 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
load_config () {
source $HOME/.config/dmenu/config
}
2022-07-17 11:03:13 +02:00
main () {
load_config
command="$@"
[ -z "$command" ] && exit
instances=$(playerctl -l | wc -l)
2022-08-01 17:51:43 +02:00
if [ "$instances" = "0" ]; then
2022-08-01 17:51:43 +02:00
exit
elif [ "$instances" -lt "2" ]; then
playerctl $command
else
choice=$(playerctl -l | $DMENU -p 'Manage:')
[ -z "$choice" ] && exit
playerctl -p $choice $command
2022-08-01 17:51:43 +02:00
fi
}
2022-08-01 17:51:43 +02:00
main $@