Skip to content

Commit

Permalink
feat: can restart a pomodoro (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmstuart authored Mar 4, 2024
1 parent 2279303 commit 3aa239d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ set -g @plugin 'olimorris/tmux-pomodoro-plus'
- `<tmux-prefix> p` to toggle between starting/pausing a Pomodoro/break
- `<tmux-prefix> P` to cancel a Pomodoro/break
- `<tmux-prefix> _` to skip a Pomodoro/break
- `<tmux-prefix> e` to restart a Pomodoro
- `<tmux-prefix> C-p` to open the Pomodoro timer menu
- `<tmux-prefix> M-p` to set a custom Pomodoro timer

Expand Down
7 changes: 7 additions & 0 deletions pomodoro.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ POMODORO_USER_LONG_BREAK_MINS_FILE="$CURRENT_DIR/scripts/user_long_break_mins.tx

default_toggle_pomodoro="p"
toggle_pomodoro="@pomodoro_toggle"
default_restart_pomodoro="e"
restart_pomodoro="@pomodoro_restart"
default_skip_pomodoro="_"
skip_pomodoro="@pomodoro_skip"
default_cancel_pomodoro="P"
Expand Down Expand Up @@ -60,6 +62,11 @@ set_keybindings() {
tmux bind-key -N "Skip a Pomodoro/break" "$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh skip"
done

restart_binding=$(get_tmux_option "$restart_pomodoro" "$default_restart_pomodoro")
for key in $restart_binding; do
tmux bind-key -N "Restart a Pomodoro" "$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh restart"
done

cancel_binding=$(get_tmux_option "$cancel_pomodoro" "$default_cancel_pomodoro")
for key in $cancel_binding; do
tmux bind-key -N "Cancel a Pomodoro/break" "$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh cancel"
Expand Down
15 changes: 13 additions & 2 deletions scripts/pomodoro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,27 @@ increment_interval() {
}

pomodoro_start() {
local verb=${1:-start}

clean_env
mkdir -p $POMODORO_DIR
write_to_file "$(get_seconds)" "$START_FILE"

set_status "in_progress"
increment_interval

if [ "$verb" = start ]; then
increment_interval
fi

refresh_statusline
send_notification "🍅 Pomodoro started!" "Your Pomodoro is underway"
send_notification "🍅 Pomodoro ${verb}ed!" "Your Pomodoro is underway"
return 0
}

pomodoro_restart() {
pomodoro_start restart
}

break_start() {
write_to_file "$(get_seconds)" "$START_FILE"

Expand Down Expand Up @@ -491,6 +500,8 @@ main() {
pomodoro_toggle
elif [ "$cmd" = "start" ]; then
pomodoro_start
elif [ "$cmd" = "restart" ]; then
pomodoro_restart
elif [ "$cmd" = "skip" ]; then
pomodoro_skip
elif [ "$cmd" = "cancel" ]; then
Expand Down

0 comments on commit 3aa239d

Please sign in to comment.