dotfiles/scripts/kb_battery.py

14 lines
323 B
Python
Raw Normal View History

2023-12-03 19:55:40 +01:00
#!/bin/env python3
import subprocess
all_statuses = subprocess.run(["upower", "-d"], capture_output=True).stdout.decode("utf-8").split("\n\n")
for s in all_statuses:
if "leko pona 1" in s:
for line in s.split("\n"):
if "percentage:" in line:
print(line.split(":")[1].strip())
exit(0)
2024-01-24 21:05:21 +01:00
print("conputer bad")