Revamped performance mode install on non Snap env
This commit is contained in:
parent
c92d907d6e
commit
8ff85e9371
|
@ -370,6 +370,36 @@ def deploy_daemon():
|
|||
call("/usr/bin/auto-cpufreq-install", shell=True)
|
||||
|
||||
|
||||
def deploy_daemon_performance():
|
||||
print("\n" + "-" * 21 + " Deploying auto-cpufreq as a daemon " + "-" * 22 + "\n")
|
||||
|
||||
# ToDo:
|
||||
# add check that performance exists otherwise exit
|
||||
|
||||
# deploy cpufreqctl script func call
|
||||
cpufreqctl()
|
||||
|
||||
# turn off bluetooth on boot
|
||||
bluetooth_disable()
|
||||
|
||||
auto_cpufreq_stats_path.touch(exist_ok=True)
|
||||
|
||||
print("\n* Deploy auto-cpufreq install script")
|
||||
shutil.copy(SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/bin/auto-cpufreq-install")
|
||||
|
||||
print("\n* Deploy auto-cpufreq remove script")
|
||||
shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/bin/auto-cpufreq-remove")
|
||||
|
||||
# output warning if gnome power profile is running
|
||||
gnome_power_detect_install()
|
||||
gnome_power_svc_disable_performance()
|
||||
|
||||
# output warning if TLP service is detected
|
||||
tlp_service_detect()
|
||||
|
||||
call("/usr/bin/auto-cpufreq-install", shell=True)
|
||||
|
||||
|
||||
# remove auto-cpufreq daemon
|
||||
def remove():
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ def gnome_power_detect_install():
|
|||
print("Detected running GNOME Power Profiles daemon service!")
|
||||
print("This daemon might interfere with auto-cpufreq and has been disabled.\n")
|
||||
print('This daemon is not automatically disabled in "monitor" mode and')
|
||||
print("will be enabled after auto-cpufreq is removed.")
|
||||
print("will be enabled after auto-cpufreq is removed.\n")
|
||||
|
||||
|
||||
# notification on snap
|
||||
|
@ -260,6 +260,16 @@ def gnome_power_svc_disable():
|
|||
|
||||
disable_power_profiles_daemon()
|
||||
|
||||
# default gnome_power_svc_disable func (performance)
|
||||
def gnome_power_svc_disable_performance():
|
||||
if systemctl_exists:
|
||||
# set performance profile if its running before disabling it
|
||||
if gnome_power_status == 0 and powerprofilesctl_exists:
|
||||
print("Using profile: ", "performance")
|
||||
call(["powerprofilesctl", "set", "performance"])
|
||||
|
||||
disable_power_profiles_daemon()
|
||||
|
||||
|
||||
# cli
|
||||
@click.pass_context
|
||||
|
@ -271,18 +281,30 @@ def gnome_power_svc_disable_ext(ctx, power_selection):
|
|||
if systemctl_exists:
|
||||
# 0 is active
|
||||
if gnome_power_status != 0:
|
||||
print("Power Profiles Daemon is already disabled, re-enable by running:\n"
|
||||
"sudo python3 power_helper.py --gnome_power_enable\n"
|
||||
"\nfollowed by running:\n"
|
||||
"sudo python3 power_helper.py --gnome_power_disable"
|
||||
)
|
||||
if os.getenv("PKG_MARKER") == "SNAP":
|
||||
print("Power Profiles Daemon is already disabled, re-enable by running:\n"
|
||||
"sudo python3 power_helper.py --gnome_power_enable\n"
|
||||
"\nfollowed by running:\n"
|
||||
"sudo python3 power_helper.py --gnome_power_disable"
|
||||
)
|
||||
else:
|
||||
print("Power Profiles Daemon is already disabled, first remove auto-cpufreq:\n"
|
||||
"sudo auto-cpufreq --remove\n"
|
||||
"\nfollowed by installing auto-cpufreq in performance mode:\n"
|
||||
"sudo auto-cpufreq --install_performance"
|
||||
)
|
||||
|
||||
# set balanced profile if its running before disabling it
|
||||
if gnome_power_status == 0 and powerprofilesctl_exists:
|
||||
print("Using profile: ", gnome_power_disable)
|
||||
call(["powerprofilesctl", "set", gnome_power_disable])
|
||||
if os.getenv("PKG_MARKER") == "SNAP":
|
||||
print("Using profile: ", gnome_power_disable)
|
||||
call(["powerprofilesctl", "set", gnome_power_disable])
|
||||
|
||||
disable_power_profiles_daemon()
|
||||
disable_power_profiles_daemon()
|
||||
else:
|
||||
print("Install auto-cpufreq in performance mode by running:\n"
|
||||
"sudo auto-cpufreq --install_performance\n"
|
||||
)
|
||||
|
||||
|
||||
@click.command()
|
||||
|
|
|
@ -23,6 +23,7 @@ from auto_cpufreq.power_helper import *
|
|||
default=True,
|
||||
help="Install/remove daemon for (permanent) automatic CPU optimizations",
|
||||
)
|
||||
@click.option("--install_performance", is_flag=True, hidden=True)
|
||||
@click.option("--stats", is_flag=True, help="View live stats of CPU optimizations made by daemon")
|
||||
@click.option(
|
||||
"--config",
|
||||
|
@ -35,7 +36,7 @@ from auto_cpufreq.power_helper import *
|
|||
@click.option("--donate", is_flag=True, help="Support the project")
|
||||
@click.option("--log", is_flag=True, hidden=True)
|
||||
@click.option("--daemon", is_flag=True, hidden=True)
|
||||
def main(config, daemon, debug, install, live, log, monitor, stats, version, donate):
|
||||
def main(config, daemon, debug, install, install_performance, live, log, monitor, stats, version, donate):
|
||||
|
||||
# display info if config file is used
|
||||
def config_info_dialog():
|
||||
|
@ -173,6 +174,18 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||
print("Show your appreciation by donating!")
|
||||
print("https://github.com/AdnanHodzic/auto-cpufreq/#donate")
|
||||
footer()
|
||||
elif install_performance:
|
||||
if os.getenv("PKG_MARKER") == "SNAP":
|
||||
root_check()
|
||||
print("This option is only available on non Snap installs"
|
||||
"Please refer to: power_helper.py script for more info\n")
|
||||
else:
|
||||
print("in performance")
|
||||
root_check()
|
||||
running_daemon()
|
||||
gov_check()
|
||||
deploy_daemon_performance()
|
||||
deploy_complete_msg()
|
||||
elif install:
|
||||
if os.getenv("PKG_MARKER") == "SNAP":
|
||||
root_check()
|
||||
|
@ -185,6 +198,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||
run("snapctl start --enable auto-cpufreq", shell=True)
|
||||
deploy_complete_msg()
|
||||
else:
|
||||
print("in install")
|
||||
root_check()
|
||||
running_daemon()
|
||||
gov_check()
|
||||
|
|
Loading…
Reference in New Issue