Run a script every minute getting battery level percentage and if 5 or less then run “shutdown -p now”.
A bit sudden-death methinks, Richard.
Such a script needs to warn the user when near doing something that drastic, maybe with beep tones every minute and a popup message (in X) or written to all consoles with wall otherwise, from perhaps 10% on down.
Another (safer) option is to use suspend rather than shutdown .. the user may just be in another room and wouldn't like to lose a two-hour edit or composition ...
Except for near-new batteries, reported percentage capacity and time remaining can be quite inaccurate, and the chip inside most laptop batteries needs recalibrating from time to time.
Another script useful for this will simply record battery state data with time and discharge rates (depending on activity) every minute or so from fully charged to battery exhaustion, ie to when the laptop shuts down itself.
I have done this for the last 20 years with Compaq and later 3 different Thinkpads, sometimes finding that time from reported 0% remaining until exhaustion can be up to an hour!
In such cases up to 3 full charge / discharge cycles may drastically improve the battery's estimates of its capabilities, and at other times make little or no difference, especially for non-genuine replacement batteries from Ebay etc.
All up, battery care scripts are not so simple, yet worthwhile.
The data from acpiconf -i0 is the most useful, though even then there are differences in reporting different batteries, e.g. mA and mAh versus mW and mWh, so a good script will have a number of parameters, with defaults.