The i3 FAQ has migrated to All content here is read-only.
Ask Your Question

warning popup when battery very low

asked 2013-04-30 23:04:36 +0000

fab gravatar image

So far so good with i3 :)

There is one thing though: When running on battery, while I have now the color of the battery text in the status bar changing to red when the battery reaches the threshold configured, it sometimes escapes my attention...

So I am thinking of having a popup or message appear when the battery reaches a certain threshold.

What would be a way to do that (without having to load any gnome stuff)? Other suggestions instead of popup also welcome.

edit retag flag offensive close merge delete


notify-osd works great for me (but I am on Ubuntu, loads of gnome in there). I tried dunst before but always failed to catch my attention, defeating the purpose of having this in the first place, so now I am back to notify-osd!

bruno.braga gravatar imagebruno.braga ( 2013-05-01 13:09:22 +0000 )edit

5 answers

Sort by » oldest newest most voted

answered 2014-04-02 20:40:46 +0000

chalist gravatar image

I found this in arch forum:

I just use a cron job to do a check every five minutes and notify if there is less than 15 minutes of charge left


BATTINFO=`acpi -b`
if [[ `echo $BATTINFO | grep Discharging` && `echo $BATTINFO | cut -f 5 -d " "` < 00:15:00 ]] ; then
    DISPLAY=:0.0 /usr/bin/notify-send "low battery" "$BATTINFO"


edit flag offensive delete link more

answered 2013-05-01 12:11:04 +0000

vandannen gravatar image

If you have a notification daemon running, like notify-osd or dunst, you could popup a notification when the battery is running low. Sending an own notification message can be done with, e.g., notify-send (package libnotify-bin for debian) or dunstify (from dunst).

edit flag offensive delete link more

answered 2013-05-02 13:00:59 +0000

fab gravatar image

This is what I finally did (it's from the archlinux form, topic id=133047, but I can't post links yet :( ) using the i3-nagbar! I actually need to tweek it because when the popups start to appear they are indeed nagging :)

    #! /bin/bash

SLEEP_TIME=5   # Default time between checks.
SAFE_PERCENT=30  # Still safe at this level.
DANGER_PERCENT=15  # Warn when battery at this level.
CRITICAL_PERCENT=5  # Hibernate when battery at this level.

export DISPLAY=:0.0

function launchNagBar
    i3-nagbar -m 'Battery low!' -b 'Hibernate!' 'pm-hibernate' >/dev/null 2>&1 &

function killNagBar
    if [[ $NAGBAR_PID -ne 0 ]]; then
        ps -p $NAGBAR_PID | grep "i3-nagbar"
        if [[ $? -eq 0 ]]; then
            kill $NAGBAR_PID

while [ true ]; do


    if [[ -n $(acpi -b | grep -i discharging) ]]; then
        rem_bat=$(acpi -b | grep -Eo "[0-9]+%" | grep -Eo "[0-9]+")

        if [[ $rem_bat -gt $SAFE_PERCENT ]]; then
            if [[ $rem_bat -le $DANGER_PERCENT ]]; then
            if [[ $rem_bat -le $CRITICAL_PERCENT ]]; then

    sleep ${SLEEP_TIME}m

edit flag offensive delete link more


Note that i3-nagbar _should not be used_ like this. Our expectation is that it’s only ever used by i3. It will never be extended to suit the needs of third-party use-cases like this. Please use something else.

Michael gravatar imageMichael ( 2014-04-17 12:34:55 +0000 )edit

Here's my version using notify-send: (

ilpianista gravatar imageilpianista ( 2015-10-31 08:48:09 +0000 )edit

answered 2014-04-09 11:52:09 +0000

Since it was a long-standing issue for me as well, I post my solution here:

  1. Use conky as system monitor. Minimal conky file is:

    out_to_x no
    own_window no
    out_to_console yes
    background no
    max_text_width 0
    total_run_times 0
    ${if_match ${laptop_mode}>=0}
     ${if_match ${battery_percent}<15}
      ${if_match ${battery_percent}<10}
       ${execi 20 xcalib -red 1.1 30.0 100.0 -alter}
       ${exec notify-send -u critical "$(acpi -b)"}
       ${execi 60  xcalib -red 1.1 20.0 100.0 -alter}
       ${execi 120 notify-send -u critical "$(acpi -b)" -t 5000}
  2. update your i3 bar (or create a new invisible one) with:

     # Inhibit SIGSTOP signal for conky
     status_command echo '{"version":1,"stop_signal":17}['; conky -c path/to/conkyrc

Since i3bar sends the SIGSTOP signal to the statusline process to save battery power, you have to inhibit this behaviour. Be sure to use the right signal by invoking kill -L (I replaced SIGSTOP by SIGCHILD here)

Apparently It's mandatory for invisible mode as well (not sure It's a feature or not).

edit flag offensive delete link more

answered 2013-05-01 16:35:44 +0000

platz gravatar image

updated 2013-05-01 16:38:23 +0000

It's not a homegrown solution, but I just have exec xfce4-power-manager in my i3 config to start the power manager on startup. This will show a popup when battery is low. (I don't believe the xfce4 plugins have any gnome dependencies.)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-04-30 23:04:36 +0000

Seen: 4,504 times

Last updated: Apr 09 '14