From 3b040ad1e42682c8865df876027162811a37a4ea Mon Sep 17 00:00:00 2001 From: ngoomie Date: Mon, 22 May 2023 23:12:23 -0600 Subject: [PATCH] reorganize bindings --- .../keys/client.lua} | 18 +++----- .../keys/global.lua} | 44 +++++++------------ .../bindtotags.lua => bindings/keys/tags.lua} | 24 ++++------ .../mouse/client.lua} | 27 +++++------- .../mouse/global.lua} | 17 +++---- awesome/rc.lua | 26 +++++------ 6 files changed, 60 insertions(+), 96 deletions(-) rename awesome/{binding/clientkeys.lua => bindings/keys/client.lua} (87%) rename awesome/{binding/globalkeys.lua => bindings/keys/global.lua} (87%) rename awesome/{binding/bindtotags.lua => bindings/keys/tags.lua} (87%) rename awesome/{binding/clientbuttons.lua => bindings/mouse/client.lua} (64%) rename awesome/{binding/globalbuttons.lua => bindings/mouse/global.lua} (55%) diff --git a/awesome/binding/clientkeys.lua b/awesome/bindings/keys/client.lua similarity index 87% rename from awesome/binding/clientkeys.lua rename to awesome/bindings/keys/client.lua index 9ea8014..9c9fe26 100644 --- a/awesome/binding/clientkeys.lua +++ b/awesome/bindings/keys/client.lua @@ -1,18 +1,12 @@ --- Standard Awesome library +--- awesome stdlib local gears = require("gears") local awful = require("awful") --- Custom Local Library --- local titlebar = require("anybox.titlebar") local _M = {} local modkey = RC.vars.modkey - -local cyclefocus = require('cyclefocus') - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +------------------ function _M.get() - local clientkeys = gears.table.join( + local client_keys = gears.table.join( awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen @@ -60,9 +54,7 @@ function _M.get() -- {description = "cycle through clients from the same screen and tag", group = "client"}) ) - return clientkeys + return client_keys end - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +------------------ return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) diff --git a/awesome/binding/globalkeys.lua b/awesome/bindings/keys/global.lua similarity index 87% rename from awesome/binding/globalkeys.lua rename to awesome/bindings/keys/global.lua index 13e9a6f..b55eaa4 100644 --- a/awesome/binding/globalkeys.lua +++ b/awesome/bindings/keys/global.lua @@ -1,22 +1,17 @@ --- Standard awesome library +--- awesome stdlib local gears = require("gears") local awful = require("awful") --- local hotkeys_popup = require("awful.hotkeys_popup").widget +--- others local hotkeys_popup = require("awful.hotkeys_popup") --- Menubar library local menubar = require("menubar") - --- Resource Configuration +--- resource configuration local modkey = RC.vars.modkey local terminal = RC.vars.terminal local _M = {} - - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +------------------ function _M.get() - local globalkeys = gears.table.join( + local global_keys = gears.table.join( awful.key({ modkey, }, "s", hotkeys_popup.show_help, {description="show help", group="awesome"}), @@ -121,30 +116,25 @@ function _M.get() -- Resize --awful.key({ modkey, "Control" }, "Left", function () awful.client.moveresize( 20, 20, -40, -40) end), --awful.key({ modkey, "Control" }, "Right", function () awful.client.moveresize(-20, -20, 40, 40) end), - awful.key({ modkey, "Control" }, "Down", + awful.key({ modkey, "Control" }, "Down", function () awful.client.moveresize( 0, 0, 0, -20) end), - awful.key({ modkey, "Control" }, "Up", + awful.key({ modkey, "Control" }, "Up", function () awful.client.moveresize( 0, 0, 0, 20) end), - awful.key({ modkey, "Control" }, "Left", + awful.key({ modkey, "Control" }, "Left", function () awful.client.moveresize( 0, 0, -20, 0) end), - awful.key({ modkey, "Control" }, "Right", + awful.key({ modkey, "Control" }, "Right", function () awful.client.moveresize( 0, 0, 20, 0) end), -- Move - awful.key({ modkey, "Shift" }, "Down", + awful.key({ modkey, "Shift" }, "Down", function () awful.client.moveresize( 0, 20, 0, 0) end), - awful.key({ modkey, "Shift" }, "Up", + awful.key({ modkey, "Shift" }, "Up", function () awful.client.moveresize( 0, -20, 0, 0) end), - awful.key({ modkey, "Shift" }, "Left", + awful.key({ modkey, "Shift" }, "Left", function () awful.client.moveresize(-20, 0, 0, 0) end), - awful.key({ modkey, "Shift" }, "Right", + awful.key({ modkey, "Shift" }, "Right", function () awful.client.moveresize( 20, 0, 0, 0) end), - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -- Menubar - --awful.key({ modkey }, "p", function() menubar.show() end, - -- {description = "show the menubar", group = "launcher"}) - awful.key({ modkey, }, "p", function() awful.util.spawn("rofi -show combi -modes combi,filebrowser -combi-modes \"drun,filebrowser,run\"") end, {description = "open rofi runner", group = "launcher"}), @@ -154,9 +144,7 @@ function _M.get() {description = "scrot", group = "launcher"}) ) - return globalkeys + return global_keys end - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) +------------------ +return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) \ No newline at end of file diff --git a/awesome/binding/bindtotags.lua b/awesome/bindings/keys/tags.lua similarity index 87% rename from awesome/binding/bindtotags.lua rename to awesome/bindings/keys/tags.lua index a7f9851..329f4ce 100644 --- a/awesome/binding/bindtotags.lua +++ b/awesome/bindings/keys/tags.lua @@ -1,21 +1,17 @@ --- Standard awesome library +--- awesome stdlib local gears = require("gears") local awful = require("awful") local _M = {} local modkey = RC.vars.modkey - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - --- {{{ Key bindings - -function _M.get(globalkeys) +------------------ +function _M.get(global_keys) -- 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. for i = 1, 9 do - globalkeys = gears.table.join(globalkeys, - + global_keys = gears.table.join(global_keys, + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- View tag only. awful.key({ modkey }, "#" .. i + 9, @@ -39,7 +35,7 @@ function _M.get(globalkeys) end end, {description = "toggle tag #" .. i, group = "tag"}), - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Move client to tag. awful.key({ modkey, "Shift" }, "#" .. i + 9, @@ -52,7 +48,7 @@ function _M.get(globalkeys) end end, {description = "move focused client to tag #"..i, group = "tag"}), - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Toggle tag on focused client. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, @@ -70,10 +66,8 @@ function _M.get(globalkeys) ) end - return globalkeys + return global_keys end -- }}} - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +------------------ return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) diff --git a/awesome/binding/clientbuttons.lua b/awesome/bindings/mouse/client.lua similarity index 64% rename from awesome/binding/clientbuttons.lua rename to awesome/bindings/mouse/client.lua index 811a6e3..64a1b32 100644 --- a/awesome/binding/clientbuttons.lua +++ b/awesome/bindings/mouse/client.lua @@ -1,30 +1,25 @@ --- Standard awesome library +--- awesome stdlib local gears = require("gears") local awful = require("awful") local _M = {} -local modkey = RC.vars.modkey - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +------------------ function _M.get() - local clientbuttons = gears.table.join( + local client_buttons = gears.table.join( awful.button({ }, 1, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) - end), + end), + awful.button({ modkey }, 1, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) awful.mouse.client.move(c) - end), + end), + awful.button({ modkey }, 3, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) awful.mouse.client.resize(c) - end) - ) - - return clientbuttons + end)) + return client_buttons end - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) +------------------ +return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) \ No newline at end of file diff --git a/awesome/binding/globalbuttons.lua b/awesome/bindings/mouse/global.lua similarity index 55% rename from awesome/binding/globalbuttons.lua rename to awesome/bindings/mouse/global.lua index 72425e1..52ed6af 100644 --- a/awesome/binding/globalbuttons.lua +++ b/awesome/bindings/mouse/global.lua @@ -1,21 +1,16 @@ --- Standard awesome library +--- awesome stdlib local gears = require("gears") local awful = require("awful") local _M = {} - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +------------------ function _M.get() - local globalbuttons = gears.table.join( + local global_buttons = gears.table.join( awful.button({ }, 3, function () RC.mainmenu:toggle() end), awful.button({ }, 4, awful.tag.viewnext), awful.button({ }, 5, awful.tag.viewprev) ) - - return globalbuttons + return global_buttons end - --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) +------------------ +return setmetatable({}, { __call = function(_, ...) return _M.get(...) end }) \ No newline at end of file diff --git a/awesome/rc.lua b/awesome/rc.lua index 7637e53..3bd239b 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -9,7 +9,7 @@ local awful = require("awful") -- Theme handling library local beautiful = require("beautiful") --- Miscellanous awesome library +-- Miscellaneous awesome library local menubar = require("menubar") RC = {} -- global namespace, on top before require any modules @@ -35,12 +35,12 @@ local main = { } -- Custom Local Library: Keys and Mouse Binding -local binding = { - globalbuttons = require("binding.globalbuttons"), - clientbuttons = require("binding.clientbuttons"), - globalkeys = require("binding.globalkeys"), - bindtotags = require("binding.bindtotags"), - clientkeys = require("binding.clientkeys") +local bindings = { + global_keys = require("bindings.keys.global"), + tags = require("bindings.keys.tags"), + client_keys = require("bindings.keys.client"), + global_buttons = require("bindings.mouse.global"), + client_buttons = require("bindings.mouse.client") } -- {{{ Layouts @@ -72,12 +72,12 @@ menubar.utils.terminal = RC.vars.terminal -- }}} -- {{{ Mouse and Key bindings -RC.globalkeys = binding.globalkeys() -RC.globalkeys = binding.bindtotags(RC.globalkeys) +RC.global_keys = bindings.global_keys() +RC.global_keys = bindings.tags(RC.global_keys) -- Set root -root.buttons(binding.globalbuttons()) -root.keys(RC.globalkeys) +root.buttons(bindings.global_buttons()) +root.keys(RC.global_keys) -- }}} -- Keyboard map indicator and switcher @@ -90,8 +90,8 @@ require("deco.statusbar") -- {{{ Rules -- Rules to apply to new clients (through the "manage" signal). awful.rules.rules = main.rules( - binding.clientkeys(), - binding.clientbuttons() + bindings.client_keys(), + bindings.client_buttons() ) -- }}}