Pārlūkot izejas kodu

made esc button also shut down

master
mortie pirms 6 gadiem
vecāks
revīzija
3d0f97a8d5
1 mainītis faili ar 9 papildinājumiem un 0 dzēšanām
  1. 9
    0
      scripts/esc-button.py

+ 9
- 0
scripts/esc-button.py Parādīt failu

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

pressed = False

shutdown = 3 * 10
iterations = 0

while True:
current = not GPIO.input(3)

@@ -18,5 +21,11 @@ while True:
elif not current and pressed:
call(["xdotool", "keyup", "Escape"])
pressed = False
iterations = 0

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

time.sleep(0.1)

Notiek ielāde…
Atcelt
Saglabāt