2012-07-06 14:19:54 +02:00
|
|
|
config.keys = {}
|
|
|
|
config.mouse = {}
|
2012-07-14 16:37:32 +02:00
|
|
|
local volume = loadrc("volume", "vbe/volume")
|
2012-07-14 16:46:19 +02:00
|
|
|
local brightness = loadrc("brightness", "vbe/brightness")
|
2012-07-14 21:21:52 +02:00
|
|
|
local keydoc = loadrc("keydoc", "vbe/keydoc")
|
2012-07-16 22:37:45 +02:00
|
|
|
local sharetags = loadrc("sharetags", "vbe/sharetags")
|
2012-07-06 14:19:54 +02:00
|
|
|
|
2012-07-15 00:21:32 +02:00
|
|
|
local function screenshot(client)
|
|
|
|
if not client then
|
|
|
|
client = "root"
|
|
|
|
else
|
|
|
|
client = client.window
|
|
|
|
end
|
|
|
|
local path = awful.util.getdir("config") .. "/screenshots/" ..
|
2012-07-18 21:35:30 +02:00
|
|
|
"screenshot-" .. os.date("%Y-%m-%d--%H:%M:%S") .. ".jpg"
|
|
|
|
awful.util.spawn("import -quality 95 -window " .. client .. " " .. path, false)
|
2012-07-15 00:21:32 +02:00
|
|
|
end
|
|
|
|
|
2012-07-17 10:59:47 +02:00
|
|
|
|
|
|
|
-- Function to toggle a given window to the currently selected and
|
|
|
|
-- focused tag. We need a filter. This function can be used to focus a
|
|
|
|
-- particular window. When the filter is unable to select something,
|
|
|
|
-- we undo previous actions (hence "toggle"). This function returns a
|
|
|
|
-- function that will effectively toggle things.
|
|
|
|
local function toggle_window(filter)
|
|
|
|
local undo = {} -- undo stack
|
|
|
|
local toggle = function()
|
|
|
|
-- "Current" screen
|
|
|
|
local s = client.focus and client.focus.screen or mouse.screen
|
|
|
|
local cl = filter() -- Client to toggle
|
|
|
|
if cl and client.focus ~= cl then
|
|
|
|
-- So, we have a client.
|
|
|
|
if not cl:isvisible() then
|
|
|
|
-- But it is not visible. So we will add it to the current
|
|
|
|
-- tag of the current screen.
|
|
|
|
local t = assert(awful.tag.selected(s))
|
|
|
|
-- Before adding the tag to the client, we should ensure it
|
|
|
|
-- is on the same screen.
|
|
|
|
if s ~= cl.screen then
|
|
|
|
sharetags.tag_move(cl:tags()[1], s)
|
|
|
|
end
|
|
|
|
-- Add our tag to the client
|
|
|
|
undo[#undo + 1] = { cl, t }
|
|
|
|
awful.client.toggletag(t, cl)
|
2012-07-16 22:37:45 +02:00
|
|
|
end
|
2012-07-17 10:59:47 +02:00
|
|
|
|
|
|
|
-- Focus and raise the client
|
2012-07-16 22:37:45 +02:00
|
|
|
if s ~= cl.screen then
|
2012-07-17 10:59:47 +02:00
|
|
|
mouse.screen = cl.screen
|
2012-07-16 22:37:45 +02:00
|
|
|
end
|
2012-07-17 10:59:47 +02:00
|
|
|
client.focus = cl
|
|
|
|
cl:raise()
|
|
|
|
else
|
|
|
|
-- OK, we need to restore the previously pushed window to its
|
|
|
|
-- original state.
|
|
|
|
local i = #undo
|
|
|
|
while i > 0 do
|
|
|
|
local cl, t = unpack(undo[i])
|
|
|
|
-- We only handle visible clients that are attached to the
|
|
|
|
-- appropriate tag. Otherwise, we try the next one.
|
2012-07-18 18:41:50 +02:00
|
|
|
if cl and cl:isvisible() and t.selected and
|
2012-07-17 10:59:47 +02:00
|
|
|
awful.util.table.hasitem(cl:tags(), t) then
|
|
|
|
awful.client.toggletag(t, cl)
|
|
|
|
table.remove(undo, i)
|
|
|
|
return
|
|
|
|
end
|
2012-07-18 18:41:50 +02:00
|
|
|
i = i - 1
|
2012-07-17 10:59:47 +02:00
|
|
|
end
|
|
|
|
-- Clean up...
|
|
|
|
while #undo > 10 do
|
|
|
|
table.remove(undo, 1)
|
2012-07-16 22:37:45 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-07-17 10:59:47 +02:00
|
|
|
return toggle
|
2012-07-16 22:37:45 +02:00
|
|
|
end
|
|
|
|
|
2012-07-17 10:59:47 +02:00
|
|
|
-- Toggle pidgin conversation window
|
|
|
|
local toggle_pidgin = toggle_window(
|
|
|
|
function ()
|
|
|
|
return awful.client.cycle(function(c)
|
|
|
|
return awful.rules.match(c, { class = "Pidgin",
|
|
|
|
role = "conversation" })
|
|
|
|
end)()
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Toggle urgent window
|
|
|
|
local toggle_urgent = toggle_window(awful.client.urgent.get)
|
|
|
|
|
2012-07-25 12:24:28 +02:00
|
|
|
-- Focus a relative screen (similar to `awful.screen.focus_relative`)
|
|
|
|
local function screen_focus(i)
|
|
|
|
local s = awful.util.cycle(screen.count(), mouse.screen + i)
|
|
|
|
local c = awful.client.focus.history.get(s, 0)
|
|
|
|
mouse.screen = s
|
|
|
|
if c then client.focus = c end
|
|
|
|
end
|
|
|
|
|
2012-07-06 14:19:54 +02:00
|
|
|
config.keys.global = awful.util.table.join(
|
2012-07-14 21:21:52 +02:00
|
|
|
keydoc.group("Focus"),
|
2012-07-06 14:19:54 +02:00
|
|
|
awful.key({ modkey, }, "j",
|
|
|
|
function ()
|
|
|
|
awful.client.focus.byidx( 1)
|
2012-07-21 10:54:43 +02:00
|
|
|
if client.focus then
|
|
|
|
client.focus:raise()
|
|
|
|
end
|
2012-07-14 21:21:52 +02:00
|
|
|
end,
|
|
|
|
"Focus next window"),
|
2012-07-06 14:19:54 +02:00
|
|
|
awful.key({ modkey, }, "k",
|
|
|
|
function ()
|
|
|
|
awful.client.focus.byidx(-1)
|
2012-07-21 10:54:43 +02:00
|
|
|
if client.focus then
|
|
|
|
client.focus:raise()
|
|
|
|
end
|
2012-07-14 21:21:52 +02:00
|
|
|
end,
|
|
|
|
"Focus previous window"),
|
2012-07-06 14:19:54 +02:00
|
|
|
awful.key({ modkey, }, "Tab",
|
|
|
|
function ()
|
|
|
|
awful.client.focus.history.previous()
|
|
|
|
if client.focus then
|
|
|
|
client.focus:raise()
|
|
|
|
end
|
2012-07-14 21:21:52 +02:00
|
|
|
end,
|
|
|
|
"Focus previously focused window"),
|
2012-07-17 10:59:47 +02:00
|
|
|
awful.key({ modkey, }, "u", toggle_pidgin,
|
|
|
|
"Toggle Pidgin conversation window"),
|
2012-07-21 10:54:43 +02:00
|
|
|
awful.key({ modkey, "Control" }, "j", function ()
|
2012-07-25 12:24:28 +02:00
|
|
|
screen_focus( 1)
|
2012-07-21 10:54:43 +02:00
|
|
|
end,
|
2012-07-14 21:21:52 +02:00
|
|
|
"Jump to next screen"),
|
2012-07-21 10:54:43 +02:00
|
|
|
awful.key({ modkey, "Control" }, "k", function ()
|
2012-07-25 12:24:28 +02:00
|
|
|
screen_focus(-1)
|
2012-07-21 10:54:43 +02:00
|
|
|
end),
|
2012-07-14 21:21:52 +02:00
|
|
|
|
|
|
|
keydoc.group("Layout manipulation"),
|
|
|
|
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
|
|
|
|
"Increase master-width factor"),
|
|
|
|
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
|
|
|
|
"Decrease master-width factor"),
|
|
|
|
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster( 1) end,
|
|
|
|
"Increase number of masters"),
|
|
|
|
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(-1) end,
|
|
|
|
"Decrease number of masters"),
|
|
|
|
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol( 1) end,
|
|
|
|
"Increase number of columns"),
|
|
|
|
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol(-1) end,
|
|
|
|
"Decrease number of columns"),
|
|
|
|
awful.key({ modkey, }, "space", function () awful.layout.inc(config.layouts, 1) end,
|
|
|
|
"Next layout"),
|
|
|
|
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(config.layouts, -1) end,
|
|
|
|
"Previous layout"),
|
|
|
|
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
|
|
|
|
"Swap with next window"),
|
|
|
|
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
|
|
|
|
"Swap with previous window"),
|
2012-07-06 14:19:54 +02:00
|
|
|
|
2012-07-14 21:21:52 +02:00
|
|
|
keydoc.group("Misc"),
|
2012-07-15 00:21:32 +02:00
|
|
|
|
|
|
|
-- Spawn a terminal
|
2012-07-14 21:21:52 +02:00
|
|
|
awful.key({ modkey, }, "Return", function () awful.util.spawn(config.terminal) end,
|
|
|
|
"Spawn a terminal"),
|
2012-07-06 14:19:54 +02:00
|
|
|
|
2012-07-15 00:21:32 +02:00
|
|
|
-- Screenshot
|
|
|
|
awful.key({}, "Print", screenshot, "Screenshot"),
|
|
|
|
|
2012-07-06 14:19:54 +02:00
|
|
|
-- Restart awesome
|
2012-07-14 21:21:52 +02:00
|
|
|
awful.key({ modkey, "Control" }, "r", awesome.restart, "Restart awesome"),
|
2012-07-07 12:16:21 +02:00
|
|
|
|
|
|
|
-- Multimedia keys
|
2012-07-14 16:46:19 +02:00
|
|
|
awful.key({ }, "XF86MonBrightnessUp", brightness.increase),
|
|
|
|
awful.key({ }, "XF86MonBrightnessDown", brightness.decrease),
|
2012-07-14 16:29:19 +02:00
|
|
|
awful.key({ }, "XF86AudioRaiseVolume", volume.increase),
|
|
|
|
awful.key({ }, "XF86AudioLowerVolume", volume.decrease),
|
2012-07-14 21:21:52 +02:00
|
|
|
awful.key({ }, "XF86AudioMute", volume.toggle),
|
|
|
|
|
|
|
|
-- Help
|
|
|
|
awful.key({ modkey, }, "F1", keydoc.display)
|
2012-07-06 14:19:54 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
config.keys.client = awful.util.table.join(
|
2012-07-14 21:21:52 +02:00
|
|
|
keydoc.group("Window-specific bindings"),
|
|
|
|
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end,
|
|
|
|
"Fullscreen"),
|
|
|
|
awful.key({ modkey, }, "x", function (c) c:kill() end,
|
|
|
|
"Close"),
|
|
|
|
awful.key({ modkey, }, "o", awful.client.movetoscreen, "Move to the other screen"),
|
|
|
|
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle, "Toggle floating"),
|
|
|
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
|
|
|
|
"Switch with master window"),
|
2012-07-16 15:10:44 +02:00
|
|
|
awful.key({ modkey, }, "t", function (c) c:raise() end,
|
|
|
|
"Raise window"),
|
2012-07-16 21:40:13 +02:00
|
|
|
awful.key({ modkey, }, "s", function (c) c.sticky = not c.sticky end,
|
|
|
|
"Stick window"),
|
2012-07-15 17:10:40 +02:00
|
|
|
awful.key({ modkey, }, "i", dbg,
|
2012-07-14 21:21:52 +02:00
|
|
|
"Get client-related information"),
|
2012-07-06 14:19:54 +02:00
|
|
|
awful.key({ modkey, }, "m",
|
|
|
|
function (c)
|
|
|
|
c.maximized_horizontal = not c.maximized_horizontal
|
|
|
|
c.maximized_vertical = not c.maximized_vertical
|
2012-07-14 21:21:52 +02:00
|
|
|
end,
|
2012-07-15 00:21:32 +02:00
|
|
|
"Maximize"),
|
|
|
|
|
|
|
|
|
|
|
|
-- Screenshot
|
|
|
|
awful.key({ modkey }, "Print", screenshot, "Screenshot")
|
2012-07-06 14:19:54 +02:00
|
|
|
)
|
|
|
|
|
2012-07-15 01:02:30 +02:00
|
|
|
keydoc.group("Misc")
|
|
|
|
|
2012-07-06 14:19:54 +02:00
|
|
|
config.mouse.client = 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))
|