From 0effebe3bbf0c4fa80fb2b6a1348556abaa56dc9 Mon Sep 17 00:00:00 2001 From: purple wazard Date: Fri, 26 Apr 2024 10:28:59 -0500 Subject: [PATCH] formatted the battery output and added stats to --debug and --status --- auto_cpufreq/battery_scripts/ideapad_acpi.py | 11 ++++++----- auto_cpufreq/battery_scripts/ideapad_laptop.py | 11 ++++++----- auto_cpufreq/battery_scripts/thinkpad.py | 11 ++++++----- auto_cpufreq/bin/auto_cpufreq.py | 2 ++ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/auto_cpufreq/battery_scripts/ideapad_acpi.py b/auto_cpufreq/battery_scripts/ideapad_acpi.py index 7ac3afa..58d7c1e 100644 --- a/auto_cpufreq/battery_scripts/ideapad_acpi.py +++ b/auto_cpufreq/battery_scripts/ideapad_acpi.py @@ -48,16 +48,17 @@ def ideapad_acpi_setup(): def ideapad_acpi_print_thresholds(): battery_count = len([name for name in os.listdir( "/sys/class/power_supply/") if name.startswith('BAT')]) - print(f"number of batteries = {battery_count}") + print("\n-------------------------------- Battery Info ---------------------------------\n") + print(f"battery count = {battery_count}\n") for b in range(battery_count): try: with open(f'/sys/class/power_supply/BAT{b}/charge_start_threshold', 'r') as f: - print(f'battery{b} start threshold is set to {f.read()}') + print(f'battery{b} start threshold = {f.read()}') f.close() with open(f'/sys/class/power_supply/BAT{b}/charge_stop_threshold', 'r') as f: - print(f'battery{b} stop threshold is set to {f.read()}') + print(f'battery{b} stop threshold = {f.read()}') f.close() - except Exception as e: - print(f"Error reading battery thresholds: {e}") + except Exception: + print(f"ERROR: failed to read battery {b} thresholds") diff --git a/auto_cpufreq/battery_scripts/ideapad_laptop.py b/auto_cpufreq/battery_scripts/ideapad_laptop.py index 8f2a709..e3b961c 100644 --- a/auto_cpufreq/battery_scripts/ideapad_laptop.py +++ b/auto_cpufreq/battery_scripts/ideapad_laptop.py @@ -85,16 +85,17 @@ def ideapad_laptop_print_thresholds(): battery_count = len([name for name in os.listdir( "/sys/class/power_supply/") if name.startswith('BAT')]) - print(f"number of batteries = {battery_count}") + print("\n-------------------------------- Battery Info ---------------------------------\n") + print(f"battery count = {battery_count}\n") for b in range(battery_count): try: with open(f'/sys/class/power_supply/BAT{b}/charge_start_threshold', 'r') as f: - print(f'battery{b} start threshold is set to {f.read()}') + print(f'battery{b} start threshold = {f.read()}') f.close() with open(f'/sys/class/power_supply/BAT{b}/charge_stop_threshold', 'r') as f: - print(f'battery{b} stop threshold is set to {f.read()}') + print(f'battery{b} stop threshold = {f.read()}') f.close() - except Exception as e: - print(f"Error reading battery thresholds: {e}") + except Exception: + print(f"ERROR: failed to read battery thresholds: {e}") diff --git a/auto_cpufreq/battery_scripts/thinkpad.py b/auto_cpufreq/battery_scripts/thinkpad.py index 3a39c7b..42779b8 100644 --- a/auto_cpufreq/battery_scripts/thinkpad.py +++ b/auto_cpufreq/battery_scripts/thinkpad.py @@ -48,16 +48,17 @@ def thinkpad_setup(): def thinkpad_print_thresholds(): battery_count = len([name for name in os.listdir( "/sys/class/power_supply/") if name.startswith('BAT')]) - print(f"number of batteries = {battery_count}") + print("\n-------------------------------- Battery Info ---------------------------------\n") + print(f"battery count = {battery_count}\n") for b in range(battery_count): try: with open(f'/sys/class/power_supply/BAT{b}/charge_start_threshold', 'r') as f: - print(f'battery{b} start threshold is set to {f.read()}') + print(f'battery{b} start threshold = {f.read()}') f.close() with open(f'/sys/class/power_supply/BAT{b}/charge_stop_threshold', 'r') as f: - print(f'battery{b} stop threshold is set to {f.read()}') + print(f'battery{b} stop threshold = {f.read()}') f.close() - except Exception as e: - print(f"Error reading battery thresholds: {e}") + except Exception: + print(f"ERROR: failed to read battery {b} thresholds") diff --git a/auto_cpufreq/bin/auto_cpufreq.py b/auto_cpufreq/bin/auto_cpufreq.py index 39fb094..1c41067 100755 --- a/auto_cpufreq/bin/auto_cpufreq.py +++ b/auto_cpufreq/bin/auto_cpufreq.py @@ -144,6 +144,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta sys.exit() elif stats: not_running_daemon_check() + battery_get_thresholds() config_info_dialog() print('\nNote: You can quit stats mode by pressing "ctrl+c"') if os.getenv("PKG_MARKER") == "SNAP": @@ -162,6 +163,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta elif debug: # ToDo: add status of GNOME Power Profile service status config_info_dialog() + battery_get_thresholds() root_check() cpufreqctl() footer()