Complete power-profiles operations helper for non Snap install
This commit is contained in:
parent
677646abbd
commit
167b761888
|
@ -317,6 +317,9 @@ def deploy_daemon():
|
|||
|
||||
auto_cpufreq_stats_path.touch(exist_ok=True)
|
||||
|
||||
# disable gnome power profiles
|
||||
gnome_power_disable()
|
||||
|
||||
print("\n* Deploy auto-cpufreq install script")
|
||||
shutil.copy(
|
||||
SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/bin/auto-cpufreq-install"
|
||||
|
@ -1083,35 +1086,4 @@ def running_daemon():
|
|||
exit(1)
|
||||
elif os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled":
|
||||
daemon_running_msg()
|
||||
exit(1)
|
||||
|
||||
# # disable gnome >= 40 power profiles (live)
|
||||
# def gnome_power_disable_live():
|
||||
# gnome_power_stats = call(["systemctl", "is-active", "--quiet", "power-profiles-daemon"])
|
||||
# if(gnome_power_stats == 0):
|
||||
# print("Disabling GNOME power profiles")
|
||||
# call(["systemctl", "stop", "power-profiles-daemon"])
|
||||
# else:
|
||||
# print("GNOME power already disabled")
|
||||
|
||||
# # disable gnome >= 40 power profiles (install)
|
||||
# def gnome_power_disable():
|
||||
# gnome_power_stats = call(["systemctl", "is-active", "--quiet", "power-profiles-daemon"])
|
||||
# if(gnome_power_stats == 0):
|
||||
# print("Disabling GNOME power profiles")
|
||||
# call(["systemctl", "stop", "power-profiles-daemon"])
|
||||
# call(["systemctl", "disable", "power-profiles-daemon"])
|
||||
# call(["systemctl", "mask", "power-profiles-daemon"])
|
||||
# else:
|
||||
# print("GNOME power already disabled")
|
||||
|
||||
# # enable gnome >= 40 power profiles (uninstall)
|
||||
# def gnome_power_enable():
|
||||
# gnome_power_stats = call(["systemctl", "is-active", "--quiet", "power-profiles-daemon"])
|
||||
# if(gnome_power_stats == 0):
|
||||
# print("Enabling GNOME power profiles")
|
||||
# call(["systemctl", "unmask", "power-profiles-daemon"])
|
||||
# call(["systemctl", "start", "power-profiles-daemon"])
|
||||
# call(["systemctl", "enable", "power-profiles-daemon"])
|
||||
# else:
|
||||
# print("GNOME power already enabled")
|
||||
exit(1)
|
|
@ -1,5 +1,5 @@
|
|||
# * add gnome_power_detect message after install (make it more visible)
|
||||
# * make sure daemon is enabled after auto-cpufreq --remove (non snap)
|
||||
# * add status as one of the available options
|
||||
# * alert user on snap if detected and how to remove first time live/stats message starts
|
||||
# * if daemon is disabled and auto-cpufreq is removed (snap) remind user to enable it back
|
||||
import os, sys, click
|
||||
from subprocess import getoutput, call, run, check_output, DEVNULL
|
||||
|
@ -8,18 +8,13 @@ sys.path.append('../')
|
|||
from auto_cpufreq.core import *
|
||||
|
||||
# app_name var
|
||||
#if os.getenv("PKG_MARKER") == "SNAP":
|
||||
# app_name = "auto-cpufreq"
|
||||
if sys.argv[0] == "gnome_power.py":
|
||||
app_name="gnome_power.py"
|
||||
app_name="python3 gnome_power.py"
|
||||
else:
|
||||
app_name="auto-cpufreq"
|
||||
|
||||
# detect if gnome power profile service is running
|
||||
gnome_power_stats = call(["systemctl", "is-active", "--quiet", "power-profiles-daemon"])
|
||||
# ToDo: remove
|
||||
print(gnome_power_stats)
|
||||
print(os.getenv('PKG_MARKER'))
|
||||
|
||||
# alert in case gnome power profile service is running
|
||||
def gnome_power_detect():
|
||||
|
@ -33,41 +28,34 @@ def gnome_power_detect():
|
|||
elif gnome_power_stats == 0:
|
||||
print("\nDetected running GNOME Power Profiles daemon service:")
|
||||
print("This daemon might interfere with auto-cpufreq and it will be disabled!")
|
||||
gnome_power_disable()
|
||||
print("\nIf you wish to enable this daemon to run concurrently with auto-cpufreq run:")
|
||||
print("cd ~/auto-cpufreq/auto_cpufreq")
|
||||
print("python3 gnome_power.py --enable")
|
||||
|
||||
# disable gnome >= 40 power profiles (live)
|
||||
def gnome_power_disable_live():
|
||||
if(gnome_power_stats != 0):
|
||||
# ToDo: remove
|
||||
print("\nDisabling GNOME power profiles")
|
||||
if(gnome_power_stats == 0):
|
||||
call(["systemctl", "stop", "power-profiles-daemon"])
|
||||
else:
|
||||
print("GNOME power already disabled")
|
||||
|
||||
# disable gnome >= 40 power profiles (install)
|
||||
def gnome_power_disable():
|
||||
if(gnome_power_stats != 0):
|
||||
# ToDo: remove
|
||||
print("\nDisabling GNOME power profiles")
|
||||
if(gnome_power_stats == 0):
|
||||
print("\n* Disabling GNOME power profiles")
|
||||
call(["systemctl", "stop", "power-profiles-daemon"])
|
||||
call(["systemctl", "disable", "power-profiles-daemon"])
|
||||
call(["systemctl", "mask", "power-profiles-daemon"])
|
||||
else:
|
||||
print("GNOME power already disabled")
|
||||
print("\n* Disabling GNOME power profiles (already disabled)")
|
||||
|
||||
# enable gnome >= 40 power profiles (uninstall)
|
||||
def gnome_power_enable():
|
||||
# ToDo: remove
|
||||
if(gnome_power_stats != 0):
|
||||
print("\nEnabling GNOME power profiles")
|
||||
if(gnome_power_stats == 0):
|
||||
print("\n* Enabling GNOME power profiles")
|
||||
call(["systemctl", "unmask", "power-profiles-daemon"])
|
||||
call(["systemctl", "start", "power-profiles-daemon"])
|
||||
call(["systemctl", "enable", "power-profiles-daemon"])
|
||||
else:
|
||||
print("GNOME power already enabled")
|
||||
print("\n* Enabling GNOME power profiles (already enabled)")
|
||||
|
||||
def valid_options():
|
||||
print("--enable\t\tEnable GNOME Power Profiles daemon")
|
||||
|
@ -81,8 +69,8 @@ def main(enable, disable):
|
|||
|
||||
root_check()
|
||||
if len(sys.argv) == 1:
|
||||
footer()
|
||||
print("Provided none of valid options.\n\nRun: \"" + app_name + " --help\" for more info")
|
||||
print("---------------- auto-cpufreq: GNOME Power Profiles helper --------------------\n")
|
||||
print("Unrecognized option!\n\nRun: \"" + app_name + " --help\" for list of available options.")
|
||||
footer()
|
||||
else:
|
||||
if enable:
|
||||
|
|
Loading…
Reference in New Issue