-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NetBSD support #20
Comments
Blocked by the ebarnard/rust-plist#34 |
FWIW the 0.4.2 release of rust-plist has the change referenced above |
Thanks for heads up, @rtyler! I tried to tackle this issue with NetBSD installed on a VirtualBox, but it was not able to emulate battery for some reasons, so I postponed it for a while. |
I have a NetBSD-based Pinebook Pro, if you have some pointers, I could take a look at wiring this up in my spurious free time 😸 |
@rtyler that would be really great, thanks! I know nothing about NetBSD, so it would be great to start with figuring out what it can provide to us, looks like Seems like Golang implementation uses When we will know what data we can operate with, we will need to check if it will be enough to fill |
A friend complained that this crate does not support NetBSD, so I took a quick look at it. Adding 'target_os = "netbsd"' to all "freebsd" cases makes it compile, but the 5 tests fail. So I guess that is not sufficient :) NetBSD's envstat source code is here: |
The general framework for system monitoring and power management on NetBSD is sysmon (https://man.netbsd.org/sysmon.4) and in particular for environmental sensors, sysmon_envsys (kernel side documented here: https://man.netbsd.org/sysmon_envsys.9, but that does not really apply here). I hope this is sufficient information! |
@svartalf What you describe (read /dev/sysmon) is exactly what envstat does too. Caveat: by default, only root may read from the sysmon device, so there should be some fallback (e.g. pretend there is no battery?). |
Another piece to take a look at could be e.g. https://github.com/NetBSD/pkgsrc/tree/trunk/sysutils/xbattbar which in the patches/ sub-directory contains a patch for adapting this to NetBSD. It is considerably smaller than the envstat program. And as far as I can see, neither envstat nor xbattbar needs to be set-uid-root to work. |
Here's some sample code that gives a plist:
On one of my systems that prints:
Sorry, I don't currently have a laptop with NetBSD i.e. no battery to test with. |
Cargo dependencies:
|
I put the code here for easier testing. |
I've extended the example code to include basic parsing of the structure and adding some example outputs, including one from a laptop with a battery. I think this now contains enough information that you should be able to extract the information you need rather easily. Can you take over from here? |
A lot of project are still depending on this library instead of using Starship's fork. I just made the full port for NetBSD. Are you (and especially the maintainer) interested by a backport ? I don't think it should be too hard. The interest might be about the ffi that the Starship's fork removed. |
This is a tracking issue for NetBSD support.
The text was updated successfully, but these errors were encountered: