Added 'Autoreload' config option

This commit is contained in:
Hayden Briese 2020-08-11 16:16:20 +10:00
parent 7b20337840
commit 320243dafe
3 changed files with 19 additions and 7 deletions

View file

@ -291,11 +291,19 @@ This is an example output:
[D] core 0 thermal status: reading valid = 1
.....
```
## Autoreload
Auto reload config on changes (unless it's deleted) can be enabled/disabled in the config
```
[General]
Autoreload = True
```
## A word about manufacturer provided tooling
Tools provided by your notebook manufacturer like [Dell Power Manager](https://www.dell.com/support/contents/us/en/04/article/product-support/self-support-knowledgebase/software-and-downloads/dell-power-manager) tend to persist their settings to the system board. If you ever had it running under Windows and activated a cool/quiet/silent/saving profile, this setting will still be active when running linux, throttling your system.
> On my Dell Latitude 5591, not even a BIOS reset to manufacturar default killed the active `Quiet` profile
## Disclaimer
This script overrides the default values set by Lenovo. I'm using it without any problem, but it is still experimental so use it at your own risk.

View file

@ -3,6 +3,8 @@
Enabled: True
# SYSFS path for checking if the system is running on AC power
Sysfs_Power_Path: /sys/class/power_supply/AC*/online
# Auto reload config on changes
Autoreload: True
## Settings to apply while connected to Battery power
[BATTERY]

View file

@ -569,7 +569,8 @@ def power_thread(config, regs, exit_event):
mchbar_mmio = None
next_hwp_write = 0
last_config_write_time = get_config_write_time()
last_config_write_time = get_config_write_time() \
if config.getboolean('GENERAL', 'Autoreload', fallback=False) else None
while not exit_event.is_set():
# log thermal status
if args.debug:
@ -578,11 +579,12 @@ def power_thread(config, regs, exit_event):
for key, value in core_thermal_status.items():
log('[D] core {} thermal status: {} = {}'.format(index, key.replace("_", " "), value))
# Reload config when modified (unless it no longer exists)
config_write_time = get_config_write_time()
if config_write_time and last_config_write_time != config_write_time:
last_config_write_time = config_write_time
config, regs = reload_config()
# Reload config on changes (unless it's deleted)
if config.getboolean('GENERAL', 'Autoreload', fallback=False):
config_write_time = get_config_write_time()
if config_write_time and last_config_write_time != config_write_time:
last_config_write_time = config_write_time
config, regs = reload_config()
# switch back to sysfs polling
if power['method'] == 'polling':