41 lines
952 B
Lua
41 lines
952 B
Lua
local taskwarrior = {}
|
|
|
|
local DEFAULT_SIGNAL = "taskwarrior::stats"
|
|
|
|
--[[
|
|
Get id of next task:
|
|
`task next | sed -n '4p' | awk '{print $1}`
|
|
|
|
Get due date and description by id:
|
|
`task _get $ID.due $ID.description`
|
|
]]--
|
|
|
|
local task_script = [[echo $(task +PENDING count) $(task +OVERDUE count)]]
|
|
|
|
--- callback: function(pending, overdue)
|
|
function taskwarrior.get(callback)
|
|
awful.spawn.easy_async_with_shell(task_script, function(out)
|
|
local pending, overdue = out:match("(%d+)%s+(%d+)")
|
|
pending = tonumber(pending)
|
|
overdue = tonumber(overdue)
|
|
callback(pending, overdue)
|
|
end)
|
|
end
|
|
|
|
function taskwarrior.emit(name)
|
|
taskwarrior.get(function(...)
|
|
awesome.emit_signal(name or DEFAULT_SIGNAL, ...)
|
|
end)
|
|
end
|
|
|
|
function taskwarrior.register_signal(signal_name, update_interval)
|
|
gears.timer {
|
|
timeout = update_interval or 10,
|
|
call_now = true,
|
|
autostart = true,
|
|
callback = function() taskwarrior.emit(signal_name) end
|
|
}
|
|
end
|
|
|
|
return taskwarrior
|