Most of the application can show nicely formatted notification on events that appear on top right corner of the screen. I'm about to write a bash script that will do fairy long processing in the background and I really want to know when it is finished. How can I show that nice notification from a bash script?
If you're using the new notification system in Jaunty, you want the notify-send command
notify-send - a program to send desktop notifications SYNOPSIS With notify-send you can sends desktop notifications to the user via a notification daemon from the command line. These notifications can be used to inform the user about an event or display some form of information without getting in the user's way. OPTIONS -u, --urgency=LEVEL Specifies the urgency level (low, normal, critical). -t, --expire-time=TIME Specifies the timeout in milliseconds at which to expire the notification. -i, --icon=ICON[,ICON...] Specifies an icon filename or stock icon to display. -c, --category=TYPE[,TYPE...] Specifies the notification category.
Found another way, through Zenity
echo 'message:hi' | zenity --notification --listen
(This also has the benefit of already being installed on Ubuntu.)
There's also xmessage that will pop-up a window, so it should work on any X11 system.
Pro: It also allows interactively prompting the user with buttons.
Con: Like any pop-up alert, it typically receives focus, so if you're in the middle of typing it can disappear before you read the message.
For KDE users:
$ kdialog --title "Long process completed!" --passivepopup "This popup will disappear in 5 seconds" 5 &
There exists a cross-platform solution called Yfiton:
$ yfiton -n desktop -Pmessage="Lunch time!" -Pposition=TOP_RIGHT
Popup notification that auto-closes after 10 seconds:
notify-send "Hello world"
Popup window with buttons to click:
[window does not get auto-focus]
notify-send -t 0 "Hello world"
Source: myself; note:
-t is ignored for all values except 0--how stupid. :(
[window gets auto-focus]
zenity --info --title "Hello" --text "World"
[MY FAVORITE, since the window auto-closes after the specified
--timeout in seconds]
zenity --info --title "Hello" --text "World" --timeout=2
Source: myself reading the man pages:
xmessage 'hello world'
In a shell script, you can also call the osd_cat utility from libxosd.