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.
56 lines
1.2 KiB
Bash
56 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
filter() {
|
|
sed "/^volume:/d" | tac | sed -e "s/\\&/&/g;s/\\[paused\\].*/<span color=\"gray\" font_style=\"italic\">/g;s/\\[playing\\].*/<span>/g" | tr -d '\n' |sed -e "s/$/<\/span>\n/g"
|
|
}
|
|
player=""
|
|
|
|
[ -z $BLOCK_INSTANCE ] || player="--player=$BLOCK_INSTANCE"
|
|
|
|
case $BLOCK_INSTANCE in
|
|
"mpd") playprog="$TERMINAL -e ncmpcpp" ;;
|
|
"spotify") playprog="$TERMINAL -e spt" ;;
|
|
"cmus") playprog="$TERMINAL -e cmus" ;;
|
|
"vlc" ) playprog="vlc" ;;
|
|
*) playprog="" ;;
|
|
esac
|
|
|
|
if [ "$BLOCK_INSTANCE" == "mpd" ]; then
|
|
status() { mpc status | filter ;}
|
|
toggle() { mpc toggle | filter ;}
|
|
next() { mpc next | filter ;}
|
|
prev() { mpc prev | filter ;}
|
|
else
|
|
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
|
|
}
|
|
fi
|
|
|
|
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 ;;
|
|
*) status ;;
|
|
esac; exit
|