2017-07-02 04:43:26 +02:00
|
|
|
----------------------------------------------------------------------------
|
|
|
|
--- This file hosts the shared constants used by the notification subsystem.
|
|
|
|
--
|
|
|
|
-- [[documented in core.lua]]
|
|
|
|
--
|
|
|
|
-- @author koniu <gkusnierz@gmail.com>
|
|
|
|
-- @author Emmanuel Lepage Vallee <elv1313@gmail.com>
|
|
|
|
-- @copyright 2008 koniu
|
|
|
|
-- @copyright 2017 Emmanuel Lepage Vallee
|
|
|
|
----------------------------------------------------------------------------
|
|
|
|
local beautiful = require("beautiful")
|
2020-09-14 10:57:18 +02:00
|
|
|
local gtable = require("gears.table")
|
2017-07-02 04:43:26 +02:00
|
|
|
local dpi = beautiful.xresources.apply_dpi
|
|
|
|
|
2020-09-14 10:57:18 +02:00
|
|
|
local ret, no_clear = {}, {}
|
2017-07-02 04:43:26 +02:00
|
|
|
|
|
|
|
ret.config = {
|
|
|
|
padding = dpi(4),
|
|
|
|
spacing = dpi(1),
|
2019-01-04 23:39:14 +01:00
|
|
|
icon_dirs = { "/usr/share/pixmaps/", "/usr/share/icons/hicolor" },
|
2017-07-02 04:43:26 +02:00
|
|
|
icon_formats = { "png", "gif" },
|
|
|
|
notify_callback = nil,
|
|
|
|
}
|
|
|
|
|
2020-09-14 10:57:18 +02:00
|
|
|
no_clear.presets = {
|
2017-07-02 04:43:26 +02:00
|
|
|
low = {
|
|
|
|
timeout = 5
|
|
|
|
},
|
|
|
|
normal = {},
|
|
|
|
critical = {
|
|
|
|
bg = "#ff0000",
|
|
|
|
fg = "#ffffff",
|
|
|
|
timeout = 0,
|
|
|
|
},
|
|
|
|
ok = {
|
|
|
|
bg = "#00bb00",
|
|
|
|
fg = "#ffffff",
|
|
|
|
timeout = 5,
|
|
|
|
},
|
|
|
|
info = {
|
|
|
|
bg = "#0000ff",
|
|
|
|
fg = "#ffffff",
|
|
|
|
timeout = 5,
|
|
|
|
},
|
|
|
|
warn = {
|
|
|
|
bg = "#ffaa00",
|
|
|
|
fg = "#000000",
|
|
|
|
timeout = 10,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-07-15 06:55:34 +02:00
|
|
|
ret.config._urgency = {
|
|
|
|
low = "\0",
|
|
|
|
normal = "\1",
|
|
|
|
critical = "\2"
|
|
|
|
}
|
|
|
|
|
|
|
|
ret.config.mapping = {
|
2020-09-14 10:57:18 +02:00
|
|
|
{{urgency = ret.config._urgency.low }, no_clear.presets.low}, --compat
|
|
|
|
{{urgency = ret.config._urgency.normal }, no_clear.presets.normal}, --compat
|
|
|
|
{{urgency = ret.config._urgency.critical}, no_clear.presets.critical}, --compat
|
|
|
|
{{urgency = "low" }, no_clear.presets.low},
|
|
|
|
{{urgency = "normal" }, no_clear.presets.normal},
|
|
|
|
{{urgency = "critical"}, no_clear.presets.critical},
|
2019-07-15 06:55:34 +02:00
|
|
|
}
|
|
|
|
|
2020-09-14 10:57:18 +02:00
|
|
|
no_clear.defaults = {
|
2017-07-02 04:43:26 +02:00
|
|
|
timeout = 5,
|
|
|
|
text = "",
|
|
|
|
screen = nil,
|
|
|
|
ontop = true,
|
|
|
|
margin = dpi(5),
|
|
|
|
border_width = dpi(1),
|
2019-07-15 05:52:07 +02:00
|
|
|
position = "top_right",
|
|
|
|
urgency = "normal",
|
2019-07-22 06:10:22 +02:00
|
|
|
message = "",
|
|
|
|
title = "",
|
|
|
|
app_name = "",
|
|
|
|
ignore = false,
|
2017-07-02 04:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ret.notification_closed_reason = {
|
2019-01-03 09:09:42 +01:00
|
|
|
too_many_on_screen = -2,
|
2017-07-02 04:43:26 +02:00
|
|
|
silent = -1,
|
|
|
|
expired = 1,
|
|
|
|
dismissedByUser = 2, --TODO v5 remove this undocumented legacy constant
|
|
|
|
dismissed_by_user = 2,
|
|
|
|
dismissedByCommand = 3, --TODO v5 remove this undocumented legacy constant
|
2019-07-17 07:50:57 +02:00
|
|
|
dismissed_by_command = 3,
|
2017-07-02 04:43:26 +02:00
|
|
|
undefined = 4
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Legacy --TODO v5 remove this alias
|
|
|
|
ret.notificationClosedReason = ret.notification_closed_reason
|
|
|
|
|
2020-09-14 10:57:18 +02:00
|
|
|
-- `no_clear` is used to prevent users from setting the entire table.
|
|
|
|
-- If they did and we added a new default value, then it would not be
|
|
|
|
-- backward compatible. For safety, we just crush the tables rather than
|
|
|
|
-- replace them.
|
|
|
|
setmetatable(ret.config, {
|
|
|
|
__index = function(_, key)
|
|
|
|
return no_clear[key]
|
|
|
|
end,
|
|
|
|
__newindex = function(_, key, value)
|
|
|
|
if no_clear[key] then
|
|
|
|
gtable.crush(no_clear[key], value)
|
|
|
|
else
|
|
|
|
rawset(ret.config, key, value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2017-07-02 04:43:26 +02:00
|
|
|
return ret
|