Skip to content

Instantly share code, notes, and snippets.

@Narrat
Last active March 26, 2016 20:22
Show Gist options
  • Save Narrat/ba758a9aaa4e983d36a5 to your computer and use it in GitHub Desktop.
Save Narrat/ba758a9aaa4e983d36a5 to your computer and use it in GitHub Desktop.
MPD Pipe Menu making use of mpc and systemctl --user
#! /bin/zsh
# MPD/MPC by olshrimpeyes
# Adjusted by me
servstatus="$(systemctl --user list-units | grep --color=no mpd.service)"
if [[ ! -z "$servstatus" ]]; then
nowplaying=$(mpc | grep - | sed -e 's/\&/&/g')
playing=$(mpc | grep playing)
fi
print "<openbox_pipe_menu>"
if [[ -z "$servstatus" ]]; then
print "<separator label=\"Server not running\"/>"
print "<item label=\"Start Server\"><action name=\"Execute\"><execute>systemctl --user start mpd</execute></action></item>"
else
if [[ ! -z $nowplaying ]]; then
print "<separator label=\"$nowplaying\"/>"
else
print "<separator label=\"Stopped\"/>"
fi
print "<separator/>"
if [[ -z $playing ]]; then
print "<item label=\"Play\"><action name=\"Execute\"><execute>mpc play</execute></action></item>"
else
print "<item label=\"Pause\"><action name=\"Execute\"><execute>mpc pause</execute></action></item>"
print "<item label=\"Stop\"><action name=\"Execute\"><execute>mpc stop</execute></action></item>"
fi
print "<item label=\"Next\"><action name=\"Execute\"><execute>mpc next</execute></action></item>"
print "<item label=\"Previous\"><action name=\"Execute\"><execute>mpc prev</execute></action></item>"
print "<separator/>"
print "<item label=\"Music Player\"><action name=\"Execute\"><execute>$TERM -e ncmpc</execute></action></item>"
print "<item label=\"Volume\"><action name=\"Execute\"><execute>pavucontrol</execute></action></item>"
print "<separator/>"
print "<item label=\"Stop Server\"><action name=\"Execute\"><execute>systemctl --user stop mpd</execute></action></item>"
print "<separator/>"
if [[ ! -z $playing ]]; then
print "<separator label=\"$playing\"/>"
fi
fi
print "</openbox_pipe_menu>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment