How to set focus on client under mouse cursor when tag changes?
When I switch to another tag a new client is selected, but sometimes I am not a client, I have a mouse pointer. To focus on the client under my mouse pointer, I need to either click on it, switch to it with Mod4+ j / k, or bring my mouse cursor back and forth on that client.
I want it to be amazing to focus on the client that is under the mouse cursor when the tag changes. How to do it?
I found the mouse.object_under_pointer () function that finds the client I want, but I don't know when to call that function. Should I attach a handler to a specific signal? I tried to connect to various signals from the Signals wiki page and check with help naughty.notify()
if this is the correct signal, but none of them were called when I switched between tags.
source to share
This code did the trick, however there must be a better way to do it than setting a huge 200ms timer (smaller timeouts didn't get me focused on some clients, but you can try setting a smaller one).
tag.connect_signal( "property::selected", function (t) local selected = tostring(t.selected) == "false" if selected then local focus_timer = timer({ timeout = 0.2 }) focus_timer:connect_signal("timeout", function() local c = awful.mouse.client_under_pointer() if not (c == nil) then client.focus = c c:raise() end focus_timer:stop() end) focus_timer:start() end end )
tag
this global object , so you should just place this code anywhere rc.lua
.
source to share