Skip to content

Is it possible to have a window come to my current space when called? #1939

Answered by brorbw
joshstobbs asked this question in Q&A
Discussion options

You must be logged in to vote

The manual man yabai and jq is very helpful when making custom queries and behavior. The below code summons Spotify to the current space. I can be saved as a script ~/config/yabai-scripts/summon-spotify-to-current-space.sh, make it executable and invoke it from skhd with your chosen shortcut.

readonly WINDOW_NAME="Spotify"
readonly CURRENT_SPACE=$(yabai -m query --spaces | jq '.[] | select(."has-focus" == true).index')
readonly TARGET_WINDOW=$(yabai -m query --windows | jq "map(select(.title == \"$WINDOW_NAME\"))[-1].id")
yabai -m window --focus $TARGET_WINDOW
yabai -m window --space $CURRENT_SPACE
sleep 0.1
yabai -m window --focus $TARGET_WINDOW

yabai can be quite annoying when switching…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@koekeishiya
Comment options

Answer selected by koekeishiya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants