From e2dcd795abd64780589da8d46736e35207adafe9 Mon Sep 17 00:00:00 2001 From: rhpidfyre Date: Fri, 6 Jun 2025 15:32:04 -0400 Subject: [PATCH] `--cpu-temp-disabled` flag --- src/cli.py | 11 +++++++---- src/main.py | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cli.py b/src/cli.py index 02d08d5..48a4508 100644 --- a/src/cli.py +++ b/src/cli.py @@ -6,14 +6,17 @@ from typing import Optional _ntfy_configure_prompt = """\033[4mPlease configure an ntfy url before starting.\033[0m Examples: \033[32mpython3 main.py 10.0.13.37:42069 -python3 main.py ntfy.domain.com\033[0m""" +python3 main.py ntfy.domain.com\033[0m + +Use \033[32m-h\033[0m or \033[32m--help\033[0m for a full list of options.""" class Interface: def __init__(self): self.parser = argparse.ArgumentParser() - self.parser.add_argument("--cpu-temp-critical", type=int, default=80, help="cpu tempature crtitical. default = 80") - self.parser.add_argument("--cpu-temp-warning", type=int, default=70, help="cpu tempature warning. default = 70") - self.parser.add_argument("--update-rate", type=int, default=1, help="how often updates happen in seconds. default = 1") + self.parser.add_argument("--cpu-temp-disabled", action="store_true", help="Disable notifications for CPU tempature.") + self.parser.add_argument("--cpu-temp-critical", type=int, default=80, help="CPU tempature for the crtitical alert. default = 80") + self.parser.add_argument("--cpu-temp-warning", type=int, default=70, help="CPU tempature for the warning alert. default = 70") + self.parser.add_argument("--update-rate", type=int, default=1, help="How often updates happen in seconds. default = 1") def parsed_args(self): return self.parser.parse_args() diff --git a/src/main.py b/src/main.py index 24a4edc..2b470f3 100644 --- a/src/main.py +++ b/src/main.py @@ -7,6 +7,7 @@ import cpu from ntfy import Ntfy def start( + cpu_temp_checking: bool, cpu_critical_temp: int, cpu_warning_temp: int, ntfy_server: str, @@ -19,16 +20,18 @@ def start( print("Ntfy monitoring software is now listening.") while True: - ntfy_cpu_temp_monitor.ntfy_check() + if not cpu_temp_checking: + ntfy_cpu_temp_monitor.ntfy_check() time.sleep(interval) if __name__ == "__main__": if package.installed("lm-sensors"): cli_args = cli.Interface() - parsed = cli_args.parsed_args() ntfy_server = cli_args.argv_1() + parsed = cli_args.parsed_args() if ntfy_server: start( + parsed.cpu_temp_checking, parsed.cpu_temp_critical, parsed.cpu_temp_warning, ntfy_server,