Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

Morse


#!/bin/bash
# Filename: morse.sh
# Version.: 01102017
# Author..: robz
# Training aid to print out and recite morse code in a terminal.
# Get stuff "sudo apt install espeak"

tabs="\n"
code=(A .- B -... C -.-. D -.. E . F ..-. G --. H .... I .. J .--- K -.- \
L .-.. M -- N -. O --- P .--. Q --.- R .-. S ... T - U ..- V ...- W .-- X -..- \
Y -.-- Z --.. 1 .---- 2 ..--- 3 ...-- 4 ....- 5 ..... 6 -.... 7 --... 8 ---.. \
9 ----. 0 ----- stop .-.-.- comma --..-- query ..--..)

trap 'kill -9 $pid 2>/dev/null; exit' TERM EXIT

for character in {0..78..2}; do
    echo -ne "$tabs ${code[character]}\t"
    espeak -a 400 "${code[character]}"
    tput bold
    while read -n1 dotdash; do
        [ "$dotdash" = "." ] && duration="0.2" || duration="0.4"
        echo -n "$dotdash"
        (speaker-test -t sine -f 400 >/dev/null) & pid="$!";\
        sleep "$duration"; kill -9 "$pid"
    done < <(echo -n "${code[((character+1))]}")
    tput sgr0
    [ "$tabs" = "\n" ] && tabs="\t|\t" || tabs="\n"
    sleep 1
done 2> /dev/null
echo -e "\n\nEnd of morse code demo.\n"

exit

No comments: