Skip to content

Commit

Permalink
feat: breaks can be disabled (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmstuart authored Mar 4, 2024
1 parent 3aa239d commit 0280f14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ set -g @pomodoro_break_mins 5 # The duration of the break after
set -g @pomodoro_intervals 4 # The number of intervals before a longer break is started
set -g @pomodoro_long_break_mins 25 # The duration of the long break
set -g @pomodoro_repeat 'off' # Automatically repeat the Pomodoros?
set -g @pomodoro_disable_breaks 'off' # Turn off breaks

set -g @pomodoro_on " 🍅" # The formatted output when the Pomodoro is running
set -g @pomodoro_complete " ✔︎" # The formatted output when the break is running
Expand Down
22 changes: 21 additions & 1 deletion scripts/pomodoro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pomodoro_interval_display="@pomodoro_interval_display"
pomodoro_sound="@pomodoro_sound"
pomodoro_notifications="@pomodoro_notifications"
pomodoro_granularity="@pomodoro_granularity"
pomodoro_disable_breaks="@pomodoro_disable_breaks"

# ______________________________________________________________| methods |__ ;

Expand Down Expand Up @@ -69,6 +70,10 @@ get_pomodoro_repeat() {
get_tmux_option "$pomodoro_repeat" "off"
}

get_pomodoro_disable_breaks() {
get_tmux_option "$pomodoro_disable_breaks" "off"
}

get_seconds() {
date +%s
}
Expand Down Expand Up @@ -387,6 +392,7 @@ pomodoro_status() {
start_time=$(read_file "$START_FILE")
elapsed_time=$((current_time - start_time - time_paused_for))
pomodoro_duration="$(minutes_to_seconds "$(get_pomodoro_duration)")"
disable_breaks=$(get_pomodoro_disable_breaks)

# ___________________________________________________| statusline |__ ;

Expand Down Expand Up @@ -438,7 +444,7 @@ pomodoro_status() {
# ________________________________________________________| break |__ ;

# Pomodoro completed, starting the break
if [ "$pomodoro_completed" = true ] && [ "$pomodoro_status" == "in_progress" ]; then
if [ "$pomodoro_completed" = true ] && [ "$pomodoro_status" == "in_progress" ] && [ "$disable_breaks" != "on" ]; then
pomodoro_status="break"
remove_time_paused_file

Expand All @@ -458,6 +464,20 @@ pomodoro_status() {
return 0
fi

# Breaks are disabled
if [ "$pomodoro_completed" = true ] && [ "$pomodoro_status" == "in_progress" ] && [ "$disable_breaks" == "on" ]; then
remove_time_paused_file

if prompt_user; then
set_status "waiting_for_pomodoro"
send_notification "🍅 Pomodo completed!" "Start a new Pomodoro?"
return 0
fi

pomodoro_start
return 0
fi

# Has the break completed or been skipped?
{ [ "$elapsed_time" -ge "$(break_length)" ] || skipped_break; } && break_complete=true || break_complete=false

Expand Down

0 comments on commit 0280f14

Please sign in to comment.