Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating KDE 4 notifications from bash scripts

I have a bash script activated by crontab and running in background. I would like to add to it the ability to send notifications during the execution. My KDE 4 desktop has a fancy notification system which pops out non-modal messages from the tray bar, and this would be perfect for my needs. So I was searching for a way to generate these notifications from a bash scripts, but I have almost no knowledge of the KDE platform and so I'm stuck. Can anybody point me to a solution?

like image 758
Massimiliano Fliri Avatar asked Sep 04 '09 14:09

Massimiliano Fliri


3 Answers

kdialog's passive popup option can be used.

kdialog --passivepopup <text> <timeout>

Example:

kdialog --passivepopup 'This is a notification' 5
like image 182
Alan Haggai Alavi Avatar answered Oct 15 '22 23:10

Alan Haggai Alavi


You may also use notify-send (on Debian-based systems, install the libnotify-bin package):

notify-send -i 'dialog-information' 'Summary' '<b><font color=red>Message body.'

To my best knowledge, this should work on several window managers (such as KDE and Gnome).

Edit: HTML formatting of the message will only work with certain notification daemons and should thus be avoided.

like image 19
mzuther Avatar answered Oct 16 '22 01:10

mzuther


kdialog --passivepopup 'message including html' timeout

is an option for KDE where the timeout is not necessary. you can tune this even with adding a headline (--title) and so on --> see kdialog --help

on the one hand it is worth mentioning, that kdialog was installed on my openSuSE KDE4 system whereas notify-send is not installed here.

on the other hand the advantage of notify-send is that you can use it with different desktop environments

like image 2
user3220705 Avatar answered Oct 16 '22 00:10

user3220705