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.
present: yes
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.
#!/bin/sh
charged=0
while : ; do
if grep -iq 'charged' /proc/acpi/battery/BAT1/state
then
# nofify if previous state is uncharged
if [ $charged = 0 ] ; then
zenity --info --text "Battery charged. You might wanna charge another."
fi
charged=1
else
charged=0
fi
sleep 5m # wait for 5 minutes
done
abui k ho yo??
ReplyDeletelastai bho yaar..
ta mula dherai coding nagar ta..einstein..:P
ma nikat bhabisya ma laptop kinchu ani tero code run garula :D..
i hope loadshedding will be history by then
hmm.... seems useful :)
ReplyDeletewhy don't u upload all your snippets to something like google code ?
pachi ekai thaaun herna ramailo huncha ;-)
Great. Kabin also had one hardware solution :)
ReplyDeletehttp://kabinshrestha.com.np/blog/inverter-battery-buying-tips-and-calculations/