mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-23 13:45:10 +02:00
refactor + additon of new functionality i,e (app_res_use)
This commit is contained in:
parent
04a9c00b12
commit
fb88158235
@ -54,10 +54,7 @@ def main(monitor, live, daemon, install, log, debug):
|
|||||||
countdown(5)
|
countdown(5)
|
||||||
run("clear")
|
run("clear")
|
||||||
else:
|
else:
|
||||||
print("\n" + "-" * 32 + " Daemon check " + "-" * 33 + "\n")
|
daemon_not_found()
|
||||||
print("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install")
|
|
||||||
footer()
|
|
||||||
exit(1)
|
|
||||||
elif monitor:
|
elif monitor:
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
@ -100,6 +97,13 @@ def main(monitor, live, daemon, install, log, debug):
|
|||||||
print("")
|
print("")
|
||||||
python_info()
|
python_info()
|
||||||
print("")
|
print("")
|
||||||
|
if charging():
|
||||||
|
print("Battery is: charging")
|
||||||
|
else:
|
||||||
|
print("Battery is: discharging")
|
||||||
|
print("")
|
||||||
|
app_res_use()
|
||||||
|
print("")
|
||||||
sysinfo()
|
sysinfo()
|
||||||
display_load()
|
display_load()
|
||||||
get_current_gov()
|
get_current_gov()
|
||||||
|
@ -47,6 +47,12 @@ dcheck = getoutput("snapctl get daemon")
|
|||||||
def app_version():
|
def app_version():
|
||||||
print("Build git commit:", check_output(["git", "describe", "--always"]).strip().decode())
|
print("Build git commit:", check_output(["git", "describe", "--always"]).strip().decode())
|
||||||
|
|
||||||
|
def app_res_use():
|
||||||
|
p = psutil.Process()
|
||||||
|
print("auto-cpufreq system resource consumption:")
|
||||||
|
print("cpu usage:", p.cpu_percent(), "%")
|
||||||
|
print("memory use:", round(p.memory_percent(),2), "%")
|
||||||
|
|
||||||
# set/change state of turbo
|
# set/change state of turbo
|
||||||
def turbo(value: bool = None):
|
def turbo(value: bool = None):
|
||||||
"""
|
"""
|
||||||
@ -163,6 +169,11 @@ def cpufreqctl_restore():
|
|||||||
def footer(l=79):
|
def footer(l=79):
|
||||||
print("\n" + "-" * l + "\n")
|
print("\n" + "-" * l + "\n")
|
||||||
|
|
||||||
|
def daemon_not_found():
|
||||||
|
print("\n" + "-" * 32 + " Daemon check " + "-" * 33 + "\n")
|
||||||
|
print("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install")
|
||||||
|
footer()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def deploy_complete_msg():
|
def deploy_complete_msg():
|
||||||
print("\n" + "-" * 17 + " auto-cpufreq daemon installed and running " + "-" * 17 + "\n")
|
print("\n" + "-" * 17 + " auto-cpufreq daemon installed and running " + "-" * 17 + "\n")
|
||||||
@ -363,10 +374,10 @@ def set_autofreq():
|
|||||||
|
|
||||||
# determine which governor should be used
|
# determine which governor should be used
|
||||||
if charging():
|
if charging():
|
||||||
print("Battery is: charging")
|
print("Battery is: charging\n")
|
||||||
set_performance()
|
set_performance()
|
||||||
else:
|
else:
|
||||||
print("Battery is: discharging")
|
print("Battery is: discharging\n")
|
||||||
set_powersave()
|
set_powersave()
|
||||||
|
|
||||||
|
|
||||||
@ -379,12 +390,12 @@ def mon_autofreq():
|
|||||||
|
|
||||||
# determine which governor should be used
|
# determine which governor should be used
|
||||||
if charging():
|
if charging():
|
||||||
print("Battery is: charging")
|
print("Battery is: charging\n")
|
||||||
get_current_gov()
|
get_current_gov()
|
||||||
print(f"Suggesting use of \"{get_avail_performance()}\" governor")
|
print(f"Suggesting use of \"{get_avail_performance()}\" governor")
|
||||||
mon_performance()
|
mon_performance()
|
||||||
else:
|
else:
|
||||||
print("Battery is: discharging")
|
print("Battery is: discharging\n")
|
||||||
get_current_gov()
|
get_current_gov()
|
||||||
print(f"Suggesting use of \"{get_avail_powersave()}\" governor")
|
print(f"Suggesting use of \"{get_avail_powersave()}\" governor")
|
||||||
mon_powersave()
|
mon_powersave()
|
||||||
@ -495,14 +506,24 @@ def sysinfo():
|
|||||||
|
|
||||||
# read log func
|
# read log func
|
||||||
def read_log():
|
def read_log():
|
||||||
|
|
||||||
|
def no_log_msg():
|
||||||
|
print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n")
|
||||||
|
print("ERROR: auto-cpufreq log is missing.\n\nMake sure to run: \"auto-cpufreq --install\" first")
|
||||||
|
|
||||||
|
# read log (snap)
|
||||||
if os.getenv("PKG_MARKER") == "SNAP":
|
if os.getenv("PKG_MARKER") == "SNAP":
|
||||||
call(["tail", "-n 50", "-f", str(auto_cpufreq_log_file_snap)])
|
if os.path.isfile(auto_cpufreq_log_file_snap):
|
||||||
|
call(["tail", "-n 50", "-f", str(auto_cpufreq_log_file_snap)])
|
||||||
|
else:
|
||||||
|
no_log_msg()
|
||||||
|
# read log (non snap)
|
||||||
elif os.path.isfile(auto_cpufreq_log_file):
|
elif os.path.isfile(auto_cpufreq_log_file):
|
||||||
call(["tail", "-n 50", "-f", str(auto_cpufreq_log_file)])
|
call(["tail", "-n 50", "-f", str(auto_cpufreq_log_file)])
|
||||||
else:
|
else:
|
||||||
print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n")
|
no_log_msg()
|
||||||
print("ERROR: auto-cpufreq log is missing.\n\nMake sure to run: \"auto-cpufreq --install\" first")
|
|
||||||
footer()
|
footer()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
# check if program (argument) is running
|
# check if program (argument) is running
|
||||||
|
Loading…
x
Reference in New Issue
Block a user