formatted the battery output and added stats to --debug and --status

This commit is contained in:
purple wazard 2024-04-26 10:28:59 -05:00
parent 02d81f06c4
commit 0effebe3bb
4 changed files with 20 additions and 15 deletions

View File

@ -48,16 +48,17 @@ def ideapad_acpi_setup():
def ideapad_acpi_print_thresholds(): def ideapad_acpi_print_thresholds():
battery_count = len([name for name in os.listdir( battery_count = len([name for name in os.listdir(
"/sys/class/power_supply/") if name.startswith('BAT')]) "/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): for b in range(battery_count):
try: try:
with open(f'/sys/class/power_supply/BAT{b}/charge_start_threshold', 'r') as f: 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() f.close()
with open(f'/sys/class/power_supply/BAT{b}/charge_stop_threshold', 'r') as f: 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() f.close()
except Exception as e: except Exception:
print(f"Error reading battery thresholds: {e}") print(f"ERROR: failed to read battery {b} thresholds")

View File

@ -85,16 +85,17 @@ def ideapad_laptop_print_thresholds():
battery_count = len([name for name in os.listdir( battery_count = len([name for name in os.listdir(
"/sys/class/power_supply/") if name.startswith('BAT')]) "/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): for b in range(battery_count):
try: try:
with open(f'/sys/class/power_supply/BAT{b}/charge_start_threshold', 'r') as f: 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() f.close()
with open(f'/sys/class/power_supply/BAT{b}/charge_stop_threshold', 'r') as f: 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() f.close()
except Exception as e: except Exception:
print(f"Error reading battery thresholds: {e}") print(f"ERROR: failed to read battery thresholds: {e}")

View File

@ -48,16 +48,17 @@ def thinkpad_setup():
def thinkpad_print_thresholds(): def thinkpad_print_thresholds():
battery_count = len([name for name in os.listdir( battery_count = len([name for name in os.listdir(
"/sys/class/power_supply/") if name.startswith('BAT')]) "/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): for b in range(battery_count):
try: try:
with open(f'/sys/class/power_supply/BAT{b}/charge_start_threshold', 'r') as f: 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() f.close()
with open(f'/sys/class/power_supply/BAT{b}/charge_stop_threshold', 'r') as f: 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() f.close()
except Exception as e: except Exception:
print(f"Error reading battery thresholds: {e}") print(f"ERROR: failed to read battery {b} thresholds")

View File

@ -144,6 +144,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta
sys.exit() sys.exit()
elif stats: elif stats:
not_running_daemon_check() not_running_daemon_check()
battery_get_thresholds()
config_info_dialog() 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"')
if os.getenv("PKG_MARKER") == "SNAP": if os.getenv("PKG_MARKER") == "SNAP":
@ -162,6 +163,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta
elif debug: elif debug:
# ToDo: add status of GNOME Power Profile service status # ToDo: add status of GNOME Power Profile service status
config_info_dialog() config_info_dialog()
battery_get_thresholds()
root_check() root_check()
cpufreqctl() cpufreqctl()
footer() footer()