calendar: fix async hanging notifications; closes #289
This commit is contained in:
parent
49a4df385e
commit
43cd98510a
5 changed files with 31 additions and 40 deletions
15
helpers.lua
15
helpers.lua
|
@ -185,21 +185,6 @@ function helpers.make_widget_textbox()
|
||||||
return t
|
return t
|
||||||
end
|
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
|
return helpers
|
||||||
|
|
|
@ -119,10 +119,15 @@ local function worker(args)
|
||||||
|
|
||||||
if alsabar.followtag then preset.screen = awful.screen.focused() end
|
if alsabar.followtag then preset.screen = awful.screen.focused() end
|
||||||
|
|
||||||
alsabar.id = naughty.notify ({
|
if not alsabar.notification then
|
||||||
replaces_id = alsabar.id,
|
alsabar.notification = naughty.notify {
|
||||||
preset = preset
|
preset = preset,
|
||||||
}).id
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,10 @@ local tonumber = tonumber
|
||||||
local calendar = { offset = 0 }
|
local calendar = { offset = 0 }
|
||||||
|
|
||||||
function calendar.hide()
|
function calendar.hide()
|
||||||
if not calendar.notification then return end
|
naughty.destroy(naughty.getById(calendar.id))
|
||||||
naughty.destroy(calendar.notification)
|
|
||||||
calendar.notification = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function calendar.show(t_out, inc_offset, scr)
|
function calendar.show(t_out, inc_offset, scr)
|
||||||
calendar.hide()
|
|
||||||
|
|
||||||
local today = os.date("%d")
|
local today = os.date("%d")
|
||||||
local offs = inc_offset or 0
|
local offs = inc_offset or 0
|
||||||
local f
|
local f
|
||||||
|
@ -69,12 +65,13 @@ function calendar.show(t_out, inc_offset, scr)
|
||||||
helpers.async(f, function(ws)
|
helpers.async(f, function(ws)
|
||||||
fg, bg = calendar.notification_preset.fg, calendar.notification_preset.bg
|
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)))
|
ws = ws:gsub("%c%[%d+[m]?%d+%c%[%d+[m]?", markup.bold(markup.color(bg, fg, today)))
|
||||||
calendar.notification = naughty.notify({
|
calendar.id = naughty.notify({
|
||||||
|
replaces_id = calendar.id,
|
||||||
preset = calendar.notification_preset,
|
preset = calendar.notification_preset,
|
||||||
text = ws:gsub("\n*$", ""),
|
text = ws:gsub("\n*$", ""),
|
||||||
icon = calendar.notify_icon,
|
icon = calendar.notify_icon,
|
||||||
timeout = t_out or calendar.notification.preset.timeout or 5
|
timeout = t_out or calendar.notification.preset.timeout or 5
|
||||||
})
|
}).id
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,10 @@ local function worker(args)
|
||||||
fs.notification_preset = args.notification_preset
|
fs.notification_preset = args.notification_preset
|
||||||
|
|
||||||
if not fs.notification_preset then
|
if not fs.notification_preset then
|
||||||
fs.notification_preset = {
|
fs.notification_preset = naughty.config.defaults
|
||||||
font = "Monospace 10",
|
fs.notification_preset.font = "Monospace 10"
|
||||||
fg = "#FFFFFF",
|
fs.notification_preset.fg = "#FFFFFF"
|
||||||
bg = "#000000"
|
fs.notification_preset.bg = "#000000"
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
helpers.set_map(partition, false)
|
helpers.set_map(partition, false)
|
||||||
|
@ -125,7 +124,7 @@ local function worker(args)
|
||||||
|
|
||||||
helpers.newtimer(partition, timeout, fs.update)
|
helpers.newtimer(partition, timeout, fs.update)
|
||||||
|
|
||||||
return fs
|
return setmetatable(fs, { __index = fs.widget })
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
|
||||||
|
|
|
@ -129,10 +129,15 @@ local function worker(args)
|
||||||
|
|
||||||
if pulsebar.followtag then preset.screen = awful.screen.focused() end
|
if pulsebar.followtag then preset.screen = awful.screen.focused() end
|
||||||
|
|
||||||
pulsebar.id = naughty.notify ({
|
if not pulsebar.notification then
|
||||||
replaces_id = pulsebar.id,
|
pulsebar.notification = naughty.notify {
|
||||||
preset = preset
|
preset = preset,
|
||||||
}).id
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue