Just yesterday I migrated from Ubuntu 18.04 to Ubuntu 20.04. In 18.04 there was a software called "Battery Monitor" that monitors your battery percentage and notifies you when your battery percentage as reached low level.

I tried to install it in 20.04 but it seems it was not made compatible for it or maybe I am doing something wrong...

Can anyone please help me with this or find me an alternative?

My most important need is to be notified when my battery percentage goes below a certain number.

Thank you


I have Ubuntu Budgie 20.04 and this worked for me:

cd /etc/UPower
sudo nano UPower.conf

If you set UsePercentageForPolicy=true then edit the percentage lines to your liking, such as:

PercentageLow=50
PercentageCritical=35

If you prefer a time based approach then set UsePercentageForPolicy to false and set the time notification options to your liking, such as:

TimeLow=1200
TimeCritical=300

Hit ctrl+X to save the UPower.conf file and close out of nano editor.
Reboot computer or sudo systemctl restart upower for changes to take effect.

By doing this I was able to get the low and critical battery notifications. The pop-up notification only displays for about 2 seconds. Here is what it looks like: enter image description here


After a lot of research, here's a script that works perfectly - and gives persistent notifications for both high and low battery ;)

Procedure

  1. Store the script (written below) in some folder (like a folder named scripts in the home directory)
  2. Open terminal and type: crontab -e
  3. Add this line to run the script automatically every 2 minutes: (Note: I've kept the script's name as battery notifications)

/2 * * * * bash /home/garmadon/scripts/battery-notifications.sh

  1. Press Ctrl + x and then enter to exit and save the crontab.
  2. Log out and log into the system (or restart) to see the effect.

The script

#!/bin/bash

export XDG_RUNTIME_DIR=/run/user/$(id -u)

V1="Charging"

V2=$(grep -w "Charging" /sys/class/power_supply/BAT0/status)

V3=$(grep -Eo '[0-9]{1,}' /sys/class/power_supply/BAT0/capacity)

if [ "$V1" = "$V2" ] && [ "$V3" -ge 85 ]; then
    notify-send -u critical "Remove Charger!"
fi

U1="Discharging"

U2=$(grep -w "Discharging" /sys/class/power_supply/BAT0/status)

if [ "$U1" = "$U2" ] && [ "$V3" -le 45 ]; then
    notify-send -u critical "Plug in Charger!"
fi

Note:

  1. I'm on ubuntu 20.04
  2. I've kept 85% and 45% as the notification level, you can modify them according to your needs.
  3. This script gives persistent notifications that won't go away until you click on them. This comes in handy if you are away from your laptop and hence prevents you from missing the reminder.