diff --git a/exec-cycle.sh b/exec-cycle.sh index a71fccd..94b68b5 100755 --- a/exec-cycle.sh +++ b/exec-cycle.sh @@ -1,14 +1,23 @@ #/bin/bash +trap 'stty sane; clear; exit 0' SIGINT SIGTERM + while true; do clear - echo "Press any key to capture image" - guvcview &> /dev/null & - read -n 1 - killall guvcview - ./webcam2ascii.sh - read -n 1 + echo + echo "[c] capture [Ctrl+C] quit" + + if read -n 1 -t 0.05 -s key && [[ "$key" == "c" || "$key" == "C" ]]; then + timestamp=$(date +%Y%m%d-%H%M%S) + cp web-cam-shot.jpg "photo-$timestamp.jpg" + cp ascii-img.txt "ascii-img-$timestamp.txt" + clear + cat "ascii-img-$timestamp.txt" + echo + echo "Saved photo-$timestamp.jpg and ascii-img-$timestamp.txt" + ./txt2printr.sh "ascii-img-$timestamp.txt" + read -n 1 -s -p "Press any key to resume live preview, Ctrl+C to quit..." + fi done - diff --git a/txt2printr.sh b/txt2printr.sh new file mode 100755 index 0000000..d16956c --- /dev/null +++ b/txt2printr.sh @@ -0,0 +1 @@ +#/bin/bash diff --git a/webcam2ascii.sh b/webcam2ascii.sh index f8e6581..9d11300 100755 --- a/webcam2ascii.sh +++ b/webcam2ascii.sh @@ -1,5 +1,5 @@ #/bin/bash -fswebcam -r 640x480 --jpeg 85 -D 1 web-cam-shot.jpg &> /dev/null +fswebcam -q --no-banner -r 640x480 --jpeg 85 web-cam-shot.jpg &> /dev/null ascii-image-converter web-cam-shot.jpg | tee ascii-img.txt