How do I configure the low battery notifications?

My laptop routinely runs between full and critical charge a few times over the course of a day (yes, it's old). Before I updated to 16.04, Cinnamon used to notify me at:

  • 20%, then again at

  • 10%, then again at

  • 7%, then again at

  • 5%, then finally

  • "The battery has reached a critical level. The computer will hibernate very soon unless it is plugged in." at 2% or so. (at which point it continues to function for another 15 minutes.)

When I installed 15.10 and obliterated Unity in favour of Cinnamon, I didn't (knowingly) change anything related to this (or know it was possible).

Some configurations were reset during my system-wide upgrade, including the ones related to these power notifications. This answer lets me set just two notifications, one for critical and one for action, but I clearly remember having the five notifications mentioned above each time as if it was yesterday (because it was, ha-ha).

As I said above, I didn't conciously install any external programs for this, so while I'm aware I could write a shell script which just continually polls the sys entry with the battery percentage and notifies at given times, I'm also convinced it was a default behaviour of Ubuntu / Cinnamon (both of which I still use).

Can I get my 5 notifications back, or should I go with the shell (or other) script?


Solution 1:

The way I have my notifications set up is via script that launches in /etc/rc.local file on every boot. Simply place the full path into that file and call it like so:

/home/USERNAME/bin/batmon.sh &

What it will do is that it will continuously echo to GUI and to command line that "hey, your battery is draining" till you plug in AC source.

The script relies on couple of things : having correct battery name ( mine is BAT1 and the file we want is /sys/class/power_supply/BAT1/uevent) and the presence of on_ac_power script, which does come with every default Ubuntu flavor ( i don't know about Kubuntu or Xubuntu or others)

The source code for the script is located on my git https://github.com/SergKolo/sergrep/blob/master/batmon.sh

Feel free to modify the script to your liking , maybe tune the delay time. I've set mine to 30 seconds in sleep function, but you can change it to minute (60 seconds) or more.