From 8a7a1835f6145089777591c86fdcd59c6b511752 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Thu, 29 Jul 2021 13:18:43 +0200 Subject: New tool: gromo (for pomodoros) --- gromo | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 gromo diff --git a/gromo b/gromo new file mode 100755 index 0000000..25372ac --- /dev/null +++ b/gromo @@ -0,0 +1,46 @@ +#!/bin/sh +# +# gromo - To count your daily gromodoros :thumbsup +# +# Dependencies: curl and mpv for the 'ding' sound; slock to force you to rest :) +################################################################################ + +DEFAULT_DING=https://gramos.me/ding.opus +GROMO_SECONDS=$((60 * 20)) +STOP_SECONDS=20 + +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 + +[ -f $DING_FILE ] || curl $DEFAULT_DING --create-dirs -so $DING_FILE + +gromos=0 +[ -f $TODAY_FILE ] && read gromos < $TODAY_FILE +echo "Gromos today: $gromos" + +while true; do + echo -ne "Press any key to start gromo > " + read -n1 ok + echo -ne "\r \r" + + sleep $GROMO_SECONDS + gromos=$(($gromos+1)) + seconds=$(($gromos * $GROMO_SECONDS)) + echo $gromos > $TODAY_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" + else + gromo_time="$(($seconds / 3600)) hours" + fi + echo -ne "Completed $gromos gromos today ($gromo_time). " +done -- cgit v1.2.3