Skip to content

Instantly share code, notes, and snippets.

@yuttie
Created June 14, 2011 16:29
Show Gist options
  • Save yuttie/1025271 to your computer and use it in GitHub Desktop.
Save yuttie/1025271 to your computer and use it in GitHub Desktop.
awesome: Key bindings and a function for placing a current window on the specified edge (tested with awesome-3.4.8)
-- Place a window on the specified edge of a screen
function place_window_edge(c, h_pos, v_pos)
local g = c:geometry()
local wa = screen[c.screen].workarea
local max_x = wa.width - g.width
local max_y = wa.height - g.height
g.x = wa.x + (h_pos + 1) * max_x / 2
g.y = wa.y + (v_pos + 1) * max_y / 2
c:geometry(g)
end
clientkeys = awful.util.table.join(
awful.key({ modkey, }, "KP_End", function (c) place_window_edge(c, -1, 1) end),
awful.key({ modkey, }, "KP_Down", function (c) place_window_edge(c, 0, 1) end),
awful.key({ modkey, }, "KP_Next", function (c) place_window_edge(c, 1, 1) end),
awful.key({ modkey, }, "KP_Left", function (c) place_window_edge(c, -1, 0) end),
awful.key({ modkey, }, "KP_Begin", function (c) place_window_edge(c, 0, 0) end),
awful.key({ modkey, }, "KP_Right", function (c) place_window_edge(c, 1, 0) end),
awful.key({ modkey, }, "KP_Home", function (c) place_window_edge(c, -1, -1) end),
awful.key({ modkey, }, "KP_Up", function (c) place_window_edge(c, 0, -1) end),
awful.key({ modkey, }, "KP_Prior", function (c) place_window_edge(c, 1, -1) end)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment