Skip to content

Instantly share code, notes, and snippets.

@chanux chanux/audiolock.sh
Last active Jan 22, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.