batalert: a /dev/apm monitor and program launcher


batalert is a simple battery monitory for OpenBSD that monitors /dev/apm and, when the estimated battery life remaining (measured in minutes) drops below a specified threshold (and the AC is disconnected), it launches a program. That's it.

Although something similar could be accomplished with sensorsd(8), I wanted something I could drop on other, non-OpenBSD computers, that could be as annoying as possible (I tend to require this... otherwise my battery runs dry and my laptop shuts off). It queries the standard APM interface for battery info, and thus compiles & runs fine on most POSIX complient OS's.


Manual: batalert(1).

For a great sample program to have batalert execute, consider the following sh script (note: it requires the xosd package to be installed for the annoying X-display message to work):


   message="!!! BATTERY DYING !!!"

   # send message to all terms
   echo $message | /usr/bin/wall 

   # also throw a loud message up in center of x display
   # (if x isn't running this will error)
   # NOTE: This requires that osd_cat (part of "xosd" package) be installed
   if [ -e /usr/local/bin/osd_cat ];
      echo $message \
         | /usr/local/bin/osd_cat -p middle -A center -f "-*-fixed-*-*-*-*-72-*" \
                                     -c yellow -l 1 &
A screen shot of the effects of the above can be seen by clicking here.


Here: batalert.tgz.

To build just a simple

will suffice. To install the binary and man page in /usr/local/,
      make install

Copyright (c) 2009 Ryan Flannery <>