Automatically disable GNOME power profiles on install

This commit is contained in:
Adnan Hodzic 2021-12-04 20:56:50 +01:00
parent fc5ac16fd6
commit db68390ec3
2 changed files with 17 additions and 15 deletions

View File

@ -312,7 +312,8 @@ def deploy_daemon():
shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/bin/auto-cpufreq-remove") shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/bin/auto-cpufreq-remove")
# output warning if gnome power profile is running # output warning if gnome power profile is running
gnome_power_detect() gnome_power_detect_install()
gnome_power_svc_disable()
call("/usr/bin/auto-cpufreq-install", shell=True) call("/usr/bin/auto-cpufreq-install", shell=True)
@ -331,6 +332,7 @@ def remove():
# output warning if gnome power profile is stopped # output warning if gnome power profile is stopped
gnome_power_rm_reminder() gnome_power_rm_reminder()
gnome_power_svc_enable()
# run auto-cpufreq daemon remove script # run auto-cpufreq daemon remove script
call("/usr/bin/auto-cpufreq-remove", shell=True) call("/usr/bin/auto-cpufreq-remove", shell=True)

View File

@ -34,6 +34,17 @@ def gnome_power_detect():
print("cd auto-cpufreq/auto_cpufreq") print("cd auto-cpufreq/auto_cpufreq")
print("python3 power_helper.py --gnome-power-disable") print("python3 power_helper.py --gnome-power-disable")
# automatically disable gnome power profile service in case it's running during install
def gnome_power_detect_install():
if gnome_power_stats == 0:
print("\n----------------------------------- Warning -----------------------------------\n")
print("Detected running GNOME Power Profiles daemon service!")
print("This daemon might interfere with auto-cpufreq and has been disabled.")
print("\nSteps to enabled disabled deamon (not recommended!) using auto-cpufreq: power_helper script:")
print("git clone https://github.com/AdnanHodzic/auto-cpufreq.git")
print("cd auto-cpufreq/auto_cpufreq")
print("python3 power_helper.py --gnome-power-enable")
# notification on snap # notification on snap
def gnome_power_detect_snap(): def gnome_power_detect_snap():
@ -54,25 +65,19 @@ def gnome_power_disable_live():
# disable gnome >= 40 power profiles (install) # disable gnome >= 40 power profiles (install)
def gnome_power_svc_disable(): def gnome_power_svc_disable():
if(gnome_power_stats == 0): print("\n* Disabling GNOME power profiles")
print("* Disabling GNOME power profiles")
call(["systemctl", "stop", "power-profiles-daemon"]) call(["systemctl", "stop", "power-profiles-daemon"])
call(["systemctl", "disable", "power-profiles-daemon"]) call(["systemctl", "disable", "power-profiles-daemon"])
call(["systemctl", "mask", "power-profiles-daemon"]) call(["systemctl", "mask", "power-profiles-daemon"])
call(["systemctl", "daemon-reload"]) call(["systemctl", "daemon-reload"])
else:
print("* GNOME power profiles already disabled")
# enable gnome >= 40 power profiles (uninstall) # enable gnome >= 40 power profiles (uninstall)
def gnome_power_svc_enable(): def gnome_power_svc_enable():
if(gnome_power_stats != 0): print("\n* Enabling GNOME power profiles")
print("* Enabling GNOME power profiles")
call(["systemctl", "unmask", "power-profiles-daemon"]) call(["systemctl", "unmask", "power-profiles-daemon"])
call(["systemctl", "start", "power-profiles-daemon"]) call(["systemctl", "start", "power-profiles-daemon"])
call(["systemctl", "enable", "power-profiles-daemon"]) call(["systemctl", "enable", "power-profiles-daemon"])
call(["systemctl", "daemon-reload"]) call(["systemctl", "daemon-reload"])
else:
print("* GNOME power profiles already enabled")
# gnome power profiles current status # gnome power profiles current status
@ -140,12 +145,7 @@ def gnome_power_rm_reminder():
if gnome_power_stats != 0: if gnome_power_stats != 0:
print("\n----------------------------------- Warning -----------------------------------\n") print("\n----------------------------------- Warning -----------------------------------\n")
print("Detected GNOME Power Profiles daemon service is stopped!") print("Detected GNOME Power Profiles daemon service is stopped!")
print("Now it's recommended to enable this service.") print("This service will now be enabled again.")
print("\nSteps to perform this action using auto-cpufreq: power_helper script:")
print("git clone https://github.com/AdnanHodzic/auto-cpufreq.git")
print("cd auto-cpufreq/auto_cpufreq")
print("python3 power_helper.py --gnome-power-enable")
def gnome_power_rm_reminder_snap(): def gnome_power_rm_reminder_snap():
print("\n----------------------------------- Warning -----------------------------------\n") print("\n----------------------------------- Warning -----------------------------------\n")