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.sh 749B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. keyboard="AT Translated Set 2 keyboard"
  3. battery="/sys/class/power_supply/BAT0"
  4. device=2
  5. faces="faces"
  6. if [ -n "$battery" ]; then
  7. st="$(cat "$battery/status")"
  8. if [ "$st" != "Discharging" ] && [ "$st" != "Unknown" ]; then
  9. ./facematcher.py match --delay 500 --device "$device" $faces/$USER/*
  10. exit $?
  11. fi
  12. fi
  13. rm -f .testfifo
  14. mkfifo .testfifo
  15. xinput test "AT Translated Set 2 keyboard" \
  16. | grep --line-buffered "key press 36" > .testfifo &
  17. xpid=$!
  18. rm -f .matchfifo
  19. mkfifo .matchfifo
  20. matcher() {
  21. cat .matchfifo | ./facematcher.py match --delay 500 --device 2 --wait $faces/$USER/*
  22. }
  23. matcher &
  24. matchpid=$!
  25. trap "kill $matchpid" SIGINT SIGTERM
  26. read <.testfifo
  27. echo > .matchfifo
  28. kill $xpid
  29. wait
  30. rm -f .testfifo
  31. rm -f .matchfifo