@@ -10,6 +10,7 @@ local Phases = constants.Phases
10
10
--- @field work_duration number
11
11
--- @field break_duration number
12
12
--- @field long_break_duration number
13
+ --- @field breaks_before_long number
13
14
--- @field break_count number
14
15
--- @field timer_duration number
15
16
--- @field start_at_launch boolean
@@ -26,6 +27,7 @@ pomodoro.long_break_duration = 15 * MIN_IN_MS
26
27
-- Delay duration in ms
27
28
pomodoro .delay_duration = 1 * MIN_IN_MS
28
29
pomodoro .break_count = 0
30
+ pomodoro .breaks_before_long = 4
29
31
pomodoro .timer_duration = 0
30
32
pomodoro .start_at_launch = true
31
33
pomodoro .timer = uv .new_timer ()
63
65
64
66
--- @return boolean
65
67
function pomodoro .isInLongBreak ()
66
- return pomodoro .break_count % 4 == 0 and pomodoro .phase == Phases .BREAK
68
+ return pomodoro .break_count % (pomodoro .breaks_before_long + 1 ) == 0
69
+ and pomodoro .phase == Phases .BREAK
67
70
end
68
71
69
72
function pomodoro .startBreak ()
97
100
98
101
function pomodoro .delayBreak ()
99
102
if pomodoro .phase == Phases .BREAK then
103
+ info (" Break delayed" )
100
104
pomodoro .phase = Phases .RUNNING
101
105
-- So if a long break is delayed the next break is still a long one
102
106
pomodoro .break_count = pomodoro .break_count - 1
139
143
--- @field break_duration ? number
140
144
--- @field long_break_duration ? number
141
145
--- @field delay_duration ? number
146
+ --- @field breaks_before_long ? number
142
147
--- @field start_at_launch ? boolean
143
148
144
149
--- @param opts PomodoroOpts
@@ -156,6 +161,9 @@ function pomodoro.setup(opts)
156
161
if opts .delay_duration ~= nil then
157
162
pomodoro .delay_duration = opts .delay_duration * MIN_IN_MS
158
163
end
164
+ if opts .breaks_before_long ~= nil then
165
+ pomodoro .breaks_before_long = opts .breaks_before_long
166
+ end
159
167
if opts .start_at_launch ~= nil then
160
168
pomodoro .start_at_launch = opts .start_at_launch
161
169
end
0 commit comments