Ubuntu / Linux news and application reviews.

notifyosd terminal notification

Dustin Kirkland, Core Developer of the Ubuntu Server posted something very interesting on his blog: an alias you can add to your .bashrc file to get notified when a job you run in a terminal is done. A simple solution for something I've been looking for in a long time.

Getting notified when the job you're running in the terminal is done can be very useful since when you compile something or run some other time consuming task, you usually don't care what's going on inside the terminal  until whatever you were running is done, right? So you switch to some other window(s) meaning you have to constantly keep checking the terminal window to see when it's done. And that's not exactly productive. Further more, you may occasionally forget you were running something in the terminal.

Dustin's simple alias makes it very easy to get a notification bubble (using NotifyOSD) when the job you're running in the terminal is done.

Setting everything up

1. To use it, simply edit your ~/.bashrc file:

gedit ~/.bashrc

and paste this at the end of the file:
alias alert_helper='history|tail -n1|sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//"'
alias alert='notify-send -i /usr/share/icons/gnome/32x32/apps/gnome-terminal.png "[$?] $(alert_helper)"'

2. Then make sure you have libnotify-bin installed:
sudo apt-get install libnotify-bin

3. Now source your .bashrc:
source ~/.bashrc

Try it out

To get notified when a job you run in a terminal is done, add "; alert" at the end of a command (without the quotes).

As a test command you can run:
sleep 20; alert


Example: If you want to get notified when you compile some program, run the "make" command like this:
make; alert


Many thanks to Dustin Kirkland for the alias!