Skip to content

Commit

Permalink
allow modifying pomodoro status
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGruber committed Nov 23, 2024
1 parent 36cb077 commit 0c11df8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Use the Pomodoro Technique in Neovim with built-in session tracking and break re
opts = function(_, opts)
table.insert(opts.sections.lualine_x, 3, {
function()
return require("pomodoro").get_pomodoro_status()
return require("pomodoro").get_pomodoro_status("🍅❌","🍅","")
end,
})
end,
Expand Down
28 changes: 24 additions & 4 deletions lua/pomodoro/pomodoro.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,38 @@ function pomodoro.startTimer(time, fn)
pomodoro.timer:start(time, 0, fn)
end

function pomodoro.get_pomodoro_status()
---@param not_running_phase? string
---@param running_phase? string
---@param break_phase? string
---@return string
function pomodoro.get_pomodoro_status(
not_running_phase,
running_phase,
break_phase
)
local time_left = pomodoro.timer_duration
- (uv.now() - pomodoro.started_timer_time)

local phase_str = ""
if pomodoro.phase == Phases.NOT_RUNNING then
phase_str = "🍅❌"
if not_running_phase then
phase_str = not_running_phase
else
phase_str = "🍅❌"
end
time_left = 0
elseif pomodoro.phase == Phases.RUNNING then
phase_str = "🍅"
if running_phase then
phase_str = running_phase
else
phase_str = "🍅"
end
elseif pomodoro.phase == Phases.BREAK then
phase_str = ""
if break_phase then
phase_str = break_phase
else
phase_str = ""
end
end

local minutes = math.floor(time_left / 60000)
Expand Down

0 comments on commit 0c11df8

Please sign in to comment.