From 80891abca22c380e00a0eb95cb88917f642e59d1 Mon Sep 17 00:00:00 2001 From: purple wazard Date: Sat, 3 Aug 2024 17:11:27 -0500 Subject: [PATCH 1/4] added the abilty to ignore certain power supplies --- auto_cpufreq/core.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index e79daaaf..a919c6b0 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -21,7 +21,7 @@ filterwarnings("ignore") -# add path to auto-cpufreq executables for GUI +# add path to auto-cpufreq executables for UI os.environ["PATH"] += ":/usr/local/bin" # ToDo: @@ -30,8 +30,7 @@ SCRIPTS_DIR = Path("/usr/local/share/auto-cpufreq/scripts/") CPUS = os.cpu_count() -# ignore these devices under /sys/class/power_supply/ -POWER_SUPPLY_IGNORELIST = ["hidpp_battery"] + # Note: # "load1m" & "cpuload" can't be global vars and to in order to show correct data must be @@ -217,12 +216,32 @@ def set_turbo(value:bool): print("Setting turbo boost:", "on" if value else "off") turbo(value) + +# ignore these devices under /sys/class/power_supply/ +def get_power_supply_ignore_list(): + + conf = config.get_config() + + list = [] + + if conf.has_option("battery","power_supply_ignore_list"): + for i in conf["battery"]["power_supply_ignore_list"]: + list.append(i) + + print(f"ignoring {list}\n") + + # these are hard coded power supplies that will always be ignored + list.append("hidpp_battery") + return list + + def charging(): """ get charge state: is battery charging or discharging """ # sort it so AC is 'always' first power_supplies = sorted(os.listdir(Path(POWER_SUPPLY_DIR))) + POWER_SUPPLY_IGNORELIST = get_power_supply_ignore_list() # check if we found power supplies. on a desktop these are not found and we assume we are on a powercable. if len(power_supplies) == 0: return True # nothing found, so nothing to check @@ -896,4 +915,4 @@ def not_running_daemon_check(): exit(1) elif IS_INSTALLED_WITH_SNAP and dcheck == "disabled": daemon_not_running_msg() - exit(1) \ No newline at end of file + exit(1) From 00f3631414beab6adc713536121f018d9c0a460f Mon Sep 17 00:00:00 2001 From: purple wazard Date: Sat, 3 Aug 2024 17:32:24 -0500 Subject: [PATCH 2/4] changed config file for ignoring power supplies --- auto_cpufreq/core.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index a919c6b0..34a5cddc 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -224,11 +224,9 @@ def get_power_supply_ignore_list(): list = [] - if conf.has_option("battery","power_supply_ignore_list"): - for i in conf["battery"]["power_supply_ignore_list"]: - list.append(i) - - print(f"ignoring {list}\n") + if conf.has_section("power_supply_ignore_list"): + for i in conf["power_supply_ignore_list"]: + list.append(conf["power_supply_ignore_list"][i]) # these are hard coded power supplies that will always be ignored list.append("hidpp_battery") From 0384e2a09522a054a79e4f23503e7a5157bb21de Mon Sep 17 00:00:00 2001 From: purple wazard Date: Sat, 3 Aug 2024 17:35:35 -0500 Subject: [PATCH 3/4] updated exapmle config file for ignoring power supplies --- auto-cpufreq.conf-example | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/auto-cpufreq.conf-example b/auto-cpufreq.conf-example index 925e79ea..1146b840 100644 --- a/auto-cpufreq.conf-example +++ b/auto-cpufreq.conf-example @@ -22,6 +22,17 @@ energy_performance_preference = performance # turbo boost setting. possible values: always, auto, never turbo = auto + +# this is for ignoring controlers and other connected devices battery from effecting +# laptop preformence +# [power_supply_ignore_list] + +# name1 = this +# name2 = is +# name3 = an +# name4 = example + + # settings for when using battery power [battery] # see available governors by running: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors From d4ec21587ba061efc6f99a383355a04c4ee8b973 Mon Sep 17 00:00:00 2001 From: purple wazard Date: Sat, 3 Aug 2024 17:45:33 -0500 Subject: [PATCH 4/4] updated docs with ignoring power supplies --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 5a595e82..f2e13fd2 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Example of `auto-cpufreq --stats` CLI output - [Battery charging thresholds](#battery-charging-thresholds) - [Supported Devices](#supported-devices) - [Battery config](#battery-config) + - [Ignoring power supplies](#Ignoring-power-supplies) - [Troubleshooting](#troubleshooting) - [AUR](#aur) - [Discussion](#discussion) @@ -513,6 +514,26 @@ this works only with `lenovo_laptop` kernel module compatable laptops. add `ideapad_laptop_conservation_mode = true` to your `auto-cpufreq.conf` file +### Ignoring power supplies + +you may have a controler or headphones and when ever they may be on battery they might cause auto-cpufreq +to limit preformence to ignore them add to you config file the name of the power supply, under `[power_supply_ignore_list]` + +the name of the power supply can be found with `ls /sys/class/power_supply/` + +``` +[power_supply_ignore_list] + +name1 = this +name2 = is +name3 = an +name4 = example + +# like this +xboxctrl = {the xbox controler power supply name} + +``` + ## Troubleshooting **Q:** If after installing auto-cpufreq you're (still) experiencing: