So the other day I was looking around and discovered the notify-send command. It basically sends notifications to the desktop. Pretty useful now adays.
[11:49:13] xavi@thinkpad: ~ $ sudo dpkg -S `which notify-send`
libnotify-bin: /usr/bin/notify-send
[11:49:15] xavi@thinkpad: ~ $
It is installed with libnotify-bin via aptitude.
[11:50:35] xavi@thinkpad: ~ $ sudo aptitude install libnotify-bin
So, once installed lets create a practical script. On my job I need to have a permanente VPN connection. Once in a while the VPN connection drops and we have to connect again. Lets create a simple script that notifies us when the connection drops.
#!/bin/bash # Check tunnel interface while "true"; do /sbin/ifconfig tun0 &> /dev/null while [ $? -ne 0 ]; do notify-send -t 5000 "VPN" "VPN is down" done sleep 300 done
We save and copy the script, give it execution permissions with chmod and send it to background.
[11:55:47] xavi@thinkpad: ~ $ chmod +x /tmp/check-vpn.sh; /tmp/check-vpn.sh &
[1] 15613
[12:00:43] xavi@thinkpad: ~ $
Here is a screenshot of it working.
Enjoy.