项目作者: qu1x

项目描述 :
Sets group write privileges and reinstates battery charge-thresholds.
高级语言: Makefile
项目地址: git://github.com/qu1x/huawei-wmi.git
创建时间: 2019-06-05T16:02:53Z
项目社区:https://github.com/qu1x/huawei-wmi

开源协议:

下载


huawei-wmi

Sets group write privileges and reinstates battery charge-thresholds.

Also reinstates keyboard backlight timeout and power mode unlock if supported.

Why?

As the Huawei WMI controller is known to forget above settings after hibernation, a few reboots, or
several hours of being powered off, this repository provides a udev rule and two systemd units to
reinstate them as required. A surprising but expected behavior is that while the MateBook is powered
off, there is nothing running which can reinstate the charge-thresholds and hence it still might
charge to 100 %. Therefore, it is recommended to unplug the power supply when powered off. Further
peculiarities are documented in the Linux on MateBook guide.

How?

The settings to be reinstated are stored in /etc/default/huawei-wmi/ and the current settings of
the kernel driver interface are mapped in /sys/devices/platform/huawei-wmi/. The udev rule fires
the static one-shot huawei-wmi-privilege service as soon as the kernel driver interface has been
populated. It sets group write privileges for the members of the system group huawei-wmi and
initializes non-existent settings in former directory with the current settings of latter directory.
Afterwards, it fires the non-static one-shot huawei-wmi-reinstate service which reinstates the
settings by copying the files from former to latter directory. Latter service is refired when waking
up from hibernation. Only non-static services can be enabled or disabled.

Installation

The services rely on the mainlined kernel driver. They are supported by the cross-platform
MateBook applet as well as the native Gnome extension and can be installed via Makefile or
distribution packages. The installer will ask for a list of desktop users separated by space which
will gain mandatory group write privileges to the kernel driver interface. For the changes to take
effect, the listed users have to be logged out. This is reliably achieved by rebooting the MateBook.

Makefile

Packages

Troubleshooting

Ensure your desktop user is a member of the system group huawei-wmi:

  1. $ groups | xargs -n 1 | grep huawei-wmi
  2. huawei-wmi

Ensure your desktop user has write privileges for default and current settings:

  1. $ echo 40 70 | tee {/etc/default,/sys/devices/platform}/huawei-wmi/charge_control_thresholds
  2. 40 70

Ensure the charge capacity lies between above charge-thresholds or choose them accordingly:

  1. $ cat /sys/class/power_supply/BAT?/capacity
  2. 60 # for example

Ensure the battery is not charging:

  1. $ cat /sys/class/power_supply/BAT?/status
  2. Not charging

Note that above and especially the Gnome/KDE charge status might be delayed by a few minutes.

Smart Charge

Newer models starting from 2020 feature a smart-charge mode which ignores any charge-thresholds if
enabled. It might get enabled by updating the BIOS, starting PC Manager on Windows, or setting one
of the thresholds to zero.

Disable smart-charge mode which would otherwise ignore charge-thresholds:

  1. $ echo 0x462848011503 | tee /sys/kernel/debug/huawei-wmi/arg
  2. 0x462848011503
  3. $ cat /sys/kernel/debug/huawei-wmi/call
  4. # ...
  5. $ cat /sys/kernel/debug/huawei-wmi/call # yes, twice
  6. # ...

This basically enables home mode and hence sets charge-thresholds to "40 70".

License

Licensed under Fair.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the
works by you shall be licensed as above, without any additional terms or conditions.