add function addkeymousemap
This commit is contained in:
@@ -66,13 +66,55 @@ local mouse_keys = {
|
||||
-- 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 = {
|
||||
-- { "Ctrl+Alt+Super+L", description, function() }
|
||||
-- }
|
||||
--]]
|
||||
|
||||
function bindings.addkeymap(target, category, map)
|
||||
if debug then debug_msg("Type of internalbindings["..target.."]: "..type(internalbindings[target])) end
|
||||
if type(internalbindings[target]) == "nil" then internalbindings[target] = {} end
|
||||
|
||||
Reference in New Issue
Block a user