Skip to content

Commit

Permalink
info-hackspeed: add format changing on the reaching of a arbitrary goal
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibostin authored Sep 28, 2024
1 parent dd3dfa2 commit 40fc3ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions polybar-scripts/info-hackspeed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ A small script that shows your typing speed. Happy Hacking!

* `KEYBOARD_ID`: name of your keyboard. See Setup above. Default: `AT Translated Set 2 keyboard`
* `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`
* `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
* `TARGET_FORMAT`: format string according to which the metric will be output when on target. Default `#%d $METRIC`
* `FORMAT`: format string according to which the metric will be output. Default: `# %d $METRIC`
* `INTERVAL`: amount of seconds to gather data. Default: 20
* `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`
Expand Down
11 changes: 8 additions & 3 deletions polybar-scripts/info-hackspeed/info-hackspeed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ KEYBOARD_ID="AT Translated Set 2 keyboard"
# wpm: words per minute (1 word = 5 characters)
METRIC=cpm
FORMAT="# %d $METRIC"

TARGET_FORMAT="# %d $METRIC"
TARGET=80
INTERVAL=20

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

printf "$FORMAT\\n" "$value"

# if we are on target, print the alternate format
if [ $value -gt $TARGET ]; then
printf "$TARGET_FORMAT\\n" "$value"
else
printf "$FORMAT\\n" "$value"
fi
sleep $INTERVAL
done

0 comments on commit 40fc3ab

Please sign in to comment.