2015-01-10 18:44:30 +01:00
|
|
|
---------------------------------------------------------------------------
|
2021-12-21 06:54:15 +01:00
|
|
|
-- Desktop notification handling library.
|
|
|
|
--
|
2015-01-10 18:44:30 +01:00
|
|
|
-- @author Uli Schlachter <psychon@znc.in>
|
|
|
|
-- @copyright 2014 Uli Schlachter
|
2015-02-22 22:25:09 +01:00
|
|
|
-- @module naughty
|
2015-01-10 18:44:30 +01:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local naughty = require("naughty.core")
|
2018-08-06 22:43:01 +02:00
|
|
|
local gdebug = require("gears.debug")
|
2019-06-20 00:02:49 +02:00
|
|
|
local capi = {awesome = awesome, screen = screen}
|
2015-01-10 18:44:30 +01:00
|
|
|
if dbus then
|
|
|
|
naughty.dbus = require("naughty.dbus")
|
|
|
|
end
|
|
|
|
|
2019-04-06 04:16:44 +02:00
|
|
|
naughty.action = require("naughty.action")
|
2017-08-13 08:49:11 +02:00
|
|
|
naughty.list = require("naughty.list")
|
2017-07-02 04:43:26 +02:00
|
|
|
naughty.layout = require("naughty.layout")
|
2017-08-13 08:49:11 +02:00
|
|
|
naughty.widget = require("naughty.widget")
|
2019-03-12 19:23:09 +01:00
|
|
|
naughty.container = require("naughty.container")
|
|
|
|
naughty.action = require("naughty.action")
|
2017-07-02 04:43:26 +02:00
|
|
|
naughty.notification = require("naughty.notification")
|
|
|
|
|
2018-08-06 22:43:01 +02:00
|
|
|
-- Attempt to handle early errors when using the manual screen mode.
|
|
|
|
--
|
|
|
|
-- Creating a notification popup before the screens are added won't work. To
|
|
|
|
-- work around this, the code below initializes some screens. One potential
|
|
|
|
-- problem is that it could emit enough signal to cause even more errors and
|
|
|
|
-- lose the original error.
|
|
|
|
--
|
|
|
|
-- For example, the following error can be displayed using this fallback:
|
|
|
|
--
|
|
|
|
-- screen.connect_signal("scanned", function() foobar() end)
|
|
|
|
--
|
|
|
|
local function screen_fallback()
|
2019-06-20 00:02:49 +02:00
|
|
|
if capi.screen.count() == 0 then
|
2021-10-05 21:13:33 +02:00
|
|
|
gdebug.print_warning("An error occurred before a screen was added")
|
2018-08-06 22:43:01 +02:00
|
|
|
|
|
|
|
-- Private API to scan for screens now.
|
|
|
|
if #screen._viewports() == 0 then
|
|
|
|
screen._scan_quiet()
|
|
|
|
end
|
|
|
|
|
|
|
|
local viewports = screen._viewports()
|
|
|
|
|
|
|
|
if #viewports > 0 then
|
|
|
|
for _, viewport in ipairs(viewports) do
|
|
|
|
local geo = viewport.geometry
|
2019-06-20 00:02:49 +02:00
|
|
|
local s = capi.screen.fake_add(geo.x, geo.y, geo.width, geo.height)
|
|
|
|
s.outputs = viewport.outputs
|
2018-08-06 22:43:01 +02:00
|
|
|
end
|
|
|
|
else
|
2019-06-20 00:02:49 +02:00
|
|
|
capi.screen.fake_add(0, 0, 640, 480)
|
2018-08-06 22:43:01 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-28 22:08:31 +02:00
|
|
|
-- Handle runtime errors during startup
|
|
|
|
if capi.awesome.startup_errors then
|
2018-08-06 22:43:01 +02:00
|
|
|
|
2019-08-03 07:43:48 +02:00
|
|
|
-- Wait until `rc.lua` is executed before creating the notifications.
|
|
|
|
-- Otherwise nothing is handling them (yet).
|
2018-08-06 22:43:01 +02:00
|
|
|
client.connect_signal("scanning", function()
|
|
|
|
-- A lot of things have to go wrong for this to happen, but it can.
|
|
|
|
screen_fallback()
|
|
|
|
|
2019-08-03 07:43:48 +02:00
|
|
|
naughty.emit_signal(
|
|
|
|
"request::display_error", capi.awesome.startup_errors, true
|
|
|
|
)
|
|
|
|
end)
|
2019-04-28 22:08:31 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Handle runtime errors after startup
|
|
|
|
do
|
|
|
|
local in_error = false
|
2018-08-06 22:43:01 +02:00
|
|
|
|
2019-04-28 22:08:31 +02:00
|
|
|
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
|
2018-08-06 22:43:01 +02:00
|
|
|
|
2019-04-28 22:08:31 +02:00
|
|
|
in_error = true
|
|
|
|
|
2018-08-06 22:43:01 +02:00
|
|
|
screen_fallback()
|
|
|
|
|
2019-04-28 22:08:31 +02:00
|
|
|
naughty.emit_signal("request::display_error", tostring(err), false)
|
|
|
|
|
|
|
|
in_error = false
|
|
|
|
end)
|
2018-08-06 22:43:01 +02:00
|
|
|
|
2019-04-28 22:08:31 +02:00
|
|
|
end
|
|
|
|
|
2015-01-10 18:44:30 +01:00
|
|
|
return naughty
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|