Idle alerts with bcvi
In case you haven't met it before, bcvi is a crazy backwards tool (written in Perl of course) that lets you type commands on a server to make things happen on your workstation. I've just released an update to the notifications plugin so I thought I'd blog about it here.
Here's a simple example to illustrate what the notifications plugin does. Imagine you've SSH'd into a server to kick off some long running command and you'd like to be notified when the command finishes. In this example, I'm running a database restore:
$ pg_restore -d acmecrm crm.pgdump; bnotify 'DB is restored!'
When the pg_restore completes, the
bnotify command will be run. Bnotify is an alias for bcvi which will send a message back to your workstation to pop up a desktop notification.
The new feature is that bnotify now accepts a
--idle option to send you a notification when the TTY is idle. The reason I wanted this is that I'm currently doing a bunch of server upgrades and although the upgrade process mostly runs unattended, I do get prompted for questions at intervals. Here's how I use the new feature:
$ bnotify --idle Starting background process to monitor /dev/pts/0 for 20 second idle period Kill monitor with: bnotify --kill $ sudo apt-get dist-upgrade [sudo] password for grant: Reading package lists... Done Building dependency tree The following NEW packages will be installed: ...
I will then leave the upgrade running and switch to do something in another window (or desktop). Some time later, the upgrade process will either complete or will pause to ask me how I'd like to deal with a possible conflict with a new version of a config file that wants to replace one I've modified. Either way, bnotify will notice that there's been no output on the terminal for some amount of time (default 20 seconds) and will signal my workstation to alert me with a message: "Notification from [servername]. Terminal is idle".
In my case, the workstation end of the notifications process is handled by Desktop::Notify - which works on Linux desktops (e.g. Gnome2/3, XFCE, KDE probably). But you could replace that with something that talked to Growl on a Mac.