Files
dotfiles/bin/battery
Archie Fox 06b8ee8caf Init commit
2025-06-08 06:59:19 +03:00

22 lines
737 B
Python
Executable File

#!/usr/bin/env python
import subprocess
def main():
with open("/sys/class/power_supply/BAT0/capacity", "r") as f:
capacity = f.read()
# capacity = 10
if int(capacity) <= 20:
text = "Внимание, низкий уровень заряда батареи! Подключите зарядное устройство"
subprocess.run(["notify-send", "-u", "critical", text])
subprocess.run(["rhvoice_say", text])
elif int(capacity) >= 80 and int(capacity) < 100:
text = "Батарея достаточно заряжена, можно отключать!"
subprocess.run(["notify-send", "-t", "15000", text])
subprocess.run(["rhvoice_say", text])
main()