awesomewm/bindings.lua

159 lines
4.9 KiB
Lua
Raw Normal View History

2013-04-13 15:17:09 +00:00
-- key bindings
local awful = awful
local conf = conf
local mpd = require("mpd")
2013-04-13 15:17:09 +00:00
local obvious = {}
local scratch = require("scratch")
obvious.popup_run_prompt = require("obvious.popup_run_prompt")
local modkey = conf.modkey or "Mod4"
local mb = require("modalbind")
local bindings = {mb = mb}
2010-06-06 02:56:07 +00:00
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}
2013-04-13 15:17:09 +00:00
local function spawnf(cmd) return function() awful.util.spawn(cmd) end end
2012-03-15 08:02:06 +00:00
mpdmap = {
name = "MPD",
m = mpd.ctrl.toggle,
n = mpd.ctrl.next,
N = mpd.ctrl.prev,
2013-04-13 15:17:09 +00:00
s = spawnf("mpd"),
S = spawnf("mpd --kill"),
g = spawnf(conf.cmd.mpd_client)
}
mpdpromts = {
name = "MPD PROMPTS",
a = mpd.prompt.artist,
A = mpd.prompt.album,
t = mpd.prompt.title,
r = mpd.prompt.toggle_replace_on_search,
}
progmap = {
name = "PROGRAMS",
2013-04-13 15:17:09 +00:00
f = spawnf(conf.cmd.browser),
i = spawnf(conf.cmd.im_client),
I = spawnf(conf.cmd.irc_client),
m = spawnf(conf.cmd.mail_client)
}
2013-04-13 15:17:09 +00:00
adapters = { u = "wwan", w = "wlan", b = "bluetooth" }
function rfkill(cmd)
map={ name = string.upper(cmd) }
for key, adapter in pairs(adapters) do
map[key] = spawnf("sudo rfkill "..cmd.." "..adapter)
end
print(map["name"])
return map
end
-- wirelessmap = {
-- name = "RFKILL",
-- b = function () mb.grab(rfkill("block")) end,
-- u = function () mb.grab(rfkill("unblock")) end
-- }
2013-04-13 15:17:09 +00:00
function bindings.extend_and_register_key_table(globalkeys)
local totalkeys = globalkeys or {}
totalkeys = awful.util.table.join(totalkeys,
awful.key({ }, "Menu", spawnf('wmselect')),
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Shift" }, "q", awesome.quit),
2013-04-13 15:17:09 +00:00
awful.key({ modkey, }, "Return", spawnf(conf.cmd.terminal)),
--{{{ Modal mappings
awful.key({ modkey }, "m", function () mb.grab(mpdmap, true) end),
awful.key({ modkey, "Shift" }, "m", function () mb.grab(mpdpromts) end),
awful.key({ modkey }, "c", function () mb.grab(progmap) end),
2013-04-13 15:17:09 +00:00
awful.key({ modkey }, "w", function () mb.grab(wirelessmap) end),
--}}}
--{{{ Audio control
2013-04-13 15:17:09 +00:00
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),
2011-12-01 12:02:59 +00:00
--}}}
-- {{{ teardrops
2013-04-13 15:17:09 +00:00
awful.key({ }, "F12", function ()
scratch.drop(conf.cmd.terminal,"center","center", 0.99, 0.7)
end ),
awful.key({ modkey }, "`", function ()
scratch.drop("urxvtc -e ncmpcpp","bottom","center", 0.99, 0.4)
end ),
awful.key({ }, "Print", function ()
scratch.drop("galsamixer","top","center", 0.99, 0.4)
end ),
-- }}}
--{{{ Prompt
2013-04-13 15:17:09 +00:00
awful.key({ modkey }, "r", spawnf("dmenu_run")),
awful.key({ modkey }, "s", spawnf("dmsearch")),
--}}}
--{{{ misc. XF86 Keys
2011-12-01 12:02:59 +00:00
2013-04-13 15:17:09 +00:00
awful.key({ }, "XF86Sleep", spawnf("s2ram")),
awful.key({ }, "XF86Away", spawnf("xlock")),
awful.key({ }, "XF86TouchpadToggle", spawnf("touchpad"))
)
2011-12-01 12:02:59 +00:00
--}}}
2013-04-13 15:17:09 +00:00
-- Set keys
root.keys(totalkeys)
end
2010-06-06 02:56:07 +00:00
2012-03-06 07:47:26 +00:00
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
2010-06-06 02:56:07 +00:00
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),
2011-04-06 00:09:56 +00:00
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
awful.key({ modkey, "Control" }, "o", function (c) c.ontop = not c.ontop end),
2010-06-06 02:56:07 +00:00
awful.key({ modkey, }, "a", function (c) c.sticky = not c.sticky end),
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
2011-04-06 00:09:56 +00:00
awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
2012-03-06 07:47:26 +00:00
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),
2011-04-06 00:09:56 +00:00
awful.key({ }, "XF86Calculater", awful.client.movetoscreen )
2010-06-06 02:56:07 +00:00
)
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))
2013-04-13 15:17:09 +00:00
return bindings
-- vim: set fenc=utf-8 tw=80 foldmethod=marker :