Skip to content

Instantly share code, notes, and snippets.

@jjrh
Created June 25, 2013 16:15
Show Gist options
  • Save jjrh/5859843 to your computer and use it in GitHub Desktop.
Save jjrh/5859843 to your computer and use it in GitHub Desktop.
Toggles mpd to play if it's stopped or paused, toggles mpd to pause if it's playing. Useful if you have a keybinding to toggle music.
#/bin/sh
status=$(mpc status | grep play)
if [ -n "$status" ]
then
mpc pause >> /dev/null
else
mpc play >> /dev/null
fi
@urbans0ft
Copy link

urbans0ft commented Dec 3, 2020

A one-liner:
[[ $(mpc status | grep paused) == *"paused"* ]] && mpc play || mpc pause

UPDATE 2021-02-14:
mpc toggle (see man page)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment