return t
end
--- shallow copy a table
-function helpers.table_shallowcopy(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in pairs(orig) do
- copy[orig_key] = orig_value
- end
- else -- number, string, boolean, etc
- copy = orig
- end
- return copy
-end
-
-- }}}
return helpers
if alsabar.followtag then preset.screen = awful.screen.focused() end
- alsabar.id = naughty.notify ({
- replaces_id = alsabar.id,
- preset = preset
- }).id
+ if not alsabar.notification then
+ alsabar.notification = naughty.notify {
+ preset = preset,
+ destroy = function() alsabar.notification = nil end
+ }
+ else
+ naughty.replace_text(alsabar.notification, preset.title, preset.text)
+ naughty.reset_timeout(alsabar.notification, preset.timeout)
+ end
end)
end
local calendar = { offset = 0 }
function calendar.hide()
- if not calendar.notification then return end
- naughty.destroy(calendar.notification)
- calendar.notification = nil
+ naughty.destroy(naughty.getById(calendar.id))
end
function calendar.show(t_out, inc_offset, scr)
- calendar.hide()
-
local today = os.date("%d")
local offs = inc_offset or 0
local f
helpers.async(f, function(ws)
fg, bg = calendar.notification_preset.fg, calendar.notification_preset.bg
ws = ws:gsub("%c%[%d+[m]?%d+%c%[%d+[m]?", markup.bold(markup.color(bg, fg, today)))
- calendar.notification = naughty.notify({
- preset = calendar.notification_preset,
- text = ws:gsub("\n*$", ""),
- icon = calendar.notify_icon,
- timeout = t_out or calendar.notification.preset.timeout or 5
- })
+ calendar.id = naughty.notify({
+ replaces_id = calendar.id,
+ preset = calendar.notification_preset,
+ text = ws:gsub("\n*$", ""),
+ icon = calendar.notify_icon,
+ timeout = t_out or calendar.notification.preset.timeout or 5
+ }).id
end)
end
fs.notification_preset = args.notification_preset
if not fs.notification_preset then
- fs.notification_preset = {
- font = "Monospace 10",
- fg = "#FFFFFF",
- bg = "#000000"
- }
+ fs.notification_preset = naughty.config.defaults
+ fs.notification_preset.font = "Monospace 10"
+ fs.notification_preset.fg = "#FFFFFF"
+ fs.notification_preset.bg = "#000000"
end
helpers.set_map(partition, false)
helpers.newtimer(partition, timeout, fs.update)
- return fs
+ return setmetatable(fs, { __index = fs.widget })
end
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
if pulsebar.followtag then preset.screen = awful.screen.focused() end
- pulsebar.id = naughty.notify ({
- replaces_id = pulsebar.id,
- preset = preset
- }).id
+ if not pulsebar.notification then
+ pulsebar.notification = naughty.notify {
+ preset = preset,
+ destroy = function() pulsebar.notification = nil end
+ }
+ else
+ naughty.replace_text(pulsebar.notification, preset.title, preset.text)
+ naughty.reset_timeout(pulsebar.notification, preset.timeout)
+ end
end)
end