A kernel module that works like a "Schmitt trigger"[0].
Suppose that LO_THRESHOLD: 20% and HI_THRESHOLD: 80%. If your battery is lower than HI_THRESHOLD, it will allow your laptop to charge. Once it hits HI_THRESHOLD, it stops charging and your laptop gets energy from the battery, even if your power adapter is plugged in.
Once it hits LO_THRESHOLD, it starts charging again. See bang bang control[1], or a thermostat[2].
If we want to build a SaaS business around this and become billionaires:
Build a service accessible through sockets. I sign up for your service, you give me some sort of API keys. I install your software on my laptop, configure it with the keys.
If I have a screen, then running your software opens a link that does all the above automatically.
The local software monitors the temperature and sends them to your service through sockets. The application logic is in your server, and it sends the command either to CHARGING_ON, or CHARGING_OFF to the local program.
There are many people who like to charge their batteries between 30% and 80%.
Or, you can offer integrations with IFTTT[3] to trigger actions.
You can do it without the "SaaS" thingy and just offer it as it is.
[0]: https://en.wikipedia.org/wiki/Schmitt_trigger
[1]: https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control
[2]: https://en.wikipedia.org/wiki/Thermostat
[3]: https://ifttt.com/