From 09478abd4bdfd0bda0e98f172b4efabe88e4b56e Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 21 Dec 2020 10:54:18 +0530 Subject: made the keybindings more 'modular' and removed some keybindings I didn't need --- awesome/rc.lua | 167 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 88 insertions(+), 79 deletions(-) diff --git a/awesome/rc.lua b/awesome/rc.lua index c958cd81..df8fa4d1 100755 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -240,15 +240,15 @@ end) -- {{{ Mouse bindings root.buttons(gears.table.join( - awful.button({ }, 3, function () mymainmenu:toggle() end), - awful.button({ }, 4, awful.tag.viewnext), - awful.button({ }, 5, awful.tag.viewprev) + awful.button({ }, 3, function () naughty.notify({ title = "Achtung!", text = "You're idling", timeout = 0 }) end), + awful.button({ }, 5, awful.tag.viewnext), + awful.button({ }, 4, awful.tag.viewprev) )) -- }}} -- for window navigation with hjkl -- i.e vim movement keys -navKeys = gears.table.join( +vimNavKeys = gears.table.join( awful.key({ "Mod4" }, "j", function () awful.client.focus.bydirection("down") if client.focus then client.focus:raise() end end), @@ -263,31 +263,9 @@ navKeys = gears.table.join( end) ) --- keybindings to navigate b/w monitors --- uncomment multiMonitorNavKeys in --- globalkeys to enable -multiMonitorNavKeys = gears.table.join( - awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, - {description = "focus the next screen", group = "screen"}), - awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, - {description = "focus the previous screen", group = "screen"}) -) - - - --- {{{ Key bindings -globalkeys = gears.table.join( - navKeys, - -- multiMonitorNavKeys, - awful.key({ modkey, }, "s", hotkeys_popup.show_help, - {description="show help", group="awesome"}), - awful.key({ "Mod1", }, "h", awful.tag.viewprev, - {description = "view previous", group = "tag"}), - awful.key({ "Mod1", }, "l", awful.tag.viewnext, - {description = "view next", group = "tag"}), - awful.key({ "Mod1", }, "Tab", awful.tag.history.restore, - {description = "go back", group = "tag"}), - -- Layout manipulation +-- for manipulating layout with hjkl +-- i.e move windows with vim movement keys +vimLayoutKeys = gears.table.join( awful.key({ "Mod4", "Shift" }, "h", function () awful.client.swap.bydirection("left") end, {description = "move client to the left", group = "client"}), awful.key({ "Mod4", "Shift" }, "j", function () awful.client.swap.bydirection("down") end, @@ -295,64 +273,44 @@ globalkeys = gears.table.join( awful.key({ "Mod4", "Shift" }, "k", function () awful.client.swap.bydirection("up") end, {description = "move client upwards", group = "client"}), awful.key({ "Mod4", "Shift" }, "l", function () awful.client.swap.bydirection("right") end, - {description = "move client to the right", group = "client"}), - - - - + {description = "move client to the right", group = "client"}) +) - awful.key({ "Mod1", }, "u", awful.client.urgent.jumpto, - {description = "jump to urgent client", group = "client"}), - awful.key({ modkey, }, "Tab", - function () - awful.client.focus.history.previous() - if client.focus then - client.focus:raise() - end - end, - {description = "go back", group = "client"}), - - awful.key({ modkey, "Control" }, "r", awesome.restart, - {description = "reload awesome", group = "awesome"}), - awful.key({ modkey, "Shift" }, "q", awesome.quit, - {description = "quit awesome", group = "awesome"}), +layoutKeys = gears.table.join( + awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, + {description = "select next", group = "layout"}), awful.key({ "Mod1", }, "j", function () awful.tag.incmwfact( 0.05) end, {description = "increase master width factor", group = "layout"}), awful.key({ "Mod1", }, "k", function () awful.tag.incmwfact(-0.05) end, - {description = "decrease master width factor", group = "layout"}), - awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster( 1, nil, true) end, - {description = "increase the number of master clients", group = "layout"}), - awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(-1, nil, true) end, - {description = "decrease the number of master clients", group = "layout"}), - awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end, - {description = "increase the number of columns", group = "layout"}), - awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end, - {description = "decrease the number of columns", group = "layout"}), - awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, - {description = "select next", group = "layout"}), - awful.key({ "Mod1", }, "space", function () awful.layout.inc(-1) end, - {description = "select previous", group = "layout"}), - - awful.key({ "Mod1", }, "o", - function () - local c = awful.client.restore() - -- Focus restored client - if c then - c:emit_signal( - "request::activate", "key.unminimize", {raise = true} - ) - end - end, - {description = "restore minimized", group = "client"}), - - -- This launches dmenu - awful.key({ "Mod1" }, "Return", function () awful.spawn.with_shell("dmenu_run") end, - {description = "run prompt", group = "launcher"}) + {description = "decrease master width factor", group = "layout"}) + +-- I don't need these keys since +-- I don't use master and stack layout +-- because it's CRINGE lol +-- awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster( 1, nil, true) end, +-- {description = "increase the number of master clients", group = "layout"}), +-- awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(-1, nil, true) end, +-- {description = "decrease the number of master clients", group = "layout"}), +-- awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end, +-- {description = "increase the number of columns", group = "layout"}), +-- awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end, +-- {description = "decrease the number of columns", group = "layout"}), ) +-- keybindings to navigate b/w monitors +-- uncomment multiMonitorNavKeys in +-- globalkeys to enable +multiMonitorNavKeys = gears.table.join( + awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, + {description = "focus the next screen", group = "screen"}), + awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, + {description = "focus the previous screen", group = "screen"}) +) +-- keybindings to handle clients +-- i.e minimizing, maximizing, hiding, closing windows clientkeys = gears.table.join( awful.key({ modkey, }, "f", function (c) @@ -360,7 +318,7 @@ clientkeys = gears.table.join( c:raise() end, {description = "toggle fullscreen", group = "client"}), - awful.key({ "Mod1", }, "w", function (c) c:kill() end, + awful.key({ "Mod1", }, "w", function (c) c:kill() end, {description = "close", group = "client"}), awful.key({ "Mod1" }, "i", awful.client.floating.toggle , {description = "toggle floating", group = "client"}), @@ -397,6 +355,57 @@ clientkeys = gears.table.join( {description = "(un)maximize horizontally", group = "client"}) ) +-- {{{ Key bindings +globalkeys = gears.table.join( + vimNavKeys, + vimLayoutKeys, + layoutKeys, + -- multiMonitorNavKeys, + awful.key({ modkey, }, "s", hotkeys_popup.show_help, + {description="show help", group="awesome"}), + awful.key({ "Mod1", }, "h", awful.tag.viewprev, + {description = "view previous", group = "tag"}), + awful.key({ "Mod1", }, "l", awful.tag.viewnext, + {description = "view next", group = "tag"}), + awful.key({ "Mod1", }, "Tab", awful.tag.history.restore, + {description = "go back", group = "tag"}), + + + + + awful.key({ "Mod1", }, "u", awful.client.urgent.jumpto, + {description = "jump to urgent client", group = "client"}), + awful.key({ modkey, }, "Tab", + function () + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, + {description = "go back", group = "client"}), + + awful.key({ modkey, "Control" }, "r", awesome.restart, + {description = "reload awesome", group = "awesome"}), + awful.key({ modkey, "Shift" }, "q", awesome.quit, + {description = "quit awesome", group = "awesome"}), + + awful.key({ "Mod1", }, "o", + function () + local c = awful.client.restore() + -- Focus restored client + if c then + c:emit_signal( + "request::activate", "key.unminimize", {raise = true} + ) + end + end, + {description = "restore minimized", group = "client"}) +) + + + + + -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it work on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. -- cgit v1.2.3