File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ # Bring a just-focused window onto the active Space and stay there.
3+ #
4+ # `yabai -m window --space mouse` alone loses two races:
5+ # 1. macOS still auto-swooshes to the window's old (now empty) Space
6+ # 2. with a second display, `mouse` may be the other screen
7+ #
8+ # YABAI_WINDOW_ID is set by the window_focused signal.
9+
10+ export PATH=" /opt/homebrew/bin:/usr/bin:/bin"
11+
12+ win=" ${YABAI_WINDOW_ID:- } "
13+ [ -n " $win " ] || exit 0
14+
15+ dest=$( yabai -m query --spaces --space | jq -r ' .index' )
16+ ws=$( yabai -m query --windows --window " $win " | jq -r ' .space' )
17+
18+ # Already on the Space we're working on (click / Cmd-Tab same Space).
19+ [ " $ws " = " $dest " ] && exit 0
20+
21+ yabai -m window " $win " --space " $dest " 2> /dev/null
22+ yabai -m space --focus " $dest " 2> /dev/null
23+ yabai -m window --focus " $win " 2> /dev/null
24+
25+ # Auto-swoosh can finish after this signal; re-assert the destination.
26+ (
27+ sleep 0.15
28+ yabai -m space --focus " $dest " 2> /dev/null
29+ yabai -m window --focus " $win " 2> /dev/null
30+ ) &
You can’t perform that action at this time.
0 commit comments