-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextclock.sh
executable file
·144 lines (129 loc) · 2.02 KB
/
textclock.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
#
hr=($(date '+%_H'))
min=10#$(date '+%M')
calcdot=$((min % 5))
HOUR_NAMES_DE=(
"eins"
"zwei"
"drei"
"vier"
"fünf"
"sechs"
"sieben"
"acht"
"neun"
"zehn"
"elf"
"zwölf"
"ein"
)
HOUR_NAMES_NO=(
"ett"
"to"
"tre"
"fire"
"fem"
"seks"
"sju"
"åtte"
"ni"
"ti"
"elleve"
"tolv"
"ett"
)
MESSAGE_DE=(
"%s Uhr"
"fünf nach %s"
"zehn nach %s"
"viertel %s"
"zehn vor halb %s"
"fünf vor halb %s"
"halb %s"
"fünf nach halb %s"
"zehn nach halb %s"
"dreiviertel %s"
"zehn vor %s"
"fünf vor %s"
)
MESSAGE_NO=(
"Klokka er %s"
"fem over %s"
"ti over %s"
"kvart over %s"
"ti på halv %s"
"fem på halv %s"
"halv %s"
"fem over halv %s"
"ti over halv %s"
"kvart på %s"
"ti på %s"
"fem på %s"
)
PREF="es ist "
HOUR_NAMES=("${HOUR_NAMES_DE[@]}")
MESSAGE=("${MESSAGE_DE[@]}")
DOTS=0
MODE_CALC=3
ADD_HR_INDEX=2
while [ "$1" != "" ]; do
case $1 in
-c)
DOTS=1
;;
-q)
MODE_CALC=5
;;
-f)
MODE_CALC=3
;;
-n)
HOUR_NAMES=("${HOUR_NAMES_NO[@]}")
MESSAGE=("${MESSAGE_NO[@]}")
DE_TIME=0
ADD_HR_INDEX=3
;;
esac
shift
done
if [[ $DOTS == 1 ]]; then
case "$calcdot" in
"1")
dots=" ."
;;
"2")
dots=" :"
;;
"3")
dots=" :."
;;
"4")
dots=" ::"
;;
*)
;;
esac
fi
index=0
if [[ $min -ge $MODE_CALC ]]; then
index=$(( (min - $MODE_CALC) / 5 + 1))
if [[ $index -gt 11 ]]; then
index=0
hr=$((hr + 1))
fi
fi
if [[ $index -gt $ADD_HR_INDEX ]]; then
hr=$((hr + 1))
fi
timestr=${MESSAGE[index]}
index=0
if [[ $hr -lt 1 ]]; then
index=11
elif [[ ($hr -eq 1 || $hr -eq 13) && $min -lt 5 ]]; then
index=12
else
index=$(((hr - 1) % 12))
fi
hrname=${HOUR_NAMES[index]}
printf "$timestr$dots\n" "$hrname"