diff options
-rwxr-xr-x | gromo | 23 | ||||
-rwxr-xr-x | mdk | 6 |
2 files changed, 14 insertions, 15 deletions
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # gromo - To count your daily gromodoros :thumbsup # @@ -13,34 +13,33 @@ DATA_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/gromo TODAY_FILE=$DATA_DIR/$(date -I) DING_FILE=${XDG_CACHE_HOME:-$HOME/.cache}/gromo/ding.opus -mkdir -p $DATA_DIR +mkdir -p "$DATA_DIR" -[ -f $DING_FILE ] || curl $DEFAULT_DING --create-dirs -so $DING_FILE +[ -f "$DING_FILE" ] || curl $DEFAULT_DING --create-dirs -so "$DING_FILE" gromos=0 -[ -f $TODAY_FILE ] && read gromos < $TODAY_FILE +[ -f "$TODAY_FILE" ] && read -r gromos < "$TODAY_FILE" echo "Gromos today: $gromos" while true; do - echo -ne "Press any key to start gromo > " - read -n1 ok + read -rn1 -p "Press any key to start gromo > " echo -ne "\r \r" sleep $GROMO_SECONDS - gromos=$(($gromos+1)) - seconds=$(($gromos * $GROMO_SECONDS)) - echo $gromos > $TODAY_FILE + gromos=$((gromos+1)) + seconds=$((gromos * GROMO_SECONDS)) + echo "$gromos" > "$TODAY_FILE" - (sleep $STOP_SECONDS && mpv --no-terminal $DING_FILE) & + (sleep $STOP_SECONDS && mpv --no-terminal "$DING_FILE") & slock echo $seconds if [ $seconds -lt 60 ]; then gromo_time="$seconds seconds" elif [ $seconds -lt 3600 ]; then - gromo_time="$(($seconds / 60)) minutes" + gromo_time="$((seconds / 60)) minutes" else - gromo_time="$(($seconds / 3600)) hours" + gromo_time="$((seconds / 3600)) hours" fi echo -ne "Completed $gromos gromos today ($gromo_time). " done @@ -15,7 +15,7 @@ fi move() { file="$1" - read -e -p "Where? " movedir + read -rep "Where? " movedir mkdir -p "$movedir" mv "$file" "$movedir/" || exit 1 @@ -44,10 +44,10 @@ for file in "$@"; do $cmd "$file" echo -e "\n==============================" prompt="[M]ove / [D]elete / [K]eep / [A]gain (${file}) > " - read -n1 -p "$prompt" key + read -rn1 -p "$prompt" key while [[ ! "$key" =~ m|d|k|a ]]; do echo -e "\nWhat?" - read -n1 -p "$prompt" key + read -rn1 -p "$prompt" key done echo case "$key" in |