2013-04-13 15:17:09 +00:00
|
|
|
-- key bindings
|
2014-08-28 08:58:03 +00:00
|
|
|
local awful = require("awful")
|
2015-02-19 10:06:25 +00:00
|
|
|
local beautiful = beautiful
|
2013-04-13 15:17:09 +00:00
|
|
|
local conf = conf
|
2012-03-15 23:52:06 +00:00
|
|
|
local mpd = require("mpd")
|
2013-04-13 15:17:09 +00:00
|
|
|
local scratch = require("scratch")
|
|
|
|
|
|
|
|
local modkey = conf.modkey or "Mod4"
|
|
|
|
local mb = require("modalbind")
|
2014-08-28 08:58:03 +00:00
|
|
|
local calendar = require("calendar")
|
2013-04-13 15:17:09 +00:00
|
|
|
|
2015-02-19 10:05:49 +00:00
|
|
|
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
|
|
|
|
|
2014-04-25 13:13:31 +00:00
|
|
|
local bindings = {modalbind = mb}
|
2010-06-06 02:56:07 +00:00
|
|
|
|
|
|
|
-- {{{ Mouse bindings
|
|
|
|
root.buttons(awful.util.table.join(
|
2014-04-25 13:13:31 +00:00
|
|
|
awful.button({ }, 4, awful.tag.viewnext),
|
|
|
|
awful.button({ }, 5, awful.tag.viewprev)
|
2010-06-06 02:56:07 +00:00
|
|
|
))
|
|
|
|
-- }}}
|
|
|
|
|
2013-04-13 15:17:09 +00:00
|
|
|
local function spawnf(cmd) return function() awful.util.spawn(cmd) end end
|
2014-04-25 13:13:31 +00:00
|
|
|
bindings.spawnf = spawnf
|
2012-03-15 08:02:06 +00:00
|
|
|
|
2014-01-21 12:20:48 +00:00
|
|
|
conf.cmd.run = conf.cmd.run or spawnf("dmenu_run")
|
|
|
|
|
2012-03-15 23:52:06 +00:00
|
|
|
mpdmap = {
|
2014-04-25 13:13:31 +00:00
|
|
|
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" }
|
2012-03-15 23:52:06 +00:00
|
|
|
}
|
2015-02-19 10:08:26 +00:00
|
|
|
|
2012-03-15 23:52:06 +00:00
|
|
|
mpdpromts = {
|
2014-04-25 13:13:31 +00:00
|
|
|
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" }
|
2012-03-15 23:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
progmap = {
|
2014-04-25 13:13:31 +00:00
|
|
|
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" },
|
2015-02-19 10:08:26 +00:00
|
|
|
m = { func = spawnf(conf.cmd.mail_client), desc = "Mail" },
|
|
|
|
s = { func = spawnf("steam"), desc = "Steam" }
|
2012-03-15 23:52:06 +00:00
|
|
|
}
|
|
|
|
|
2014-01-21 12:20:48 +00:00
|
|
|
docmap = {
|
2015-02-19 10:08:26 +00:00
|
|
|
u = { func = spawnf("docopen ~/doc/uni pdf"), desc = "Uni-Dokumente" },
|
2014-08-19 06:04:42 +00:00
|
|
|
b = { func = spawnf("docopen ~/books pdf epub mobi txt lit html htm"), desc = "Bücher" },
|
2015-02-19 10:08:26 +00:00
|
|
|
t = { func = spawnf("dmtexdoc"), desc = "Texdoc" },
|
|
|
|
j = { func = spawnf("dmjavadoc"), desc = "Javadoc" }
|
2014-01-21 12:20:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:17:10 +00:00
|
|
|
calendarmap = {
|
2014-08-19 06:04:42 +00:00
|
|
|
o = { func = function() calendar:next() end, desc = "Next" },
|
|
|
|
i = { func = function() calendar:prev() end, desc = "Prev" },
|
|
|
|
q = { func = function() calendar:prev() end, desc = "Close" }
|
2014-05-16 16:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
adapters = { u = "wwan", w = "wlan", b = "bluetooth" }
|
2014-04-25 13:13:31 +00:00
|
|
|
local function rfkill(cmd)
|
|
|
|
map = {}
|
2013-04-13 15:17:09 +00:00
|
|
|
for key, adapter in pairs(adapters) do
|
2014-04-25 13:13:31 +00:00
|
|
|
map[key] = { func = spawnf("sudo rfkill "..cmd.." "..adapter), desc = adapter }
|
2013-04-13 15:17:09 +00:00
|
|
|
end
|
|
|
|
return map
|
|
|
|
end
|
2014-01-21 12:20:48 +00:00
|
|
|
|
|
|
|
connectmap = {
|
2014-04-25 13:13:31 +00:00
|
|
|
u = { func = spawnf("umts"), desc = "umts" },
|
|
|
|
w = { func = spawnf("wlanacpi"), desc = "wlan" }
|
2014-01-21 12:20:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 22:25:52 +00:00
|
|
|
wirelessmap = {
|
2014-04-25 13:13:31 +00:00
|
|
|
b = { func = mb.grabf(rfkill("block"),"Block"), desc = "block" },
|
|
|
|
u = { func = mb.grabf(rfkill("unblock"),"Unblock"), desc = "unblock" },
|
|
|
|
c = { func = mb.grabf(connectmap, "Connect"), desc = "connect" }
|
2013-05-01 22:25:52 +00:00
|
|
|
}
|
2012-03-15 23:52:06 +00:00
|
|
|
|
2014-04-25 13:13:31 +00:00
|
|
|
function bindings.extend_key_table(globalkeys)
|
|
|
|
return awful.util.table.join(globalkeys or {},
|
2014-08-19 06:04:42 +00:00
|
|
|
awful.key({ }, "Pause", spawnf('wmselect')),
|
2012-03-15 23:52:06 +00:00
|
|
|
|
|
|
|
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)),
|
2012-03-15 23:52:06 +00:00
|
|
|
|
|
|
|
--{{{ Modal mappings
|
|
|
|
|
2014-04-25 13:13:31 +00:00
|
|
|
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 }, "w", mb.grabf(wirelessmap, "Wifi")),
|
|
|
|
awful.key({ modkey }, "d", mb.grabf(docmap, "Documents")),
|
2012-03-15 23:52:06 +00:00
|
|
|
--}}}
|
|
|
|
|
|
|
|
--{{{ 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")),
|
2012-03-15 23:52:06 +00:00
|
|
|
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
|
|
|
|
|
|
|
--}}}
|
2014-05-16 16:17:10 +00:00
|
|
|
|
2012-03-15 23:52:06 +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 ()
|
2014-01-21 12:20:48 +00:00
|
|
|
scratch.drop("gpms","bottom","center", 0.99, 0.4)
|
2013-04-13 15:17:09 +00:00
|
|
|
end ),
|
|
|
|
awful.key({ }, "Print", function ()
|
2014-01-21 12:20:48 +00:00
|
|
|
scratch.drop("gpulse-mixer","top","center", 0.99, 0.4)
|
2013-04-13 15:17:09 +00:00
|
|
|
end ),
|
2012-03-15 23:52:06 +00:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
--{{{ Prompt
|
|
|
|
|
2014-01-21 12:20:48 +00:00
|
|
|
awful.key({ modkey }, "r", conf.cmd.run),
|
2015-02-19 10:05:49 +00:00
|
|
|
awful.key({ modkey, "Shift" }, "r", menubar.show),
|
2013-04-13 15:17:09 +00:00
|
|
|
|
|
|
|
awful.key({ modkey }, "s", spawnf("dmsearch")),
|
2012-03-15 23:52:06 +00:00
|
|
|
|
|
|
|
--}}}
|
|
|
|
|
|
|
|
--{{{ 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")),
|
2014-05-16 16:17:10 +00:00
|
|
|
awful.key({ }, "XF86TouchpadToggle", spawnf("touchpad")),
|
|
|
|
|
|
|
|
--}}}
|
|
|
|
|
|
|
|
-- calendar {{{
|
|
|
|
awful.key({ modkey }, "y", function() calendar:toggle() end),
|
|
|
|
awful.key({ modkey, "Shift" }, "y", function()
|
|
|
|
calendar.wibox.visible = true
|
|
|
|
mb.grab(calendarmap, "Calendar", true)
|
|
|
|
end)
|
2013-04-13 15:17:09 +00:00
|
|
|
)
|
2011-12-01 12:02:59 +00:00
|
|
|
|
|
|
|
--}}}
|
2013-04-13 15:17:09 +00:00
|
|
|
end
|
|
|
|
|
2010-06-06 02:56:07 +00:00
|
|
|
|
2014-04-25 13:13:31 +00:00
|
|
|
local function client_opacity_set(c, default, max, step)
|
2012-03-06 07:47:26 +00:00
|
|
|
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),
|
2014-05-16 16:17:10 +00:00
|
|
|
awful.key({ modkey, "Shift" }, "a", function (c) c.sticky = not c.sticky end),
|
2010-06-06 02:56:07 +00:00
|
|
|
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),
|
2015-02-19 10:06:25 +00:00
|
|
|
awful.key({ modkey, }, "b", function (c) c.border_width = c.border_width > 0 and 0 or beautiful.border_width 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
|
2012-03-15 23:52:06 +00:00
|
|
|
-- vim: set fenc=utf-8 tw=80 foldmethod=marker :
|