naughty: Move the boilerplate rc.lua error handling to naughty.

This removes the imperative "mutex" logic from rc.lua, where it doesn't
belong. It also makes it closer to the "vision" of making `rc.lua` fully
modular.
This commit is contained in:
Emmanuel Lepage Vallee 2019-04-28 16:08:31 -04:00
parent 047245fd03
commit efbc707279
2 changed files with 28 additions and 0 deletions

View File

@ -512,6 +512,12 @@ function naughty.set_expiration_paused(p)
end
end
--- Emitted when an error occurred and requires attention.
-- @signal request::display_error
-- @tparam string message The error message.
-- @tparam boolean startup If the error occurred during the initial loading of
-- rc.lua (and thus caused the fallback to kick in).
--- Emitted when a notification is created.
-- @signal added
-- @tparam naughty.notification notification The notification object

View File

@ -5,6 +5,7 @@
---------------------------------------------------------------------------
local naughty = require("naughty.core")
local capi = {awesome = awesome}
if dbus then
naughty.dbus = require("naughty.dbus")
end
@ -17,6 +18,27 @@ naughty.container = require("naughty.container")
naughty.action = require("naughty.action")
naughty.notification = require("naughty.notification")
-- Handle runtime errors during startup
if capi.awesome.startup_errors then
naughty.emit_signal(
"request::display_error", capi.awesome.startup_errors, true
)
end
-- Handle runtime errors after startup
do
local in_error = false
capi.awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.emit_signal("request::display_error", tostring(err), false)
in_error = false
end)
end
return naughty
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80