added option where only lapotps with intel_pstate enabled are supported
This commit is contained in:
parent
d079b179fe
commit
32716dee3d
|
@ -5,6 +5,7 @@ import os
|
|||
import sys
|
||||
import time
|
||||
import psutil
|
||||
import platform
|
||||
|
||||
# ToDo:
|
||||
# - only run if driver is Intel pstate
|
||||
|
@ -15,10 +16,21 @@ import psutil
|
|||
# - add option to enable turbo in powersave
|
||||
# - go thru all other ToDo's
|
||||
|
||||
# global var
|
||||
p = psutil
|
||||
s = subprocess
|
||||
tool_run = "python3 auto-cpufreq.py"
|
||||
|
||||
def driver_check():
|
||||
driver = s.getoutput("cpufreqctl --driver")
|
||||
if driver != "intel_pstate":
|
||||
sys.exit(f"\nError:\nOnly laptops with enabled \"intel_pstate\" (CPU Performance Scaling Driver) are supported.\n")
|
||||
|
||||
# print distro
|
||||
# print chipset
|
||||
# print laptop
|
||||
|
||||
|
||||
def avail_gov():
|
||||
# available governors
|
||||
get_avail_gov = s.getoutput("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors")
|
||||
|
@ -40,7 +52,7 @@ def root_check():
|
|||
# set powersave
|
||||
def set_powersave():
|
||||
print("\nSetting: powersave")
|
||||
s.run("sudo cpufreqctl --governor --set=powersave", shell=True)
|
||||
s.run("cpufreqctl --governor --set=powersave", shell=True)
|
||||
|
||||
print("Setting turbo: off")
|
||||
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||
|
@ -48,9 +60,9 @@ def set_powersave():
|
|||
# set performance
|
||||
def set_performance():
|
||||
print("\nSetting: performance")
|
||||
s.run("sudo cpufreqctl --governor --set=performance", shell=True)
|
||||
s.run("cpufreqctl --governor --set=performance", shell=True)
|
||||
# alternative
|
||||
# sudo echo performance /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||
# echo performance /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||
|
||||
# enable turbo boost
|
||||
set_turbo()
|
||||
|
@ -81,9 +93,19 @@ def set_turbo():
|
|||
|
||||
# - display cpu/load/sensors(?) info
|
||||
#def sysload_info():
|
||||
# ....
|
||||
# distro
|
||||
# kernel
|
||||
# number of cores
|
||||
# driver?
|
||||
# chipset
|
||||
# laptop maker/model?
|
||||
# sensors?
|
||||
|
||||
def autofreq():
|
||||
|
||||
driver_check()
|
||||
|
||||
# ToDo: make a function?
|
||||
# check battery status
|
||||
get_bat_state = s.getoutput("cat /sys/class/power_supply/BAT0/status")
|
||||
bat_state = get_bat_state.split()[0]
|
||||
|
@ -97,7 +119,9 @@ def autofreq():
|
|||
if __name__ == '__main__':
|
||||
while True:
|
||||
root_check()
|
||||
|
||||
#load()
|
||||
#set_powersave()
|
||||
|
||||
autofreq()
|
||||
time.sleep(10)
|
Loading…
Reference in New Issue