2009-04-03 16:30:38 +02:00
|
|
|
---------------------------------------------------------------------------
|
2014-05-20 13:02:39 +02:00
|
|
|
--- Startup notification module for awful
|
|
|
|
--
|
2009-04-03 16:30:38 +02:00
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2009 Julien Danjou
|
2014-05-20 13:02:39 +02:00
|
|
|
-- @module awful.startup_notification
|
2009-04-03 16:30:38 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local ipairs = ipairs
|
|
|
|
local table = table
|
|
|
|
local capi =
|
|
|
|
{
|
2009-07-31 16:28:17 +02:00
|
|
|
awesome = awesome,
|
2009-04-03 16:30:38 +02:00
|
|
|
root = root
|
|
|
|
}
|
2017-03-01 21:46:26 +01:00
|
|
|
local beautiful = require("beautiful")
|
2009-04-03 16:30:38 +02:00
|
|
|
|
|
|
|
local app_starting = {}
|
|
|
|
|
2012-06-12 20:13:09 +02:00
|
|
|
local cursor_waiting = "watch"
|
2009-04-03 16:30:38 +02:00
|
|
|
|
2017-03-01 21:46:26 +01:00
|
|
|
--- Show busy mouse cursor during spawn.
|
|
|
|
-- @beautiful beautiful.enable_spawn_cursor
|
|
|
|
-- @tparam[opt=true] boolean enable_spawn_cursor
|
|
|
|
|
2009-04-03 16:30:38 +02:00
|
|
|
local function update_cursor()
|
2017-03-01 21:46:26 +01:00
|
|
|
if #app_starting > 0 and beautiful.enable_spawn_cursor ~= false then
|
2009-04-03 16:30:38 +02:00
|
|
|
capi.root.cursor(cursor_waiting)
|
|
|
|
else
|
|
|
|
capi.root.cursor("left_ptr")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function unregister_event(event_id)
|
|
|
|
for k, v in ipairs(app_starting) do
|
|
|
|
if v == event_id then
|
|
|
|
table.remove(app_starting, k)
|
|
|
|
update_cursor()
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function register_event(event_id)
|
|
|
|
table.insert(app_starting, event_id)
|
|
|
|
update_cursor()
|
|
|
|
end
|
|
|
|
|
2009-07-31 16:28:17 +02:00
|
|
|
local function unregister_hook(event) unregister_event(event.id) end
|
|
|
|
local function register_hook(event) register_event(event.id) end
|
2009-04-03 16:30:38 +02:00
|
|
|
|
2009-10-09 20:39:55 +02:00
|
|
|
capi.awesome.connect_signal("spawn::initiated", register_hook)
|
|
|
|
capi.awesome.connect_signal("spawn::canceled", unregister_hook)
|
|
|
|
capi.awesome.connect_signal("spawn::completed", unregister_hook)
|
|
|
|
capi.awesome.connect_signal("spawn::timeout", unregister_hook)
|
2009-04-03 16:30:38 +02:00
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|