{"id":19078763,"url":"https://github.com/qu1x/huawei-wmi","last_synced_at":"2025-04-30T05:20:34.760Z","repository":{"id":41047795,"uuid":"190426102","full_name":"qu1x/huawei-wmi","owner":"qu1x","description":"Sets group write privileges and reinstates battery charge-thresholds.","archived":false,"fork":false,"pushed_at":"2023-11-08T17:59:39.000Z","size":59,"stargazers_count":41,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-30T13:01:44.886Z","etag":null,"topics":["charge-thresholds","debian","huawei-wmi","linux","matebook","matebook-applet","systemd-units","udev-rules"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qu1x.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-05T16:02:53.000Z","updated_at":"2024-10-27T20:29:48.000Z","dependencies_parsed_at":"2023-11-08T18:41:32.833Z","dependency_job_id":null,"html_url":"https://github.com/qu1x/huawei-wmi","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qu1x%2Fhuawei-wmi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qu1x%2Fhuawei-wmi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qu1x%2Fhuawei-wmi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qu1x%2Fhuawei-wmi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qu1x","download_url":"https://codeload.github.com/qu1x/huawei-wmi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645673,"owners_count":21620790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["charge-thresholds","debian","huawei-wmi","linux","matebook","matebook-applet","systemd-units","udev-rules"],"created_at":"2024-11-09T02:11:49.709Z","updated_at":"2025-04-30T05:20:34.722Z","avatar_url":"https://github.com/qu1x.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# huawei-wmi\n\nSets group write privileges and reinstates battery charge-thresholds.\n\nAlso reinstates keyboard backlight timeout and power mode unlock if supported.\n\n## Why?\n\nAs the Huawei WMI controller is known to forget above settings after hibernation, a few reboots, or\nseveral hours of being powered off, this repository provides a udev rule and two systemd units to\nreinstate them as required. A surprising but expected behavior is that while the MateBook is powered\noff, there is nothing running which can reinstate the charge-thresholds and hence it still might\ncharge to 100 %. Therefore, it is recommended to unplug the power supply when powered off. Further\npeculiarities are documented in the [Linux on MateBook] guide.\n\n## How?\n\nThe settings to be reinstated are stored in `/etc/default/huawei-wmi/` and the current settings of\nthe [kernel driver] interface are mapped in `/sys/devices/platform/huawei-wmi/`. The udev rule fires\nthe static one-shot `huawei-wmi-privilege` service as soon as the [kernel driver] interface has been\npopulated. It sets group write privileges for the members of the system group `huawei-wmi` and\ninitializes non-existent settings in former directory with the current settings of latter directory.\nAfterwards, it fires the non-static one-shot `huawei-wmi-reinstate` service which reinstates the\nsettings by copying the files from former to latter directory. Latter service is refired when waking\nup from hibernation. Only non-static services can be enabled or disabled.\n\n## Installation\n\nThe services rely on the mainlined [kernel driver]. They are supported by the cross-platform\n[MateBook applet] as well as the native [Gnome extension] and can be installed via Makefile or\ndistribution packages. The installer will ask for a list of desktop users separated by space which\nwill gain mandatory group write privileges to the [kernel driver] interface. For the changes to take\neffect, the listed users have to be logged out. This is reliably achieved by rebooting the MateBook.\n\n[Linux on MateBook]: https://github.com/nekr0z/linux-on-huawei-matebook-13-2019\n[kernel driver]: https://github.com/aymanbagabas/Huawei-WMI\n[MateBook applet]: https://github.com/nekr0z/matebook-applet\n[Gnome extension]: https://github.com/egormanga/gnome-extension-huawei-wmi\n\n### Makefile\n\n  * [Generic]\n\n### Packages\n\n  * [Debian]\n  * [Arch Linux] maintained by [Ben Woodward]\n\n[Generic]: generic\n[Debian]: debian\n[Arch Linux]: https://aur.archlinux.org/packages/huawei-wmi\n[Ben Woodward]: https://github.com/Sacro\n\n## Troubleshooting\n\nEnsure your desktop user is a member of the system group `huawei-wmi`:\n\n```sh\n$ groups | xargs -n 1 | grep huawei-wmi\nhuawei-wmi\n```\n\nEnsure your desktop user has write privileges for default and current settings:\n\n```sh\n$ echo 40 70 | tee {/etc/default,/sys/devices/platform}/huawei-wmi/charge_control_thresholds\n40 70\n```\n\nEnsure the charge capacity lies between above charge-thresholds or choose them accordingly:\n\n```sh\n$ cat /sys/class/power_supply/BAT?/capacity\n60 # for example\n```\n\nEnsure the battery is not charging:\n\n```sh\n$ cat /sys/class/power_supply/BAT?/status\nNot charging\n```\n\nNote that above and especially the Gnome/KDE charge status might be delayed by a few minutes.\n\n### Smart Charge\n\nNewer models starting from 2020 feature a smart-charge mode which ignores any charge-thresholds if\nenabled. It might get enabled by updating the BIOS, starting PC Manager on Windows, or setting one\nof the thresholds to zero.\n\nDisable smart-charge mode which would otherwise ignore charge-thresholds:\n\n```sh\n$ echo 0x462848011503 | tee /sys/kernel/debug/huawei-wmi/arg\n0x462848011503\n$ cat /sys/kernel/debug/huawei-wmi/call\n# ...\n$ cat /sys/kernel/debug/huawei-wmi/call # yes, twice\n# ...\n```\n\nThis basically enables home mode and hence sets charge-thresholds to `\"40 70\"`.\n\n## License\n\nLicensed under [Fair].\n\n[Fair]: https://opensource.org/licenses/Fair\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the\nworks by you shall be licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqu1x%2Fhuawei-wmi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqu1x%2Fhuawei-wmi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqu1x%2Fhuawei-wmi/lists"}