diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 9f28977..3b0c238 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -18,6 +18,9 @@ from pathlib import Path from shutil import which from subprocess import getoutput, call, run, check_output, DEVNULL +# execution timestamp used in countdown func +from datetime import datetime + sys.path.append("../") from auto_cpufreq.power_helper import * @@ -459,19 +462,18 @@ def countdown(s): # Fix for wrong stats output and "TERM environment variable not set" os.environ["TERM"] = "xterm" - for remaining in range(s, 0, -1): - sys.stdout.write("\r") - sys.stdout.write('\t\t\t"auto-cpufreq" refresh in:{:2d}'.format(remaining)) - sys.stdout.flush() + print("\t\t\"auto-cpufreq\" is about to refresh ", end = "") + + for remaining in range(s, -1, -1): + + if remaining <= 3 and remaining >= 0: + print(".", end="", flush=True) time.sleep(1) if auto_cpufreq_stats_file is not None: auto_cpufreq_stats_file.seek(0) auto_cpufreq_stats_file.truncate(0) - # execution timestamp - from datetime import datetime - now = datetime.now() current_time = now.strftime("%B %d (%A) - %H:%M:%S") 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( max(psutil.cpu_percent(percpu=True, interval=0.01)), 100 ): - print("\nHigh CPU load") + print("High CPU load") # high cpu usage trigger if cpuload >= 20: @@ -637,7 +639,7 @@ def set_powersave(): turbo(False) elif load1m > powersave_load_threshold: - print("\nHigh system load") + print("High system load") # high cpu usage trigger if cpuload >= 20: @@ -660,7 +662,7 @@ def set_powersave(): turbo(False) else: - print("\nLoad optimal") + print("Load optimal") # high cpu usage trigger if cpuload >= 20: @@ -701,7 +703,7 @@ def mon_powersave(): if psutil.cpu_percent(percpu=False, interval=0.01) >= 30.0 or isclose( max(psutil.cpu_percent(percpu=True, interval=0.01)), 100 ): - print("\nHigh CPU load") + print("High CPU load") # high cpu usage trigger if cpuload >= 20: @@ -724,7 +726,7 @@ def mon_powersave(): get_turbo() elif load1m > powersave_load_threshold: - print("\nHigh system load") + print("High system load") # high cpu usage trigger if cpuload >= 20: @@ -747,7 +749,7 @@ def mon_powersave(): get_turbo() else: - print("\nLoad optimal") + print("Load optimal") # high cpu usage trigger if cpuload >= 20: @@ -823,7 +825,7 @@ def set_performance(): psutil.cpu_percent(percpu=False, interval=0.01) >= 20.0 or max(psutil.cpu_percent(percpu=True, interval=0.01)) >= 75 ): - print("\nHigh CPU load") + print("High CPU load") # high cpu usage trigger if cpuload >= 20: @@ -846,7 +848,7 @@ def set_performance(): turbo(True) elif load1m >= performance_load_threshold: - print("\nHigh system load") + print("High system load") # high cpu usage trigger if cpuload >= 20: @@ -869,7 +871,7 @@ def set_performance(): turbo(True) else: - print("\nLoad optimal") + print("Load optimal") # high cpu usage trigger if cpuload >= 20: @@ -914,7 +916,7 @@ def mon_performance(): psutil.cpu_percent(percpu=False, interval=0.01) >= 20.0 or max(psutil.cpu_percent(percpu=True, interval=0.01)) >= 75 ): - print("\nHigh CPU load") + print("High CPU load") # high cpu usage trigger if cpuload >= 20: @@ -937,7 +939,7 @@ def mon_performance(): get_turbo() elif load1m > performance_load_threshold: - print("\nHigh system load") + print("High system load") # high cpu usage trigger if cpuload >= 20: @@ -960,7 +962,7 @@ def mon_performance(): get_turbo() else: - print("\nLoad optimal") + print("Load optimal") # high cpu usage trigger if cpuload >= 20: diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq index e01ab40..3832abd 100755 --- a/bin/auto-cpufreq +++ b/bin/auto-cpufreq @@ -66,7 +66,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor distro_info() sysinfo() set_autofreq() - countdown(5) + countdown(2) elif os.getenv("PKG_MARKER") != "SNAP": gnome_power_detect() tlp_service_detect() @@ -77,7 +77,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor distro_info() sysinfo() set_autofreq() - countdown(5) + countdown(2) else: daemon_not_found() elif monitor: @@ -99,7 +99,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor distro_info() sysinfo() mon_autofreq() - countdown(5) + countdown(2) elif live: root_check() config_info_dialog() @@ -121,7 +121,7 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor distro_info() sysinfo() set_autofreq() - countdown(5) + countdown(2) except KeyboardInterrupt: gnome_power_start_live() print("") @@ -135,7 +135,6 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor else: gnome_power_detect() tlp_service_detect() - time.sleep(1) read_stats() elif log: deprecated_log_msg()