Add flag to turn off bluetooth on boot

This commit is contained in:
Adnan Hodzic 2025-04-13 08:22:19 +02:00
parent 6789cb6ce4
commit a7df573ec8
2 changed files with 31 additions and 23 deletions

View File

@ -14,6 +14,7 @@ from auto_cpufreq.config.config import config as conf, find_config_file
from auto_cpufreq.core import *
from auto_cpufreq.globals import GITHUB, IS_INSTALLED_WITH_AUR, IS_INSTALLED_WITH_SNAP
from auto_cpufreq.modules.system_monitor import ViewType, SystemMonitor
# import everything from power_helper, including bluetooth_disable
from auto_cpufreq.power_helper import *
from threading import Thread
@ -29,10 +30,13 @@ from threading import Thread
@click.option("--stats", is_flag=True, help="View live stats of CPU optimizations made by daemon")
@click.option("--get-state", is_flag=True, hidden=True)
@click.option("--completions", is_flag=False, help="Enables shell completions for bash, zsh and fish.\n Possible values bash|zsh|fish")
@click.option("--bluetooth_boot_off", is_flag=True, help="Turn off Bluetooth on boot")
@click.option("--debug", is_flag=True, help="Show debug info (include when submitting bugs)")
@click.option("--version", is_flag=True, help="Show currently installed version")
@click.option("--donate", is_flag=True, help="Support the project")
def main(monitor, live, daemon, install, update, remove, force, config, stats, get_state, completions, debug, version, donate):
def main(monitor, live, daemon, install, update, remove, force, config, stats, get_state, completions,
bluetooth_boot_off,
debug, version, donate):
# display info if config file is used
config_path = find_config_file(config)
conf.set_path(config_path)
@ -43,13 +47,11 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g
if len(sys.argv) == 1:
print("\n" + "-" * 32 + " auto-cpufreq " + "-" * 33 + "\n")
print("Automatic CPU speed & power optimizer for Linux")
print("\nExample usage:\nauto-cpufreq --monitor")
print("\n-----\n")
run(["auto-cpufreq", "--help"])
footer()
else:
# set governor override unless None or invalid
if force is not None:
not_running_daemon_check()
@ -151,6 +153,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g
running_daemon_check()
gnome_power_detect_snap()
tlp_service_detect_snap()
# ToDo: add note to say you can use bluetooth flag to enable bluetooth on boot
bluetooth_notif_snap()
gov_check()
run("snapctl set daemon=enabled", shell=True)
@ -158,6 +161,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g
else:
running_daemon_check()
gov_check()
# ToDo: add note to say you can use bluetooth flag to enable bluetooth on boot
deploy_daemon()
deploy_complete_msg()
elif update:
@ -206,7 +210,6 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g
auto_cpufreq_stats_file.close()
auto_cpufreq_stats_path.unlink()
# ToDo:
# {the following snippet also used in --update, update it there too(if required)}
# * undo bluetooth boot disable
gnome_power_rm_reminder_snap()
@ -248,6 +251,10 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g
print("Run the below command in your current shell!\n")
print("echo '_AUTO_CPUFREQ_COMPLETE=fish_source auto-cpufreq | source' > ~/.config/fish/completions/auto-cpufreq.fish")
else: print("Invalid Option, try bash|zsh|fish as argument to --completions")
elif bluetooth_boot_off:
root_check()
bluetooth_disable()
footer()
elif debug:
# ToDo: add status of GNOME Power Profile service status
config_info_dialog()

View File

@ -6,9 +6,10 @@ from shutil import which
from subprocess import call, DEVNULL, getoutput, STDOUT
from sys import argv
from auto_cpufreq.core import *
from auto_cpufreq.globals import GITHUB, IS_INSTALLED_WITH_SNAP
from auto_cpufreq.tlp_stat_parser import TLPStatusParser
# ToDo: update README part how to run this script
from .core import *
from .globals import GITHUB, IS_INSTALLED_WITH_SNAP
from .tlp_stat_parser import TLPStatusParser
# app_name var
app_name = "python3 power_helper.py" if argv[0] == "power_helper.py" else "auto-cpufreq"