Переглянути джерело

more reliable shutdown

master
mortie 6 роки тому
джерело
коміт
e879761cdc
1 змінених файлів з 4 додано та 5 видалено
  1. 4
    5
      scripts/esc-button.py

+ 4
- 5
scripts/esc-button.py Переглянути файл

@@ -9,8 +9,8 @@ GPIO.setup(3, GPIO.IN)

pressed = False

shutdown = 3 * 10
iterations = 0
shutdown = 2.5
press_start = time.time()

while True:
current = not GPIO.input(3)
@@ -18,14 +18,13 @@ while True:
if current and not pressed:
call(["xdotool", "keydown", "Escape"])
pressed = True
press_start = time.time()
elif not current and pressed:
call(["xdotool", "keyup", "Escape"])
pressed = False
iterations = 0

if current:
iterations += 1
if iterations > shutdown:
if time.time() - shutdown >= press_start:
call(["sudo", "shutdown", "-h", "now"])

time.sleep(0.1)

Завантаження…
Відмінити
Зберегти