+5  A: 

I'm not on an Ubuntu box so I can't write out any examples.

But Ubuntu's NotificationDevelopmentGuidelines page has a lot of information.

Examples in C, C#, and Python.

Debain also has a tutorial that should more or less have some commonality.

Basically your going to be tying into the NotifyOSD framework which leverages the Free Desktop Foundations D-Bus messaging system.

For development you'll need libnotify ( only online documentation I could find )

If you just want some quick results from the command line or to use in a shell script you can also use the notify-send command.

Usage:

notify-send [OPTION...] <SUMMARY> [BODY]

Example:

notify-send Test "Totally gnarly message bro"

Or you can specify an icon:

notify-send -i ../icon.jpg  Image "This is a sweet picture"

There are a bunch of other options, expire time, urgency level, category.

Ubuntu doesn't follow the Notification specification that closely, they don't honor alot of the options defined by the FSF. Don't be surprised if some things don't work with ubuntu's notifier that you see working with another notifier system.

Some Other resources:

  • Ubuntu's NotifyOSD wiki page.
  • ArsTechnica has a great article on the new notification's system.
  • Great article on some of the flaws in Ubuntu's notification's implementation.
Brian Gianforcaro
I bet you used some crazy filters on google to find this stuff! Thanks! ;-)
Lucas McCoy
+2  A: 

Here (manishtech.wordpress.com) is a nice post on working with libnotify, with some sample code in C

Sathya