-
-
Save techris45/f1890d0abeea5fb2fdc9ba856cc427fa to your computer and use it in GitHub Desktop.
dbus xchat integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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