36 lines
1.2 KiB
Lua
36 lines
1.2 KiB
Lua
|
|
-- Called by the scheduler when a pomodoro phase ends.
|
||
|
|
-- Flip the phase, speak the cue, schedule the next phase. Run forever
|
||
|
|
-- until pomodoro.stop deletes the scheduled task.
|
||
|
|
|
||
|
|
local pom_work = "pomodoro_work"
|
||
|
|
local pom_break = "pomodoro_break"
|
||
|
|
local script_path = jarvis.context.command_path .. "/tick.lua"
|
||
|
|
script_path = script_path:gsub("/", "\\")
|
||
|
|
|
||
|
|
local phase = jarvis.state.get("pomodoro_phase") or "work"
|
||
|
|
|
||
|
|
if phase == "work" then
|
||
|
|
-- work session just ended → announce break
|
||
|
|
jarvis.speak("Время перерыва. 5 минут отдыха.")
|
||
|
|
jarvis.state.set("pomodoro_phase", "break")
|
||
|
|
jarvis.scheduler.add({
|
||
|
|
id = pom_break,
|
||
|
|
name = "Pomodoro break end",
|
||
|
|
schedule = "in 5 minutes",
|
||
|
|
action = { type = "lua", script_path = script_path },
|
||
|
|
})
|
||
|
|
else
|
||
|
|
-- break ended → back to work
|
||
|
|
jarvis.speak("Перерыв окончен. Возвращаемся к работе. 25 минут.")
|
||
|
|
jarvis.state.set("pomodoro_phase", "work")
|
||
|
|
jarvis.scheduler.add({
|
||
|
|
id = pom_work,
|
||
|
|
name = "Pomodoro work end",
|
||
|
|
schedule = "in 25 minutes",
|
||
|
|
action = { type = "lua", script_path = script_path },
|
||
|
|
})
|
||
|
|
end
|
||
|
|
|
||
|
|
jarvis.audio.play_reply()
|
||
|
|
return { chain = false }
|