Skip to content

Instantly share code, notes, and snippets.

@qwerty12
Created February 13, 2012 14:09
Show Gist options
  • Save qwerty12/1817171 to your computer and use it in GitHub Desktop.
Save qwerty12/1817171 to your computer and use it in GitHub Desktop.
Notification of gnome-screensaver state changes through D-Bus
#!/usr/bin/env python
import gobject, dbus
from dbus.mainloop.glib import DBusGMainLoop
def screensaver_state_changed(isActive):
print "locked" if isActive else "unlocked"
DBusGMainLoop(set_as_default=True)
sess_bus = dbus.SessionBus()
sess_bus.add_signal_receiver(screensaver_state_changed, path='/org/gnome/ScreenSaver', dbus_interface='org.gnome.ScreenSaver', signal_name='ActiveChanged')
gobject.MainLoop().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment