add function addkeymousemap

This commit is contained in:
Sebastian Zerbe
2022-01-05 21:06:10 +01:00
parent 0b0698eaf2
commit 2240ae4422

View File

@@ -66,13 +66,55 @@ local mouse_keys = {
-- more to come... -- more to come...
} }
--[[
-- targetmap may be a string or a table with one or two entries
--
-- map = {
-- { "Ctrl+Alt+Super+L", "Super+LeftClick", description, function() }
-- }
--]]
function bindings.addkeyandmousemap(targetmap, category, map)
if type(targetmap) == "string" then
targetkey = targetmap.."_key"
targetmouse = targetmap.."_mouse"
elseif type(targetmap) == "table" then
if #targetmap == 1 then
targetkey = targetmap[1].."_key"
targetmouse = targetmap[1].."_mouse"
elseif #targetmap == 2 then
targetkey = targetmap[1]
targetmouse = targetmap[2]
end
else
return nil
end
if type(internalbindings[targetkey]) == "nil" then internalbindings[targetkey] = {} end
if type(internalbindings[targetmouse]) == "nil" then internalbindings[targetmouse] = {} end
for _, mapentry in ipairs(map) do
local keys = mapentry[1]
local mkeys = mapentry[2]
local desc = mapentry[3]
local bindfunc = mapentry[4]
if keys then
internalbindings[targetkey] = gearstable.join(internalbindings[targetkey],
awful.key(getmodkeys(keys), getkey(keys), bindfunc, {description = desc, group = category})
)
end
if mkeys then
internalbindings[targetmouse] = gearstable.join(internalbindings[targetmouse],
awful.button(getmodkeys(mkeys), getmousekey(mkeys), bindfunc)
)
end
end
return { keys = internalbindings[targetkey], mouse = internalbindings[targetmouse] }
end
--[[ --[[
-- map = { -- map = {
-- { "Ctrl+Alt+Super+L", description, function() } -- { "Ctrl+Alt+Super+L", description, function() }
-- } -- }
--]] --]]
function bindings.addkeymap(target, category, map) function bindings.addkeymap(target, category, map)
if debug then debug_msg("Type of internalbindings["..target.."]: "..type(internalbindings[target])) end if debug then debug_msg("Type of internalbindings["..target.."]: "..type(internalbindings[target])) end
if type(internalbindings[target]) == "nil" then internalbindings[target] = {} end if type(internalbindings[target]) == "nil" then internalbindings[target] = {} end