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 helpers = require("lain.helpers")
10 local markup = require("lain.util").markup
11 local awful = require("awful")
12 local naughty = require("naughty")
14 local string = { format = string.format, gsub = string.gsub }
16 -- Taskwarrior notification
17 -- lain.widget.contrib.task
21 if not task.notification then return end
22 naughty.destroy(task.notification)
23 task.notification = nil
26 function task.show(scr)
28 if task.followtag then
29 task.notification_preset.screen = awful.screen.focused()
31 task.notification_preset.screen = scr
34 helpers.async({ awful.util.shell, "-c", task.show_cmd }, function(f)
35 local widget_focused = true
37 if mouse.current_widgets then
38 widget_focused = false
39 for _,v in ipairs(mouse.current_widgets) do
40 if task.widget == v then
47 if widget_focused then
49 task.notification = naughty.notify({
50 preset = task.notification_preset,
52 text = markup.font(task.notification_preset.font,
53 awful.util.escape(f:gsub("\n*$", "")))
59 function task.prompt()
61 prompt = task.prompt_text,
62 textbox = awful.screen.focused().mypromptbox.widget,
63 exe_callback = function(t)
64 helpers.async(t, function(f)
66 preset = task.notification_preset,
68 text = markup.font(task.notification_preset.font,
69 awful.util.escape(f:gsub("\n*$", "")))
73 history_path = awful.util.getdir("cache") .. "/history_task"
77 function task.attach(widget, args)
78 local args = args or {}
79 task.show_cmd = args.show_cmd or "task next"
80 task.prompt_text = args.prompt_text or "Enter task command: "
81 task.followtag = args.followtag or false
82 task.notification_preset = args.notification_preset
85 if not task.notification_preset then
86 task.notification_preset = {
87 font = "Monospace 10",
88 icon = helpers.icons_dir .. "/taskwarrior.png"
93 widget:connect_signal("mouse::enter", function () task.show() end)
94 widget:connect_signal("mouse::leave", function () task.hide() end)