Send desktop notification from shell scripts

Install packages
sudo apt-get install libnotify-bin

send some notification
notify-send "rsnapshot done :)"

#another example
...
alert=18000
live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g')
[ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i   "BSE Sensex touched 18k";  notify_counter=1; }

...

-t 5000: Specifies the timeout in milliseconds ( 5000 milliseconds = 5 seconds)
-u low : Set the urgency level (i.e. low, normal, or critical).
-i gtk-dialog-info : Set an icon filename or stock icon to display (you can set path as -i /path/to/your-icon.png).


A Note About GUI Tools and Cronjob

You need to request local display/input service using export DISPLAY=[user’s machine]:0 command if you are using cronjob to call your scripts. For example, call /home/vivek/scripts/monitor.stock.sh as follows which uses zenity tool:

@hourly DISPLAY=:0.0 /home/vivek/scripts/monitor.stock.sh

Mobile Access SSL Network Extender (SNX) remote users with Windows 11 24H2 fail to connect

  Cause The conflict resolution mechanism in Windows 11 24H2 is different than in earlier versions of Windows. Solution On the Windows endpo...

Mais vistos