All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 Licensed under GNU General Public License v2
9 local icons_dir = require("lain.helpers").icons_dir
11 local awful = require("awful")
12 local beautiful = require("beautiful")
13 local naughty = require("naughty")
17 local string = { len = string.len }
18 local tonumber = tonumber
20 local setmetatable = setmetatable
22 -- Taskwarrior notification
23 -- lain.widgets.contrib.task
26 local task_notification = nil
28 function findLast(haystack, needle)
29 local i=haystack:match(".*"..needle.."()")
30 if i==nil then return nil else return i-1 end
34 if task_notification ~= nil then
35 naughty.destroy(task_notification)
36 task_notification = nil
40 function task:show(scr_pos)
45 if task.followmouse then
46 local scrp = mouse.screen
48 local scrp = scr_pos or task.scr_pos
51 f = io.popen('task ' .. task.cmdline)
52 c_text = "<span font='"
54 .. task.font_size .. "'>"
55 .. f:read("*all"):gsub("\n*$", "")
59 task_notification = naughty.notify({ title = "[task next]",
61 icon = task.notify_icon,
62 position = task.position,
65 timeout = task.timeout,
70 function task:prompt_add()
71 awful.prompt.run({ prompt = "Add task: " },
72 mypromptbox[mouse.screen].widget,
74 local f = io.popen("task add " .. ...)
75 c_text = "\n<span font='"
77 .. task.font_size .. "'>"
84 icon = task.notify_icon,
85 position = task.position,
88 timeout = task.timeout,
92 awful.util.getdir("cache") .. "/history_task_add")
95 function task:prompt_search()
96 awful.prompt.run({ prompt = "Search task: " },
97 mypromptbox[mouse.screen].widget,
99 local f = io.popen("task " .. ...)
100 c_text = f:read("*all"):gsub(" \n*$", "")
103 if string.len(c_text) == 0
105 c_text = "No results found."
107 c_text = "<span font='"
109 .. task.font_size .. "'>"
115 title = "[task next " .. ... .. "]",
117 icon = task.notify_icon,
118 position = task.position,
121 timeout = task.timeout,
122 screen = mouse.screen
126 awful.util.getdir("cache") .. "/history_task")
129 function task:attach(widget, args)
130 local args = args or {}
132 task.font_size = tonumber(args.font_size) or 12
133 task.font = args.font or beautiful.font:sub(beautiful.font:find(""),
134 findLast(beautiful.font, " "))
135 task.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
136 task.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
137 task.position = args.position or "top_right"
138 task.timeout = args.timeout or 7
139 task.scr_pos = args.scr_pos or 1
140 task.followmouse = args.followmouse or false
141 task.cmdline = args.cmdline or "next"
143 task.notify_icon = icons_dir .. "/taskwarrior/task.png"
144 task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png"
146 widget:connect_signal("mouse::enter", function () task:show(task.scr_pos) end)
147 widget:connect_signal("mouse::leave", function () task:hide() end)
150 return setmetatable(task, { __call = function(_, ...) return create(...) end })