]> git.madduck.net Git - etc/awesome.git/blob - widgets/contrib/task.lua.orig

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge branch 'master' of https://github.com/copycat-killer/lain
[etc/awesome.git] / widgets / contrib / task.lua.orig
1
2 --[[
3                                                   
4      Licensed under GNU General Public License v2 
5       * (c) 2013, Jan Xie                         
6                                                   
7 --]]
8
9 local icons_dir    = require("lain.helpers").icons_dir
10
11 local awful        = require("awful")
12 local beautiful    = require("beautiful")
13 local naughty      = require("naughty")
14
15 <<<<<<< HEAD
16 =======
17 local mouse        = mouse
18 >>>>>>> upstream/master
19 local io           = io
20 local string       = { len = string.len }
21 local tonumber     = tonumber
22
23 local setmetatable = setmetatable
24
25 -- Taskwarrior notification
26 -- lain.widgets.contrib.task
27 local task = {}
28
29 local task_notification = nil
30
31 function task:hide()
32     if task_notification ~= nil then
33         naughty.destroy(task_notification)
34         task_notification = nil
35     end
36 end
37
38 <<<<<<< HEAD
39 function task:show()
40 =======
41 function task:show(scr_pos)
42 >>>>>>> upstream/master
43     task:hide()
44
45     local f, c_text
46
47 <<<<<<< HEAD
48 =======
49     if task.followmouse then
50         local scrp = mouse.screen
51     else
52         local scrp = scr_pos or task.scr_pos
53     end
54
55 >>>>>>> upstream/master
56     f = io.popen('task')
57     c_text = "<span font='"
58              .. task.font .. " "
59              .. task.font_size .. "'>"
60              .. f:read("*all"):gsub("\n*$", "")
61              .. "</span>"
62     f:close()
63
64     task_notification = naughty.notify({ title = "[task next]",
65                                          text = c_text,
66                                          icon = task.notify_icon,
67                                          position = task.position,
68                                          fg = task.fg,
69                                          bg = task.bg,
70                                          timeout = task.timeout,
71 <<<<<<< HEAD
72 =======
73                                          screen = scrp
74 >>>>>>> upstream/master
75                                      })
76 end
77
78 function task:prompt_add()
79   awful.prompt.run({ prompt = "Add task: " },
80       mypromptbox[mouse.screen].widget,
81       function (...)
82           local f = io.popen("task add " .. ...)
83           c_text = "\n<span font='"
84                    .. task.font .. " "
85                    .. task.font_size .. "'>"
86                    .. f:read("*all")
87                    .. "</span>"
88           f:close()
89
90           naughty.notify({
91               text     = c_text,
92               icon     = task.notify_icon,
93               position = task.position,
94               fg       = task.fg,
95               bg       = task.bg,
96               timeout  = task.timeout,
97           })
98       end,
99       nil,
100       awful.util.getdir("cache") .. "/history_task_add")
101 end
102
103 function task:prompt_search()
104   awful.prompt.run({ prompt = "Search task: " },
105       mypromptbox[mouse.screen].widget,
106       function (...)
107           local f = io.popen("task " .. ...)
108           c_text = f:read("*all"):gsub(" \n*$", "")
109           f:close()
110
111           if string.len(c_text) == 0
112           then
113               c_text = "No results found."
114           else
115               c_text = "<span font='"
116                        .. task.font .. " "
117                        .. task.font_size .. "'>"
118                        .. c_text
119                        .. "</span>"
120           end
121
122           naughty.notify({
123               title    = "[task next " .. ... .. "]",
124               text     = c_text,
125               icon     = task.notify_icon,
126               position = task.position,
127               fg       = task.fg,
128               bg       = task.bg,
129               timeout  = task.timeout,
130 <<<<<<< HEAD
131 =======
132               screen   = mouse.screen
133 >>>>>>> upstream/master
134           })
135       end,
136       nil,
137       awful.util.getdir("cache") .. "/history_task")
138 end
139
140 function task:attach(widget, args)
141 <<<<<<< HEAD
142     local args     = args or {}
143
144     task.font_size = tonumber(args.font_size) or 12
145     task.font      = beautiful.font:sub(beautiful.font:find(""),
146                      beautiful.font:find(" "))
147     task.fg        = args.fg or beautiful.fg_normal or "#FFFFFF"
148     task.bg        = args.bg or beautiful.bg_normal or "#FFFFFF"
149     task.position  = args.position or "top_right"
150     task.timeout   = args.timeout or 7
151 =======
152     local args       = args or {}
153
154     task.font_size   = tonumber(args.font_size) or 12
155     task.font        = beautiful.font:sub(beautiful.font:find(""),
156                        beautiful.font:find(" "))
157     task.fg          = args.fg or beautiful.fg_normal or "#FFFFFF"
158     task.bg          = args.bg or beautiful.bg_normal or "#FFFFFF"
159     task.position    = args.position or "top_right"
160     task.timeout     = args.timeout or 7
161     task.scr_pos     = args.scr_pos or 1
162     task.followmouse = args.followmouse or false
163 >>>>>>> upstream/master
164
165     task.notify_icon = icons_dir .. "/taskwarrior/task.png"
166     task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png"
167
168 <<<<<<< HEAD
169     widget:connect_signal("mouse::enter", function () task:show() end)
170 =======
171     widget:connect_signal("mouse::enter", function () task:show(task.scr_pos) end)
172 >>>>>>> upstream/master
173     widget:connect_signal("mouse::leave", function () task:hide() end)
174 end
175
176 return setmetatable(task, { __call = function(_, ...) return create(...) end })