Skip to content

fix: get power supplies of type battery #480

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

Merged
merged 1 commit into from
May 17, 2025

Conversation

xx4h
Copy link
Collaborator

@xx4h xx4h commented May 15, 2025

  • cleanup unused variables
  • remove no longer needed directory test

fix #455

* cleanup unused variables
* remove no longer needed directory test

fix erikw#455
Copy link
Owner

@erikw erikw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test the updated code myself at this moment, but the code changes looks good as far as I can see.

fi
done
done <<<"$(grep -l "Battery" /sys/class/power_supply/*/type | sed -e 's,/type$,,')"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a better solution!

local bn
bf=$(cat "$full")
bn=$(cat "$now")
total_full=$((total_full + bf))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, summing up total battery is preserved.

@erikw erikw merged commit ad98fe3 into erikw:main May 17, 2025
1 check passed
@xx4h
Copy link
Collaborator Author

xx4h commented May 17, 2025

I can't test the updated code myself at this moment, but the code changes looks good as far as I can see.

I should have mentioned, that i tested it.
Only thing i can think of right now that could mess things up would be batteries with wrong type, or non-batteries with type "Battery".

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.

Questions about BAT0 or BAT1 in battery.sh
2 participants