Skip to content

Update linux/battery module to support both BAT0 and BAT1 #838

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zencrab
Copy link

@zencrab zencrab commented Apr 11, 2025

Update linux/battery module to support both BAT0 and BAT1

Description

This PR added support for BAT1 in the linux battery module. For some linux dirstros, such as Arch Linux (which I run) the battery for certain laptop can be BAT1, instead of BAT0 which plyer already supported.

This PR will make plyer battery module work for every linux distribution. Fixing the error I asked to reopen and now Closes #743.

Related Issue(s)

Changes

  • Updated linux/battery module to support BAT1.
  • Refactored conflicting code in plyer/tests/test_battery.py, which was running assert_called_once_with() and added testing for both BAT0 and BAT1. N.B.: I didn't understand why had to make sure it was called once, please refactor or lemme know.

How Has This Been Tested?

  • Ran all unit tests using pytest and confirmed they passed, but TestUniqueID.test_uniqueid which was failing beforehand.
  • Performed manual testing on Linux to verify BAT1 work as expected. Need somebody to manually test on a Linux system with BAT0

Screenshots

plyer-bat1

Checklist

  • My code follows the project's style guidelines, I hooked PEP8 before committing.
  • I have commented my code, especially in hard-to-understand areas.
  • Change documentation is not needed as it doesn't specify the if the battery is BAT0 or BAT1
  • My changes generate no new warnings.
  • I have added tests to prove my fix or feature works.
  • Any dependent changes have been merged and published in downstream modules.

Additional Notes

The only concern is that I had to change the previous test as it required for the battery to only be called once (I don't understand why), the command is one call already.
However, if there is a reason behind it, this my port breaking changes. Please @KeyWeeUsr, let me know if the check for one call is mandatory.

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.

[Bug] battery.status gives an error.
1 participant