Revamp of gnome_detect & disable default enable functionality
This commit is contained in:
parent
d6bfdfc680
commit
1d4f88d78d
|
@ -183,11 +183,6 @@ function tool_remove {
|
||||||
[ -f $srv_remove ] && rm $srv_remove
|
[ -f $srv_remove ] && rm $srv_remove
|
||||||
[ -f $stats_file ] && rm $stats_file
|
[ -f $stats_file ] && rm $stats_file
|
||||||
|
|
||||||
# enable GNOME power profiles in case it was disabled by auto-cpufreq
|
|
||||||
systemctl unmask power-profiles-daemon
|
|
||||||
systemctl start power-profiles-daemon
|
|
||||||
systemctl enable power-profiles-daemon
|
|
||||||
|
|
||||||
separator
|
separator
|
||||||
echo -e "\nauto-cpufreq tool and all its supporting files successfully removed."
|
echo -e "\nauto-cpufreq tool and all its supporting files successfully removed."
|
||||||
separator
|
separator
|
||||||
|
|
|
@ -80,7 +80,6 @@ def get_config(config_file=''):
|
||||||
# get distro name
|
# get distro name
|
||||||
dist_name = distro.id()
|
dist_name = distro.id()
|
||||||
|
|
||||||
|
|
||||||
# display running version of auto-cpufreq
|
# display running version of auto-cpufreq
|
||||||
def app_version():
|
def app_version():
|
||||||
|
|
||||||
|
@ -317,9 +316,6 @@ def deploy_daemon():
|
||||||
|
|
||||||
auto_cpufreq_stats_path.touch(exist_ok=True)
|
auto_cpufreq_stats_path.touch(exist_ok=True)
|
||||||
|
|
||||||
# disable gnome power profiles
|
|
||||||
gnome_power_disable()
|
|
||||||
|
|
||||||
print("\n* Deploy auto-cpufreq install script")
|
print("\n* Deploy auto-cpufreq install script")
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/bin/auto-cpufreq-install"
|
SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/bin/auto-cpufreq-install"
|
||||||
|
@ -328,8 +324,12 @@ def deploy_daemon():
|
||||||
print("\n* Deploy auto-cpufreq remove script")
|
print("\n* Deploy auto-cpufreq remove script")
|
||||||
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
|
||||||
|
gnome_power_detect()
|
||||||
|
|
||||||
call("/usr/bin/auto-cpufreq-install", shell=True)
|
call("/usr/bin/auto-cpufreq-install", shell=True)
|
||||||
|
|
||||||
|
# ToDo: change to be a warning and move to power_helper?
|
||||||
def bt_snap():
|
def bt_snap():
|
||||||
if os.getenv("PKG_MARKER") == "SNAP":
|
if os.getenv("PKG_MARKER") == "SNAP":
|
||||||
try:
|
try:
|
||||||
|
@ -365,10 +365,10 @@ def remove():
|
||||||
else:
|
else:
|
||||||
print("* Turn on bluetooth on boot [skipping] (package providing bluetooth access is not present)")
|
print("* Turn on bluetooth on boot [skipping] (package providing bluetooth access is not present)")
|
||||||
|
|
||||||
# enable gnome power profiles
|
# output warning if gnome power profile is stopped
|
||||||
gnome_power_enable()
|
gnome_power_rm_reminder()
|
||||||
|
|
||||||
# run auto-cpufreq daemon install script
|
# run auto-cpufreq daemon remove script
|
||||||
call("/usr/bin/auto-cpufreq-remove", shell=True)
|
call("/usr/bin/auto-cpufreq-remove", shell=True)
|
||||||
|
|
||||||
# remove auto-cpufreq-remove
|
# remove auto-cpufreq-remove
|
||||||
|
|
|
@ -20,25 +20,34 @@ if os.getenv('PKG_MARKER') != "SNAP":
|
||||||
# alert in case gnome power profile service is running
|
# alert in case gnome power profile service is running
|
||||||
def gnome_power_detect():
|
def gnome_power_detect():
|
||||||
if gnome_power_stats == 0:
|
if gnome_power_stats == 0:
|
||||||
print("\nDetected running GNOME Power Profiles daemon service:")
|
print("\n----------------------------------- Warning -----------------------------------\n")
|
||||||
print("This daemon might interfere with auto-cpufreq and it will be disabled!")
|
print("Detected running GNOME Power Profiles daemon service!")
|
||||||
print("\nIf you wish to enable this daemon to run concurrently with auto-cpufreq run:")
|
print("This daemon might interfere with auto-cpufreq and should be disabled.")
|
||||||
print("cd ~/auto-cpufreq/auto_cpufreq")
|
print("\nSteps to perform this action using auto-cpufreq: power_helper script:")
|
||||||
print("python3 gnome_power.py --enable")
|
print("git clone https://github.com/AdnanHodzic/auto-cpufreq.git")
|
||||||
|
print("cd auto-cpufreq/auto_cpufreq")
|
||||||
|
# ToDo: add proper argument after rename
|
||||||
|
print("python3 gnome_power.py --disable")
|
||||||
|
|
||||||
|
|
||||||
# notification on snap
|
# notification on snap
|
||||||
def gnome_power_detect_snap():
|
def gnome_power_detect_snap():
|
||||||
print("\nUnable to detect state of GNOME Power Profiles daemon service:")
|
print("\n----------------------------------- Warning -----------------------------------\n")
|
||||||
print("This daemon might interfere with auto-cpufreq and should be disabled!\n")
|
print("Unable to detect state of GNOME Power Profiles daemon service!")
|
||||||
print("Due to Snap limitations, it needs to be disabled manually by running, i.e:")
|
print("This daemon might interfere with auto-cpufreq and should be disabled.")
|
||||||
print("cd ~/auto-cpufreq/auto_cpufreq")
|
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 gnome_power.py --disable")
|
print("python3 gnome_power.py --disable")
|
||||||
|
|
||||||
|
|
||||||
|
# ToDo: remove function?
|
||||||
# disable gnome >= 40 power profiles (live)
|
# disable gnome >= 40 power profiles (live)
|
||||||
def gnome_power_disable_live():
|
def gnome_power_disable_live():
|
||||||
if(gnome_power_stats == 0):
|
if(gnome_power_stats == 0):
|
||||||
call(["systemctl", "stop", "power-profiles-daemon"])
|
call(["systemctl", "stop", "power-profiles-daemon"])
|
||||||
|
|
||||||
|
|
||||||
# disable gnome >= 40 power profiles (install)
|
# disable gnome >= 40 power profiles (install)
|
||||||
def gnome_power_disable():
|
def gnome_power_disable():
|
||||||
if(gnome_power_stats == 0):
|
if(gnome_power_stats == 0):
|
||||||
|
@ -46,46 +55,79 @@ def gnome_power_disable():
|
||||||
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"])
|
||||||
else:
|
call(["systemctl", "daemon-reload"])
|
||||||
print("\n* Disabling GNOME power profiles (already disabled)")
|
|
||||||
|
|
||||||
# enable gnome >= 40 power profiles (uninstall)
|
# enable gnome >= 40 power profiles (uninstall)
|
||||||
def gnome_power_enable():
|
def gnome_power_enable():
|
||||||
if(gnome_power_stats == 0):
|
if(gnome_power_stats != 0):
|
||||||
print("\n* Enabling GNOME power profiles")
|
print("\n* 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"])
|
||||||
else:
|
call(["systemctl", "daemon-reload"])
|
||||||
print("\n* Enabling GNOME power profiles (already enabled)")
|
|
||||||
|
# gnome power profiles current status
|
||||||
|
def gnome_power_status():
|
||||||
|
print("\n* GNOME power profiles status")
|
||||||
|
call(["systemctl", "status", "power-profiles-daemon"])
|
||||||
|
# ToDo: add how to disable/enable
|
||||||
|
|
||||||
|
# gnome power removal reminder
|
||||||
|
def gnome_power_rm_reminder():
|
||||||
|
if gnome_power_stats != 0:
|
||||||
|
print("\n----------------------------------- Warning -----------------------------------\n")
|
||||||
|
print("Detected GNOME Power Profiles daemon service is stopped!")
|
||||||
|
print("Now it's recommended to enable this service.")
|
||||||
|
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 gnome_power.py --enable")
|
||||||
|
|
||||||
|
def gnome_power_rm_reminder_snap():
|
||||||
|
print("\n----------------------------------- Warning -----------------------------------\n")
|
||||||
|
print("\nUnable to detect state of GNOME Power Profiles daemon service!")
|
||||||
|
print("Now it's recommended to enable this service.")
|
||||||
|
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 gnome_power.py --enable")
|
||||||
|
|
||||||
def valid_options():
|
def valid_options():
|
||||||
print("--enable\t\tEnable GNOME Power Profiles daemon")
|
print("--enable\t\tEnable GNOME Power Profiles daemon")
|
||||||
print("--disable\t\tDisable GNOME Power Profiles daemon\n")
|
print("--disable\t\tDisable GNOME Power Profiles daemon\n")
|
||||||
|
|
||||||
|
|
||||||
# cli
|
# cli
|
||||||
# ToDo: implement status option
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--enable", is_flag=True, help="Monitor and see suggestions for CPU optimizations")
|
@click.option("--enable", is_flag=True, help="Enable GNOME Power profiles service")
|
||||||
@click.option("--disable", is_flag=True, help="Monitor and make (temp.) suggested CPU optimizations")
|
@click.option("--disable", is_flag=True, help="Disable GNOME Power profiles service")
|
||||||
def main(enable, disable):
|
@click.option("--status", is_flag=True, help="Get status of GNOME Power profiles service")
|
||||||
|
def main(enable, disable, status):
|
||||||
|
|
||||||
root_check()
|
root_check()
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
print("---------------- auto-cpufreq: GNOME Power Profiles helper --------------------\n")
|
print("\n------------------------- auto-cpufreq: Power helper -------------------------\n")
|
||||||
print("Unrecognized option!\n\nRun: \"" + app_name + " --help\" for list of available options.")
|
print("Unrecognized option!\n\nRun: \"" + app_name + " --help\" for list of available options.")
|
||||||
footer()
|
footer()
|
||||||
else:
|
else:
|
||||||
if enable:
|
if enable:
|
||||||
# Todo: prettify output
|
footer()
|
||||||
root_check()
|
root_check()
|
||||||
print("Enabling")
|
print("Enabling GNOME Power Profiles")
|
||||||
gnome_power_enable()
|
gnome_power_enable()
|
||||||
|
footer()
|
||||||
elif disable:
|
elif disable:
|
||||||
# Todo: prettify output
|
footer()
|
||||||
root_check()
|
root_check()
|
||||||
print("Disabling")
|
print("Disabling GNOME Power Profiles")
|
||||||
gnome_power_disable()
|
gnome_power_disable()
|
||||||
|
footer()
|
||||||
|
elif status:
|
||||||
|
footer()
|
||||||
|
root_check()
|
||||||
|
print("Status of GNOME Power Profiles")
|
||||||
|
gnome_power_status()
|
||||||
|
footer()
|
||||||
else:
|
else:
|
||||||
print("whatever")
|
print("whatever")
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# auto-cpufreq - Automatic CPU speed & power optimizer for Linux
|
# auto-cpufreq - Automatic CPU speed & power optimizer for Linux
|
||||||
#
|
#
|
||||||
# Blog post: http://foolcontrol.org/?p=3124
|
# Blog post: https://foolcontrol.org/?p=3124
|
||||||
|
|
||||||
# core import
|
# core import
|
||||||
import sys
|
import sys
|
||||||
|
@ -12,7 +12,7 @@ from subprocess import call, run
|
||||||
|
|
||||||
sys.path.append('../')
|
sys.path.append('../')
|
||||||
from auto_cpufreq.core import *
|
from auto_cpufreq.core import *
|
||||||
#from auto_cpufreq.gnome_power import *
|
from auto_cpufreq.gnome_power import *
|
||||||
|
|
||||||
# cli
|
# cli
|
||||||
@click.command()
|
@click.command()
|
||||||
|
@ -44,11 +44,11 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
else:
|
else:
|
||||||
if daemon:
|
if daemon:
|
||||||
config_info_dialog()
|
config_info_dialog()
|
||||||
|
root_check()
|
||||||
file_stats()
|
file_stats()
|
||||||
if os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled":
|
if os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled":
|
||||||
gnome_power_detect_snap()
|
gnome_power_detect_snap()
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
|
||||||
footer()
|
footer()
|
||||||
gov_check()
|
gov_check()
|
||||||
cpufreqctl()
|
cpufreqctl()
|
||||||
|
@ -58,10 +58,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
countdown(5)
|
countdown(5)
|
||||||
elif os.getenv("PKG_MARKER") != "SNAP":
|
elif os.getenv("PKG_MARKER") != "SNAP":
|
||||||
gnome_power_detect()
|
gnome_power_detect()
|
||||||
# ToDo: disable only if not disabled already
|
|
||||||
gnome_power_disable()
|
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
|
||||||
footer()
|
footer()
|
||||||
gov_check()
|
gov_check()
|
||||||
cpufreqctl()
|
cpufreqctl()
|
||||||
|
@ -73,11 +70,14 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
daemon_not_found()
|
daemon_not_found()
|
||||||
elif monitor:
|
elif monitor:
|
||||||
config_info_dialog()
|
config_info_dialog()
|
||||||
|
root_check()
|
||||||
|
print("\nNote: You can quit monitor mode by pressing \"ctrl+c\"")
|
||||||
|
if os.getenv("PKG_MARKER") == "SNAP":
|
||||||
|
gnome_power_detect_snap()
|
||||||
|
else:
|
||||||
|
gnome_power_detect()
|
||||||
while True:
|
while True:
|
||||||
print("\nNote: You can quit monitor mode by pressing \"ctrl+c\"")
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
root_check()
|
|
||||||
# ToDO: add gnome profile detect/disable?
|
|
||||||
running_daemon()
|
running_daemon()
|
||||||
footer()
|
footer()
|
||||||
gov_check()
|
gov_check()
|
||||||
|
@ -87,6 +87,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
mon_autofreq()
|
mon_autofreq()
|
||||||
countdown(5)
|
countdown(5)
|
||||||
elif live:
|
elif live:
|
||||||
|
root_check()
|
||||||
config_info_dialog()
|
config_info_dialog()
|
||||||
print("\nNote: You can quit live mode by pressing \"ctrl+c\"")
|
print("\nNote: You can quit live mode by pressing \"ctrl+c\"")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -94,10 +95,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
gnome_power_detect_snap()
|
gnome_power_detect_snap()
|
||||||
else:
|
else:
|
||||||
gnome_power_detect()
|
gnome_power_detect()
|
||||||
# ToDo: disable only if not disabled already
|
|
||||||
gnome_power_disable()
|
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
|
||||||
running_daemon()
|
running_daemon()
|
||||||
footer()
|
footer()
|
||||||
gov_check()
|
gov_check()
|
||||||
|
@ -109,11 +107,16 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
elif stats:
|
elif stats:
|
||||||
config_info_dialog()
|
config_info_dialog()
|
||||||
print("\nNote: You can quit stats mode by pressing \"ctrl+c\"")
|
print("\nNote: You can quit stats mode by pressing \"ctrl+c\"")
|
||||||
|
if os.getenv("PKG_MARKER") == "SNAP":
|
||||||
|
gnome_power_detect_snap()
|
||||||
|
else:
|
||||||
|
gnome_power_detect()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
read_stats()
|
read_stats()
|
||||||
elif log:
|
elif log:
|
||||||
deprecated_log_msg()
|
deprecated_log_msg()
|
||||||
elif debug:
|
elif debug:
|
||||||
|
# ToDo: add status of GNOME Power Profile servie status
|
||||||
config_info_dialog()
|
config_info_dialog()
|
||||||
root_check()
|
root_check()
|
||||||
footer()
|
footer()
|
||||||
|
@ -151,7 +154,8 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
root_check()
|
root_check()
|
||||||
running_daemon()
|
running_daemon()
|
||||||
gnome_power_detect_snap()
|
gnome_power_detect_snap()
|
||||||
bt_snap()
|
# ToDo: move elsewhere after func revamp
|
||||||
|
#bt_snap()
|
||||||
gov_check()
|
gov_check()
|
||||||
run("snapctl set daemon=enabled", shell=True)
|
run("snapctl set daemon=enabled", shell=True)
|
||||||
run("snapctl start --enable auto-cpufreq", shell=True)
|
run("snapctl start --enable auto-cpufreq", shell=True)
|
||||||
|
@ -159,9 +163,6 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
else:
|
else:
|
||||||
root_check()
|
root_check()
|
||||||
running_daemon()
|
running_daemon()
|
||||||
gnome_power_detect()
|
|
||||||
# ToDo: disable only if not disabled already
|
|
||||||
gnome_power_disable()
|
|
||||||
gov_check()
|
gov_check()
|
||||||
deploy_daemon()
|
deploy_daemon()
|
||||||
deploy_complete_msg()
|
deploy_complete_msg()
|
||||||
|
@ -176,8 +177,8 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
||||||
|
|
||||||
auto_cpufreq_stats_path.unlink()
|
auto_cpufreq_stats_path.unlink()
|
||||||
# ToDo:
|
# ToDo:
|
||||||
# * add message to enable GNOME power profiles again
|
|
||||||
# * undo bluetooth boot disable
|
# * undo bluetooth boot disable
|
||||||
|
gnome_power_rm_reminder_snap()
|
||||||
remove_complete_msg()
|
remove_complete_msg()
|
||||||
else:
|
else:
|
||||||
root_check()
|
root_check()
|
||||||
|
|
|
@ -26,7 +26,6 @@ parts:
|
||||||
stage-packages:
|
stage-packages:
|
||||||
- coreutils
|
- coreutils
|
||||||
- dmidecode
|
- dmidecode
|
||||||
- rfkill
|
|
||||||
source: .
|
source: .
|
||||||
|
|
||||||
deploy-scripts:
|
deploy-scripts:
|
||||||
|
@ -39,7 +38,7 @@ parts:
|
||||||
plugs:
|
plugs:
|
||||||
etc-auto-cpufreq-conf:
|
etc-auto-cpufreq-conf:
|
||||||
interface: system-files
|
interface: system-files
|
||||||
write:
|
read:
|
||||||
- /etc/auto-cpufreq.conf
|
- /etc/auto-cpufreq.conf
|
||||||
|
|
||||||
apps:
|
apps:
|
||||||
|
@ -54,7 +53,6 @@ apps:
|
||||||
- cpu-control
|
- cpu-control
|
||||||
- system-observe
|
- system-observe
|
||||||
- hardware-observe
|
- hardware-observe
|
||||||
- network-control
|
|
||||||
- etc-auto-cpufreq-conf
|
- etc-auto-cpufreq-conf
|
||||||
|
|
||||||
service:
|
service:
|
||||||
|
@ -63,7 +61,6 @@ apps:
|
||||||
- cpu-control
|
- cpu-control
|
||||||
- system-observe
|
- system-observe
|
||||||
- hardware-observe
|
- hardware-observe
|
||||||
- network-control
|
|
||||||
- etc-auto-cpufreq-conf
|
- etc-auto-cpufreq-conf
|
||||||
environment:
|
environment:
|
||||||
LC_ALL: C.UTF-8
|
LC_ALL: C.UTF-8
|
||||||
|
|
Loading…
Reference in New Issue