mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-27 07:34:25 +02:00
Improve charging detection (#332)
This commit is contained in:
parent
78ddf145e7
commit
64e33827b8
@ -39,6 +39,9 @@ ALL_GOVERNORS = (
|
|||||||
)
|
)
|
||||||
CPUS = os.cpu_count()
|
CPUS = os.cpu_count()
|
||||||
|
|
||||||
|
# ignore these devices under /sys/class/power_supply/
|
||||||
|
POWER_SUPPLY_IGNORELIST = ["hidpp_battery"]
|
||||||
|
|
||||||
# Note:
|
# Note:
|
||||||
# "load1m" & "cpuload" can't be global vars and to in order to show correct data must be
|
# "load1m" & "cpuload" can't be global vars and to in order to show correct data must be
|
||||||
# decraled where their execution takes place
|
# decraled where their execution takes place
|
||||||
@ -194,6 +197,8 @@ def charging():
|
|||||||
"""
|
"""
|
||||||
power_supply_path = "/sys/class/power_supply/"
|
power_supply_path = "/sys/class/power_supply/"
|
||||||
power_supplies = os.listdir(Path(power_supply_path))
|
power_supplies = os.listdir(Path(power_supply_path))
|
||||||
|
# sort it so AC is 'always' first
|
||||||
|
power_supplies = sorted(power_supplies)
|
||||||
|
|
||||||
# check if we found power supplies. on a desktop these are not found
|
# check if we found power supplies. on a desktop these are not found
|
||||||
# and we assume we are on a powercable.
|
# and we assume we are on a powercable.
|
||||||
@ -203,10 +208,12 @@ def charging():
|
|||||||
# we found some power supplies, lets check their state
|
# we found some power supplies, lets check their state
|
||||||
else:
|
else:
|
||||||
for supply in power_supplies:
|
for supply in power_supplies:
|
||||||
# skip battery of hid devices
|
# Check if supply is in ignore list
|
||||||
# see issue #321
|
ignore_supply = any(item in supply for item in POWER_SUPPLY_IGNORELIST)
|
||||||
if "hid" in supply.lower():
|
# If found in ignore list, skip it.
|
||||||
|
if ignore_supply:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(Path(power_supply_path + supply + "/type")) as f:
|
with open(Path(power_supply_path + supply + "/type")) as f:
|
||||||
supply_type = f.read()[:-1]
|
supply_type = f.read()[:-1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user