I didn't find a pure Software solution, so I've set up a quick hack based on the Belkin WeMo Switch and a Node.js app. The WeMo is a power outlet that can be switched on and off via Wifi. So you can plug your laptop charger on the WeMo, and a script or an app running on your laptop monitor the battery and switch the outlet on and off accordingly.
Edit: more explanations from the original blog post (the link is dead.):
My inspiration came from an Article on Wired, explaining that to improve your battery life, you must keep it charged in the 40% - 80% range.
In fact I really doubt the Wired article really make sense. "Not charging the battery up to 100% increase the discharge cycles", ok it's probably true. If the laptop is almost always plugged in and the battery is at 100%, you can expect 300-500 cycles, but your are only "using" a cycle once in a while. If the laptop is permanently cycling between 40-80% you can get 1200-2000 cycles, ok it's a lot more, but you are now using 10 cycles a day.
I'm not chemist and I don't know what's really going on in the battery. What happens if instead of doing 40%-80% cycles,
we do tens of thoushands 79%-80% cycles ? What percentage variation is considered a cycle ? Does 0%-80% cycles are better than 20%-100% ? As always the evil is probably in the details, and all batteries, even among the LiPo familly have different specifications.
I think it would be more useful to just pop up a notification if the battery get lower than x%. Just to remind you that if you are close from a power source that would worth it to plug your laptop.