Skip to content

The Wheel: Let me reinvent it for you! (update-notifier redux)

UNIX

OK, for the record: I DESPISE Linux. I Hate, Loathe, Abhor and Revile it. I am a BSD-Bigot and proud of it, and if all the BSDs suddenly evaporated I would eschew Linux in favor of a commercial Unix (probably AIX).

Why do I hate Linux so much? Simply put, it's shoddy code written by shoddy coders. In my experience shit mysteriously breaks for no reason, standards and conventions are arbitrarily ignored, critical components of the system are perpetually at version zero-dot-something, regression testing seems to be a myth, and the average Linux developer seems to make no effort to ensure their code will work on anything except their particular favorite distribution (to say nothing about porting it to <GASP> a BSD system, or <HORRORS> Commercial Unix).

This particular tirade was kicked off by the Ubuntu update-notifier program suddenly and mysteriously no longer popping up update notification balloons. As some of you know my company ships a Linux-based appliance (built around a very stripped-down Ubuntu plus our commercial packages), and one of the things that made me go with Ubuntu was that they had gotten the update-notifier thing working beautifully and it had been stable for several versions.
Lo and Behold about a month ago our support guys came to visit me and asked "Hey, is the update notifier bubble broken?" I looked upon it and saw that it indeed appeared to be non-functional, but as all good (lazy) admins are wont to do I demanded they test and verify the breakage.

The breakage came back to me verified earlier this week, and as I really couldn't be assed to figure out why the update-notifier is happy to display the "you must reboot!" dialog box but refuses to display the "Yo, bitch! You have updates!" notifier icon & bubble I took the easy way out and re-implemented update-notifier in Python.

Since one or two people mentioned wanting a non-breaking update-notifier bubble I'm posting the hideous python code here. Do with it what you will - I probably won't update this code... ever.
Note that this probably doesn't work for you KDE folks, but if someone wants to adapt the code I'm all for it. Our appliance runs Gnome for historical reasons, and this is the very definition of a ghetto hack (until we can port our software to run on one of the BSDs - probably another year or so).


#!/usr/bin/env python
#
# Update-checker script, replaces update-notifier
# which apparently can't send notifications on some versions of
# Ubuntu.
#
# C: mikeg@bsd-box.net
#
# This script should not mysteriously break as long as you're in 
# GNOME, but I'm not catching any exceptions so you may be
# unplesantly surprised.
# This script assumes the user has sufficient rights to run
# update-manager without needing to sudo.
#

import gtk
import pynotify
import time
import os

def default_cb(n, action):
 icon.set_visible(False)
 n.close()
 os.system("/usr/bin/update-manager")
 gtk.main_quit()

def show_cb(icon):
 n.show()

if __name__ == '__main__':
 if pynotify.init("Update Notice"):
  n=pynotify.Notification("Updates Available", "Please click here to run the Update Manager", "/opt/premier_heart/share/images/3dmp_icon.png")
  n.set_urgency(pynotify.URGENCY_NORMAL)
  n.add_action("default","Default Action", default_cb)
  icon = gtk.status_icon_new_from_icon_name("update-manager")
  icon.set_blinking(True)
  icon.set_visible(False)
  icon.connect('activate', show_cb)
  icon.set_tooltip("Updates Available")
  while True:
   if os.system("/usr/lib/update-notifier/apt-check 2>&1 | grep '0;0' > /dev/null 2>&1"):
    icon.set_visible(True)
    n.attach_to_status_icon(icon)
    n.show()
    gtk.main()
   time.sleep(600)


Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Dave on :

*Linux, tell it like it is. It really is a pile of you know what. I spent hours trying to write all this recursive language, only for it to just blow over with zero error messages. I had to download an emulator for the compiler and run it outside of linux just to show where it was failing. Hate it.

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5


Twitter, Pavatar, Gravatar author images supported.
Form options