#!/bin/sh x1=128 y1=128 x2=256 y2=256 w=16 h=16 actkbd -Ps | \ while read frame key held; do echo "$x1 $y1" #key1=$(echo "$key" | awk '{split($0, a, "+"); print a[1];}') #key2=$(echo "$key" | awk '{split($0, a, "+"); print a[2];}') [ "$key" = "KEY_W" ] && x1=$(expr $x1 - 1) [ "$key" = "KEY_S" ] && x1=$(expr $x1 + 1) [ "$key" = "KEY_A" ] && y1=$(expr $y1 - 1) [ "$key" = "KEY_D" ] && y1=$(expr $y1 + 1) xy=$(printf "1\n$w,$h\n$x1,$y1\n$w,$h\n$x2,$y2" | ./clld | tail -n1 | tr -d ','); x1=$(echo "$xy" | awk '{print $1}'); y1=$(echo "$xy" | awk '{print $2}'); done