Init commit
This commit is contained in:
21
bin/battery
Executable file
21
bin/battery
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/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()
|
||||
Reference in New Issue
Block a user