This was much easier than I had reckoned.
Having the battery_names array is sadly a necessary evil for now.
Use the same logic for all platforms. Tested on FreeBSD.
Needs retesting on Linux, macOS and OpenBSD. The price of
support multiple operating systems!