koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
23.27k stars 641 forks source link

Request: mouse follow focus command #879

Open aws-nlaquet opened 3 years ago

aws-nlaquet commented 3 years ago

I'd like to disable MFF on all windows by default, but I'd like the behavior to remain on all of my keyboard shortcuts that change which display/window is focused.

I dug though the code a bit (pretty easy to read!) and found the window_manager_center_mouse function. It'd be really cool if I could invoke that function via yabai: something like yabai -m window --center-mouse. I suppose right now what I could do is something like

yabai -m config mouse_follows_focus on; yabai existing command; yabai -m config mouse_follows_focus off;

For my keyboard shortcuts, though that is a bit cumbersome.

aws-nlaquet commented 3 years ago

This was solved pretty easily with the following script:

#!/usr/bin/env bash

yabai -m config mouse_follows_focus on
"$@"
yabai -m config mouse_follows_focus off

Now my .skhdrc looks something like

# ...
shift + cmd - f13 : ~/scripts/follow_focus.sh yabai -m window --space 1
# ...

Am still interested in the command though, since it could clean things up a little bit. But it isn't a super high priority.

WhatisRT commented 3 years ago

I think it would be nice to have that as a third option for mouse_follows_focus, as I think it would be a good default. mouse_follows_focus on can be pretty annoying if some program suddenly decides to have some popup without user action, but an option to always follow the focus if initiated by a yabai command would be pretty useful for me.