Add support for OpenBSD battery capacity and fix OpenBSD compilation #1345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
On OpenBSD, the
apm(advanced power management) utility has a different output to that of FreeBSD and NetBSD. However, previouslyewwattempted to read in like the other BSDs, resulting in an unwrap error. This PR fixes this by implementing the required logic to parse theapmof OpenBSD. It also fixes the compile error regardingcrate::regex. Finally, it fixes a warning on non-Linux systems, asstd::fs::read_to_stringis only used intarget_os = "linux"code, but was included regardless.Usage
There is no usage change for the end user, as the function is marked
#[cfg(target_os = "openbsd")].Additional Notes
I am unsure if OpenBSD's apm supports multiple batteries and I do not have the facilities to test this functionality, thus the suggested implementation assumes only one battery. If anybody happens to be running OpenBSD on a laptop with more than 1 battery, then testing there would be appreciated.
Checklist
Please make sure you can check all the boxes that apply to this PR.