Automatically enable/disable GNOME power savings profiles

This commit is contained in:
Adnan Hodzic 2021-11-21 09:22:22 +01:00
parent 01b7c0fe2e
commit ec4556c835
4 changed files with 41 additions and 1 deletions

View File

@ -183,6 +183,10 @@ function tool_remove {
[ -f $srv_remove ] && rm $srv_remove
[ -f $stats_file ] && rm $stats_file
# enable GNOME power profiles in case it was disabled by auto-cpufreq
systemctl start power-profiles-daemon
systemctl enable power-profiles-daemon
separator
echo -e "\nauto-cpufreq tool and all its supporting files successfully removed."
separator

View File

@ -352,6 +352,9 @@ def remove():
else:
print("* Turn on bluetooth on boot [skipping] (package providing bluetooth access is not present)")
# enable gnome power profiles
gnome_power_enable()
# run auto-cpufreq daemon install script
call("/usr/bin/auto-cpufreq-remove", shell=True)
@ -1083,3 +1086,33 @@ def running_daemon():
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"])
#call(["systemctl", "mask", "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"])
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", "start", "power-profiles-daemon"])
call(["systemctl", "enable", "power-profiles-daemon"])
else:
print("GNOME power already enabled")

View File

@ -83,6 +83,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
elif live:
config_info_dialog()
print("\nNote: You can quit live mode by pressing \"ctrl+c\"")
gnome_power_disable_live()
time.sleep(1)
while True:
root_check()
@ -138,6 +139,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
if os.getenv('PKG_MARKER') == "SNAP":
root_check()
running_daemon()
gnome_power_disable()
gov_check()
run("snapctl set daemon=enabled", shell=True)
run("snapctl start --enable auto-cpufreq", shell=True)
@ -145,6 +147,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
else:
root_check()
running_daemon()
gnome_power_disable()
gov_check()
deploy_daemon()
deploy_complete_msg()

View File

@ -1,6 +1,6 @@
name: auto-cpufreq
base: core20
version: '1.7.2'
version: '1.8.0'
summary: Automatic CPU speed & power optimizer for Linux
description: |
Automatic CPU speed & power optimizer for Linux based on active