First of all I would like to give a big shout out to the folks who wrote libnotify. Libnotify standarized gnome notification solution, and they did a good job of it. The popup widget allows you to add buttons, images, and they look very good.

notify-send is a command line utility that makes uses libnotify to send notifications the the user.

for example:

notify-send hi

shows this:


As soon as i discouvered this I started using it to notify me when my build is finished. So:


make && notify-send DONE!

Then I got fancier and I added this to my .bashrc:

alias saydone='notify-send "Done! `if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi`"'

no explanation nessesary of course.

so now I do;

../frysk/ ; saydone

If the autogen returns a 0 i get a smily face, otherwise I get a frowny.


Now for the bash guros out there. How do i make it print the previously run command so that the notification says “../frysk/ finished :)”

About these ads

20 Responses to “notify-send”

  1. uzytkownik Says:

    % cat
    ($@) && notify-send “Done” “$@”

  2. sami Says:

    That works :)

  3. Michal Says:

    sami, your idea with the smiles made my socks drop! that was SO FUN ! thanks for the post

  4. sami Says:

    Thanks Michal… although i shouldnt take credit… i stole it from a friend of mine who had it on his bash prompt :).

  5. Sami Wagiaalla » Blog Archive » saydone Says:

    [...] while back I blogged about how I use notify-send from libnotify to tell me when my builds are [...]

  6. thebohemian Says:

    Here is a bash function which you can put into .bashrc and prepend to all commands which you would like to be notified.

    Erroneous state is highlighted in multiple ways:
    – ‘critical’ message urgency (paints in red here)
    – unhappy smiley
    – failed written in italics

    sd ()

    if [ $? = 0 ]
    notify-send “:-) done: $@”
    notify-send –urgency=critical “:’( failed: $@”

    Happy hacking!

  7. thebohemian Says:

    Markup was eaten by blog….

    Surround failed with and .

  8. sami Says:

    wordress ate up the markup again :)

    whats is strange is the italics mark up does not work for me from command line either

    Nice patch… but i kind of like the smily after the done/failed.

  9. U-P-S Says:

    alias saydone=’notify-send “Done! `if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi`”‘

    alias quiet-upgrade= apt-get update > update.txt && apt-get upgrade -y > upgrade.txt ; saydone

    then only

    sudo quiet-upgrade

    (or maybe not?) ;)
    all you have are logs and notify.

  10. U-P-S Says:

    i am quite wrong so i had to rewrite whole script. looks like .sh file + bash + aliases = boom so my script looks like this:

    apt-get update > apt-update-\`date\`-.txt && apt-get upgrade > apt-upgrade-\`date\`.txt ; notify-send “Done! `if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi`”

    run with

    sudo bash

    NOTE: it will not print any date in name of file, but however, without \s in front of ` script epic fails, you can try

  11. sami Says:

    Neat :)

  12. Andrew Conkling Says:

    Thanks for your post; clever idea! For what it’s worth, on Debian/Ubuntu notify-send is part of the libnotify-bin package. :)

  13. Joe Says:

    took your saydone script and modified to show alerts in the tray (using zenity, instead of notify-send):

    ($@) ; zenity –notification –text “Done! `if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi` $1″

  14. Solnce Says:

    such a real story..

  15. Execute-Notify Says:

    [...] a useful command-line interface to libnotify that lets alerts pop up on the desktop. As is the case for many others, I like the idea of using this tool to notify me that my long-running jobs are finished, so I can [...]

  16. Jacob Lunde Says:

    I also was using this to pass along info to users of updates or uploads to there work stations, I find if you use -t 0 in the mix it requires them to press the x to kill the message. I thought -u critical would do this, but it didnt seem to work, might be that cairo-dock is taking some time to theme it. Hope this helps any one else out there.

  17. notify-send – apeekaboo:s wonderful world Says:

    [...] Another interesting example of notify-send can be found here. [...]

  18. Command: notify-send | apeekaboo:s wonderful world of Linux Says:

    [...] Another interesting example of notify-send can be found here. [...]

  19. notify-send notification look (design) Says:

    [...] a regular user, the notification is displayed in right lower corner and is white (looks like this When running as root, the notification is displayed in upper right corner and is black (looks [...]

  20. seo Says:

    Would you be able to information me on your webmaster or the guy who deals with your site, I’d like to know if it would be very easy to be a visitor poster

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: