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:
- Install libnotify-bin:
- Learn how to use notify-send:
- In your scripts, just use it like this:
sudo aptitude install libnotify-bin
notify-send --help
notify-send 'title of notification' 'body of notification'
Your notification will now show up on your desktop like this:
There you go, pretty simple, but very useful in your scripts.


