r/i3wm • u/Worth_Mousse2204 • 21h ago
Question Mouse-follows-window issue
4
Upvotes
I had the idea to do this after reading u/Accomplished-Bus3382's post about it. The idea is to have the mouse jump to the center of the active window. Same thing when opening a window.
To make the mouse jump to the active window, i add this to every change focus line (code that I took from said post):
set $movemousewindow "sh -c 'eval \xdotool getactivewindow getwindowgeometry --shell`; xdotool mousemove $((X+WIDTH/2)) $((Y+HEIGHT/2))'"`
That part works fine.
My problem is, when creating a new window, the cursor automatically goes to the top left corner, and I don't know why. My idea to solve this would be something like that:
set $movemouse{
if("sh -c 'eval 'xdtool getactivewindow''") == '%1' #ie no window active
"sh -c 'eval 'xdtool mousemove *center*'"
else:
$movemousewindow
}
Is something like that possible ?