notify-send command sends notification to the desktop. It is non intrusive. It does not ask user to press ok, and it does not take any control away from the user.
This article explains how to send various types of desktop notifications using notify-send program.
1. Simple Notification
notify-send can be used to send simple notification as shown below.
$ notify-send 'Title of the message' 'Text of the message'
2. Notification with an icon
notify-send can be used to send notification along with an icon using -i option.
$ notify-send -u critical -i "notification-message-IM" 'Boss !!' 'Am done with the execution'
notification-message-IM is a type of icon that can be used in the notify-send program.
To view all available notification icons, refer to the Notify send guidelines (under the section “How do I get these slick icons”).
3. Notification with custom icon
You can use your own custom icon using the notify-send -i option as shown below.
$ notify-send -i /home/sathiya/deal.ico 'Deal success'
4. Show output of any command
For example, you can display the last few lines of syslog as shown below.
$ notify-send syslog "`tail /var/log/syslog`"
In the same way, you can use any command (for example, date) and display its output as desktop notification using notify-send.
5. Notify after completing a command execution
To notify only if the command execution succeeds, use &&.
command && notify-send
To notify after a command (or shell-script, or background job) is completed, without worrying whether the commands succeeded or failed use ;.
long job ; notify-send
This method is extremely helpful when you are executing a long running shell-script in the background and you would like to be notified with a little nice non-intrusive pop-up when the job is completed.
Comments on this entry are closed.
of course, users have to install “libnotify-bin” first.
sudo apt-get install libnotify-bin
other than that great post! 🙂
what about incoming email notifiations?
just placed two cron entries for lunch time and time to go home 🙂
it would be interesting to have a script that connects to a remote server by ssh and makes some check in the log files. if some key words are found, then to return a value and send me a notification.
for crontab to work, you must place this in front of the command:
like here http://ubuntuforums.org/showthread.php?t=615882
In order to use this command libnotify-bin must be installed.
Very helpful, maybe you should add info about the package in which notify-send is included (libnotify-bin). In my Ubuntu 10.10 wasn’t installed by default.
Dear Ramesh Natarajan,
Cheers and best wishes for service intentioned blog. Keep it up.
Pleasant community feeling is inhibited amongst the open source software users. I am an addict of 73 years old with no background of computer technology.
Great stuff, and it’s not just for people who use Ubuntu – it works for me in FreeBSD as well. I think the first thing I’m going to do with this, is see if I can use it to notify me whenever someone talks to me on IRC, when I get new e-mail and so on 🙂
Btw, for other FreeBSD users:
# pkg_info -W /usr/local/bin/notify-send
/usr/local/bin/notify-send was installed by package libnotify-0.4.5_4
Hi, I can’t change the pop-up show time. The default value is 10, but the option “-t” does not works . Only if i set it with value “0” the pop-up change in a window with button for exit. I make a scripts that show me (with notify-send) if the caps lock is “on” or “off”. If i push caps lock two times quickly, i must attend 10 seconds for message “on” and 10 seconds for message “off”. How can I do to solve this problem?? thanks!
Thank you! This is so helpful to me right now.
Thanks. Very helpful article.
Do you have a way to execute notify-send with setting it’s parameters dynamically? Say within a shell script?
For example in below , I’d like to pass counter ‘v’ and command line argument ‘TITLE’ to notify-send…
TITLE=$1 //read 1st cmd-line argument from std input
for v in 1 2
notify-send ‘$v : ‘ ‘$”TITLE”‘
…and expect to send alerts as follows: