Sometimes you run a task from the console which takes a while. (E.g.: compiling some programs, downloading something from the internet or installing updates.) Often you do not wait until this task finishes and just toggle to the next window. Would it be nice if you would get some kind of notification, when the task has finished? I found the following solution, which uses the Ubuntu notification system:

  • Edit the .bashrc file from you home directory and append the following lines:
    1. alias alert_helper=‘history|tail -n1|sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//"’
    2. alias alert=‘notify-send -i /usr/share/icons/gnome/32×32/apps/gnome-terminal.png "[$?] $(alert_helper)"’
  • Install the libnotify-bin package
    sudo apt-get install libnotify-bin
  • If you do not want to restart execute the next command in a console:
    source ~/.bashrc

Now you have a new command available on your console: alert
If you do something time consuming now add the additional alert after the last command and you will get a nice notification:

notification

notification from the console