Ask Ubuntu Asked by Abdullah Omar on December 19, 2021
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
After a lot of research, here's a script that works perfectly - and gives persistent notifications for both high and low battery ;)
crontab -e
/2 * * * * bash /home/garmadon/scripts/battery-notifications.sh
#!/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
Answered by Ensei_Tankado on December 19, 2021
Could be very related as i ended up looking into how to restore battery indicator
$ sudo systemctl restart upower
Job for upower.service failed because a fatal signal was delivered to the control process. See "systemctl status upower.service" and "journalctl -xe" for details.
$ systemctl --failed
UNIT LOAD ACTIVE SUB DESCRIPTION
● upower.service loaded failed failed Daemon for power management
so i had to install
$ sudo apt install systemd:amd64 systemd-timesyncd:amd64
and now service started and battery indicator is back
$ sudo systemctl start upower
Answered by Tim on December 19, 2021
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:
Answered by hoatzin on December 19, 2021
I came to this workaround:
Works in ubuntu 20
sudo apt install gir1.2-appindicator3-0.1
sudo apt install acpi
sudo apt install libappindicator3-1
sudo apt install libnotify4
sudo apt install libgirepository1.0-dev
sudo apt install libcairo2
python3 -m pip install pycairo
cd ~/Downloads/
wget https://github.com/maateen/battery-monitor/archive/master.zip
unzip master.zip
cd battery-monitor-master/
nano Makefile (3 changes)
# 1. change sh in first line to bash
# 2. change from:
PREFIX ?= /usr
# to:
PREFIX ?= /home/USERNAME/.local
# 3 change python version (two lines to modify!)
# from:
python setup.py
# to:
python3 setup.py
sudo su
export PYTHONPATH=/home/USERNAME/.local/lib/python3.8/site-packages/
make install
exit
nohup battery-monitor &
I know it is odd but, I had to fix this:
# ↓↓↓ your python version of install ↓↓↓ your python version
sudo nano /home/USERNAME/.local/lib/python3.8/site-packages/battery_monitor-0.0.0-py3.8.egg/battery_monitor/Notification.py
# change the old lines with the new ones
elif state == 'charging':
NEW if (percentage >= self.upper_threshold_warning and
OLD if (percentage != self.last_percentage and
remaining != "discharging at zero rate - will never fully discharge" and
self.last_notification != "upper_threshold_warning"):
self.last_percentage = percentage
NEW self.last_notification = "upper_threshold_warning"
OLD self.last_notification!="upper_threshold_warning"
self.show_notification(type="upper_threshold_warning",
battery_percentage=percentage,
remaining_time=remaining)
Answered by Ferroao on December 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP