Bindings: move layout bindings into binding module and make them modal
This commit is contained in:
parent
dd7b34d3c7
commit
6a5115bc7b
79
bindings.lua
79
bindings.lua
|
@ -70,25 +70,24 @@ calendarmap = {
|
||||||
onClose = function() calendar:hide() end
|
onClose = function() calendar:hide() end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function use_layout(layout) return function() awful.layout.set(layout) end end
|
||||||
adapters = { u = "wwan", w = "wlan", b = "bluetooth" }
|
layoutmap = {
|
||||||
local function rfkill(cmd)
|
f = { func = use_layout(awful.layout.suit.fair), desc ="Fair" },
|
||||||
map = {}
|
h = { func = use_layout(awful.layout.suit.fair.horizontal), desc ="Fair Horizontal" },
|
||||||
for key, adapter in pairs(adapters) do
|
t = { func = use_layout(awful.layout.suit.tile), desc ="Tile" },
|
||||||
map[key] = { func = spawnf("sudo rfkill "..cmd.." "..adapter), desc = adapter }
|
b = { func = use_layout(awful.layout.suit.tile.bottom), desc ="Tile Bottom" },
|
||||||
end
|
m = { func = use_layout(awful.layout.suit.max), desc ="Maximized" },
|
||||||
return map
|
F = { func = use_layout(awful.layout.suit.max.fullscreen), desc ="Fullscreen" },
|
||||||
end
|
Space = { func = use_layout(awful.layout.suit.floating), desc ="Float" }
|
||||||
|
|
||||||
connectmap = {
|
|
||||||
u = { func = spawnf("umts"), desc = "umts" },
|
|
||||||
w = { func = spawnf("wlanacpi"), desc = "wlan" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wirelessmap = {
|
layoutsettings = {
|
||||||
b = { func = mb.grabf(rfkill("block"),"Block"), desc = "block" },
|
l = { func = function () awful.tag.incmwfact( 0.05) end, desc = "Master bigger" },
|
||||||
u = { func = mb.grabf(rfkill("unblock"),"Unblock"), desc = "unblock" },
|
h = { func = function () awful.tag.incmwfact(-0.05) end, desc = "Master smaller" },
|
||||||
c = { func = mb.grabf(connectmap, "Connect"), desc = "connect" }
|
H = { func = function () awful.tag.incnmaster( 1) end, desc = "More masters" },
|
||||||
|
L = { func = function () awful.tag.incnmaster(-1) end, desc = "Less masters" },
|
||||||
|
c = { func = function () awful.tag.incncol( 1) end, desc = "More columns" },
|
||||||
|
C = { func = function () awful.tag.incncol(-1) end, desc = "Less columns" },
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindings.extend_key_table(globalkeys)
|
function bindings.extend_key_table(globalkeys)
|
||||||
|
@ -109,13 +108,51 @@ function bindings.extend_key_table(globalkeys)
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
|
|
||||||
|
--{{{ Layout manipulation and client position
|
||||||
|
awful.key({ modkey }, "j", function ()
|
||||||
|
awful.client.focus.byidx( 1)
|
||||||
|
if client.focus then client.focus:raise() end
|
||||||
|
end),
|
||||||
|
awful.key({ modkey }, "k", function ()
|
||||||
|
awful.client.focus.byidx(-1)
|
||||||
|
if client.focus then client.focus:raise() end
|
||||||
|
end),
|
||||||
|
|
||||||
|
-- Layout manipulation
|
||||||
|
awful.key({ modkey }, "Tab", function ()
|
||||||
|
awful.client.focus.history.previous()
|
||||||
|
if client.focus then
|
||||||
|
client.focus:raise()
|
||||||
|
end
|
||||||
|
end),
|
||||||
|
awful.key({ "Mod1", }, "Tab", function ()
|
||||||
|
awful.client.focus.history.previous()
|
||||||
|
if client.focus then
|
||||||
|
client.focus:raise()
|
||||||
|
end
|
||||||
|
end),
|
||||||
|
awful.key({ modkey, "Shift" }, "j", function ()
|
||||||
|
awful.client.swap.byidx( 1)
|
||||||
|
end),
|
||||||
|
awful.key({ modkey, "Shift" }, "k", function ()
|
||||||
|
awful.client.swap.byidx( -1)
|
||||||
|
end),
|
||||||
|
awful.key({ modkey, }, "h", function ()
|
||||||
|
awful.screen.focus_relative( 1)
|
||||||
|
end),
|
||||||
|
awful.key({ modkey, }, "l", function ()
|
||||||
|
awful.screen.focus_relative(-1)
|
||||||
|
end),
|
||||||
|
--}}}
|
||||||
|
|
||||||
--{{{ Modal mappings
|
--{{{ Modal mappings
|
||||||
|
|
||||||
awful.key({ modkey }, "m", mb.grabf(mpdmap, "MPD", true)),
|
awful.key({ modkey }, "m", mb.grabf(mpdmap, "MPD", true)),
|
||||||
awful.key({ modkey, "Shift" }, "m", mb.grabf(mpdpromts, "MPD - Search for")),
|
awful.key({ modkey, "Shift" }, "m", mb.grabf(mpdpromts, "MPD - Search for")),
|
||||||
awful.key({ modkey }, "c", mb.grabf(progmap, "Commands")),
|
awful.key({ modkey }, "c", mb.grabf(progmap, "Commands")),
|
||||||
awful.key({ modkey }, "w", mb.grabf(wirelessmap, "Wifi")),
|
|
||||||
awful.key({ modkey }, "d", mb.grabf(docmap, "Documents")),
|
awful.key({ modkey }, "d", mb.grabf(docmap, "Documents")),
|
||||||
|
awful.key({ modkey }, "space", mb.grabf(layoutmap, "Layouts")),
|
||||||
|
awful.key({ modkey, "Shift" }, "space", mb.grabf(layoutsettings, "Layout settings", true)),
|
||||||
--}}}
|
--}}}
|
||||||
|
|
||||||
--{{{ Audio control
|
--{{{ Audio control
|
||||||
|
@ -185,6 +222,12 @@ clientkeys = awful.util.table.join(
|
||||||
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
|
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
|
||||||
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
|
||||||
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
|
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
|
||||||
|
awful.key({ modkey, "Shift" }, "h", function ()
|
||||||
|
awful.client.movetoscreen(c, mouse.screen + 1)
|
||||||
|
end),
|
||||||
|
awful.key({ modkey, "Shift" }, "l", function ()
|
||||||
|
awful.client.movetoscreen(c, mouse.screen - 1)
|
||||||
|
end),
|
||||||
awful.key({ modkey, "Control" }, "o", function (c) c.ontop = not c.ontop end),
|
awful.key({ modkey, "Control" }, "o", function (c) c.ontop = not c.ontop end),
|
||||||
awful.key({ modkey, "Shift" }, "a", function (c) c.sticky = not c.sticky end),
|
awful.key({ modkey, "Shift" }, "a", function (c) c.sticky = not c.sticky end),
|
||||||
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
|
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
|
||||||
|
|
63
layouts.lua
63
layouts.lua
|
@ -17,69 +17,6 @@ function layouts.set_list(layout_list)
|
||||||
list = layout_list
|
list = layout_list
|
||||||
end
|
end
|
||||||
|
|
||||||
function layouts.extend_key_table(globalkeys)
|
|
||||||
local layoutkeys = globalkeys or {}
|
|
||||||
return awful.util.table.join(layoutkeys,
|
|
||||||
awful.key({ modkey }, "j", function ()
|
|
||||||
awful.client.focus.byidx( 1)
|
|
||||||
if client.focus then client.focus:raise() end
|
|
||||||
end),
|
|
||||||
awful.key({ modkey }, "k", function ()
|
|
||||||
awful.client.focus.byidx(-1)
|
|
||||||
if client.focus then client.focus:raise() end
|
|
||||||
end),
|
|
||||||
|
|
||||||
-- Layout manipulation
|
|
||||||
awful.key({ modkey }, "Tab", function ()
|
|
||||||
awful.client.focus.history.previous()
|
|
||||||
if client.focus then
|
|
||||||
client.focus:raise()
|
|
||||||
end
|
|
||||||
end),
|
|
||||||
awful.key({ "Mod1", }, "Tab", function ()
|
|
||||||
awful.client.focus.history.previous()
|
|
||||||
if client.focus then
|
|
||||||
client.focus:raise()
|
|
||||||
end
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, }, "l", function ()
|
|
||||||
awful.tag.incmwfact( 0.05)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, }, "h", function ()
|
|
||||||
awful.tag.incmwfact(-0.05)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Shift" }, "h", function ()
|
|
||||||
awful.tag.incnmaster( 1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Shift" }, "l", function ()
|
|
||||||
awful.tag.incnmaster(-1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Control" }, "h", function ()
|
|
||||||
awful.tag.incncol(1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Control" }, "l", function ()
|
|
||||||
awful.tag.incncol(-1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, }, "space", function ()
|
|
||||||
awful.layout.inc(list, 1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Shift" }, "space", function ()
|
|
||||||
awful.layout.inc(list, -1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Shift" }, "j", function ()
|
|
||||||
awful.client.swap.byidx( 1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Shift" }, "k", function ()
|
|
||||||
awful.client.swap.byidx( -1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Control" }, "j", function ()
|
|
||||||
awful.screen.focus_relative( 1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Control" }, "k", function ()
|
|
||||||
awful.screen.focus_relative(-1)
|
|
||||||
end)
|
|
||||||
);
|
|
||||||
end
|
|
||||||
|
|
||||||
layouts.mt.__index = list
|
layouts.mt.__index = list
|
||||||
layouts.mt.__newindex = list
|
layouts.mt.__newindex = list
|
||||||
|
|
1
rc.lua
1
rc.lua
|
@ -58,7 +58,6 @@ end
|
||||||
|
|
||||||
-- {{{ Key bindings
|
-- {{{ Key bindings
|
||||||
globalkeys = {}
|
globalkeys = {}
|
||||||
globalkeys = layouts.extend_key_table(globalkeys);
|
|
||||||
globalkeys = tags.extend_key_table(globalkeys);
|
globalkeys = tags.extend_key_table(globalkeys);
|
||||||
|
|
||||||
bindings = require("bindings")
|
bindings = require("bindings")
|
||||||
|
|
Loading…
Reference in a new issue