Skip to content
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

Assumed battery location on Linux systems #2

Open
akiva opened this issue Aug 5, 2015 · 3 comments
Open

Assumed battery location on Linux systems #2

akiva opened this issue Aug 5, 2015 · 3 comments

Comments

@akiva
Copy link

akiva commented Aug 5, 2015

This module, and consequently the battery-life module, do not work on all Linux-based systems due to a hard-coded expectation of the location of the battery in the filesystem (ie. /org/freedesktop/UPower/devices/). For instance, my Arch Linux machine uses /sys/class/power_supply/BAT0/, although some systems may still use the now deprecated (as of kernel 2.6.24) /proc for such information.

@kevva
Copy link
Owner

kevva commented Aug 5, 2015

As always, it's hard to account for all the differences in all Linux distros. One alternative would be to check if the path exists before and then use that. Do you know of any other paths used?

@sindresorhus
Copy link

Or even better, is there somewhere on the system we can check for what path to use?

@kevva
Copy link
Owner

kevva commented May 22, 2017

So, I think we should remove the battery_ prefix from the results outputted in https://github.com/kevva/linux-batteries (since that's already implicit), and then change the location to check in here to /sys/class/power_supply/${battery} and fall back to the /proc path. It seems to be the best solution to maintain cross platform compatibility.

I have no Linux system available so any help with this would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants