diff --git a/awesome/keys.lua b/awesome/keys.lua index 426cb84..c03b2e9 100644 --- a/awesome/keys.lua +++ b/awesome/keys.lua @@ -24,6 +24,37 @@ local modkey = "Mod4" -- define module table local keys = {} +-- AwesomeWM Vim Tmux Navigator + +local focus_bydirection = function(direction) + awful.client.focus.global_bydirection(direction) + if client.focus then + -- focus on the client + client.focus:raise() + end + + -- BUG: focus across screens is wonky when there are no clients on the destination screen + -- https://github.com/awesomeWM/awesome/issues/3638 + -- Workaround: manually unfocus client after moving focus to an empty screen + local is_empty_destination = #awful.screen.focused().clients < 1 + + if is_empty_destination then + -- manually unfocus the current focused client + client.focus = nil + end +end + +require("awesomewm-vim-tmux-navigator") { + up = {"Up", "k"}, + down = {"Down", "j"}, + left = {"Left", "h"}, + right = {"Right", "l"}, + mod = "Mod4", + mod_keysym = "Super_L", + experimental = true, + focus = focus_bydirection +} + -- =================================================================== -- Movement Functions (Called by some keybinds) diff --git a/awesome/rc.lua b/awesome/rc.lua index 12d241f..e224b5e 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -132,16 +132,6 @@ screen.connect_signal("property::geometry", awesome.restart) collectgarbage("setpause", 110) collectgarbage("setstepmul", 1000) -require("awesomewm-vim-tmux-navigator") { - up = {"Up", "k"}, - down = {"Down", "j"}, - left = {"Left", "h"}, - right = {"Right", "l"}, - mod = "Mod4", - mod_keysym = "Super_L", - experimental = true -} - local function move_mouse_onto_focused_client() local c = client.focus if c then