mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-27 15:44:16 +02:00
added warnings to laptop_acpi
This commit is contained in:
parent
bd811ca32b
commit
0134da5e50
@ -42,5 +42,3 @@ def battery_get_thresholds():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,11 +5,12 @@ from auto_cpufreq.core import get_config
|
|||||||
|
|
||||||
|
|
||||||
def set_battery(value, mode, bat):
|
def set_battery(value, mode, bat):
|
||||||
try:
|
path = f"/sys/class/power_supply/BAT{bat}/charge_{mode}_threshold"
|
||||||
|
if os.path.isfile(path):
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
f"echo {value} | tee /sys/class/power_supply/BAT{bat}/charge_{mode}_threshold", shell=True, text=True)
|
f"echo {value} | tee {path}", shell=True, text=True)
|
||||||
except Exception as e:
|
else:
|
||||||
print(f"Error writing to file_path: {e}")
|
print(f"WARNING: {path} does NOT exist")
|
||||||
|
|
||||||
|
|
||||||
def get_threshold_value(mode):
|
def get_threshold_value(mode):
|
||||||
@ -33,12 +34,15 @@ def ideapad_acpi_setup():
|
|||||||
if not config["battery"]["enable_thresholds"] == "true":
|
if not config["battery"]["enable_thresholds"] == "true":
|
||||||
return
|
return
|
||||||
|
|
||||||
battery_count = len([name for name in os.listdir(
|
if os.path.exists("/sys/class/power_supply/"):
|
||||||
"/sys/class/power_supply/") if name.startswith('BAT')])
|
battery_count = len([name for name in os.listdir(
|
||||||
|
"/sys/class/power_supply/") if name.startswith('BAT')])
|
||||||
|
|
||||||
for bat in range(battery_count):
|
for bat in range(battery_count):
|
||||||
set_battery(get_threshold_value("start"), "start", bat)
|
set_battery(get_threshold_value("start"), "start", bat)
|
||||||
set_battery(get_threshold_value("stop"), "stop", bat)
|
set_battery(get_threshold_value("stop"), "stop", bat)
|
||||||
|
else:
|
||||||
|
print("WARNING: could NOT access /sys/class/power_supply")
|
||||||
|
|
||||||
|
|
||||||
def ideapad_acpi_print_thresholds():
|
def ideapad_acpi_print_thresholds():
|
||||||
|
@ -34,7 +34,7 @@ def thinkpad_setup():
|
|||||||
if not config["battery"]["enable_thresholds"] == "true":
|
if not config["battery"]["enable_thresholds"] == "true":
|
||||||
return
|
return
|
||||||
|
|
||||||
if os.path.isfile("/sys/class/power_supply/"):
|
if os.path.exists("/sys/class/power_supply/"):
|
||||||
battery_count = len([name for name in os.listdir(
|
battery_count = len([name for name in os.listdir(
|
||||||
"/sys/class/power_supply/") if name.startswith('BAT')])
|
"/sys/class/power_supply/") if name.startswith('BAT')])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user