You are not logged in.

#1 2020-10-04 20:09:10

amatika
Member
Registered: 2016-03-17
Posts: 59

[SOLVED] Missing low battery warning

What would be best way to show low battery warning on graphical desktop environment?
Currently system just shuts down when battery runs out.  No suspend nor sleep but it just shuts down losing all the unsaved data.
I am using Budgie desktop. Budgie's power management offers no solution for this.

Last edited by amatika (2020-10-05 06:37:49)

Offline

#2 2020-10-04 20:38:27

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 74,754

Re: [SOLVED] Missing low battery warning

You could poll the battery w/ https://www.archlinux.org/packages/comm … 6_64/acpi/ and act accordingly w/ a simple bash script.
For display you could use https://www.archlinux.org/packages/comm … sdbattery/ https://www.archlinux.org/packages/comm … cbatticon/ or just conky.

Offline

#3 2020-10-05 06:36:49

amatika
Member
Registered: 2016-03-17
Posts: 59

Re: [SOLVED] Missing low battery warning

Ended up this solution. Seems to work.

battery_test.sh

#!/bin/bash

battery_level=`acpi | grep -oP '(?<=, )\d+(?=%)'`

if [ "$battery_level" -le 10 ]
then
  notify-send "Battery low. Battery level is ${battery_level}%!"
elif [ "$battery_level" -le 3 ]
then
  notify-send "Battery critical. Battery level is ${battery_level}%! Suspending..."
  sleep 5
  systemctl suspend
fi

Crontab:

PATH=/usr/bin
*/5 * * * * XDG_RUNTIME_DIR=/run/user/$(id -u) /home/amatika/scripts/battery_test.sh

Last edited by amatika (2020-10-11 18:54:06)

Offline

Board footer

Powered by FluxBB