Ubuntu Notifications using libnotify-bin

23 11 2008

Did you ever need to have one of your shell script notify you of something? Do you want to learn a quick way to do this in Ubuntu? Then read this.

I wrote a script that backs-up all my files to Amazon S3 using jets3t’s synchronise tool. It works very well for me. Last week, my laptop got busted: I was upgrading to Ubuntu 8.10 and it overheated and shut down at a bad time (in the middle of the install). I couldn’t boot it after that. Luckily, I had backed up all my files to S3, so I was able to reinstall Ubuntu 8.10 from scratch and recover all my backed-up files. 3 hours later, I was up and running running Ubuntu 8.10 with all my files recovered.

However the point of this post is about notifications from a shell script. See, when I synchronise my files with S3 it takes some time and I would like to get alerted when everything is done backing up, so I needed a way to do that from my bash script.

Here is a quick way to do it on Ubuntu:

  1. Install libnotify-bin:
  2. sudo aptitude install libnotify-bin

  3. Learn how to use notify-send:
  4. notify-send --help

  5. In your scripts, just use it like this:
  6. notify-send 'title of notification' 'body of notification'

Your notification will now show up on your desktop like this:

notify-send

There you go, pretty simple, but very useful in your scripts.


Actions

Information

5 responses

5 01 2009
Showing Gnome/Ubuntu LibNotify Notifications from Mono and C# | Martijn's C# Coding Blog

[...] to displaying notification messages from Mono I came across a post by Luc Castera showing how you can simply show these notifications from a shell [...]

21 03 2009
Jonathan Lumb

Just what I was looking for – thanks!

4 06 2009
Using cron to treat my strained muscle « dambalah

[...] icing my legs, so I’m using a combination of gnome-schedule, a nice little GUI for cron and notify-send to remind me to start/stop icing at the right [...]

5 08 2009
markitoxs

Quick tip, thanks!

22 01 2010
M.

su – user -c “DISPLAY=:0.0 gdialog –msgbox ‘Your message!’”

Leave a comment