mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-07 13:54:43 +02:00
Real time auto-cpufreq refresh
This commit is contained in:
parent
06b188438b
commit
c8f9095067
@ -18,6 +18,9 @@ from pathlib import Path
|
|||||||
from shutil import which
|
from shutil import which
|
||||||
from subprocess import getoutput, call, run, check_output, DEVNULL
|
from subprocess import getoutput, call, run, check_output, DEVNULL
|
||||||
|
|
||||||
|
# execution timestamp used in countdown func
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
sys.path.append("../")
|
sys.path.append("../")
|
||||||
from auto_cpufreq.power_helper import *
|
from auto_cpufreq.power_helper import *
|
||||||
|
|
||||||
@ -459,19 +462,18 @@ def countdown(s):
|
|||||||
# Fix for wrong stats output and "TERM environment variable not set"
|
# Fix for wrong stats output and "TERM environment variable not set"
|
||||||
os.environ["TERM"] = "xterm"
|
os.environ["TERM"] = "xterm"
|
||||||
|
|
||||||
for remaining in range(s, 0, -1):
|
print("\t\t\"auto-cpufreq\" is about to refresh ", end = "")
|
||||||
sys.stdout.write("\r")
|
|
||||||
sys.stdout.write('\t\t\t"auto-cpufreq" refresh in:{:2d}'.format(remaining))
|
for remaining in range(s, -1, -1):
|
||||||
sys.stdout.flush()
|
|
||||||
|
if remaining <= 3 and remaining >= 0:
|
||||||
|
print(".", end="", flush=True)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if auto_cpufreq_stats_file is not None:
|
if auto_cpufreq_stats_file is not None:
|
||||||
auto_cpufreq_stats_file.seek(0)
|
auto_cpufreq_stats_file.seek(0)
|
||||||
auto_cpufreq_stats_file.truncate(0)
|
auto_cpufreq_stats_file.truncate(0)
|
||||||
|
|
||||||
# execution timestamp
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
current_time = now.strftime("%B %d (%A) - %H:%M:%S")
|
current_time = now.strftime("%B %d (%A) - %H:%M:%S")
|
||||||
print("\n\t\tExecuted on:", current_time)
|
print("\n\t\tExecuted on:", current_time)
|
||||||
@ -614,7 +616,7 @@ def set_powersave():
|
|||||||
if psutil.cpu_percent(percpu=False, interval=0.01) >= 30.0 or isclose(
|
if psutil.cpu_percent(percpu=False, interval=0.01) >= 30.0 or isclose(
|
||||||
max(psutil.cpu_percent(percpu=True, interval=0.01)), 100
|
max(psutil.cpu_percent(percpu=True, interval=0.01)), 100
|
||||||
):
|
):
|
||||||
print("\nHigh CPU load")
|
print("High CPU load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -637,7 +639,7 @@ def set_powersave():
|
|||||||
turbo(False)
|
turbo(False)
|
||||||
|
|
||||||
elif load1m > powersave_load_threshold:
|
elif load1m > powersave_load_threshold:
|
||||||
print("\nHigh system load")
|
print("High system load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -660,7 +662,7 @@ def set_powersave():
|
|||||||
turbo(False)
|
turbo(False)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("\nLoad optimal")
|
print("Load optimal")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -701,7 +703,7 @@ def mon_powersave():
|
|||||||
if psutil.cpu_percent(percpu=False, interval=0.01) >= 30.0 or isclose(
|
if psutil.cpu_percent(percpu=False, interval=0.01) >= 30.0 or isclose(
|
||||||
max(psutil.cpu_percent(percpu=True, interval=0.01)), 100
|
max(psutil.cpu_percent(percpu=True, interval=0.01)), 100
|
||||||
):
|
):
|
||||||
print("\nHigh CPU load")
|
print("High CPU load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -724,7 +726,7 @@ def mon_powersave():
|
|||||||
get_turbo()
|
get_turbo()
|
||||||
|
|
||||||
elif load1m > powersave_load_threshold:
|
elif load1m > powersave_load_threshold:
|
||||||
print("\nHigh system load")
|
print("High system load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -747,7 +749,7 @@ def mon_powersave():
|
|||||||
get_turbo()
|
get_turbo()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("\nLoad optimal")
|
print("Load optimal")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -823,7 +825,7 @@ def set_performance():
|
|||||||
psutil.cpu_percent(percpu=False, interval=0.01) >= 20.0
|
psutil.cpu_percent(percpu=False, interval=0.01) >= 20.0
|
||||||
or max(psutil.cpu_percent(percpu=True, interval=0.01)) >= 75
|
or max(psutil.cpu_percent(percpu=True, interval=0.01)) >= 75
|
||||||
):
|
):
|
||||||
print("\nHigh CPU load")
|
print("High CPU load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -846,7 +848,7 @@ def set_performance():
|
|||||||
turbo(True)
|
turbo(True)
|
||||||
|
|
||||||
elif load1m >= performance_load_threshold:
|
elif load1m >= performance_load_threshold:
|
||||||
print("\nHigh system load")
|
print("High system load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -869,7 +871,7 @@ def set_performance():
|
|||||||
turbo(True)
|
turbo(True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("\nLoad optimal")
|
print("Load optimal")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -914,7 +916,7 @@ def mon_performance():
|
|||||||
psutil.cpu_percent(percpu=False, interval=0.01) >= 20.0
|
psutil.cpu_percent(percpu=False, interval=0.01) >= 20.0
|
||||||
or max(psutil.cpu_percent(percpu=True, interval=0.01)) >= 75
|
or max(psutil.cpu_percent(percpu=True, interval=0.01)) >= 75
|
||||||
):
|
):
|
||||||
print("\nHigh CPU load")
|
print("High CPU load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -937,7 +939,7 @@ def mon_performance():
|
|||||||
get_turbo()
|
get_turbo()
|
||||||
|
|
||||||
elif load1m > performance_load_threshold:
|
elif load1m > performance_load_threshold:
|
||||||
print("\nHigh system load")
|
print("High system load")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
@ -960,7 +962,7 @@ def mon_performance():
|
|||||||
get_turbo()
|
get_turbo()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("\nLoad optimal")
|
print("Load optimal")
|
||||||
|
|
||||||
# high cpu usage trigger
|
# high cpu usage trigger
|
||||||
if cpuload >= 20:
|
if cpuload >= 20:
|
||||||
|
@ -66,7 +66,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor
|
|||||||
distro_info()
|
distro_info()
|
||||||
sysinfo()
|
sysinfo()
|
||||||
set_autofreq()
|
set_autofreq()
|
||||||
countdown(5)
|
countdown(2)
|
||||||
elif os.getenv("PKG_MARKER") != "SNAP":
|
elif os.getenv("PKG_MARKER") != "SNAP":
|
||||||
gnome_power_detect()
|
gnome_power_detect()
|
||||||
tlp_service_detect()
|
tlp_service_detect()
|
||||||
@ -77,7 +77,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor
|
|||||||
distro_info()
|
distro_info()
|
||||||
sysinfo()
|
sysinfo()
|
||||||
set_autofreq()
|
set_autofreq()
|
||||||
countdown(5)
|
countdown(2)
|
||||||
else:
|
else:
|
||||||
daemon_not_found()
|
daemon_not_found()
|
||||||
elif monitor:
|
elif monitor:
|
||||||
@ -99,7 +99,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor
|
|||||||
distro_info()
|
distro_info()
|
||||||
sysinfo()
|
sysinfo()
|
||||||
mon_autofreq()
|
mon_autofreq()
|
||||||
countdown(5)
|
countdown(2)
|
||||||
elif live:
|
elif live:
|
||||||
root_check()
|
root_check()
|
||||||
config_info_dialog()
|
config_info_dialog()
|
||||||
@ -121,7 +121,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor
|
|||||||
distro_info()
|
distro_info()
|
||||||
sysinfo()
|
sysinfo()
|
||||||
set_autofreq()
|
set_autofreq()
|
||||||
countdown(5)
|
countdown(2)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
gnome_power_start_live()
|
gnome_power_start_live()
|
||||||
print("")
|
print("")
|
||||||
@ -135,7 +135,6 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor
|
|||||||
else:
|
else:
|
||||||
gnome_power_detect()
|
gnome_power_detect()
|
||||||
tlp_service_detect()
|
tlp_service_detect()
|
||||||
time.sleep(1)
|
|
||||||
read_stats()
|
read_stats()
|
||||||
elif log:
|
elif log:
|
||||||
deprecated_log_msg()
|
deprecated_log_msg()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user