-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmorseled
executable file
·62 lines (55 loc) · 1.43 KB
/
morseled
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
LEDS="caps scroll num" # Any of: caps scroll num
TTY=/dev/tty7
Tdot=0.2
Tdash=0.6 # 3 * Tdot
Tword=1.4 # 7 * Tdot
die () { echo "$0: $@" >&2; exit 1; }
start () { setleds -L $(echo $LEDS | sed 's/^\| /\0+/g') <$TTY; }
stop () { setleds -L $(echo $LEDS | sed 's/^\| /\0-/g') <$TTY; }
dot () { start; sleep $Tdot; stop; sleep $Tdot; }
dash () { start; sleep $Tdash; stop; sleep $Tdot; }
letter () {
case "$1" in
a|A) dot;dash;;
b|B) dash;dot;dot;dot;;
c|C) dash;dot;dash;dot;;
d|D) dash;dot;dot;;
e|E) dot;;
f|F) dot;dot;dash;dot;;
g|G) dash;dash;dot;;
h|H) dot;dot;dot;dot;;
i|I) dot;dot;;
j|J) dot;dash;dash;dash;;
k|K) dash;dot;dash;;
l|L) dot;dash;dot;dot;;
m|M) dash;dash;;
n|N) dash;dot;;
o|O) dash;dash;dash;;
p|P) dot;dash;dash;dot;;
q|Q) dash;dash;dot;dash;;
r|R) dot;dash;dot;;
s|S) dot;dot;dot;;
t|T) dash;;
u|U) dot;dot;dash;;
v|V) dot;dot;dot;dash;;
w|W) dot;dash;dash;;
x|X) dash;dot;dot;dash;;
y|Y) dash;dot;dash;dash;;
z|Z) dash;dash;dot;dot;;
*) ;; # Ignore everything else...
esac
}
word () {
for l in $(echo "$1" | sed 's/./\0 /g'); do
letter $l
sleep $Tdash
done
}
[ $# -ge 1 ] || die "Not enough arguments"
word "$1"
shift
for w in "$@"; do
sleep $Tword
word "$@"
done