mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-24 06:05:08 +02:00
Extend gnome_power_profiles to use profiles
This commit is contained in:
parent
8fb5469ace
commit
0558c7cf37
@ -1,6 +1,7 @@
|
|||||||
# * add status as one of the available options
|
# * add status as one of the available options
|
||||||
# * alert user on snap if detected and how to remove first time live/stats message starts
|
# * 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
|
# * if daemon is disabled and auto-cpufreq is removed (snap) remind user to enable it back
|
||||||
|
from logging import root
|
||||||
import os, sys, click
|
import os, sys, click
|
||||||
from subprocess import getoutput, call, run, check_output, DEVNULL
|
from subprocess import getoutput, call, run, check_output, DEVNULL
|
||||||
|
|
||||||
@ -124,23 +125,24 @@ def gnome_power_start_live():
|
|||||||
|
|
||||||
|
|
||||||
# disable gnome >= 40 power profiles (install)
|
# disable gnome >= 40 power profiles (install)
|
||||||
def gnome_power_svc_disable():
|
# def gnome_power_svc_disable(profile):
|
||||||
if systemctl_exists:
|
# if systemctl_exists:
|
||||||
# set balanced profile if its running before disabling it
|
# # set balanced profile if its running before disabling it
|
||||||
if gnome_power_status == 0 and powerprofilesctl_exists:
|
# if gnome_power_status == 0 and powerprofilesctl_exists:
|
||||||
call(["powerprofilesctl", "set", "balanced"])
|
# print("Using profile: ", profile)
|
||||||
|
# call(["powerprofilesctl", "set", profile])
|
||||||
|
|
||||||
# always disable power-profiles-daemon
|
# # always disable power-profiles-daemon
|
||||||
try:
|
# try:
|
||||||
print("\n* Disabling GNOME power profiles")
|
# print("\n* 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"])
|
||||||
except:
|
# except:
|
||||||
print("\nUnable to disable GNOME power profiles")
|
# print("\nUnable to disable GNOME power profiles")
|
||||||
print("If this causes any problems, please submit an issue:")
|
# print("If this causes any problems, please submit an issue:")
|
||||||
print("https://github.com/AdnanHodzic/auto-cpufreq/issues")
|
# print("https://github.com/AdnanHodzic/auto-cpufreq/issues")
|
||||||
|
|
||||||
|
|
||||||
# enable gnome >= 40 power profiles (uninstall)
|
# enable gnome >= 40 power profiles (uninstall)
|
||||||
@ -257,15 +259,42 @@ def valid_options():
|
|||||||
|
|
||||||
|
|
||||||
# cli
|
# cli
|
||||||
|
@click.pass_context
|
||||||
|
def gnome_power_svc_disable(ctx, select_profile):
|
||||||
|
gnome_power_profile_selection = ctx.params["gnome_power_disable"]
|
||||||
|
#print(f"Will use: {gnome_power_profile_selection} profile")
|
||||||
|
|
||||||
|
if systemctl_exists:
|
||||||
|
# set balanced profile if its running before disabling it
|
||||||
|
if gnome_power_status == 0 and powerprofilesctl_exists:
|
||||||
|
print("Using profile: ", gnome_power_profile_selection)
|
||||||
|
call(["powerprofilesctl", "set", gnome_power_profile_selection])
|
||||||
|
|
||||||
|
# always disable power-profiles-daemon
|
||||||
|
try:
|
||||||
|
print("\n* Disabling GNOME power profiles")
|
||||||
|
call(["systemctl", "stop", "power-profiles-daemon"])
|
||||||
|
call(["systemctl", "disable", "power-profiles-daemon"])
|
||||||
|
call(["systemctl", "mask", "power-profiles-daemon"])
|
||||||
|
call(["systemctl", "daemon-reload"])
|
||||||
|
except:
|
||||||
|
print("\nUnable to disable GNOME power profiles")
|
||||||
|
print("If this causes any problems, please submit an issue:")
|
||||||
|
print("https://github.com/AdnanHodzic/auto-cpufreq/issues")
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
@click.option("--gnome_power_disable", help="Disable GNOME Power profiles service", is_flag=False, type=click.Choice(['balanced', 'performance'], case_sensitive=True), show_choices=True, multiple=True, default="balanced", show_default=True)
|
||||||
|
#@click.option("--gnome_power_disable", help="Disable GNOME Power profiles service", is_flag=False, type=click.Choice(['balanced', 'performance'], case_sensitive=True), show_choices=True, multiple=True, default="balanced", show_default=True, required=False)
|
||||||
|
@click.option("--select_profile", hidden=True)
|
||||||
@click.option("--gnome_power_enable", is_flag=True, help="Enable GNOME Power profiles service")
|
@click.option("--gnome_power_enable", is_flag=True, help="Enable GNOME Power profiles service")
|
||||||
@click.option("--gnome_power_disable", is_flag=True, help="Disable GNOME Power profiles service")
|
#@click.option("--gnome_power_disable", is_flag=True, help="Disable GNOME Power profiles service", type=(str), default="balanced", show_default=True)
|
||||||
@click.option(
|
#@click.argument("profile")
|
||||||
"--gnome_power_status", is_flag=True, help="Get status of GNOME Power profiles service"
|
@click.option("--gnome_power_status", is_flag=True, help="Get status of GNOME Power profiles service"
|
||||||
)
|
)
|
||||||
@click.option("--bluetooth_boot_on", is_flag=True, help="Turn on Bluetooth on boot")
|
@click.option("--bluetooth_boot_on", is_flag=True, help="Turn on Bluetooth on boot")
|
||||||
@click.option("--bluetooth_boot_off", is_flag=True, help="Turn off Bluetooth on boot")
|
@click.option("--bluetooth_boot_off", is_flag=True, help="Turn off Bluetooth on boot")
|
||||||
def main(
|
def main(
|
||||||
|
select_profile,
|
||||||
gnome_power_enable,
|
gnome_power_enable,
|
||||||
gnome_power_disable,
|
gnome_power_disable,
|
||||||
gnome_power_status,
|
gnome_power_status,
|
||||||
@ -290,7 +319,7 @@ def main(
|
|||||||
elif gnome_power_disable:
|
elif gnome_power_disable:
|
||||||
header()
|
header()
|
||||||
root_check()
|
root_check()
|
||||||
gnome_power_svc_disable()
|
gnome_power_svc_disable(select_profile)
|
||||||
helper_opts()
|
helper_opts()
|
||||||
footer()
|
footer()
|
||||||
elif gnome_power_status:
|
elif gnome_power_status:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user