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.
Get the Linux Sysadmin Course Now!