2008-11-25

I often forget to start Pidgin when I first sit down at the computer, because I’m usually entrenched in thinking about whatever task brought me there in the first place. Setting up Pidgin to run automatically at login might at first appear to be a good solution to this, but there are times when I don’t want to sign in to instant messaging, such as in the middle of class.

The solution? A gentle reminder at login.

Pidgin is not running. Would you like to start it?
#!/usr/bin/env python
# Adapted from test-multi-actions.py in python-notify

import pygtk
pygtk.require('2.0')

import gtk
import pynotify
import sys
import subprocess
import time

time.sleep(8)

def ignore(notification):
notification.close()
gtk.main_quit()

def start(notification):
subprocess.Popen('pidgin')
notification.close()
gtk.main_quit()

if __name__ == '__main__':
if not pynotify.init("Start Pidgin"):
sys.exit(1)

icon = "file:///usr/share/icons/hicolor/48x48/apps/pidgin.png"
notification = pynotify.Notification(
"Start Pidgin",
"Pidgin is not running. Would you like to start it?",
icon)
notification.set_urgency(pynotify.URGENCY_LOW)
notification.add_action("start", "Start Pidgin", start)
notification.add_action("ignore", "Ignore", ignore)
notification.set_timeout(20000)
notification.set_hint("x", 1000)
notification.set_hint("y", 19)

if not notification.show():
print "Failed to show notification"
sys.exit(1)

gtk.main()