Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

info-hackspeed: add format changing on the reaching of a arbitrary goal #450

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading