aboutsummaryrefslogtreecommitdiff
path: root/.scripts/pomo
diff options
context:
space:
mode:
authorMarvin Borner2023-05-17 17:45:18 +0200
committerMarvin Borner2023-05-17 17:53:44 +0200
commitb96beb25dcb0511f38c13b07c44cc929d5fd53ad (patch)
treed4c3a9cfed6f9776ad27e79b1cff1c6838a7f9c4 /.scripts/pomo
parenta8a6c3a400174cf476ec8e75bb2e5a5b0afb34da (diff)
Sync
Diffstat (limited to '.scripts/pomo')
-rwxr-xr-x.scripts/pomo122
1 files changed, 0 insertions, 122 deletions
diff --git a/.scripts/pomo b/.scripts/pomo
deleted file mode 100755
index b10b49b..0000000
--- a/.scripts/pomo
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/bin/bash
-
-### Send desktop notifications
-## Params: header {String} - Notification highlighted text
-## Params: body {String} - Notification complementary text
-## Returns: {Void}
-function notify() {
- header=$1
- body=$2
- notify-send -u critical -t 0 -a pomo "${header:?}" "${body:?}"
-}
-
-### Show a countdown timer and a message and updates without
-### cleaning the whole screen
-## Params: seconds {Number} - Countdown time in seconds
-## Params: message {String} - Timer description
-## Returns: {String} - "hh:mm:ss - $message"
-function countdown(){
- secs=$1
- shift
- message=$*
- while [ $secs -gt -1 ]
- do
- sleep 1 &
- printf "\r%s - %02d:%02d:%02d" "$message" $((secs/3600)) $(((secs/60)%60)) $((secs%60))
- secs=$(( $secs - 1 ))
- wait
- done
- echo
-}
-
-### Transforms minutes into seconds
-## Params: minutes {Number} - Ammount of minutes to be transformed to seconds
-## Returns: {Number} - Seconds
-function minutes_to_seconds() {
- minutes=$1
- echo $(($minutes * 60))
-}
-
-### Add minutes to current time
-## Params: minutes {Number} - Ammounts of minutes to be added
-## Returns: {Date} - Current date plus minutes
-function current_time_plus_minutes() {
- minutes=$1
- date -d "$minutes minutes" +'%H:%M'
-}
-
-### Display a summary of the settings defined by the user
-## Params: focus_minutes {Number} - Ammount of minutes to last a focus period
-## Params: break_minutes {Number} - Ammount of minutes to last a break period
-## Params: long_break_minutes {Number} - Ammount of minutes to last a long break period
-## Params: breaks_until_long {Number} - Ammount of breaks until a long break period starts
-## Returns: {String} - Formatted summary of the settings
-function display_summary() {
- focus_minutes=$1
- break_minutes=$2
- long_break_minutes=$3
- breaks_until_long=$4
-
- echo "╔════════════════╦════════╗"
- echo "║ FOCUS ║ $(printf "%03d\n" $focus_minutes) ║"
- echo "║ BREAK ║ $(printf "%03d\n" $break_minutes) ║"
- echo "║ LONG BREAK ║ $(printf "%03d\n" $long_break_minutes) ║"
- echo "║ BREAKS TL LONG ║ $(printf "%03d\n" $breaks_until_long) ║"
- echo "╚════════════════╩════════╝"
-}
-
-### Display a help message
-## Returns: {String} - Formatted help message with all available settings and options
-function display_help() {
- echo "Usage: `basename $0` [options] [focus] [break] [long_break] [breaks_until_long]"
- echo " options -h: display help message"
- echo " focus Minutes of focus until break | Default = 25"
- echo " break Minutes of break until focus | Default = 5"
- echo " long_break Minutes of long break until focus | Default = 15"
- echo " breaks_until_long Number of breaks until long break | Default = 4"
-}
-
-### Controls the application flow, parse arguments, show the countdown and notifications
-## Params: focus_minutes {Number} - Ammount of minutes to last a focus period
-## Params: break_minutes {Number} - Ammount of minutes to last a break period
-## Params: long_break_minutes {Number} - Ammount of minutes to last a long break period
-## Params: breaks_until_long {Number} - Ammount of breaks until a long break period starts
-## Returns: {Void}
-function main() {
- focus_minutes=${1-25} # default = 25
- break_minutes=${2-5} # default = 5
- long_break_minutes=${3-15} # default = 15
- breaks_until_long=${4-4} # default = 4
-
- focus_seconds=$(minutes_to_seconds $focus_minutes)
- break_seconds=$(minutes_to_seconds $break_minutes)
- long_break_seconds=$(minutes_to_seconds $long_break_minutes)
-
-
- display_summary $focus_minutes $break_minutes $long_break_minutes $breaks_until_long
-
-
- while true; do
- for (( i=1; i<=$breaks_until_long; i++ )); do
- countdown "$focus_seconds" "FOCUS TIME"
- notify "BREAK: $break_minutes MINUTES" "Focus time at $(current_time_plus_minutes $break_minutes)"
-
- if [ $(($i)) -ne $breaks_until_long ]; then
- countdown $break_seconds "BREAK TIME"
- notify "FOCUS: $focus_minutes MINUTES" "Break time at $(current_time_plus_minutes $focus_minutes)"
- else
- notify "LONG BREAK: $long_break_minutes MINUTES" "Focus time at $(current_time_plus_minutes $long_break_minutes)"
- fi
- done
- countdown $long_break_seconds "LONG BREAK TIME"
- notify "FOCUS: $focus_minutes MINUTES" "Break time at $(current_time_plus_minutes $focus_minutes)"
- done
-}
-
-## Help message
-if [ "$1" == "-h" ]; then
- display_help
- exit 0
-fi
-
-main $1 $2 $3 $4