Music Player Daemon Community Wiki


525pages on
this wiki
Add New Page
Talk0 Share

# This little dirty hack waits for D-Bus events from GNOME screensaver and
# toggles music playing on each of them. Since 2011-12-13 it checks if mpd was
# playing music and resumes it only if it was
# Inspired and influenced by "Screensaver Play/Pause" Rhythmbox plugin by Jannik
# Heller
# ([1])
# Written by Vadim "dexpl" Raskhozhev, licensed under WTFPL

_event_expr='^[[:space:]]*boolean\ (true|false)'
# 1 here means that mpd was _not_ playing

play_pause() {
# if screensaver activated
    if [ $1 -eq 0 ]; then
# find if mpd plays music
        mpc | grep -q '^\[playing\]'
        [ "$_was_playing" -eq 0 ] && mpc pause
# if screensaver deactivated
# resume only if mpd was playing when screensaver activated
        [ "$_was_playing" -eq 0 ] && mpc play

dbus-monitor --session "$_dbus_expr" | while read _line ; do
    if [[ "$_line" =~ $_event_expr ]]; then
        play_pause $?

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki