I'm in the process of setting up a laptop running Debian Jesse with xmonad as the display manager. I use xmobar to display information about the current state of the system, including the battery level. However, I find that I forget to check regularly and I'm always surprised when my computer suddenly shuts off because the battery died --- I miss the pop-up notifications that I used to get with XFCE.

What can I use to get an attention-grabbing warning about my low battery? Most solutions I've found use dzen, or just display a number on the status bar, which I've found to be insufficient.


2 Answers 2


This is no ready solution, but an idea: I would use osd_cat which comes in the package xosd in Fedora Linux together with a cronjob, that checks your battery status.

You can edit your cronjobs with

crontab -e

and you find your battery status in /sys/class/power_supply/, and there it is in my case BAT1/ with some files charge_now and charge_full. With those files, that is with


you could find the percentage remaining in your battery, which could then show you a big message with osd_cat (onscreen display).


Here is a short script I wrote following @erik's suggestion of using osd_cat:

from subprocess import Popen, PIPE

with open("/sys/class/power_supply/BAT0/charge_now") as f:
    charge_now = float(f.read())
with open("/sys/class/power_supply/BAT0/charge_full") as f:
    charge_full = float(f.read())

percent = 100*charge_now/charge_full

if percent < 10:
    p = Popen(['osd_cat','-A','center','-p','middle','-f','-*-*-bold-*-*-*-36-120-*-*-*-*-*-*','-cred','-s','5'],stdin=PIPE)
    p.communicate(input="Battery Low!")

which you can then run via a cron job every minute:


* * * * * python ~/power_warning.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.