You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.4 KiB
Bash
80 lines
1.4 KiB
Bash
#!/bin/sh
|
|
|
|
filter() {
|
|
sed "/^volume:/d" | tac | sed -e "s/\\&/&/g;s/\\[paused\\].*/ /g;s/\\[playing\\].*/ /g" | tr -d '\n' |sed -e "s/$/\n/g"
|
|
}
|
|
player=""
|
|
|
|
[ -z $BLOCK_INSTANCE ] || player="--player=$BLOCK_INSTANCE"
|
|
|
|
case $BLOCK_INSTANCE in
|
|
"mpd") playprog="$TERMINAL -e ncmpcpp" ;;
|
|
"spotify"|"spotifyd") playprog="$TERMINAL -e spt" ;;
|
|
"cmus") playprog="$TERMINAL -e cmus" ;;
|
|
"vlc" ) playprog="vlc" ;;
|
|
*) playprog="" ;;
|
|
esac
|
|
|
|
case $BLOCK_INSTANCE in
|
|
"mpd")
|
|
playprog="$TERMINAL -e ncmpcpp"
|
|
status() { mpc status | filter ;}
|
|
toggle() { mpc toggle | filter ;}
|
|
next() { mpc next | filter ;}
|
|
prev() { mpc prev | filter ;};;
|
|
"spotify"|"spotifyd")
|
|
playprog="$TERMINAL -e spt"
|
|
status() {
|
|
spt pb -s
|
|
}
|
|
|
|
toggle() {
|
|
spt pb -t
|
|
status
|
|
}
|
|
|
|
next() {
|
|
spt pb -n
|
|
status
|
|
}
|
|
prev() {
|
|
spt pb -p
|
|
status
|
|
}
|
|
;;
|
|
*)
|
|
status() {
|
|
playerctl metadata $player -f '{{artist}} - {{title}}
|
|
[{{lc(status)}}]' | filter
|
|
}
|
|
|
|
toggle() {
|
|
playerctl play-pause $player
|
|
status
|
|
}
|
|
|
|
next() {
|
|
playerctl next $player
|
|
status
|
|
}
|
|
prev() {
|
|
playerctl previous $player
|
|
status
|
|
}
|
|
;;
|
|
esac
|
|
|
|
case $BLOCK_BUTTON in
|
|
1) status && setsid $playprog & ;;
|
|
2) toggle ;;
|
|
3) status && notify-send "🎵 Music module" "\- Shows playing song.
|
|
- Italic when paused.
|
|
- Left click opens player.
|
|
- Middle click pauses.
|
|
- Scroll changes tracks.:" ;;
|
|
4) prev ;;
|
|
5) next ;;
|
|
6) status && setsid $TERMINAL -e $EDITOR $0 &;;
|
|
*) status ;;
|
|
esac; exit
|