This article briefly presents a « solution » to the battery switching issue mentioned at the bottom of this blog entry.
Indeed, while having two batteries ensures a (very) long battery life, you have to switch manually from the secondary battery to the primary, in order to prevent deep discharges that harms lithium batteries.
Until now, I used to manage it by typing some aliases in my shell, but it is clearly not convenient nor reliable (Sometimes, I simply forget it).
But now, one little bash script and one line in your root’s crontable, and the job’s done :)
There is battery_switch.sh (deprecated, see baswim.sh below). It basically allows automatic switching to main battery when a given percentage level is reached by the secondary battery. Some parameters are available by editing variables values directly in the script, but only LOW_LEVEL is really interesting.
The cron line I use:
# sudo crontab -e # m h dom mon dow command */5 * * * * /opt/bin/battery_switch.sh
Of course it is aware of your laptop’s status. In fact, if it switched to the main battery (by forcing the main battery to discharge), and then you re-plug your laptop, it will cease to force discharge and will return to normal state.
Since I may not be clear, do a
tail -F /var/log/battery_switch.log
to get relevant information.
I hope that will help :)
EDIT: please find there baswim (battery switching improved) a new script that provides a *really* interesting feature: It permits to switch from one battery to another according to both remaining percentage and cycles count.
It follows this simple scheme:
1) Get batteries cycle status 2) Decide which battery should discharge first based on cycles and remaining percentage (above the low_level) 3) Get AC status 3) If AC is unplugged, begin discharge with chosen battery 4) If needed by long unplugged operation, switch to the other battery
It basically a hack from the first script, there are some oddities (one line functions…) but hey it works (surprisingly)!
EDIT: A little but likely important update. This time, both scripts can handle two cases: one battery plus dvd-drive or both batteries.
EDIT:
If you want baswim to be a little more aware of acpi events,
you can make some symbolic links in /etc/acpi/battery.d and /etc/acpi/ac.d.
ln -s /opt/bin/baswim.sh /etc/acpi/battery.d/ ln -s /opt/bin/baswim.sh /etc/acpi/ac.d/
Then, baswim will be executed every time you plug or unplug your AC.