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
5 * (c) 2013, Luke Bonham
9 local icons_dir = require("lain.helpers").icons_dir
11 local awful = require("awful")
12 local beautiful = require("beautiful")
13 local naughty = require("naughty")
15 local io = { popen = io.popen }
16 local os = { date = os.date }
20 >>>>>>> upstream/master
21 local tonumber = tonumber
23 local setmetatable = setmetatable
25 -- Calendar notification
26 -- lain.widgets.calendar
28 local cal_notification = nil
30 function calendar:hide()
31 if cal_notification ~= nil then
32 naughty.destroy(cal_notification)
33 cal_notification = nil
37 function calendar:show(t_out, inc_offset, scr)
40 local offs = inc_offset or 0
41 local tims = t_out or 0
43 local today = tonumber(os.date('%d'))
44 local init_t = calendar.cal .. ' ' .. calendar.post_cal .. ' ' ..
45 ' | sed -r -e "s/_\\x08//g" | sed -r -e "s/(^| )('
47 calendar.offset = calendar.offset + offs
49 if offs == 0 or calendar.offset == 0
50 then -- current month showing, today highlighted
52 calendar.notify_icon = calendar.icons .. today .. ".png"
54 -- bg and fg inverted to highlight today
55 f = io.popen( init_t .. today ..
56 ')($| )/\\1<b><span foreground=\\"'
60 '\\">\\2<\\/span><\\/b>\\3/"' )
62 else -- no current month showing, no day to highlight
63 local month = tonumber(os.date('%m'))
64 local year = tonumber(os.date('%Y'))
66 month = month + calendar.offset
82 calendar.notify_icon = nil
84 f = io.popen(calendar.cal .. ' ' .. month .. ' ' .. year .. ' ' ..
88 c_text = "<tt><span font='" .. calendar.font .. " "
89 .. calendar.font_size .. "'><b>"
90 .. f:read() .. "</b>\n\n"
93 .. f:read("*a"):gsub("\n*$", "")
98 .. f:read("*all"):gsub("\n*$", "")
102 if calendar.followmouse then
105 scrp = scr or calendar.scr_pos
108 >>>>>>> upstream/master
109 cal_notification = naughty.notify({
111 icon = calendar.notify_icon,
112 position = calendar.position,
120 >>>>>>> upstream/master
124 function calendar:attach(widget, args)
125 local args = args or {}
127 calendar.cal = args.cal or "/usr/bin/cal"
128 calendar.post_cal = args.post_cal or ""
129 calendar.icons = args.icons or icons_dir .. "cal/white/"
130 calendar.font = args.font or beautiful.font:sub(beautiful.font:find(""),
131 beautiful.font:find(" "))
132 calendar.font_size = tonumber(args.font_size) or 11
133 calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
134 calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
135 calendar.position = args.position or "top_right"
136 calendar.scr_pos = args.scr_pos or 1
139 calendar.notify_icon = nil
141 widget:connect_signal("mouse::enter", function () calendar:show(0, 0, scr_pos) end)
142 widget:connect_signal("mouse::leave", function () calendar:hide() end)
143 widget:buttons(awful.util.table.join( awful.button({ }, 1, function ()
144 calendar:show(0, -1, scr_pos) end),
145 awful.button({ }, 3, function ()
146 calendar:show(0, 1, scr_pos) end),
147 awful.button({ }, 4, function ()
148 calendar:show(0, -1, scr_pos) end),
149 awful.button({ }, 5, function ()
150 calendar:show(0, 1, scr_pos) end)))
153 calendar.cal = args.cal or "/usr/bin/cal"
154 calendar.post_cal = args.post_cal or ""
155 calendar.icons = args.icons or icons_dir .. "cal/white/"
156 calendar.font = args.font or beautiful.font:sub(beautiful.font:find(""),
157 beautiful.font:find(" "))
158 calendar.font_size = tonumber(args.font_size) or 11
159 calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
160 calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
161 calendar.position = args.position or "top_right"
162 calendar.scr_pos = args.scr_pos or 1
163 calendar.followmouse = args.followmouse or false
166 calendar.notify_icon = nil
168 widget:connect_signal("mouse::enter", function () calendar:show(0, 0, calendar.scr_pos) end)
169 widget:connect_signal("mouse::leave", function () calendar:hide() end)
170 widget:buttons(awful.util.table.join(awful.button({ }, 1, function ()
171 calendar:show(0, -1, calendar.scr_pos) end),
172 awful.button({ }, 3, function ()
173 calendar:show(0, 1, calendar.scr_pos) end),
174 awful.button({ }, 4, function ()
175 calendar:show(0, -1, calendar.scr_pos) end),
176 awful.button({ }, 5, function ()
177 calendar:show(0, 1, calendar.scr_pos) end)))
178 >>>>>>> upstream/master
181 return setmetatable(calendar, { __call = function(_, ...) return create(...) end })