Tuesday, July 18, 2017

A script that pause/plays on lock/unlock Spotify

A script that pause/plays on lock/unlock
#!/bin/bash

dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'" | \
(
  while true; do
    read X
    echo $X
    if echo $X | grep "boolean true" &> /dev/null; then
        dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
    elif echo $X | grep "boolean false" &> /dev/null; then
        dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
    fi
  done
)

No comments:

Post a Comment