≡ Menu

How To Send Desktop Notifications on Ubuntu Using notify-send

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'

Fig: Simple desktop notification

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”).

Fig: Notification with IM icon

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'

Fig: Notification with your custom icon

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.

Fig: Notification displaying output of date command

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.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • vagvaf December 20, 2010, 3:10 am

    of course, users have to install “libnotify-bin” first.

    sudo apt-get install libnotify-bin

    other than that great post! 🙂

  • giannis December 20, 2010, 3:12 am

    what about incoming email notifiations?

  • al_mic December 20, 2010, 5:49 am

    nice 🙂
    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.

  • al_mic December 20, 2010, 6:10 am

    for crontab to work, you must place this in front of the command:
    DISPLAY=:0.0

    like here http://ubuntuforums.org/showthread.php?t=615882

  • Vince December 20, 2010, 6:51 am

    In order to use this command libnotify-bin must be installed.

  • Paul Kilo December 20, 2010, 9:06 am

    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.

  • V.Govindan December 21, 2010, 5:23 am

    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.

  • erikano January 14, 2011, 12:10 pm

    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

  • Francesco December 1, 2011, 6:28 pm

    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!

  • Animesh June 29, 2012, 12:56 am

    Thank you! This is so helpful to me right now.

  • madhu April 15, 2014, 7:45 am

    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
    do
    notify-send ‘$v : ‘ ‘$”TITLE”‘
    done
    …and expect to send alerts as follows:
    1:
    2: