diff --git a/lib/awful/init.lua.in b/lib/awful/init.lua.in index 58b05c43..9cda7a2f 100644 --- a/lib/awful/init.lua.in +++ b/lib/awful/init.lua.in @@ -18,6 +18,7 @@ require("awful.widget") require("awful.menu") require("awful.mouse") require("awful.remote") +require("awful.startup_notification") --- AWesome Functions very UsefuL module("awful") diff --git a/lib/awful/startup_notification.lua.in b/lib/awful/startup_notification.lua.in new file mode 100644 index 00000000..d09dfdf7 --- /dev/null +++ b/lib/awful/startup_notification.lua.in @@ -0,0 +1,57 @@ +--------------------------------------------------------------------------- +-- @author Julien Danjou <julien@danjou.info> +-- @copyright 2009 Julien Danjou +-- @release @AWESOME_VERSION@ +--------------------------------------------------------------------------- + +-- Grab environment we need +local hooks = require("awful.hooks") +local ipairs = ipairs +local table = table +local capi = +{ + root = root +} + +--- Startup notification module for awful +module("awful.startup_notification") + +local app_starting = {} + +cursor_waiting = "watch" + +local function update_cursor() + if #app_starting > 0 then + 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 + +local function startup_hook(event) + if event.type == "initiated" then + register_event(event.id) + elseif event.type == "canceled" + or event.type == "completed" then + unregister_event(event.id) + end +end + +hooks.startup_notification.register(startup_hook) + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80