Last active
March 8, 2022 06:23
-
-
Save sdague/265a43f255716c11cc62 to your computer and use it in GitHub Desktop.
dbus xchat integration
This file contains 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