Show info config file is used only when relevant

This commit is contained in:
Adnan Hodzic 2021-10-16 19:45:38 +02:00
parent 9ff2fa439e
commit d9cbb288f0
1 changed files with 11 additions and 3 deletions

View File

@ -26,6 +26,12 @@ from auto_cpufreq.core import *
@click.option("--version", is_flag=True, help="Show currently installed version") @click.option("--version", is_flag=True, help="Show currently installed version")
@click.option("--donate", is_flag=True, help="Support the project") @click.option("--donate", is_flag=True, help="Support the project")
def main(config, daemon, debug, install, live, log, monitor, stats, version, donate): def main(config, daemon, debug, install, live, log, monitor, stats, version, donate):
# display info if config file is used
def config_info_dialog():
if bool(get_config(config)):
print("\nUsing settings defined in " + config + " file")
if len(sys.argv) == 1: if len(sys.argv) == 1:
print("\n" + "-" * 32 + " auto-cpufreq " + "-" * 33 + "\n") print("\n" + "-" * 32 + " auto-cpufreq " + "-" * 33 + "\n")
print("Automatic CPU speed & power optimizer for Linux") print("Automatic CPU speed & power optimizer for Linux")
@ -35,10 +41,8 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
run(["auto-cpufreq", "--help"]) run(["auto-cpufreq", "--help"])
footer() footer()
else: else:
if bool(get_config(config)):
print("\nUsing settings defined in " + config + " file")
# Important: order does matter
if daemon: if daemon:
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":
while True: while True:
@ -63,6 +67,7 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
else: else:
daemon_not_found() daemon_not_found()
elif monitor: elif monitor:
config_info_dialog()
while True: while True:
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)
@ -76,6 +81,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:
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)
while True: while True:
@ -89,12 +95,14 @@ def main(config, daemon, debug, install, live, log, monitor, stats, version, don
set_autofreq() set_autofreq()
countdown(5) countdown(5)
elif stats: elif stats:
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\"")
time.sleep(1) time.sleep(1)
read_stats() read_stats()
elif log: elif log:
deprecated_log_msg() deprecated_log_msg()
elif debug: elif debug:
config_info_dialog()
root_check() root_check()
footer() footer()
distro_info() distro_info()