You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

facewaiter.py 812B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. import subprocess
  3. keyboard = "AT Translated Set 2 keyboard"
  4. battery = "/sys/class/power_supply/BAT0"
  5. device = "2"
  6. faces = "faces"
  7. key = "36"
  8. bat = False
  9. if battery is not None:
  10. with open(f"{battery}/status", "r") as f:
  11. s = f.read().strip()
  12. if s == "Discharging" or s == "Unknown":
  13. bat = True
  14. print("starting facematcher")
  15. proc = subprocess.Popen(
  16. f"./facematcher.py match --wait --delay 500 --device {device} {faces}/$USER/*",
  17. stdin=subprocess.PIPE, shell=True)
  18. if bat:
  19. print(f"On battery, so waiting for {key}")
  20. subprocess.check_output(
  21. f"xinput test '{keyboard}' | grep --line-buffered 'key press {key}' | exit",
  22. shell=True)
  23. print(f"Got {key}.")
  24. proc.stdin.write(b"hello\n")
  25. proc.stdin.flush()
  26. exit(proc.wait())