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/autogen.sh ; 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/autogen.sh finished
“


July 27, 2007 at 12:42 pm |
% cat untested.sh
#!/bin/sh
($@) && notify-send “Done” “$@”
October 3, 2007 at 10:19 am |
That works
March 9, 2008 at 9:23 am |
sami, your idea with the smiles made my socks drop! that was SO FUN ! thanks for the post
March 9, 2008 at 9:11 pm |
Thanks Michal… although i shouldnt take credit… i stole it from a friend of mine who had it on his bash prompt
.
March 30, 2008 at 12:20 pm |
[...] while back I blogged about how I use notify-send from libnotify to tell me when my builds are [...]
March 31, 2008 at 8:52 pm |
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 ]
then
notify-send “:-) done: $@”
else
notify-send –urgency=critical “:’( failed: $@”
fi
}
Happy hacking!
March 31, 2008 at 8:54 pm |
Markup was eaten by blog….
Surround failed with and .
April 1, 2008 at 4:57 pm |
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.
August 30, 2008 at 8:17 am |
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.
August 30, 2008 at 8:43 am |
i am quite wrong so i had to rewrite whole script. looks like .sh file + bash asdf.sh + 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 quiet-upgrade.sh
NOTE: it will not print any date in name of file, but however, without \s in front of ` script epic fails, you can try
September 4, 2008 at 9:04 am |
Neat
November 4, 2008 at 7:51 am |
Thanks for your post; clever idea! For what it’s worth, on Debian/Ubuntu notify-send is part of the libnotify-bin package.
November 7, 2008 at 10:11 pm |
took your saydone script and modified to show alerts in the tray (using zenity, instead of notify-send):
#!/bin/sh
($@) ; zenity –notification –text “Done! `if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi` $1″
January 22, 2009 at 8:09 am |
such a real story..
December 13, 2009 at 10:12 am |
[...] 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 [...]
January 2, 2010 at 8:58 pm |
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.
March 1, 2010 at 4:31 pm |
[...] Another interesting example of notify-send can be found here. [...]
December 12, 2010 at 10:01 am |
[...] Another interesting example of notify-send can be found here. [...]
July 20, 2011 at 7:16 am |
[...] a regular user, the notification is displayed in right lower corner and is white (looks like this http://wagiaalla.com/2007/06/06/notify-send/). When running as root, the notification is displayed in upper right corner and is black (looks [...]