added option to clean screen + other minor changes

This commit is contained in:
Adnan Hodzic 2019-12-30 21:07:34 +01:00
parent a4edff0dfb
commit dcf4f53e5c
1 changed files with 8 additions and 5 deletions

View File

@ -12,13 +12,12 @@ import re
# ToDo: # ToDo:
# - check if debian based + first time setup (install necessary packages) # - check if debian based + first time setup (install necessary packages)
# - add option to run as daemon on boot # - add option to run as daemon on boot (systemd)
# - add revert options # - add revert/uninstall options for ^
# - sort out imports # - sort out imports
# - add option to enable turbo in powersave # - add option to enable turbo in powersave
# - go thru all other ToDo's # - go thru all other ToDo's
# - copy cpufreqctl script if it doesn't exist # - copy cpufreqctl script if it doesn't exist
# - clean/refresh screen instead of constant publish
# global var # global var
p = psutil p = psutil
@ -80,15 +79,18 @@ def set_turbo():
if load1m > 2: if load1m > 2:
print("High load, turbo bost: on") print("High load, turbo bost: on")
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True) s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
print("\n" + "-" * 60 + "\n")
# print("High load:", load1m) # print("High load:", load1m)
# print("CPU load:", cpuload, "%") # print("CPU load:", cpuload, "%")
elif cpuload > 25: elif cpuload > 25:
print("High CPU load, turbo boost: on") print("High CPU load, turbo boost: on")
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True) s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
print("\n" + "-" * 60 + "\n")
else: else:
print("Load optimal, turbo boost: off") print("Load optimal, turbo boost: off")
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True) s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
print("\n" + "-" * 60 + "\n")
def autofreq(): def autofreq():
@ -136,7 +138,7 @@ def sysinfo():
# ToDo: make more generic and not only for thinkpad # ToDo: make more generic and not only for thinkpad
#print(psutil.sensors_fans()) #print(psutil.sensors_fans())
current_fans = p.sensors_fans()['thinkpad'][0].current current_fans = p.sensors_fans()['thinkpad'][0].current
print("\nCPU fan speed:", current_fans), "RPM" print("\nCPU fan speed:", current_fans, "RPM")
# ToDo: add CPU temperature for each core # ToDo: add CPU temperature for each core
# issue: https://github.com/giampaolo/psutil/issues/1650 # issue: https://github.com/giampaolo/psutil/issues/1650
@ -149,4 +151,5 @@ if __name__ == '__main__':
gov_check() gov_check()
sysinfo() sysinfo()
autofreq() autofreq()
time.sleep(10) time.sleep(10)
subprocess.call("clear")