blob: 3c30be1f768da2e1b28a3f436139dfc45c341711 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/env bash
## you might want to edit these to suit your tastes.
width=10
height=$width
words_per_puzzle=$[width]
x=$[-10 * $width / 2]
y=$[10 * $width / 2]
z=0
clicked=""
wordlist=/usr/share/dict/words
echo derp
wordsearch -w <(shuf $wordlist 2>/dev/null | grep '^.\{1,'"$width"'\}$' 2>/dev/null | head -n $words_per_puzzle | tee /dev/stderr) --columns $width --rows $height --text | tail -n+4 | head -n $height | while read -r line;do
echo "$line" | tr -d ' ' | fold -w 1 | while read letter;do
name="_${x}_${y}"
printf "%s addshape 2 4 %s %s %s %s %s %s %s %s %s %s %s %s\n" \
"$name" \
$[$x-2] $[$y-3] $z \
$[$x+8] $[$y-3] $z \
$[$x+8] $[$y+7] $z \
$[$x-2] $[$y+7] $z
echo $letter | makelabel.sh "$name" $x $y $z
x=$[$x+10]
done
y=$[$y-10]
done
while read group action args;do
if [ $action = action ];then
if grep "$args" <<< "$clicked" 2>&1 >/dev/null;then
clicked=$(grep -v '^'"$args"'$' <<< "$clicked")
printf "%s move 0 0 0\n" "$args"
else
clicked="$clicked"$'\n'"$args"
printf "%s move 0 0 -5\n" "$args"
fi
# xmessage -nearmouse "$args"
fi
done
|