Pidgin Status Switcher
Saturday, June 28, 2008
Previously I always had the problem while playing, that some guys were always messaging me, and the popups made trouble while my games running in fullscreen. Now I finally found the perfect solution to solve that problem. I wrote a tiny script, which has two options. It can a) set the status of your Pidgin offline and b) restore the last status. I then wrote another shell script, which calls the status switcher, pushing Pidgin in offline mode, then starts the game, and afterwards restores the Pidgin status again. The latter script shouldn't really matter you, but here's the status switcher script. It requires you for having Pidgin for sure, Python and a *nix system with DBUS:I hope this is helpfful for somebody.#!/usr/bin/pythonimport dbus, gobject, os, sys# Status constant for beeing offlineSTATUS_OFFLINE = 1# File to store the statusSTORAGE_FILE = os.path.abspath(sys.path[0]) + '/storedStatus'# Get purple DBUS objectbus = dbus.SessionBus()obj = bus.get_object("im.pidgin.purple.PurpleService","/im/pidgin/purple/PurpleObject")purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")# Check command line argumentsmethod = Noneif len(sys.argv) > 1:method = sys.argv[1]if method not in ('--offline', '--restore'):print 'Use either with --offline or --restore'sys.exit(0)# Check what to doif method == '--offline':# Fetch the current status and store it for later restorecurrentStatus = purple.PurpleSavedstatusGetCurrent()storeFile = file(STORAGE_FILE, 'w')print >> storeFile, currentStatusstoreFile.close()# Create the offline status and activate itofflineStatus = purple.PurpleSavedstatusNew("", STATUS_OFFLINE)purple.PurpleSavedstatusActivate(offlineStatus)print 'Gone offline'else:try:# Read the stored statusstoreFile = file(STORAGE_FILE, 'r')storedStatus = int(storeFile.readline())storeFile.close()# Restore the stored statuspurple.PurpleSavedstatusActivate(storedStatus)print 'Status restored'except:print 'Could not restore status'
Comments to this article
Leave a comment
Please note that your email address will not be shown, it is only used to fetch your avatar image from gravatar.com and for notifications.


Thanks so much! I found this script very useful.
Thanks a lot for that script!