From 12a666cbfdfe9cbccfc52b6ecb8fb587e45113cd Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 17 Jul 2022 21:18:00 -0700 Subject: [PATCH] Cleaned up keybinds Closes: #5 --- binds/awesome.lua | 51 ------------ binds/client.lua | 78 ------------------ binds/init.lua | 13 --- binds/layout.lua | 43 ---------- binds/system.lua | 24 ------ binds/tags.lua | 41 --------- core/keybinds.lua | 206 ++++++++++++++++++++++++++++++++++++++++++++++ rc.lua | 5 +- 8 files changed, 208 insertions(+), 253 deletions(-) delete mode 100755 binds/awesome.lua delete mode 100755 binds/client.lua delete mode 100755 binds/init.lua delete mode 100755 binds/layout.lua delete mode 100644 binds/system.lua delete mode 100755 binds/tags.lua create mode 100755 core/keybinds.lua diff --git a/binds/awesome.lua b/binds/awesome.lua deleted file mode 100755 index 985b709..0000000 --- a/binds/awesome.lua +++ /dev/null @@ -1,51 +0,0 @@ -local hotkeys = require("awful.hotkeys_popup") - -return gears.table.join( - awful.key( {"Mod4"}, "s", - hotkeys.show_help, - { - description = "Show help", - group = "Desktop" - } - ), - - awful.key( {"Mod4", "Control", "Shift"}, "r", - awesome.restart, - { - description = "Restart awesome", - group = "Desktop" - } - ), - - awful.key( {"Mod4"}, "r", - function () - awful.screen.focused().mypromptbox:run() - end, - { - description = "Run prompt", - group = "Launcher" - } - ), - - awful.key( {"Mod4"}, "Return", - function () - awful.spawn(config.core.terminal) - end, - - { - description = "Open a terminal", - group = "Launcher" - } - ), - - awful.key( {"Mod4"}, "\\", - function () - awful.spawn(config.core.browser) - end, - - { - description = "Open a browser tab", - group = "Launcher" - } - ) -) diff --git a/binds/client.lua b/binds/client.lua deleted file mode 100755 index 90e914d..0000000 --- a/binds/client.lua +++ /dev/null @@ -1,78 +0,0 @@ -return gears.table.join( - awful.key( {"Mod4"}, "Left", - function () - awful.client.focus.byidx( 1) - end, - { - description = "Focus next", - group = "Client" - } - ), - - awful.key( {"Mod4"}, "Right", - function () - awful.client.focus.byidx(-1) - end, - { - description = "Focus previous", - group = "Client" - } - ), - - awful.key( {"Mod4", "Shift"}, "j", - function () - awful.client.swap.byidx(1) - end, - { - description = "Swap with next window", - group = "Client" - } - ), - - awful.key( {"Mod4", "Shift"}, "k", - function () - awful.client.swap.byidx(-1) - end, - { - description = "Swap with previous window", - group = "Client" - } - ), - - awful.key( {"Mod4"}, "u", - awful.client.urgent.jumpto, - { - description = "Jump to urgent window", - group = "Client" - } - ), - - awful.key( {"Mod4"}, "b", - function () - awful.client.focus.history.previous() - if client.focus then - client.focus:raise() - end - end, - { - description = "Go back", - group = "Client" - } - ), - - awful.key( {"Mod4", "Control"}, "n", - 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" - } - ) -) diff --git a/binds/init.lua b/binds/init.lua deleted file mode 100755 index 3b422d6..0000000 --- a/binds/init.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - keys = gears.table.join( - require("binds.system"), - - require("binds.client"), - require("binds.layout"), - require("binds.tags"), - - require("binds.awesome") - ), - - buttons = {} -} diff --git a/binds/layout.lua b/binds/layout.lua deleted file mode 100755 index 41e7a2b..0000000 --- a/binds/layout.lua +++ /dev/null @@ -1,43 +0,0 @@ -local layoutmanager = require("core.layouts.layoutmanager") - -return gears.table.join( - awful.key( {"Mod4"}, "+", - function () - awful.tag.incmwfact( 0.05) - end, - { - description = "increase master width factor", - group = "Layout" - } - ), - - awful.key({"Mod4"}, "-", - function () - awful.tag.incmwfact(-0.05) - end, - { - description = "decrease master width factor", - group = "Layout" - } - ), - - awful.key( {"Mod4"}, ",", - function () - layoutmanager:next() - end, - { - description = "select layouts", - group = "Layout" - } - ), - - awful.key( {"Mod4"}, ".", - function () - layoutmanager:next_alt() - end, - { - description = "cycle alt layouts", - group = "Layout" - } - ) -) diff --git a/binds/system.lua b/binds/system.lua deleted file mode 100644 index eef1d4b..0000000 --- a/binds/system.lua +++ /dev/null @@ -1,24 +0,0 @@ -local function shutdown(confirm_prompt) - if (string.lower(confirm_prompt) == "y") or (string.lower(confirm_prompt) == "yes") then - awful.spawn("shutdown now", false) - elseif (string.lower(confirm_prompt) == "r") or (string.lower(confirm_prompt) == "reset") then - awful.spawn("shutdown -r now", false) - end -end - - -return gears.table.join( - awful.key( {"Mod4"}, "p", - function () - awful.prompt.run { - prompt = "Really shutdown? (y/n/r) ", - textbox = awful.screen.focused().mypromptbox.widget, - exe_callback = shutdown - } - end, - { - description = "Shutdown", - group = "System" - } - ) -) diff --git a/binds/tags.lua b/binds/tags.lua deleted file mode 100755 index dea5080..0000000 --- a/binds/tags.lua +++ /dev/null @@ -1,41 +0,0 @@ -return gears.table.join( - awful.key( {"Mod1", "Control"}, "Left", - function () - awful.screen.focused().tagger:left() - end, - { - description = "Left", - group = "Tags" - } - ), - - awful.key( {"Mod1", "Control"}, "Right", - function () - awful.screen.focused().tagger:right() - end, - { - description = "Right", - group = "Tags" - } - ), - - awful.key( {"Mod1", "Control"}, "Up", - function () - awful.screen.focused().tagger:up() - end, - { - description = "Up", - group = "Tags" - } - ), - - awful.key( {"Mod1", "Control"}, "Down", - function () - awful.screen.focused().tagger:down() - end, - { - description = "Down", - group = "Tags" - } - ) -) diff --git a/core/keybinds.lua b/core/keybinds.lua new file mode 100755 index 0000000..580abc7 --- /dev/null +++ b/core/keybinds.lua @@ -0,0 +1,206 @@ +local hotkeys = require("awful.hotkeys_popup") +local layoutmanager = require("core.layouts.layoutmanager") + +local function shutdown(confirm_prompt) + if (string.lower(confirm_prompt) == "y") or (string.lower(confirm_prompt) == "yes") then + awful.spawn("shutdown now", false) + elseif (string.lower(confirm_prompt) == "r") or (string.lower(confirm_prompt) == "reset") then + awful.spawn("shutdown -r now", false) + end +end + +return gears.table.join( + awful.key( {"Mod4"}, "s", + hotkeys.show_help, + { + description = "Show help", + group = "Desktop" + } + ), + + awful.key( {"Mod4", "Control", "Shift"}, "r", + awesome.restart, + { + description = "Restart awesome", + group = "Desktop" + } + ), + + awful.key( {"Mod4"}, "r", + function () + awful.screen.focused().mypromptbox:run() + end, + { + description = "Run prompt", + group = "Launcher" + } + ), + + awful.key( {"Mod4"}, "Return", + function () + awful.spawn(config.core.terminal) + end, + + { + description = "Open a terminal", + group = "Launcher" + } + ), + + awful.key( {"Mod4"}, "\\", + function () + awful.spawn(config.core.browser) + end, + + { + description = "Open a browser tab", + group = "Launcher" + } + ), + + + -- Layouts + awful.key( {"Mod4"}, "+", + function () + awful.tag.incmwfact( 0.05) + end, + { + description = "increase master width factor", + group = "Layout" + } + ), + + awful.key({"Mod4"}, "-", + function () + awful.tag.incmwfact(-0.05) + end, + { + description = "decrease master width factor", + group = "Layout" + } + ), + + awful.key( {"Mod4"}, ",", + function () + layoutmanager:next() + end, + { + description = "select layouts", + group = "Layout" + } + ), + + awful.key( {"Mod4"}, ".", + function () + layoutmanager:next_alt() + end, + { + description = "cycle alt layouts", + group = "Layout" + } + ), + + + -- System + awful.key( {"Mod4"}, "p", + function () + awful.prompt.run { + prompt = "Really shutdown? (y/n/r) ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = shutdown + } + end, + { + description = "Shutdown", + group = "System" + } + ), + + + -- Tags + awful.key( {"Mod1", "Control"}, "Left", + function () + awful.screen.focused().tagger:left() + end, + { + description = "Left", + group = "Tags" + } + ), + + awful.key( {"Mod1", "Control"}, "Right", + function () + awful.screen.focused().tagger:right() + end, + { + description = "Right", + group = "Tags" + } + ), + + awful.key( {"Mod1", "Control"}, "Up", + function () + awful.screen.focused().tagger:up() + end, + { + description = "Up", + group = "Tags" + } + ), + + awful.key( {"Mod1", "Control"}, "Down", + function () + awful.screen.focused().tagger:down() + end, + { + description = "Down", + group = "Tags" + } + ), + + + + -- Clients + awful.key( {"Mod4"}, "Left", + function () + awful.client.focus.byidx( 1) + end, + { + description = "Focus next", + group = "Client" + } + ), + + awful.key( {"Mod4"}, "Right", + function () + awful.client.focus.byidx(-1) + end, + { + description = "Focus previous", + group = "Client" + } + ) + + + --[[ + awful.key( {"Mod4", "Shift"}, "j", + function () + awful.client.swap.byidx(1) + end, + { + description = "Swap with next window", + group = "Client" + } + ), + + awful.key( {"Mod4", "Shift"}, "k", + function () + awful.client.swap.byidx(-1) + end, + { + description = "Swap with previous window", + group = "Client" + } + ) + --]] +) diff --git a/rc.lua b/rc.lua index e7e252a..4abf45e 100755 --- a/rc.lua +++ b/rc.lua @@ -28,9 +28,8 @@ beautiful.init(require("theme")) -- Load key bindings -local binds = require("binds") -local keys = binds.keys -local buttons = binds.buttons +local keys = require("core.keybinds") +local buttons = {} -- Load modules