#!/bin/bash keyboard="AT Translated Set 2 keyboard" battery="/sys/class/power_supply/BAT0" device=2 faces="faces" if [ -n "$battery" ]; then st="$(cat "$battery/status")" if [ "$st" != "Discharging" ] && [ "$st" != "Unknown" ]; then ./facematcher.py match --delay 500 --device "$device" $faces/$USER/* exit $? fi fi rm -f .testfifo mkfifo .testfifo xinput test "AT Translated Set 2 keyboard" \ | grep --line-buffered "key press 36" > .testfifo & xpid=$! rm -f .matchfifo mkfifo .matchfifo matcher() { cat .matchfifo | ./facematcher.py match --delay 500 --device 2 --wait $faces/$USER/* } matcher & matchpid=$! trap "kill $matchpid" SIGINT SIGTERM read <.testfifo echo > .matchfifo kill $xpid wait rm -f .testfifo rm -f .matchfifo