traversing on empty tags does not cause an error anymore

This commit is contained in:
BZ 2020-04-28 19:15:15 +02:00
parent c9de6a1055
commit e7880a702a
1 changed files with 63 additions and 18 deletions

View File

@ -17,35 +17,80 @@ local keys = {
right = { "l" } right = { "l" }
} }
local function loadrequire(mod)
local function requiref(mdl)
require(mdl)
end
local res = pcall(requiref, mod)
return res
end
local function new(ks) local function new(ks)
keys = ks or keys keys = ks or keys
local aw = {} local aw = {}
glib.idle_add(glib.PRIORITY_DEFAULT_IDLE, function() local use_collision = loadrequire("collision")
for k, v in pairs(keys) do if use_collision then
for _, key_name in ipairs(v) do collision = require("collision"){} -- load collision without any keybinds
aw[#aw + 1] = awful.key( end
{ "Mod4" },
key_name, if use_collision then
function() glib.idle_add(glib.PRIORITY_DEFAULT_IDLE, function()
module.focus(k) for k, v in pairs(keys) do
end, for _, key_name in ipairs(v) do
{ aw[#aw + 1] = awful.key(
description = "Change focus to the " .. key_name .. " window", { "Mod4" },
group = "Navigator" key_name,
} function()
) module.focus(k)
end,
{
description = "Change focus to the " .. key_name .. " Window / Tmux Pane / VIM Split",
group = "Navigator"
}
)
aw[#aw + 1] = awful.key(
{ "Mod4", "Shift" },
key_name,
function()
collision.move(k)
end,
{
description = "Move to the " .. key_name,
group = "Collision"
}
)
end
end end
end capi.root.keys(awful.util.table.join(capi.root.keys(), unpack(aw)))
capi.root.keys(awful.util.table.join(capi.root.keys(), unpack(aw))) end)
end) else
glib.idle_add(glib.PRIORITY_DEFAULT_IDLE, function()
for k, v in pairs(keys) do
for _, key_name in ipairs(v) do
aw[#aw + 1] = awful.key(
{ "Mod4" },
key_name,
function()
module.focus(k)
end,
{
description = "Change focus to the " .. key_name .. " window",
group = "Navigator"
}
)
end
end
capi.root.keys(awful.util.table.join(capi.root.keys(), unpack(aw)))
end)
end
return module return module
end end
function module.focus(dir) function module.focus(dir)
local c = client.focus local c = client.focus
local client_name = c.name or "" local client_name = c and c.name or ""
if string.find(client_name, "- N?VIM$") then if string.find(client_name, "- N?VIM$") then
keygrabber.stop() keygrabber.stop()