Hi, Once I got my head around dbus, this was surprisingly easy to do. See the attached python script. Just start it with your kde session, and it runs the command whenever the screensaver changes state (maybe that should be changed to only run on screensaver start). Cheers, Johannes On Friday 01 November 2013 13:41:25 Johannes Zarl wrote: > Thanks for the suggestion. It's definitely an interesting way to do it and > avoids the problems with replacing kscreenlocker_greet. OTOH it's a > relatively complex hack for such a (seemingly) simple task... > > In the meantime I found out that there is a dbus signal that is emitted > whenever the screensaver changes state. Maybe I can leverage that to get > what I want. > > If I get anywhere with this approach, I'll write a followup. Otherwise I > might just use your suggestion. > > Thanks! > Johannes > > On Wednesday 30 October 2013 13:19:24 Rubin Abdi wrote: > > I haven't figured out any better methods to do this yet, and would love > > it if I didn't hack it up like I did with... > > > > http://lists.debian.org/debian-kde/2013/07/msg00050.html
#!/usr/bin/python # mainloop: import gobject # dbus: import dbus from dbus.mainloop.glib import DBusGMainLoop from os import system # callback: def print_signal_handler(value): print "screensaverd.py: Flushing gpg-agent passphrases..." system("killall -SIGHUP gpg-agent") return # create session bus object: DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() try: busobject = bus.get_object("org.freedesktop.ScreenSaver","/ScreenSaver") busobject.connect_to_signal("ActiveChanged", print_signal_handler, dbus_interface="org.freedesktop.ScreenSaver") except dbus.DBusException: traceback.print_exc() print usage sys.exit(1) # set up event loop: loop = gobject.MainLoop() loop.run()
Attachment:
signature.asc
Description: This is a digitally signed message part.