Fix external battery handling + minor improvements
The way external batteries are currently handled only takes into account a few specific cases.
This MR is an attempt at making it more generic so it can work with more use-cases (for example, wireless keyboards and mice).
It also packs in a minor improvement to the build system.
Fixes: #2 (closed), #3 (closed)
Edited by Arnaud Ferraris