Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
D-Bus service providing org.gnome.ScreenSaver GetActive method for slimlock
#!/usr/bin/env python2
import dbus
import dbus.mainloop.glib
import dbus.service
import gobject
import psutil
class ScreenSaver(dbus.service.Object):
def __init__(self):
self.session_bus = dbus.SessionBus()
name = dbus.service.BusName("org.gnome.ScreenSaver", bus=self.session_bus)
dbus.service.Object.__init__(self, name, "/")
@dbus.service.method("org.gnome.ScreenSaver", in_signature='', out_signature='b')
def GetActive(self):
for pid in psutil.process_iter():
if pid.name() == "slimlock":
return True
return False
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
loop = gobject.MainLoop()
object = ScreenSaver()
loop.run()
[D-BUS Service]
Name=org.gnome.ScreenSaver
Exec=/usr/share/dbus-1/scripts/org.gnome.ScreenSaver.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.