add proper states and a sane API for players
[multypo.git] / play.sh
diff --git a/play.sh b/play.sh
index 6c3b185f3961edf18b957e1664cbaa6e37df0a54..128a25d93bf509feb9e786467b3c21daee9e17e1 100755 (executable)
--- a/play.sh
+++ b/play.sh
@@ -1,8 +1,19 @@
-#!/bin/sh
+#!/bin/bash
 
 # you should probably download a txt dictionary of your favourite language and use that as a words.txt
 
 
 # you should probably download a txt dictionary of your favourite language and use that as a words.txt
 
+cd "$(readlink -e $(dirname "$0"))"
+
 WORDSTOPLAY=10
 WORDSTOPLAY=10
+WORDSFILE="$1"
+if [[ -z "$WORDSFILE" ]]; then
+       WORDSFILE="words.txt"
+fi
 
 
-sort -R dict.txt | egrep '^[A-Za-z]{5,}$' | head -n $WORDSTOPLAY | tr [:upper:] [:lower:]  | qt/multypo
+export LC_ALL=C # dont do unicode stuff in egrep
+while true; do
+  sort -R "$WORDSFILE" | sed 's/\/.*//' | egrep '^[A-Za-z]{5,}$' | head -n "$WORDSTOPLAY" | tr [:upper:] [:lower:]  | qt/multypo
+  echo "Press Ctrl-C to quit"
+  sleep 3
+done