Skip to content

Commit 484742a

Browse files
PurpleWazardAdnanHodzicBOOTMGRBowDown097shadeyg56
authored
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 <[email protected]> Co-authored-by: Harsh Panchal <[email protected]> Co-authored-by: BowDown097 <[email protected]> Co-authored-by: shadeyg56 <[email protected]>
1 parent 27f0690 commit 484742a

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Example of `auto-cpufreq --stats` CLI output
5656
- [Battery charging thresholds](#battery-charging-thresholds)
5757
- [Supported Devices](#supported-devices)
5858
- [Battery config](#battery-config)
59+
- [Ignoring power supplies](#Ignoring-power-supplies)
5960
- [Troubleshooting](#troubleshooting)
6061
- [AUR](#aur)
6162
- [Discussion](#discussion)
@@ -525,6 +526,26 @@ this works only with `lenovo_laptop` kernel module compatable laptops.
525526

526527
add `ideapad_laptop_conservation_mode = true` to your `auto-cpufreq.conf` file
527528

529+
### Ignoring power supplies
530+
531+
you may have a controler or headphones and when ever they may be on battery they might cause auto-cpufreq
532+
to limit preformence to ignore them add to you config file the name of the power supply, under `[power_supply_ignore_list]`
533+
534+
the name of the power supply can be found with `ls /sys/class/power_supply/`
535+
536+
```
537+
[power_supply_ignore_list]
538+
539+
name1 = this
540+
name2 = is
541+
name3 = an
542+
name4 = example
543+
544+
# like this
545+
xboxctrl = {the xbox controler power supply name}
546+
547+
```
548+
528549
## Troubleshooting
529550

530551
**Q:** If after installing auto-cpufreq you're (still) experiencing:

auto-cpufreq.conf-example

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ energy_performance_preference = performance
2828
# turbo boost setting. possible values: always, auto, never
2929
turbo = auto
3030

31+
32+
# this is for ignoring controllers and other connected devices battery from affecting
33+
# laptop preformence
34+
# [power_supply_ignore_list]
35+
36+
# name1 = this
37+
# name2 = is
38+
# name3 = an
39+
# name4 = example
40+
41+
3142
# settings for when using battery power
3243
[battery]
3344
# see available governors by running: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

auto_cpufreq/core.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
SCRIPTS_DIR = Path("/usr/local/share/auto-cpufreq/scripts/")
3434
CPUS = os.cpu_count()
3535

36-
# ignore these devices under /sys/class/power_supply/
37-
POWER_SUPPLY_IGNORELIST = ["hidpp_battery"]
36+
3837

3938
# Note:
4039
# "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):
220219
print("Setting turbo boost:", "on" if value else "off")
221220
turbo(value)
222221

222+
223+
# ignore these devices under /sys/class/power_supply/
224+
def get_power_supply_ignore_list():
225+
226+
conf = config.get_config()
227+
228+
list = []
229+
230+
if conf.has_section("power_supply_ignore_list"):
231+
for i in conf["power_supply_ignore_list"]:
232+
list.append(conf["power_supply_ignore_list"][i])
233+
234+
# these are hard coded power supplies that will always be ignored
235+
list.append("hidpp_battery")
236+
return list
237+
238+
223239
def charging():
224240
"""
225241
get charge state: is battery charging or discharging
226242
"""
227243
# sort it so AC is 'always' first
228244
power_supplies = sorted(os.listdir(Path(POWER_SUPPLY_DIR)))
245+
POWER_SUPPLY_IGNORELIST = get_power_supply_ignore_list()
229246

230247
# check if we found power supplies. on a desktop these are not found and we assume we are on a powercable.
231248
if len(power_supplies) == 0: return True # nothing found, so nothing to check

0 commit comments

Comments
 (0)