Much of this code was taken from the Kobo implementation of an auxiliary battery. The biggest difference between the Kobo and Kindle implementation is that the status file for the charging cover is not present when the cover is detached, so the check for status there will result in the file failing to read.