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 os = { date = os.date }
17 local tonumber = tonumber
19 local setmetatable = setmetatable
24 local task_notification = nil
27 if task_notification ~= nil then
28 naughty.destroy(task_notification)
29 task_notification = nil
33 function task:show(t_out, inc_offset)
36 local offs = inc_offset or 0
37 local tims = t_out or 0
39 local today = tonumber(os.date('%d'))
40 local init_t = '/usr/bin/cal | sed -r -e "s/(^| )( '
41 -- let's take font only, font size is set in task table
42 local font = beautiful.font:sub(beautiful.font:find(""),
43 beautiful.font:find(" "))
46 then -- current month showing, today highlighted
49 init_t = '/usr/bin/cal | sed -r -e "s/(^| )('
53 task.notify_icon = task.icons .. today .. ".png"
55 -- bg and fg inverted to highlight today
56 f = io.popen( init_t .. today ..
57 ')($| )/\\1<b><span foreground=\\"'
61 '\\">\\2<\\/span><\\/b>\\3/"' )
63 else -- no current month showing, no day to highlight
64 local month = tonumber(os.date('%m'))
65 local year = tonumber(os.date('%Y'))
67 task.offset = task.offset + offs
68 month = month + task.offset
84 task.notify_icon = nil
86 f = io.popen('/usr/bin/cal ' .. month .. ' ' .. year)
90 --c_text = "<tt><span font='" .. font .. " "
91 --.. task.font_size .. "'><b>"
92 --.. f:read() .. "</b>\n\n"
94 --.. f:read("*all"):gsub("\n*$", "")
96 c_text = "hello tasks!"
99 task_notification = naughty.notify({ text = c_text,
100 icon = task.notify_icon,
101 position = task.position,
107 function task:attach(widget, args)
108 local args = args or {}
109 task.icons = args.icons or icons_dir .. "cal/white/"
110 task.font_size = tonumber(args.font_size) or 12
111 task.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
112 task.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
113 task.position = args.position or "top_right"
116 task.notify_icon = nil
118 widget:connect_signal("mouse::enter", function () task:show() end)
119 widget:connect_signal("mouse::leave", function () task:hide() end)
120 widget:buttons(awful.util.table.join( awful.button({ }, 1, function ()
121 task:show(0, -1) end),
122 awful.button({ }, 3, function ()
123 task:show(0, 1) end) ))
126 return setmetatable(task, { __call = function(_, ...) return create(...) end })