22 lines
737 B
Python
Executable File
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()
|