From 484742a683b4cd25e412d0e6bd0b23a50cc0de5a Mon Sep 17 00:00:00 2001 From: PurpleWazard <155469001+PurpleWazard@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:18:10 -0500 Subject: [PATCH] Ignoring power supplies FIX #753 (#760) * added the abilty to ignore certain power supplies * changed config file for ignoring power supplies * updated exapmle config file for ignoring power supplies * updated docs with ignoring power supplies * Update README.md Update image URL's * Add support for setting "Platform Profile" (#752) * Add support for setting "Platform Profile" * Add reference for Platform Profile * Fix unsafe access to PATH (#756) * Fix unsafe access to PATH * Fix leading separator if PATH is empty * Unpin psutil and requests (#759) * Remove network-online.target as a systemd-service dependency (improve boot time). Closes: #739 * minor grammer correction. * removed wonky file --------- Co-authored-by: Adnan Hodzic Co-authored-by: Harsh Panchal Co-authored-by: BowDown097 <42720004+BowDown097@users.noreply.github.com> Co-authored-by: shadeyg56 <31134255+shadeyg56@users.noreply.github.com> --- README.md | 21 +++++++++++++++++++++ auto-cpufreq.conf-example | 11 +++++++++++ auto_cpufreq/core.py | 21 +++++++++++++++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c49254e..0411e20 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) @@ -525,6 +526,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: diff --git a/auto-cpufreq.conf-example b/auto-cpufreq.conf-example index a6a5924..9c7ff21 100644 --- a/auto-cpufreq.conf-example +++ b/auto-cpufreq.conf-example @@ -28,6 +28,17 @@ energy_performance_preference = performance # turbo boost setting. possible values: always, auto, never turbo = auto + +# this is for ignoring controllers and other connected devices battery from affecting +# 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 diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index de492be..2e74c42 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -33,8 +33,7 @@ else: 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 @@ -220,12 +219,30 @@ 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_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") + 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