refactor of get_current_gov func and its use

This commit is contained in:
Adnan Hodzic 2020-09-11 09:02:19 +02:00
parent 878733a20f
commit 04a9c00b12
2 changed files with 13 additions and 12 deletions

View File

@ -102,6 +102,7 @@ def main(monitor, live, daemon, install, log, debug):
print("") print("")
sysinfo() sysinfo()
display_load() display_load()
get_current_gov()
get_turbo() get_turbo()
footer() footer()
elif install: elif install:

View File

@ -36,6 +36,13 @@ load1m, _, _ = os.getloadavg()
# get CPU utilization as a percentage # get CPU utilization as a percentage
cpuload = psutil.cpu_percent(interval=1) cpuload = psutil.cpu_percent(interval=1)
# auto-cpufreq log file
auto_cpufreq_log_file = Path("/var/log/auto-cpufreq.log")
auto_cpufreq_log_file_snap = Path("/var/snap/auto-cpufreq/current/auto-cpufreq.log")
# daemon check
dcheck = getoutput("snapctl get daemon")
# ToDo: read version from snap/snapcraft.yaml and write to $SNAP/version for use with snap installs # ToDo: read version from snap/snapcraft.yaml and write to $SNAP/version for use with snap installs
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())
@ -117,16 +124,7 @@ def get_avail_performance():
def get_current_gov(): def get_current_gov():
return getoutput("cpufreqctl --governor").strip().split(" ")[0] return print("Currently using:", getoutput("cpufreqctl --governor").strip().split(" ")[0], "governor")
# auto-cpufreq log file
auto_cpufreq_log_file = Path("/var/log/auto-cpufreq.log")
auto_cpufreq_log_file_snap = Path("/var/snap/auto-cpufreq/current/auto-cpufreq.log")
# daemon check
dcheck = getoutput("snapctl get daemon")
def cpufreqctl(): def cpufreqctl():
""" """
@ -382,11 +380,13 @@ 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")
print(f"Suggesting use of \"{get_avail_performance()}\" governor\nCurrently using:", get_current_gov()) get_current_gov()
print(f"Suggesting use of \"{get_avail_performance()}\" governor")
mon_performance() mon_performance()
else: else:
print("Battery is: discharging") print("Battery is: discharging")
print(f"Suggesting use of \"{get_avail_powersave()}\" governor\nCurrently using:", get_current_gov()) get_current_gov()
print(f"Suggesting use of \"{get_avail_powersave()}\" governor")
mon_powersave() mon_powersave()
def python_info(): def python_info():