Browse Source

made esc button also shut down

master
mortie 6 years ago
parent
commit
3d0f97a8d5
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      scripts/esc-button.py

+ 9
- 0
scripts/esc-button.py View File



pressed = False pressed = False


shutdown = 3 * 10
iterations = 0

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


elif not current and pressed: elif not current and pressed:
call(["xdotool", "keyup", "Escape"]) call(["xdotool", "keyup", "Escape"])
pressed = False pressed = False
iterations = 0

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


time.sleep(0.1) time.sleep(0.1)

Loading…
Cancel
Save