From d220c88b26b8d69508270bdc5964a2e8205dc2d6 Mon Sep 17 00:00:00 2001 From: achintya Date: Sat, 20 Nov 2021 09:21:28 +0000 Subject: [PATCH 1/4] fixed the heating problem --- auto_cpufreq/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 3d1c90e8..cac21b33 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -183,6 +183,11 @@ def charging(): else: ac_state = True + heat = get_config() + + if(heat['heating_problem']['charging_heating_problem'] == 1): + ac_state = False + # if both ac-adapter and battery states are unknown default to not charging return ac_state From 4552a4bb06e503c36792165675932f7eee05423f Mon Sep 17 00:00:00 2001 From: achintya Date: Sat, 20 Nov 2021 14:54:57 +0530 Subject: [PATCH 2/4] fixed some bugs --- auto_cpufreq/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index cac21b33..c99ba50b 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -168,10 +168,13 @@ def charging(): computer_type = getoutput("dmidecode --string chassis-type") if computer_type in ["Notebook", "Laptop", "Convertible", "Portable"]: + # AC adapter states: 0, 1, unknown + ac_info = getoutput(f"grep . {power_dir}A*/online").splitlines() # Battery statuses: Full, Charging, Discharging, Unknown battery_status = getoutput(f"grep . {power_dir}B*/status").splitlines() - # if there's one battery charging, ac_state is True - ac_state = any(["Full" in ac or "Charging" in ac for ac in battery_status]) + # if there's one battery charging, or if there's one ac-adapter on-line, ac_state is True + ac_state = (any([not "Discharging" in ac for ac in battery_status]) or + any(["1" in ac.split(":")[-1] for ac in ac_info])) else: has_battery = psutil.sensors_battery() is not None if has_battery: From b4233d67c37350855a42db20f648bcf8f97ac044 Mon Sep 17 00:00:00 2001 From: achintya Date: Sat, 20 Nov 2021 15:01:34 +0530 Subject: [PATCH 3/4] changing the ac_state to Battery I have added a new parameter for the /etc/auto-cpufreq.conf file. If you are facing heating issue, set the new parameter as 1. --- auto_cpufreq/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index c99ba50b..b2438917 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -189,8 +189,8 @@ def charging(): heat = get_config() if(heat['heating_problem']['charging_heating_problem'] == 1): - ac_state = False - + ac_state = False + # if both ac-adapter and battery states are unknown default to not charging return ac_state From 8a10f4e851eeee9c703059b603de7df80500b5b0 Mon Sep 17 00:00:00 2001 From: achintya Date: Sun, 21 Nov 2021 10:20:38 +0000 Subject: [PATCH 4/4] fixed error by exception handling --- auto_cpufreq/core.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index b2438917..c693018b 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -186,11 +186,14 @@ def charging(): else: ac_state = True - heat = get_config() - - if(heat['heating_problem']['charging_heating_problem'] == 1): - ac_state = False - + try: + heat = get_config() + if(heat['heating_problem']['charging_heating_problem'] == 1): + ac_state = False + except: + print("No config file being used") + + # if both ac-adapter and battery states are unknown default to not charging return ac_state