From 52bf4a588833f281cb02045acc50b9ca887bfc34 Mon Sep 17 00:00:00 2001 From: bibo Date: Sat, 28 Sep 2024 12:44:34 +0200 Subject: [PATCH] info-hackspeed: add format changing on the reaching of a arbitrary goal Adds a TARGET parameter that changes the output of the script to a different format, set using TARGET_FORMAT when the wpm or cpm (depending on the value of METRIC) value exceeds that of the set TARGET. The idea being that you can set a wpm or cpm goal and see if you are achieving it. --- polybar-scripts/info-hackspeed/README.md | 2 ++ polybar-scripts/info-hackspeed/info-hackspeed.sh | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/polybar-scripts/info-hackspeed/README.md b/polybar-scripts/info-hackspeed/README.md index a548a8fa..ebfc78c7 100644 --- a/polybar-scripts/info-hackspeed/README.md +++ b/polybar-scripts/info-hackspeed/README.md @@ -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` diff --git a/polybar-scripts/info-hackspeed/info-hackspeed.sh b/polybar-scripts/info-hackspeed/info-hackspeed.sh index 999c31e6..ddb35cdb 100644 --- a/polybar-scripts/info-hackspeed/info-hackspeed.sh +++ b/polybar-scripts/info-hackspeed/info-hackspeed.sh @@ -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 @@ -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