OK, it turns out the previous script was totally wrong. Pickels coordinates are weird. The arguments tp pickel are from the top-left corner on the screen. The output is (Y,X) with coordinates from the top-right corner of the screen. Also, if you pass 0 0 0 0 as one of the rectangles it will take that rectangle as the whole screen, which is why I use 0 0 1 1 for the rectangle I don't care about.
Code:
#!/bin/sh
[ $# -gt 0 ] || {
echo 'Usage: tap-actiond.sh COMMAND'
echo ' Wait for a sequence of taps on the touch screen and exec COMMAND when they occur.'
exit 0
}
FB_MODE="$(fbset | grep '^mode' | cut -d \" -f 2)"
FB_MODE="${FB_MODE%-*}"
FB_W="${FB_MODE%x*}"
FB_H="${FB_MODE#*x}"
w=$(( $FB_W / 4))
h=$(( $FB_H / 5))
waithit() {
coords="$(( $1 * $w )) $(( $2 * $h )) $w $h"
/usr/local/Kobo/pickel wait-for-hit $coords 0 0 1 1 &>/dev/null
}
listen=true
while $listen; do
waithit 3 4
[ $? -eq 1 ] || continue
start=$(date +'%s')
waithit 2 4
[ $? -eq 1 ] || continue
[ $(( $(date +'%s') - $start )) -lt 3 ] || continue
waithit 1 4
[ $? -eq 1 ] || continue
[ $(( $(date +'%s') - $start )) -lt 3 ] || continue
waithit 0 4
[ $? -eq 1 ] || continue
[ $(( $(date +'%s') - $start )) -lt 3 ] || continue
listen=false
done
exec $@