diff --git a/configs/awesome/error_handling.lua b/configs/awesome/error_handling.lua new file mode 100644 index 0000000..918a1ab --- /dev/null +++ b/configs/awesome/error_handling.lua @@ -0,0 +1,39 @@ +-- Notification library +local naughty = require("naughty") + +local function init(awesome) + -- {{{ Error handling + -- Check if awesome encountered an error during startup and fell back to + -- another config (This code will only ever execute for the fallback config) + if awesome.startup_errors then + naughty.notify({ + preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors + }) + end + + -- Handle runtime errors after startup + do + local in_error = false + 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.notify({ + preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = tostring(err) + }) + in_error = false + end) + end + -- }}} +end + +return { + init = init +} \ No newline at end of file diff --git a/configs/awesome/rc.lua b/configs/awesome/rc.lua index 133280c..6fa8cf2 100644 --- a/configs/awesome/rc.lua +++ b/configs/awesome/rc.lua @@ -10,44 +10,12 @@ require("awful.autofocus") local wibox = require("wibox") -- Theme handling library local beautiful = require("beautiful") --- Notification library -local naughty = require("naughty") local menubar = require("menubar") local hotkeys_popup = require("awful.hotkeys_popup") -- Enable hotkeys help widget for VIM and other apps -- when client with a matching name is opened: require("awful.hotkeys_popup.keys") - --- {{{ Error handling --- Check if awesome encountered an error during startup and fell back to --- another config (This code will only ever execute for the fallback config) -if awesome.startup_errors then - naughty.notify({ - preset = naughty.config.presets.critical, - title = "Oops, there were errors during startup!", - text = awesome.startup_errors - }) -end - --- Handle runtime errors after startup -do - local in_error = false - 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.notify({ - preset = naughty.config.presets.critical, - title = "Oops, an error happened!", - text = tostring(err) - }) - in_error = false - end) -end --- }}} +require("error_handling").init(awesome) -- {{{ Variable definitions -- Themes define colours, icons, font and wallpapers.