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

Change "energy" to "charge" in battery-combined-udev.sh #452

Closed
wants to merge 1 commit into from

Conversation

metam1nd
Copy link

The /sys/class/power_supply/ files seem to have been renamed to "charge_", using the script in its original form would throw division by zero errors, no values could be read under "energy_".

The /sys/class/power_supply/ files seem to have been renamed to "charge_", using the script in its original form would throw division by zero errors, no values could be read under "energy_".
@x70b1
Copy link
Member

x70b1 commented Oct 15, 2024

On which kernel?
I still have /sys/class/power_supply/BAT0/energy_now on 6.11.3-arch1-1.

Maybe its different between vendors?

@metam1nd
Copy link
Author

metam1nd commented Oct 15, 2024

Yeah I think you have the right idea, I'm using the same kernel as you and ChatGPT said the following:

On most Linux systems, the battery's information can be found under /sys/class/power_supply/BAT0/, but the exact files available vary based on the kernel version and the hardware.

/sys/class/power_supply/BAT0/energy_now is typically found on systems where energy-based reporting is used (i.e., the battery reports its state in milliwatt-hours (mWh)).

/sys/class/power_supply/BAT0/charge_now is used on systems where charge-based reporting is used (i.e., the battery reports its state in milliamp-hours (mAh)).

Only one of these files (either energy_now or charge_now) is generally present, depending on how the battery hardware and driver report the battery status.

I'm using an older Dell Inspiron Laptop. So there should be a detection logic looking for either version and use the version that is present?

@x70b1
Copy link
Member

x70b1 commented Oct 15, 2024

Oh, then its probably your kernel that will switch the naming in the future. Or it keeps as it is.

Somehow yes. On the other side: If your script is not working, then just change the paths.
As this case will only be an issue at the setup a check about that sounds a bit like an overkill.

@metam1nd
Copy link
Author

Oh, then its probably your kernel that will switch the naming in the future. Or it keeps as it is.

What do you mean? I'm on 6.11.3-arch1-1 too, same as you.

I'm gonna play around with it for a bit and add some detection logic, I'm in some kind of programming mood right now :D

I'll send you a new PR when I've got it working.

@metam1nd metam1nd closed this Oct 15, 2024
@metam1nd metam1nd deleted the patch-1 branch October 15, 2024 21:06
@x70b1
Copy link
Member

x70b1 commented Oct 15, 2024

What do you mean? I'm on 6.11.3-arch1-1 too, same as you.

My mistake. Have seen "I'm using an older Debian Inspiron Laptop.". But that was wrong.

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

Successfully merging this pull request may close these issues.

2 participants