Load-shedding is driving us nuts! My solution is to move all my works to laptop and buy a spare battery. I think this is more cost effective and energy saving than buying expensive inverters. I've got an extra 8-cell battery for my laptop and altogether I have 6+ hours of backup.
But the problem is I keep forgetting to charge the batteries. The one in laptop starts charging when light is back but when it's done charging I forget to switch battery.
The solution lies at /proc/acpi/battery/BAT1/state
$ cat /proc/acpi/battery/BAT1/stateOur line of concern is 'charging state:' which can have one of three values - charging, discharging or charged. So here's a simple bash script to monitor this file for charged state and pop a message to switch the battery.
capacity state: ok
charging state: discharging
present rate: 1342 mA
remaining capacity: 2201 mAh
present voltage: 11432 mV
Now put this program to System > Preferences > Sessions > Startup Programs.
while : ; do
if grep -iq 'charged' /proc/acpi/battery/BAT1/state
# nofify if previous state is uncharged
if [ $charged = 0 ] ; then
zenity --info --text "Battery charged. You might wanna charge another."
sleep 5m # wait for 5 minutes