awful: add urgent client fast switching
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
400b61677d
commit
2e2b6a3112
|
@ -96,6 +96,8 @@ Navigation.
|
||||||
Focus next client.
|
Focus next client.
|
||||||
*Mod4 \+ k*::
|
*Mod4 \+ k*::
|
||||||
Focus previous client.
|
Focus previous client.
|
||||||
|
*Mod4 \+ u*::
|
||||||
|
Focus first urgent client.
|
||||||
*Mod4 \+ Left*::
|
*Mod4 \+ Left*::
|
||||||
View previous tag.
|
View previous tag.
|
||||||
*Mod4 \+ Right*::
|
*Mod4 \+ Right*::
|
||||||
|
|
|
@ -224,6 +224,7 @@ keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
|
||||||
keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
|
keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
|
||||||
keybinding({ modkey }, "o", awful.client.movetoscreen):add()
|
keybinding({ modkey }, "o", awful.client.movetoscreen):add()
|
||||||
keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
|
keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
|
||||||
|
keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
|
||||||
|
|
||||||
-- Layout manipulation
|
-- Layout manipulation
|
||||||
keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
|
keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
|
||||||
|
|
|
@ -62,6 +62,9 @@ widget.taglist = {}
|
||||||
widget.taglist.label = {}
|
widget.taglist.label = {}
|
||||||
widget.tasklist = {}
|
widget.tasklist = {}
|
||||||
widget.tasklist.label = {}
|
widget.tasklist.label = {}
|
||||||
|
client.urgent = {}
|
||||||
|
client.urgent.stack = {}
|
||||||
|
client.urgent.stack.data = {}
|
||||||
|
|
||||||
--- Make i cycle.
|
--- Make i cycle.
|
||||||
-- @param t A length.
|
-- @param t A length.
|
||||||
|
@ -73,6 +76,56 @@ local function cycle(t, i)
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the first client that got the urgent hint.
|
||||||
|
-- @return The first urgent client.
|
||||||
|
function client.urgent.get()
|
||||||
|
if #client.urgent.stack.data > 0 then
|
||||||
|
return client.urgent.stack.data[1]
|
||||||
|
else
|
||||||
|
-- fallback behaviour: iterate through clients and get the first urgent
|
||||||
|
local clients = capi.client.get()
|
||||||
|
for k, cl in pairs(clients) do
|
||||||
|
if cl.urgent then
|
||||||
|
return cl
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Jump to the client that received the urgent hint first.
|
||||||
|
function client.urgent.jumpto()
|
||||||
|
local c = client.urgent.get()
|
||||||
|
if c then
|
||||||
|
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
|
||||||
|
-- focus the screen
|
||||||
|
if s ~= c.screen then
|
||||||
|
capi.mouse.screen = c.screen
|
||||||
|
end
|
||||||
|
-- focus the tag
|
||||||
|
tag.viewonly(c:tags()[1])
|
||||||
|
-- focus the client
|
||||||
|
capi.client.focus = c
|
||||||
|
c:raise()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Adds client to urgent stack.
|
||||||
|
-- @param The client object.
|
||||||
|
function client.urgent.stack.add(c)
|
||||||
|
table.insert(client.urgent.stack.data, c)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove client from urgent stack.
|
||||||
|
-- @param The client object.
|
||||||
|
function client.urgent.stack.delete(c)
|
||||||
|
for k, cl in ipairs(client.urgent.stack.data) do
|
||||||
|
if c == cl then
|
||||||
|
table.remove(client.urgent.stack.data, k)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Remove a client from the focus history
|
--- Remove a client from the focus history
|
||||||
-- @param c The client that must be removed.
|
-- @param c The client that must be removed.
|
||||||
function client.focus.history.delete(c)
|
function client.focus.history.delete(c)
|
||||||
|
@ -1421,4 +1474,8 @@ hooks.unfocus.register(titlebar.update)
|
||||||
hooks.titleupdate.register(titlebar.update)
|
hooks.titleupdate.register(titlebar.update)
|
||||||
hooks.unmanage.register(titlebar.remove)
|
hooks.unmanage.register(titlebar.remove)
|
||||||
|
|
||||||
|
hooks.urgent.register(client.urgent.stack.add)
|
||||||
|
hooks.focus.register(client.urgent.stack.delete)
|
||||||
|
hooks.unmanage.register(client.urgent.stack.delete)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue