From b6e5feb04a133e572836ceffcf4044e7ac2cb101 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 13 Dec 2016 19:25:18 +0100 Subject: Do not wrap around at edges, implement 2d behavior --- config/awesome/rc.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index 418579f..362786a 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -226,8 +226,8 @@ root.buttons(awful.util.table.join( -- {{{ Key bindings globalkeys = awful.util.table.join( - awful.key({ modkey, }, "Left", awful.tag.viewprev ), - awful.key({ modkey, }, "Right", awful.tag.viewnext ), + --awful.key({ modkey, }, "Left", awful.tag.viewprev ), + --awful.key({ modkey, }, "Right", awful.tag.viewnext ), -- awful.key({ modkey, }, "Escape", awful.tag.history.restore), awful.key({ modkey, }, "j", @@ -294,9 +294,6 @@ globalkeys = awful.util.table.join( awful.key({ "Control", "Mod1"}, "l", function () awful.util.spawn_with_shell("xscreensaver-command -lock") end), - awful.key({ modkey, }, "Up" , function () awful.tag.viewidx(-5) end ), - awful.key({ modkey, }, "Down", function () awful.tag.viewidx( 5) end ), - awful.key({ }, "XF86AudioRaiseVolume", function () awful.util.spawn("amixer -q -D default sset Master 5%+", false) end), awful.key({ }, "XF86AudioLowerVolume", function () @@ -316,6 +313,24 @@ globalkeys = awful.util.table.join( ) -- more weasel + local function viewidx_no_wrap(num_cols, delta_rows, delta_cols) + local screen = mouse.screen + local cur = awful.tag.getidx() + local cc = (cur-1) % num_cols + local jump = delta_rows * num_cols + delta_cols + + if cc + delta_cols >= 0 and cc + delta_cols < num_cols and + cur + jump > 0 and cur + jump <= #tags[screen] then + awful.tag.viewidx(jump) + end + end + globalkeys = awful.util.table.join(globalkeys, + awful.key({ modkey, }, "Left" , function () viewidx_no_wrap (5, 0, -1) end ), + awful.key({ modkey, }, "Right", function () viewidx_no_wrap (5, 0, 1) end ), + awful.key({ modkey, }, "Up" , function () viewidx_no_wrap (5, -1, 0) end ), + awful.key({ modkey, }, "Down" , function () viewidx_no_wrap (5, 1, 0) end ) + ) + local tag_keys = { "1", "2", "3", "4", "5", -- cgit v1.2.3