Separate custom bindings from generic bindings
This commit is contained in:
parent
6f0a85e0db
commit
6ec1f92bc9
271
bindings.lua
271
bindings.lua
|
@ -1,271 +0,0 @@
|
||||||
-- key bindings
|
|
||||||
local awful = require("awful")
|
|
||||||
local beautiful = beautiful
|
|
||||||
local conf = conf
|
|
||||||
local mpd = require("mpd")
|
|
||||||
local scratch = require("scratch")
|
|
||||||
|
|
||||||
local modkey = conf.modkey or "Mod4"
|
|
||||||
local mb = require("modalbind")
|
|
||||||
local calendar = require("calendar")
|
|
||||||
|
|
||||||
local globalkeys = {}
|
|
||||||
|
|
||||||
app_folders = {
|
|
||||||
"/usr/share/applications",
|
|
||||||
"/usr/local/share/applications",
|
|
||||||
os.getenv("HOME") .. "/.local/applications",
|
|
||||||
os.getenv("HOME") .. "/Desktop"
|
|
||||||
}
|
|
||||||
local menubar = require("menubar")
|
|
||||||
|
|
||||||
menubar.utils.terminal = conf.cmd.terminal -- Set the terminal for applications that require it
|
|
||||||
|
|
||||||
local bindings = {modalbind = mb}
|
|
||||||
|
|
||||||
-- {{{ Mouse bindings
|
|
||||||
root.buttons(awful.util.table.join(
|
|
||||||
awful.button({ }, 4, awful.tag.viewnext),
|
|
||||||
awful.button({ }, 5, awful.tag.viewprev)
|
|
||||||
))
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
local function spawnf(cmd) return function() awful.util.spawn(cmd) end end
|
|
||||||
bindings.spawnf = spawnf
|
|
||||||
|
|
||||||
conf.cmd.run = conf.cmd.run or spawnf("dmenu_run")
|
|
||||||
|
|
||||||
local function mpdserver(host)
|
|
||||||
return function()
|
|
||||||
mpd.set_server(host, "6600")
|
|
||||||
awful.util.spawn("mpd-host set " .. host .. " 6600")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mpdhosts = {
|
|
||||||
n = { func = mpdserver("nas"), desc = "NAS" },
|
|
||||||
b = { func = mpdserver("berryhorst"), desc = "Berry" },
|
|
||||||
l = { func = mpdserver("127.0.0.1"), desc = "Local" }
|
|
||||||
}
|
|
||||||
|
|
||||||
mpdmap = {
|
|
||||||
m = { func = mpd.ctrl.toggle, desc = "Toggle" },
|
|
||||||
n = { func = mpd.ctrl.next, desc = "Next" },
|
|
||||||
N = { func = mpd.ctrl.prev, desc = "Prev" },
|
|
||||||
s = { func = spawnf("mpd"), desc = "start MPD" },
|
|
||||||
S = { func = spawnf("mpd --kill"), desc = "kill MPD" },
|
|
||||||
g = { func = spawnf(conf.cmd.mpd_client), desc = "Gmpc" },
|
|
||||||
}
|
|
||||||
|
|
||||||
mpdpromts = {
|
|
||||||
a = { func = mpd.prompt.artist, desc = "artist" },
|
|
||||||
b = { func = mpd.prompt.album, desc = "album" },
|
|
||||||
t = { func = mpd.prompt.title, desc = "title" },
|
|
||||||
r = { func = mpd.prompt.toggle_replace_on_search, desc = "toggle replacing" },
|
|
||||||
h = { func = mb.grabf(mpdhosts, "Select MPD host"), desc = "Change host" }
|
|
||||||
}
|
|
||||||
|
|
||||||
progmap = {
|
|
||||||
f = { func = spawnf(conf.cmd.browser), desc = "Browser" },
|
|
||||||
i = { func = spawnf(conf.cmd.im_client), desc = "IM Client" },
|
|
||||||
I = { func = spawnf(conf.cmd.irc_client), desc = "IRC" },
|
|
||||||
t = { func = spawnf("telegram"), desc = "Telegram" },
|
|
||||||
m = { func = spawnf(conf.cmd.mail_client), desc = "Mail" },
|
|
||||||
s = { func = spawnf("steam"), desc = "Steam" }
|
|
||||||
}
|
|
||||||
|
|
||||||
docmap = {
|
|
||||||
u = { func = spawnf("docopen ~/doc/uni pdf"), desc = "Uni-Dokumente" },
|
|
||||||
b = { func = spawnf("docopen ~/books pdf epub mobi txt lit html htm"), desc = "Bücher" },
|
|
||||||
t = { func = spawnf("dmtexdoc"), desc = "Texdoc" },
|
|
||||||
j = { func = spawnf("dmjavadoc"), desc = "Javadoc" }
|
|
||||||
}
|
|
||||||
|
|
||||||
calendarmap = {
|
|
||||||
o = { func = function() calendar:next() end, desc = "Next" },
|
|
||||||
i = { func = function() calendar:prev() end, desc = "Prev" },
|
|
||||||
onClose = function() calendar:hide() end
|
|
||||||
}
|
|
||||||
|
|
||||||
local function use_layout(layout) return function() awful.layout.set(layout) end end
|
|
||||||
layoutmap = {
|
|
||||||
f = { func = use_layout(awful.layout.suit.fair), desc ="Fair" },
|
|
||||||
h = { func = use_layout(awful.layout.suit.fair.horizontal), desc ="Fair Horizontal" },
|
|
||||||
t = { func = use_layout(awful.layout.suit.tile), desc ="Tile" },
|
|
||||||
b = { func = use_layout(awful.layout.suit.tile.bottom), desc ="Tile Bottom" },
|
|
||||||
m = { func = use_layout(awful.layout.suit.max), desc ="Maximized" },
|
|
||||||
F = { func = use_layout(awful.layout.suit.max.fullscreen), desc ="Fullscreen" },
|
|
||||||
Space = { func = use_layout(awful.layout.suit.floating), desc ="Float" }
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutsettings = {
|
|
||||||
l = { func = function () awful.tag.incmwfact( 0.05) end, desc = "Master bigger" },
|
|
||||||
h = { func = function () awful.tag.incmwfact(-0.05) end, desc = "Master smaller" },
|
|
||||||
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.setup()
|
|
||||||
globalkeys = awful.util.table.join(
|
|
||||||
awful.key({ }, "Pause", spawnf('wmselect')), -- old keyboard
|
|
||||||
awful.key({ }, "Print", spawnf('wmselect')), -- new keyboard
|
|
||||||
|
|
||||||
awful.key({ modkey, "Control" }, "r", awesome.restart),
|
|
||||||
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
|
||||||
awful.key({ modkey, }, "Return", spawnf(conf.cmd.terminal)),
|
|
||||||
|
|
||||||
awful.key({ modkey, "Control" }, "n", awful.client.restore),
|
|
||||||
awful.key({ modkey, "Shift" }, "n",
|
|
||||||
function()
|
|
||||||
local tag = awful.tag.selected()
|
|
||||||
for i=1, #tag:clients() do
|
|
||||||
awful.client.restore(tag:clients()[i])
|
|
||||||
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
|
|
||||||
|
|
||||||
awful.key({ modkey }, "m", mb.grabf(mpdmap, "MPD", true)),
|
|
||||||
awful.key({ modkey, "Shift" }, "m", mb.grabf(mpdpromts, "MPD - Search for")),
|
|
||||||
awful.key({ modkey }, "c", mb.grabf(progmap, "Commands")),
|
|
||||||
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
|
|
||||||
|
|
||||||
awful.key({ }, "XF86AudioLowerVolume", spawnf("amixer set Master 2%-")),
|
|
||||||
awful.key({ }, "XF86AudioRaiseVolume", spawnf("amixer set Master 2%+")),
|
|
||||||
awful.key({ }, "XF86AudioMute", spawnf("amixer set Master toggle")),
|
|
||||||
awful.key({ }, "XF86AudioPlay", mpd.ctrl.toggle),
|
|
||||||
awful.key({ }, "XF86AudioNext", mpd.ctrl.next),
|
|
||||||
awful.key({ }, "XF86AudioPrev", mpd.ctrl.prev),
|
|
||||||
|
|
||||||
--}}}
|
|
||||||
|
|
||||||
-- {{{ teardrops
|
|
||||||
awful.key({ }, "F12", function ()
|
|
||||||
scratch.drop(conf.cmd.terminal,"center","center", 0.99, 0.7)
|
|
||||||
end ),
|
|
||||||
awful.key({ modkey }, "`", function ()
|
|
||||||
scratch.drop("gpms","bottom","center", 0.99, 0.4)
|
|
||||||
end ),
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
--{{{ Prompt
|
|
||||||
|
|
||||||
awful.key({ modkey }, "r", conf.cmd.run),
|
|
||||||
awful.key({ modkey, "Shift" }, "r", menubar.show),
|
|
||||||
|
|
||||||
awful.key({ modkey }, "s", spawnf("dmsearch")),
|
|
||||||
|
|
||||||
--}}}
|
|
||||||
|
|
||||||
--{{{ misc. XF86 Keys
|
|
||||||
|
|
||||||
awful.key({ }, "XF86Sleep", spawnf("s2ram")),
|
|
||||||
awful.key({ }, "Scroll_Lock", spawnf("xlock")),
|
|
||||||
awful.key({ }, "XF86Explorer", spawnf("touchpad")),
|
|
||||||
awful.key({ "Shift" }, "XF86Explorer", spawnf("wacomtouch")),
|
|
||||||
|
|
||||||
--}}}
|
|
||||||
|
|
||||||
-- calendar {{{
|
|
||||||
awful.key({ modkey, }, "y", function()
|
|
||||||
calendar:show()
|
|
||||||
mb.grab(calendarmap, "Calendar", true)
|
|
||||||
end)
|
|
||||||
)
|
|
||||||
|
|
||||||
--}}}
|
|
||||||
end
|
|
||||||
|
|
||||||
function bindings.add_bindings(keys)
|
|
||||||
globalkeys = awful.util.table.join(globalkeys, keys);
|
|
||||||
end
|
|
||||||
|
|
||||||
function bindings.apply()
|
|
||||||
root.keys(globalkeys)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function client_opacity_set(c, default, max, step)
|
|
||||||
if c.opacity < 0 or c.opacity > 1 then
|
|
||||||
c.opacity = default
|
|
||||||
end
|
|
||||||
|
|
||||||
if c.opacity * step < (max-step) * step then
|
|
||||||
c.opacity = c.opacity + step
|
|
||||||
else
|
|
||||||
c.opacity = max
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
clientkeys = awful.util.table.join(
|
|
||||||
awful.key({ modkey, "Shift" }, "f", function (c) c.fullscreen = not c.fullscreen end),
|
|
||||||
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
|
|
||||||
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, }, "o", awful.client.movetoscreen ),
|
|
||||||
awful.key({ modkey, "Shift" }, "h", function (c)
|
|
||||||
awful.client.movetoscreen(c, mouse.screen - 1)
|
|
||||||
end),
|
|
||||||
awful.key({ modkey, "Shift" }, "l", function (c)
|
|
||||||
awful.client.movetoscreen(c, mouse.screen + 1)
|
|
||||||
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" }, "r", function (c) c:redraw() end),
|
|
||||||
awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
|
|
||||||
awful.key({ modkey, }, "b", function (c) c.border_width = c.border_width > 0 and 0 or beautiful.border_width end),
|
|
||||||
awful.key({ modkey, }, "Up", function(c) client_opacity_set(c, 1, 1, 0.1) end),
|
|
||||||
awful.key({ modkey, }, "Down", function(c) client_opacity_set(c, 1, 0, -0.1) end),
|
|
||||||
awful.key({ }, "XF86Calculater", awful.client.movetoscreen )
|
|
||||||
)
|
|
||||||
|
|
||||||
clientbuttons = awful.util.table.join(
|
|
||||||
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
|
||||||
awful.button({ modkey }, 1, awful.mouse.client.move),
|
|
||||||
awful.button({ modkey }, 3, awful.mouse.client.resize))
|
|
||||||
|
|
||||||
return bindings
|
|
||||||
-- vim: set fenc=utf-8 tw=80 foldmethod=marker :
|
|
|
@ -7,6 +7,9 @@ conf.modkey = "Mod4"
|
||||||
-- screen number, on which rules will put clients by default
|
-- screen number, on which rules will put clients by default
|
||||||
conf.rule_screen=1
|
conf.rule_screen=1
|
||||||
|
|
||||||
|
-- default layout for tags
|
||||||
|
conf.default_layout = awful.layout.suit.fair
|
||||||
|
|
||||||
conf.mpd = {
|
conf.mpd = {
|
||||||
-- should mpd prompt clear playlist before adding matched songs
|
-- should mpd prompt clear playlist before adding matched songs
|
||||||
replace_on_search = true,
|
replace_on_search = true,
|
||||||
|
|
116
mybindings.lua
Normal file
116
mybindings.lua
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
-- key bindings
|
||||||
|
local awful = require("awful")
|
||||||
|
local conf = conf
|
||||||
|
|
||||||
|
local modkey = conf.modkey or "Mod4"
|
||||||
|
local binder = binder or require("separable.binder")
|
||||||
|
local mb = binder.modal
|
||||||
|
|
||||||
|
local mpd = require("separable.mpd")
|
||||||
|
local scratch = require("scratch")
|
||||||
|
local calendar = require("separable.calendar")
|
||||||
|
|
||||||
|
local myglobalkeys = {}
|
||||||
|
|
||||||
|
local function mpdserver(host)
|
||||||
|
return function()
|
||||||
|
mpd.set_server(host, "6600")
|
||||||
|
awful.util.spawn("mpd-host set " .. host .. " 6600")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local mpdhosts = {
|
||||||
|
n = { func = mpdserver("nas"), desc = "NAS" },
|
||||||
|
b = { func = mpdserver("berryhorst"), desc = "Berry" },
|
||||||
|
l = { func = mpdserver("127.0.0.1"), desc = "Local" }
|
||||||
|
}
|
||||||
|
|
||||||
|
local mpdmap = {
|
||||||
|
m = { func = mpd.ctrl.toggle, desc = "Toggle" },
|
||||||
|
n = { func = mpd.ctrl.next, desc = "Next" },
|
||||||
|
N = { func = mpd.ctrl.prev, desc = "Prev" },
|
||||||
|
s = { func = binder.spawn("mpd"), desc = "start MPD" },
|
||||||
|
S = { func = binder.spawn("mpd --kill"), desc = "kill MPD" },
|
||||||
|
g = { func = binder.spawn(conf.cmd.mpd_client), desc = "Gmpc" },
|
||||||
|
}
|
||||||
|
|
||||||
|
local mpdpromts = {
|
||||||
|
a = { func = mpd.prompt.artist, desc = "artist" },
|
||||||
|
b = { func = mpd.prompt.album, desc = "album" },
|
||||||
|
t = { func = mpd.prompt.title, desc = "title" },
|
||||||
|
r = { func = mpd.prompt.toggle_replace_on_search, desc = "toggle replacing" },
|
||||||
|
h = { func = mb.grabf(mpdhosts, "Select MPD host"), desc = "Change host" }
|
||||||
|
}
|
||||||
|
|
||||||
|
local progmap = {
|
||||||
|
f = { func = binder.spawn(conf.cmd.browser), desc = "Browser" },
|
||||||
|
i = { func = binder.spawn(conf.cmd.im_client), desc = "IM Client" },
|
||||||
|
I = { func = binder.spawn(conf.cmd.irc_client), desc = "IRC" },
|
||||||
|
t = { func = binder.spawn("telegram"), desc = "Telegram" },
|
||||||
|
m = { func = binder.spawn(conf.cmd.mail_client), desc = "Mail" },
|
||||||
|
s = { func = binder.spawn("steam"), desc = "Steam" }
|
||||||
|
}
|
||||||
|
|
||||||
|
local docmap = {
|
||||||
|
u = { func = binder.spawn("docopen ~/doc/uni pdf"), desc = "Uni-Dokumente" },
|
||||||
|
b = { func = binder.spawn("docopen ~/books pdf epub mobi txt lit html htm"), desc = "Bücher" },
|
||||||
|
t = { func = binder.spawn("dmtexdoc"), desc = "Texdoc" },
|
||||||
|
j = { func = binder.spawn("dmjavadoc"), desc = "Javadoc" }
|
||||||
|
}
|
||||||
|
|
||||||
|
local calendarmap = {
|
||||||
|
o = { func = function() calendar:next() end, desc = "Next" },
|
||||||
|
i = { func = function() calendar:prev() end, desc = "Prev" },
|
||||||
|
onClose = function() calendar:hide() end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local myglobalkeys = awful.util.table.join(
|
||||||
|
awful.key({ }, "Pause", binder.spawn('wmselect')),
|
||||||
|
|
||||||
|
--{{{ Modal mappings
|
||||||
|
|
||||||
|
awful.key({ modkey }, "m", mb.grabf(mpdmap, "MPD", true)),
|
||||||
|
awful.key({ modkey, "Shift" }, "m", mb.grabf(mpdpromts, "MPD - Search for")),
|
||||||
|
awful.key({ modkey }, "c", mb.grabf(progmap, "Commands")),
|
||||||
|
awful.key({ modkey }, "d", mb.grabf(docmap, "Documents")),
|
||||||
|
--}}}
|
||||||
|
|
||||||
|
-- {{{ scratch drop
|
||||||
|
awful.key({ }, "F12", function ()
|
||||||
|
scratch.drop(conf.cmd.terminal,"center","center", 0.99, 0.7)
|
||||||
|
end ),
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
--{{{ dmenu prompts
|
||||||
|
|
||||||
|
awful.key({ modkey }, "s", binder.spawn("dmsearch")),
|
||||||
|
awful.key({ modkey }, "x", binder.spawn("dmxrandr")),
|
||||||
|
|
||||||
|
--}}}
|
||||||
|
|
||||||
|
--{{{ misc. XF86 Keys
|
||||||
|
|
||||||
|
awful.key({ }, "Scroll_Lock", binder.spawn("xlock")),
|
||||||
|
awful.key({ }, "XF86Explorer", binder.spawn("touchpad")),
|
||||||
|
awful.key({ "Shift" }, "XF86Explorer", binder.spawn("wacomtouch")),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioPlay", mpd.ctrl.toggle),
|
||||||
|
awful.key({ }, "XF86AudioNext", mpd.ctrl.next),
|
||||||
|
awful.key({ }, "XF86AudioPrev", mpd.ctrl.prev),
|
||||||
|
|
||||||
|
--}}}
|
||||||
|
|
||||||
|
-- calendar {{{
|
||||||
|
awful.key({ modkey }, "y",
|
||||||
|
function()
|
||||||
|
calendar:show()
|
||||||
|
mb.grab(calendarmap, "Calendar", true)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
--}}}
|
||||||
|
)
|
||||||
|
|
||||||
|
return myglobalkeys
|
||||||
|
|
||||||
|
-- vim: set fenc=utf-8 tw=80 foldmethod=marker :
|
14
rc.lua
14
rc.lua
|
@ -56,11 +56,15 @@ end
|
||||||
|
|
||||||
-- {{{ Key bindings
|
-- {{{ Key bindings
|
||||||
|
|
||||||
bindings = require("bindings")
|
binder = require("separable.binder")
|
||||||
bindings.setup()
|
binder.modal.set_x_offset(18)
|
||||||
bindings.modalbind.set_x_offset(18)
|
|
||||||
bindings.add_bindings(tags.create_bindings())
|
binder.add_default_bindings()
|
||||||
bindings.apply()
|
binder.add_bindings(tags.create_bindings())
|
||||||
|
binder.add_bindings(require("mybindings"))
|
||||||
|
|
||||||
|
binder.apply()
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ rules
|
-- {{{ rules
|
||||||
|
|
|
@ -3,6 +3,7 @@ local awful = require("awful")
|
||||||
local tags = tags
|
local tags = tags
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local inspect=require("inspect")
|
local inspect=require("inspect")
|
||||||
|
local binder = binder or require("separable.binder")
|
||||||
|
|
||||||
local rule_screen = 1
|
local rule_screen = 1
|
||||||
|
|
||||||
|
@ -26,10 +27,10 @@ local function setup(self)
|
||||||
border_color = beautiful.border_normal,
|
border_color = beautiful.border_normal,
|
||||||
focus = awful.client.focus.filter,
|
focus = awful.client.focus.filter,
|
||||||
raise = true,
|
raise = true,
|
||||||
keys = clientkeys,
|
|
||||||
minimized = false,
|
minimized = false,
|
||||||
size_hints_honor = false,
|
size_hints_honor = false,
|
||||||
buttons = clientbuttons
|
keys = binder.client.keys(),
|
||||||
|
buttons = binder.client.buttons(),
|
||||||
},
|
},
|
||||||
-- print name and class of new windows for debugging purposes
|
-- print name and class of new windows for debugging purposes
|
||||||
callback = function(c)
|
callback = function(c)
|
||||||
|
|
199
separable/binder.lua
Normal file
199
separable/binder.lua
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
-- key bindings
|
||||||
|
local awful = require("awful")
|
||||||
|
local beautiful = beautiful
|
||||||
|
|
||||||
|
local modkey = conf.modkey or "Mod4"
|
||||||
|
local mb = require("separable.modalbind")
|
||||||
|
|
||||||
|
local globalkeys = {}
|
||||||
|
|
||||||
|
app_folders = {
|
||||||
|
"/usr/share/applications",
|
||||||
|
"/usr/local/share/applications",
|
||||||
|
os.getenv("HOME") .. "/.local/applications",
|
||||||
|
os.getenv("HOME") .. "/Desktop"
|
||||||
|
}
|
||||||
|
local menubar = require("menubar")
|
||||||
|
|
||||||
|
menubar.utils.terminal = conf.cmd.terminal -- Set the terminal for applications that require it
|
||||||
|
|
||||||
|
local binder = {modal = mb}
|
||||||
|
|
||||||
|
-- {{{ Mouse bindings
|
||||||
|
root.buttons(awful.util.table.join(
|
||||||
|
awful.button({ }, 4, awful.tag.viewnext),
|
||||||
|
awful.button({ }, 5, awful.tag.viewprev)
|
||||||
|
))
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
local function spawnf(cmd) return function() awful.util.spawn(cmd) end end
|
||||||
|
binder.spawn = spawnf
|
||||||
|
|
||||||
|
conf.cmd.run = conf.cmd.run or spawnf("dmenu_run")
|
||||||
|
|
||||||
|
local function use_layout(layout) return function() awful.layout.set(layout) end end
|
||||||
|
layoutmap = {
|
||||||
|
f = { func = use_layout(awful.layout.suit.fair), desc ="Fair" },
|
||||||
|
h = { func = use_layout(awful.layout.suit.fair.horizontal), desc ="Fair Horizontal" },
|
||||||
|
t = { func = use_layout(awful.layout.suit.tile), desc ="Tile" },
|
||||||
|
b = { func = use_layout(awful.layout.suit.tile.bottom), desc ="Tile Bottom" },
|
||||||
|
m = { func = use_layout(awful.layout.suit.max), desc ="Maximized" },
|
||||||
|
F = { func = use_layout(awful.layout.suit.max.fullscreen), desc ="Fullscreen" },
|
||||||
|
Space = { func = use_layout(awful.layout.suit.floating), desc ="Float" }
|
||||||
|
}
|
||||||
|
|
||||||
|
layoutsettings = {
|
||||||
|
l = { func = function () awful.tag.incmwfact( 0.05) end, desc = "Master bigger" },
|
||||||
|
h = { func = function () awful.tag.incmwfact(-0.05) end, desc = "Master smaller" },
|
||||||
|
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" },
|
||||||
|
}
|
||||||
|
|
||||||
|
local default_bindings = awful.util.table.join(
|
||||||
|
awful.key({ modkey, "Control" }, "r", awesome.restart),
|
||||||
|
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
||||||
|
awful.key({ modkey, }, "Return", spawnf(conf.cmd.terminal)),
|
||||||
|
|
||||||
|
awful.key({ modkey, "Control" }, "n", awful.client.restore),
|
||||||
|
awful.key({ modkey, "Shift" }, "n",
|
||||||
|
function()
|
||||||
|
local tag = awful.tag.selected()
|
||||||
|
for i=1, #tag:clients() do
|
||||||
|
awful.client.restore(tag:clients()[i])
|
||||||
|
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
|
||||||
|
|
||||||
|
awful.key({ modkey }, "space", mb.grabf(layoutmap, "Layouts")),
|
||||||
|
awful.key({ modkey, "Control" }, "space", mb.grabf(layoutsettings, "Layout settings", true)),
|
||||||
|
--}}}
|
||||||
|
|
||||||
|
--{{{ Audio control
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioLowerVolume", spawnf("amixer set Master 2%-")),
|
||||||
|
awful.key({ }, "XF86AudioRaiseVolume", spawnf("amixer set Master 2%+")),
|
||||||
|
awful.key({ }, "XF86AudioMute", spawnf("amixer set Master toggle")),
|
||||||
|
|
||||||
|
--}}}
|
||||||
|
|
||||||
|
--{{{ Prompt
|
||||||
|
|
||||||
|
awful.key({ modkey }, "r", conf.cmd.run),
|
||||||
|
awful.key({ modkey, "Shift" }, "r", menubar.show)
|
||||||
|
--}}}
|
||||||
|
)
|
||||||
|
|
||||||
|
function binder.add_bindings(keys)
|
||||||
|
globalkeys = awful.util.table.join(globalkeys, keys);
|
||||||
|
return binder
|
||||||
|
end
|
||||||
|
|
||||||
|
function binder.add_default_bindings()
|
||||||
|
return binder.add_bindings(default_bindings)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function binder.apply()
|
||||||
|
root.keys(globalkeys)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function client_opacity_set(c, default, max, step)
|
||||||
|
if c.opacity < 0 or c.opacity > 1 then
|
||||||
|
c.opacity = default
|
||||||
|
end
|
||||||
|
|
||||||
|
if c.opacity * step < (max-step) * step then
|
||||||
|
c.opacity = c.opacity + step
|
||||||
|
else
|
||||||
|
c.opacity = max
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local clientkeys = awful.util.table.join(
|
||||||
|
awful.key({ modkey, "Shift" }, "f", function (c) c.fullscreen = not c.fullscreen end),
|
||||||
|
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
|
||||||
|
awful.key({ modkey, }, "f", awful.client.floating.toggle ),
|
||||||
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
|
||||||
|
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
|
||||||
|
awful.key({ modkey, "Shift" }, "h", function (c)
|
||||||
|
awful.client.movetoscreen(c, mouse.screen - 1)
|
||||||
|
end),
|
||||||
|
awful.key({ modkey, "Shift" }, "l", function (c)
|
||||||
|
awful.client.movetoscreen(c, mouse.screen + 1)
|
||||||
|
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" }, "r", function (c) c:redraw() end),
|
||||||
|
awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
|
||||||
|
awful.key({ modkey, }, "b", function (c) c.border_width = c.border_width > 0 and 0 or beautiful.border_width end),
|
||||||
|
awful.key({ modkey, }, "Up", function(c) client_opacity_set(c, 1, 1, 0.1) end),
|
||||||
|
awful.key({ modkey, }, "Down", function(c) client_opacity_set(c, 1, 0, -0.1) end),
|
||||||
|
awful.key({ }, "XF86Calculater", awful.client.movetoscreen )
|
||||||
|
)
|
||||||
|
|
||||||
|
local clientbuttons = awful.util.table.join(
|
||||||
|
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
||||||
|
awful.button({ modkey }, 1, awful.mouse.client.move),
|
||||||
|
awful.button({ modkey }, 3, awful.mouse.client.resize))
|
||||||
|
|
||||||
|
binder.client = {}
|
||||||
|
|
||||||
|
function binder.client.buttons()
|
||||||
|
return clientbuttons
|
||||||
|
end
|
||||||
|
|
||||||
|
function binder.client.keys()
|
||||||
|
return clientkeys
|
||||||
|
end
|
||||||
|
|
||||||
|
function binder.client.add_buttons(buttons)
|
||||||
|
clientbuttons = awful.util.table.join(clientbuttons, buttons);
|
||||||
|
end
|
||||||
|
|
||||||
|
function binder.client.add_bindings(keys)
|
||||||
|
clientkeys = awful.util.table.join(clientkeys, keys);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return binder
|
||||||
|
-- vim: set fenc=utf-8 tw=80 foldmethod=marker :
|
|
@ -1,7 +1,6 @@
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local conf = conf
|
local conf = conf
|
||||||
local mb = require("modalbind")
|
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
|
|
||||||
local log = log
|
local log = log
|
Loading…
Reference in a new issue