Skip to content

Instantly share code, notes, and snippets.

@sdague
Last active March 8, 2022 06:23
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sdague/265a43f255716c11cc62 to your computer and use it in GitHub Desktop.
Save sdague/265a43f255716c11cc62 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