summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-12-27 20:55:32 +0000
committerdavidovski <david@davidovski.xyz>2023-12-27 20:55:32 +0000
commit16f0bf390cb978a9b340e1437bbfe572ca5cb8b4 (patch)
tree3fab1aea5e628bf9abd537d246ba994ea7c683ac
parent02ebb5ec768d25feb6ddc4a2a9beb750ffa2b214 (diff)
calculate wpm using standard calculation
-rwxr-xr-xtypr.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/typr.sh b/typr.sh
index aaa802b..46ed83a 100755
--- a/typr.sh
+++ b/typr.sh
@@ -1,7 +1,6 @@
#!/bin/sh
words="the be of and a to in he have it that for they i with as not on she at by this we you do but from or which one would all will there say who make when can more if no man out other so what time up go about than into could state only new year some take come these know see use get like then first any work now may such give over think most even find day also after way many must look before great back through long where much should well people down own just because good each those feel seem how high too place little world very still nation hand old life tell write become here show house both between need mean call develop under last right move thing general school never same another begin while number part turn real leave might want point form off child few small since against ask late home interest large person end open public follow during present without again hold govern around possible head consider word program problem however lead system set order eye plan run keep face fact group play stand increase early course change help line"
-alphanum="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|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|0|1|2|3|4|5|6|7|8|9|,|.|?|\"|'|!|-"
entered_text=""
text=""
@@ -98,6 +97,10 @@ typr_draw_time () {
[ ! -z "$start" ] && printf "[$((areay-1));${areax}H%s" "$(typr_get_time)"
}
+typr_calculate_wpm () {
+ printf "%s" "$((${#entered_text}*60000000000/(time_ns*5)))"
+}
+
typr_show_results () {
tput clear
tput civis
@@ -106,7 +109,7 @@ typr_show_results () {
time_ns=$((now-start))
words="$(set -- $text ; printf "%s" "$#")"
- wpm="$((words*60000000000/time_ns))"
+ wpm="$(typr_calculate_wpm)"
acc="$(typr_calculate_acc)"
printf "[%s;${areax}H%s" \