Kind of a kludge because commands don't run inside the case statements until the window is closed. Best run in a terminal, since the program calls itself, you have to kill it to stop.
Cheers,
s
Code: Select all
#!/bin/sh
# requires technosaurus' svgame
# svg-placer -click on location & close window
# run in terminal to kill
if ! [ -f /tmp/svgame.svg ]; then
echo '
<svg width="640" height="480">
<defs>
<pattern id="grid" width="48" height="48" patternUnits="userSpaceOnUse">
<rect fill="white" stroke="black" x="0" y="0" width="48" height="48"/>
</pattern>
</defs>
<rect fill="url(#grid)" stroke="black" x="0" y="0" width="640" height="480"/>
</svg>' >/tmp/svgame.svg
fi
svgame /tmp/svgame.svg 2>/dev/null | \
while read LINE; do
case "$LINE" in
BUTTON*)
LINE="${LINE//BUTTON=/}"
x="${LINE%,*}"
y="${LINE##*,}" ;;
*) exit
;;
esac
Xdialog --title "Image or Text dialog" --stdout --yesno "Is this an image file?" 0 0
case $? in
0)
FILE="`Xdialog --backtitle "Please choose Image." --title "Image selector" --stdout --no-buttons --fselect /usr/share/pixmaps 0 0`"
sed -i 's|</svg>||' /tmp/svgame.svg
echo '
<image x="'$x'" y="'$y'" width="48" height="48"
xlink:href="'$FILE'" />
</svg>' >>/tmp/svgame.svg ;;
1)
TEXT="`Xdialog --backtitle "Please type text below" --title "Text Select" --stdout --no-wrap --inputbox "short text no wrap" 0 0`"
sed -i 's|</svg>||' /tmp/svgame.svg
echo '
<text x="'$x'" y="'$y'"
style="font-size:20" fill="black"
>'"$TEXT"'</text>
</svg>' >>/tmp/svgame.svg ;;
255)
exit ;;
esac
done
$0