Away-on-lock

Away-on-Lock is a simple plugin for Pidgin (or any other libpurple-based IM client) to change your status when the screensaver gets activated.

It currently supports Gnome Screensaver and KScreensaver since they’re the only ones that make use of DBus to advertise their status.

Download

Version 0.5.2

Development and Bugs

Code, bugs and feature requests over on github.

Extra

Away-on-lock has been implemented as a C plugin simply because I wanted to toy with the idea (and with a CMake-based build system).

It could have been implemented with something like the following python script, but what’s the fun in doing something just one way?

#!/usr/bin/env python
 
import dbus, gobject
from dbus.mainloop.glib import DBusGMainLoop
 
dbus_loop = DBusGMainLoop()
 
bus = dbus.SessionBus(mainloop=dbus_loop)
dbus_obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(dbus_obj, "im.pidgin.purple.PurpleInterface")
 
status_current = None
 
def set_status_cb(screensaver_active):
        global staus_away,status_current
 
        status_away = purple.PurpleSavedstatusGetIdleaway()
 
        if screensaver_active:
                status_current = purple.PurpleSavedstatusGetCurrent()
                purple.PurpleSavedstatusActivate(status_away)
        elif status_current:
                purple.PurpleSavedstatusActivate(status_current)
 
bus.add_signal_receiver(set_status_cb, signal_name='ActiveChanged', dbus_interface='org.gnome.ScreenSaver')
 
gobject.MainLoop().run()