libnotify over ssh
Posted by bene - 15/02/08 at 09:02:36 pmlibnotify is a nice desktop notification framework, very similar to Growl. It’s basically a client-server architecture: the desktop implements a notification-daemon where the clients send notifications to (via D-Bus).
In my case it’s notification-daemon-xfce and on the client side primarily galarm and pidgin (using a patched pidgin-libnotify plugin).
With notify-send you can also create your own notification. I wrote a little zsh wrapper function to get a notification when the command terminates:
# run some command and notify about the result via the notification-daemon
function run () {
$@
local error=$?
if [[ $error -eq 0 ]]; then
notify-send “`hostname -s` | terminated:” “$1 $2″ -i finish -t 0
else
notify-send “`hostname -s` | aborted:” “$1 $2″ -u critical -i undo -t 0
fi
return $error
}
The usage is quite simple:
# run sudo update-eix
All of this is nice but I decided to need notification of remote events as well.
I hate to wait or poll till a command on my server terminates, instead the server should notify me. ![]()
Additionally I run a WeeChat IRC-client 24/7 in screen and want a notification for (private) IRC messages.
Accomplishing my requirements is a tough task, but after some research I found this nice idea of Jared Quinn: libnotify-with-irssi-over-ssh.
The trick is to tunnel the notification through the terminal using the print pipe.
I adapted his scripts and patched them to fit my needs:
My favorite terminal is rxvt-unicode so the .Xdefaults entry looks a bit different:
URxvt.print-pipe: ~/scripts/unmarshal.pl
My unmarshal script collects the content of the pipe and sends the notification to the daemon:
unmarshal.pl (html)
…the WeeChat plugin (based on growl-notify):
…and finally the drop-in replacement for notify-send:
If notify-send is placed in /usr/local/bin/ on the remote host, you can just type something like run sudo updatedb and get a notification to the desk. ![]()
Powered by WordPress with GimpStyle Theme design by Horacio Bella. Get Entries and comments.