Skip to content

Instantly share code, notes, and snippets.

@chanux
Last active January 22, 2016 09:06
Show Gist options
  • Save chanux/ac171b8072da5979c39b to your computer and use it in GitHub Desktop.
Save chanux/ac171b8072da5979c39b to your computer and use it in GitHub Desktop.
Pause/Play audio on screen lock/unlock
#!/usr/bin/env bash
# This script pauses music on Ubuntu when screen is locked (cmd+l)
# My other script 'playdog' is required.
# It gives you seamless controls to vlc, spotify and mocp
# You should add this script to startup scripts
# Get playdog here: https://gist.github.com/chanux/db01bd2c66effc7a259f
dbus-monitor --session "type='signal',interface='com.ubuntu.Upstart0_6'" |
while read x; do
$(echo $x | grep "desktop-lock" &> /dev/null) && playdog -pause &> /dev/null;
$(echo $x | grep "desktop-unlock" &> /dev/null) && playdog -playpause &> /dev/null;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment