Historically, there were different approaches to problem of "notifications". There isn't even consensus of what "notification" is. Do we use it to only tell user that something happened? Do we expect any action from him? If so, how is input gathered? Can that action be delayed, or should user act immediately? How long could it be delayed? How is user supposed to review all pending actions? Answers to all these questions shape solutions proposed by different teams.
The bottom line is, there is no single, definite answer to your question. But there are different approaches that you can try and pick one that fits your particular use-case.
notify-send
At one point, a standard for notifications on Linux emerged. The driving force behind it, if memory serves me right, was GNOME 3 team. They strove for unified way for all applications to notify user and figured out that some component of desktop environment should be responsible for handling (queuing, displaying, gathering input) all notifications. Applications merely send their notification to that component and hope that user receive it.
You can create that kind of notification with notify-send
command line app. Note that it purposeful does not allow for customization. You only pass your message and leave the rest to desktop environment. This kind of notifications is supported by Unity (Ubuntu), GNOME 3 and KDE SC/Plasma.
osd_cat
osd_cat
is application that displays content of file on X server layer. By using -d
switch, you can make it automatically disappear after some time, which makes it somewhat suitable as notification app.
The default font will be ugly, but you can make it better by using -f
switch. -f
argument must be string constructed by xfontsel
.
A sample notification could be created this way:
echo -e "sample\nnotification" |osd_cat -p middle -A center -d 1 -f '-*-helvetica-*-r-*-*-34-*-*-*-*-*-*-*' -O 1 -c '#fff'
Contrary to notify-send
, you can place your notification anywhere on the screen and you can customize it a bit (select font and color; there is no background color). The main drawback is that it is X-specific, so it will not work under Mir or Wayland.
zenity/kdialog
zenity
(for GTK desktops - Unity and GNOME) and kdialog
(for Qt desktops - KDE and LxQt) allow user to create simple dialog windows from command line. You can put text inside, but also some predefined icons, buttons, input forms, lists, file pickers or progress bars. With a little work on your side, you could use them as a way to notify user.
zenity
supports --width=
and --height=
command line switches, but doesn't provide any way to change placement of window. Personally, I am using --title=
to give window some custom title and window manager rules. Window manager (KWin in my case) picks all windows that match certain criteria, like title containing string, and modify their properties. For notifications I put these windows in lower right corner of screen, remove window title bar, make them appear on all virtual desktops and remove them from task bar.
Custom solution
If neither of above programs suits your requirements, you can always write your custom solution. python provides bindings to both GTK and Qt and will allow you to relatively painlessly create custom GUI. You will have all the customization options in the world, but this will require some initial work to get started.
notify-osd
. There's a simplified alias for bash defined by default in your.bashrc
file calledalert
. But they do not fulfil most of your requirements.notify-send "title" "message body"
. You can usenotify-send --help
for more options, but it doesn't have options for notification color or position. (You can set the icon, urgency, timeout, and a couple other options though.)