Skip to content

Instantly share code, notes, and snippets.

@ecelis
Forked from sdague/imaway
Created May 23, 2016 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecelis/cb8518d727273478693eee73ae660939 to your computer and use it in GitHub Desktop.
Save ecelis/cb8518d727273478693eee73ae660939 to your computer and use it in GitHub Desktop.
dbus xchat integration
#!/usr/bin/python
import dbus
import dbus.glib
import gobject
import subprocess
def lock():
print "Screen saver turned on"
subprocess.call("pactl set-sink-mute 0 1", shell=True)
subprocess.call("xchat -e -c 'AWAY'", shell=True)
def unlock():
subprocess.call("pactl set-sink-mute 0 0", shell=True)
subprocess.call("xchat -e -c 'BACK'", shell=True)
print "Screen saver deactivated"
def main(args):
bus = dbus.SessionBus()
# listen for changes in screensaver activity
bus.add_signal_receiver(
lock,
'Locked',
dbus_interface='com.canonical.Unity.Session')
bus.add_signal_receiver(
unlock,
'Unlocked',
dbus_interface='com.canonical.Unity.Session')
mainLoop = gobject.MainLoop()
mainLoop.run()
if __name__ == '__main__':
import sys
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment