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
29 if task_notification ~= nil then
30 naughty.destroy(task_notification)
31 task_notification = nil
35 function task:show(scr_pos)
40 if task.followmouse then
41 local scrp = mouse.screen
43 local scrp = scr_pos or task.scr_pos
46 f = io.popen('task ' .. task.cmdline)
47 c_text = "<span font='"
49 .. task.font_size .. "'>"
50 .. f:read("*all"):gsub("\n*$", "")
54 task_notification = naughty.notify({ title = "[task next]",
56 icon = task.notify_icon,
57 position = task.position,
60 timeout = task.timeout,
65 function task:prompt_add()
66 awful.prompt.run({ prompt = "Add task: " },
67 mypromptbox[mouse.screen].widget,
69 local f = io.popen("task add " .. ...)
70 c_text = "\n<span font='"
72 .. task.font_size .. "'>"
79 icon = task.notify_icon,
80 position = task.position,
83 timeout = task.timeout,
87 awful.util.getdir("cache") .. "/history_task_add")
90 function task:prompt_search()
91 awful.prompt.run({ prompt = "Search task: " },
92 mypromptbox[mouse.screen].widget,
94 local f = io.popen("task " .. ...)
95 c_text = f:read("*all"):gsub(" \n*$", "")
98 if string.len(c_text) == 0
100 c_text = "No results found."
102 c_text = "<span font='"
104 .. task.font_size .. "'>"
110 title = "[task next " .. ... .. "]",
112 icon = task.notify_icon,
113 position = task.position,
116 timeout = task.timeout,
117 screen = mouse.screen
121 awful.util.getdir("cache") .. "/history_task")
124 function task:attach(widget, args)
125 local args = args or {}
127 task.font_size = tonumber(args.font_size) or 12
128 task.font = beautiful.font:sub(beautiful.font:find(""),
129 beautiful.font:find(" "))
130 task.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
131 task.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
132 task.position = args.position or "top_right"
133 task.timeout = args.timeout or 7
134 task.scr_pos = args.scr_pos or 1
135 task.followmouse = args.followmouse or false
136 task.cmdline = args.cmdline or "next"
138 task.notify_icon = icons_dir .. "/taskwarrior/task.png"
139 task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png"
141 widget:connect_signal("mouse::enter", function () task:show(task.scr_pos) end)
142 widget:connect_signal("mouse::leave", function () task:hide() end)
145 return setmetatable(task, { __call = function(_, ...) return create(...) end })