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 833B

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