mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-24 22:24:51 +02:00
Revamp of bluetooth & gnome power profile control on Snap
This commit is contained in:
parent
2daa37cf0e
commit
d6bfdfc680
@ -330,6 +330,14 @@ def deploy_daemon():
|
|||||||
|
|
||||||
call("/usr/bin/auto-cpufreq-install", shell=True)
|
call("/usr/bin/auto-cpufreq-install", shell=True)
|
||||||
|
|
||||||
|
def bt_snap():
|
||||||
|
if os.getenv("PKG_MARKER") == "SNAP":
|
||||||
|
try:
|
||||||
|
print("\n* Turn off bluetooth on boot")
|
||||||
|
call("rfkill block bluetooth", shell=True)
|
||||||
|
except:
|
||||||
|
print("n\nERROR:\nWas unable to turn off bluetooth on boot")
|
||||||
|
|
||||||
|
|
||||||
# remove auto-cpufreq daemon
|
# remove auto-cpufreq daemon
|
||||||
def remove():
|
def remove():
|
||||||
|
@ -14,24 +14,26 @@ else:
|
|||||||
app_name="auto-cpufreq"
|
app_name="auto-cpufreq"
|
||||||
|
|
||||||
# detect if gnome power profile service is running
|
# detect if gnome power profile service is running
|
||||||
gnome_power_stats = call(["systemctl", "is-active", "--quiet", "power-profiles-daemon"])
|
if os.getenv('PKG_MARKER') != "SNAP":
|
||||||
|
gnome_power_stats = call(["systemctl", "is-active", "--quiet", "power-profiles-daemon"])
|
||||||
|
|
||||||
# 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():
|
||||||
# ToDo: broken, can't be checked like this
|
if gnome_power_stats == 0:
|
||||||
if os.getenv('PKG_MARKER') == "SNAP" and gnome_power_stats == 0:
|
|
||||||
print("\nDetected running GNOME Power Profiles daemon service:")
|
|
||||||
print("This daemon might interfere with auto-cpufreq and should be disabled!\n")
|
|
||||||
print("Due to Snap limitations, it needs to be disabled manually by running, i.e:")
|
|
||||||
print("cd ~/auto-cpufreq/auto_cpufreq")
|
|
||||||
print("python3 gnome_power.py --disable")
|
|
||||||
elif gnome_power_stats == 0:
|
|
||||||
print("\nDetected running GNOME Power Profiles daemon service:")
|
print("\nDetected running GNOME Power Profiles daemon service:")
|
||||||
print("This daemon might interfere with auto-cpufreq and it will be disabled!")
|
print("This daemon might interfere with auto-cpufreq and it will be disabled!")
|
||||||
print("\nIf you wish to enable this daemon to run concurrently with auto-cpufreq run:")
|
print("\nIf you wish to enable this daemon to run concurrently with auto-cpufreq run:")
|
||||||
print("cd ~/auto-cpufreq/auto_cpufreq")
|
print("cd ~/auto-cpufreq/auto_cpufreq")
|
||||||
print("python3 gnome_power.py --enable")
|
print("python3 gnome_power.py --enable")
|
||||||
|
|
||||||
|
# notification on snap
|
||||||
|
def gnome_power_detect_snap():
|
||||||
|
print("\nUnable to detect state of GNOME Power Profiles daemon service:")
|
||||||
|
print("This daemon might interfere with auto-cpufreq and should be disabled!\n")
|
||||||
|
print("Due to Snap limitations, it needs to be disabled manually by running, i.e:")
|
||||||
|
print("cd ~/auto-cpufreq/auto_cpufreq")
|
||||||
|
print("python3 gnome_power.py --disable")
|
||||||
|
|
||||||
# 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):
|
||||||
@ -62,6 +64,7 @@ def valid_options():
|
|||||||
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="Monitor and see suggestions for CPU optimizations")
|
||||||
@click.option("--disable", is_flag=True, help="Monitor and make (temp.) suggested CPU optimizations")
|
@click.option("--disable", is_flag=True, help="Monitor and make (temp.) suggested CPU optimizations")
|
||||||
@ -74,10 +77,15 @@ def main(enable, disable):
|
|||||||
footer()
|
footer()
|
||||||
else:
|
else:
|
||||||
if enable:
|
if enable:
|
||||||
|
# Todo: prettify output
|
||||||
root_check()
|
root_check()
|
||||||
print("Enabling")
|
print("Enabling")
|
||||||
|
gnome_power_enable()
|
||||||
elif disable:
|
elif disable:
|
||||||
|
# Todo: prettify output
|
||||||
|
root_check()
|
||||||
print("Disabling")
|
print("Disabling")
|
||||||
|
gnome_power_disable()
|
||||||
else:
|
else:
|
||||||
print("whatever")
|
print("whatever")
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||||||
config_info_dialog()
|
config_info_dialog()
|
||||||
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()
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
footer()
|
footer()
|
||||||
@ -56,6 +57,9 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||||||
set_autofreq()
|
set_autofreq()
|
||||||
countdown(5)
|
countdown(5)
|
||||||
elif os.getenv("PKG_MARKER") != "SNAP":
|
elif os.getenv("PKG_MARKER") != "SNAP":
|
||||||
|
gnome_power_detect()
|
||||||
|
# ToDo: disable only if not disabled already
|
||||||
|
gnome_power_disable()
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
footer()
|
footer()
|
||||||
@ -73,6 +77,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||||||
print("\nNote: You can quit monitor mode by pressing \"ctrl+c\"")
|
print("\nNote: You can quit monitor mode by pressing \"ctrl+c\"")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
root_check()
|
root_check()
|
||||||
|
# ToDO: add gnome profile detect/disable?
|
||||||
running_daemon()
|
running_daemon()
|
||||||
footer()
|
footer()
|
||||||
gov_check()
|
gov_check()
|
||||||
@ -85,10 +90,14 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||||||
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)
|
||||||
|
if os.getenv("PKG_MARKER") == "SNAP":
|
||||||
|
gnome_power_detect_snap()
|
||||||
|
else:
|
||||||
|
gnome_power_detect()
|
||||||
|
# ToDo: disable only if not disabled already
|
||||||
|
gnome_power_disable()
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
gnome_power_detect()
|
|
||||||
gnome_power_disable_live()
|
|
||||||
running_daemon()
|
running_daemon()
|
||||||
footer()
|
footer()
|
||||||
gov_check()
|
gov_check()
|
||||||
@ -141,8 +150,8 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||||||
if os.getenv('PKG_MARKER') == "SNAP":
|
if os.getenv('PKG_MARKER') == "SNAP":
|
||||||
root_check()
|
root_check()
|
||||||
running_daemon()
|
running_daemon()
|
||||||
gnome_power_detect()
|
gnome_power_detect_snap()
|
||||||
gnome_power_disable()
|
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)
|
||||||
@ -151,6 +160,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||||||
root_check()
|
root_check()
|
||||||
running_daemon()
|
running_daemon()
|
||||||
gnome_power_detect()
|
gnome_power_detect()
|
||||||
|
# ToDo: disable only if not disabled already
|
||||||
gnome_power_disable()
|
gnome_power_disable()
|
||||||
gov_check()
|
gov_check()
|
||||||
deploy_daemon()
|
deploy_daemon()
|
||||||
@ -165,6 +175,9 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
|
|||||||
auto_cpufreq_stats_file.close()
|
auto_cpufreq_stats_file.close()
|
||||||
|
|
||||||
auto_cpufreq_stats_path.unlink()
|
auto_cpufreq_stats_path.unlink()
|
||||||
|
# ToDo:
|
||||||
|
# * add message to enable GNOME power profiles again
|
||||||
|
# * undo bluetooth boot disable
|
||||||
remove_complete_msg()
|
remove_complete_msg()
|
||||||
else:
|
else:
|
||||||
root_check()
|
root_check()
|
||||||
|
@ -26,6 +26,7 @@ parts:
|
|||||||
stage-packages:
|
stage-packages:
|
||||||
- coreutils
|
- coreutils
|
||||||
- dmidecode
|
- dmidecode
|
||||||
|
- rfkill
|
||||||
source: .
|
source: .
|
||||||
|
|
||||||
deploy-scripts:
|
deploy-scripts:
|
||||||
@ -40,27 +41,21 @@ plugs:
|
|||||||
interface: system-files
|
interface: system-files
|
||||||
write:
|
write:
|
||||||
- /etc/auto-cpufreq.conf
|
- /etc/auto-cpufreq.conf
|
||||||
etc-bluetooth-conf:
|
|
||||||
interface: system-files
|
|
||||||
write:
|
|
||||||
- /etc/bluetooth/main.conf
|
|
||||||
|
|
||||||
|
|
||||||
apps:
|
apps:
|
||||||
auto-cpufreq:
|
auto-cpufreq:
|
||||||
command: bin/auto-cpufreq
|
command: bin/auto-cpufreq
|
||||||
environment:
|
environment:
|
||||||
PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
|
PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
|
||||||
|
LC_ALL: C.UTF-8
|
||||||
|
LANG: C.UTF-8
|
||||||
|
PKG_MARKER: SNAP
|
||||||
plugs:
|
plugs:
|
||||||
- cpu-control
|
- cpu-control
|
||||||
- system-observe
|
- system-observe
|
||||||
- hardware-observe
|
- hardware-observe
|
||||||
|
- network-control
|
||||||
- etc-auto-cpufreq-conf
|
- etc-auto-cpufreq-conf
|
||||||
- etc-bluetooth-conf
|
|
||||||
environment:
|
|
||||||
LC_ALL: C.UTF-8
|
|
||||||
LANG: C.UTF-8
|
|
||||||
PKG_MARKER: SNAP
|
|
||||||
|
|
||||||
service:
|
service:
|
||||||
command: usr/bin/snapdaemon
|
command: usr/bin/snapdaemon
|
||||||
@ -68,6 +63,8 @@ apps:
|
|||||||
- cpu-control
|
- cpu-control
|
||||||
- system-observe
|
- system-observe
|
||||||
- hardware-observe
|
- hardware-observe
|
||||||
|
- network-control
|
||||||
|
- etc-auto-cpufreq-conf
|
||||||
environment:
|
environment:
|
||||||
LC_ALL: C.UTF-8
|
LC_ALL: C.UTF-8
|
||||||
LANG: C.UTF-8
|
LANG: C.UTF-8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user