Skip to content

Instantly share code, notes, and snippets.

@Vresod
Created October 28, 2020 01:33
Show Gist options
  • Save Vresod/c2fea668b20708c63f8fef6f7eec38b0 to your computer and use it in GitHub Desktop.
Save Vresod/c2fea668b20708c63f8fef6f7eec38b0 to your computer and use it in GitHub Desktop.
#!/bin/sh
updatesonglist() {
IFS="
"
songlist=""
for i in $(mpc listall|sed "s/ /@/g"); do songlist="$(echo "$i"|awk -F '....$' '{print $1}')\n$songlist"; done
IFS=""
songlist=$(echo $songlist|sed "s/@/ /g"|sort)
}
action=$(printf "toggle\nplay\npause\nnext\nprev\nsong\nrestart"|rofi -dmenu -p mpd -mesg "playing $(mpc status|head -n 1) $([ $(mpc status|awk -F '[][]' '{print $2}'|tail -n 2|head -n 1) = 'paused' ] && echo '(paused)')") || exit 1
[ $action = "song" ] && (updatesonglist && toplay=$(echo $songlist|rofi -dmenu -p play -no-custom) && mpc searchplay $toplay) && exit
[ $action = "restart" ] && mpc prev && mpc next && exit
mpc $action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment