{"id":700,"date":"2012-02-18T06:26:45","date_gmt":"2012-02-18T11:26:45","guid":{"rendered":"http:\/\/www.xavignu.com\/?p=700"},"modified":"2013-04-30T16:41:21","modified_gmt":"2013-04-30T20:41:21","slug":"notify-send-command","status":"publish","type":"post","link":"https:\/\/www.xavignu.com\/?p=700","title":{"rendered":"Notify-send command"},"content":{"rendered":"<p>So the other day I was looking around and discovered the <a href=\"http:\/\/manpages.ubuntu.com\/manpages\/gutsy\/man1\/notify-send.1.html\" target=\"_blank\">notify-send<\/a> command. It basically sends notifications to the desktop. Pretty useful now adays.<\/p>\n<p><b>[11:49:13] xavi@thinkpad: ~ $ sudo dpkg -S `which notify-send`<br \/>\nlibnotify-bin: \/usr\/bin\/notify-send<br \/>\n[11:49:15] xavi@thinkpad: ~ $<\/b> <\/p>\n<p>It is installed with libnotify-bin via aptitude.<\/p>\n<p><b>[11:50:35] xavi@thinkpad: ~ $ sudo aptitude install libnotify-bin<\/b><\/p>\n<p>So, once installed lets create a practical script. On my job I need to have a permanente <a href=\"http:\/\/en.wikipedia.org\/wiki\/Virtual_private_network\" target=\"_blank\">VPN<\/a> 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.<\/p>\n<p>[bash]<br \/>\n#!\/bin\/bash<\/p>\n<p># Check tunnel interface<br \/>\nwhile &quot;true&quot;; do<br \/>\n        \/sbin\/ifconfig tun0 &amp;&gt; \/dev\/null<br \/>\n        while [ $? -ne 0 ]; do<br \/>\n                notify-send -t 5000 &quot;VPN&quot; &quot;VPN is down&quot;<br \/>\n        done<br \/>\n        sleep 300<br \/>\ndone<br \/>\n[\/bash]<\/p>\n<p>We save and copy the script, give it execution permissions with chmod and send it to background.<\/p>\n<p><b>[11:55:47] xavi@thinkpad: ~ $ chmod +x \/tmp\/check-vpn.sh; \/tmp\/check-vpn.sh &#038;<br \/>\n[1] 15613<br \/>\n[12:00:43] xavi@thinkpad: ~ $<\/b> <\/p>\n<p>Here is a screenshot of it working.<\/p>\n<p><a href=\"http:\/\/www.xavignu.com\/wp-content\/uploads\/2012\/02\/vpn.png\"><img loading=\"lazy\" src=\"http:\/\/www.xavignu.com\/wp-content\/uploads\/2012\/02\/vpn-300x187.png\" alt=\"vpn notify-send\" title=\"vpn\" width=\"300\" height=\"187\" class=\"aligncenter size-medium wp-image-704\" srcset=\"https:\/\/www.xavignu.com\/wp-content\/uploads\/2012\/02\/vpn-300x187.png 300w, https:\/\/www.xavignu.com\/wp-content\/uploads\/2012\/02\/vpn-1024x640.png 1024w, https:\/\/www.xavignu.com\/wp-content\/uploads\/2012\/02\/vpn.png 1440w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[56,22,6,23,70,29],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pTQgt-bi","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/700"}],"collection":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=700"}],"version-history":[{"count":8,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/700\/revisions"}],"predecessor-version":[{"id":818,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/700\/revisions\/818"}],"wp:attachment":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}