Skip to content

Commit 40fc3ab

Browse files
authored
info-hackspeed: add format changing on the reaching of a arbitrary goal
1 parent dd3dfa2 commit 40fc3ab

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Diff for: polybar-scripts/info-hackspeed/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ A small script that shows your typing speed. Happy Hacking!
1616

1717
* `KEYBOARD_ID`: name of your keyboard. See Setup above. Default: `AT Translated Set 2 keyboard`
1818
* `METRIC`: either `cpm` (characters per minute) of `wpm` ([words per minute, 1 word = 5 characters](https://en.wikipedia.org/wiki/Words_per_minute)). Default: `cpm`
19+
* `TARGET`: value at which to change from FORMAT to TARGET_FORMAT, useful if you have a specific wpm or cpm goal you want to know that you have hit while typing. Default: 80
20+
* `TARGET_FORMAT`: format string according to which the metric will be output when on target. Default `#%d $METRIC`
1921
* `FORMAT`: format string according to which the metric will be output. Default: `# %d $METRIC`
2022
* `INTERVAL`: amount of seconds to gather data. Default: 20
2123
* `LAYOUT`: keyboard layout, to be able to only count letters and numbers. Currently supported are `qwerty`, `azerty`, `qwertz` and `dvorak`. If you have a different layout, please contribute a condition for it! See the script's source code. Use the special value `dontcare` to count all keys, not just letters and numbers. Default: `qwerty`

Diff for: polybar-scripts/info-hackspeed/info-hackspeed.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ KEYBOARD_ID="AT Translated Set 2 keyboard"
77
# wpm: words per minute (1 word = 5 characters)
88
METRIC=cpm
99
FORMAT="# %d $METRIC"
10-
10+
TARGET_FORMAT="# %d $METRIC"
11+
TARGET=80
1112
INTERVAL=20
1213

1314
# If you have a keyboard layout that is not listed here yet, create a condition
@@ -58,7 +59,11 @@ while true; do
5859
# then divide
5960
value=$((lines * multiply_by / divide_by))
6061

61-
printf "$FORMAT\\n" "$value"
62-
62+
# if we are on target, print the alternate format
63+
if [ $value -gt $TARGET ]; then
64+
printf "$TARGET_FORMAT\\n" "$value"
65+
else
66+
printf "$FORMAT\\n" "$value"
67+
fi
6368
sleep $INTERVAL
6469
done

0 commit comments

Comments
 (0)