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")
16 local string = { len = string.len }
17 local tonumber = tonumber
19 local setmetatable = setmetatable
21 -- Taskwarrior notification
22 -- lain.widgets.contrib.task
25 local task_notification = nil
27 function findLast(haystack, needle)
28 local i=haystack:match(".*"..needle.."()")
29 if i==nil then return nil else return i-1 end
33 if task_notification ~= nil then
34 naughty.destroy(task_notification)
35 task_notification = nil
39 function task.show(scr_pos)
44 if task.followtag then
45 scrp = awful.screen.focused()
47 scrp = scr_pos or task.scr_pos
50 f = io.popen('task ' .. task.cmdline)
51 c_text = "<span font='"
53 .. task.font_size .. "'>"
54 .. awful.util.escape(f:read("*all"):gsub("\n*$", ""))
58 task_notification = naughty.notify({ title = "[task next]",
60 icon = task.notify_icon,
61 position = task.position,
64 timeout = task.timeout,
69 function task.prompt_add()
70 awful.prompt.run({ prompt = "Add task: " },
71 mypromptbox[awful.screen.focused()].widget,
73 local f = io.popen("task add " .. ...)
74 c_text = "\n<span font='"
76 .. task.font_size .. "'>"
77 .. awful.util.escape(f:read("*all"))
83 icon = task.notify_icon,
84 position = task.position,
87 timeout = task.timeout,
91 awful.util.getdir("cache") .. "/history_task_add")
94 function task.prompt_search()
95 awful.prompt.run({ prompt = "Search task: " },
96 mypromptbox[awful.screen.focused()].widget,
98 local f = io.popen("task " .. ...)
99 c_text = f:read("*all"):gsub(" \n*$", "")
102 if string.len(c_text) == 0
104 c_text = "No results found."
106 c_text = "<span font='"
108 .. task.font_size .. "'>"
109 .. awful.util.escape(c_text)
114 title = "[task next " .. ... .. "]",
116 icon = task.notify_icon,
117 position = task.position,
120 timeout = task.timeout,
121 screen = awful.screen.focused()
125 awful.util.getdir("cache") .. "/history_task")
128 function task.attach(widget, args)
129 local args = args or {}
131 task.font_size = tonumber(args.font_size) or 12
132 task.font = args.font or beautiful.font:sub(beautiful.font:find(""),
133 findLast(beautiful.font, " "))
134 task.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
135 task.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
136 task.position = args.position or "top_right"
137 task.timeout = args.timeout or 7
138 task.scr_pos = args.scr_pos or 1
139 task.followtag = args.followtag or false
140 task.cmdline = args.cmdline or "next"
142 task.notify_icon = icons_dir .. "/taskwarrior/task.png"
143 task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png"
145 widget:connect_signal("mouse::enter", function () task.show(task.scr_pos) end)
146 widget:connect_signal("mouse::leave", function () task.hide() end)
149 return setmetatable(task, { __call = function(_, ...) return create(...) end })