Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving a window while cycling through spaces #124

Open
maxjowett opened this issue Apr 24, 2020 · 3 comments
Open

Moving a window while cycling through spaces #124

maxjowett opened this issue Apr 24, 2020 · 3 comments

Comments

@maxjowett
Copy link

First, I'd like to say I am really enjoying yabai. I've spent some time tweaking my config and have found myself looking for a solution to move windows without explicitly stating which space first.

For example - I'm currently using the following to loop through spaces with alt + space:

alt - space : yabai -m space --focus "$(yabai -m query --spaces --display \ 0 | jq 'reverse | nth(index(map(select(.focused == 1))) - 1).index')"

Is it possible to select a window, cycle through spaces, and drop it in the active space? This pattern would almost resemble a drag and drop, better yet, select and drop.

Using jq, I'm able to query for the active window id, as far as I know I can't set variables in my skhdrc. Is it possible to store this value somehow? If I could get over this hump I feel like the rest would come together fairly easily.

If I can clarify anything please let me know. It could be that this is simply not possible.

@koekeishiya
Copy link
Owner

as far as I know I can't set variables in my skhdrc. Is it possible to store this value somehow?

I assume what you mean is that you would use one bind to select a window, and then press some other bind to actually perform the move operation?

If that is the case the only option I can think of right now would be to write the window id to some file /tmp/whatever and read that same file back in, when hitting the other bind.

@maxjowett
Copy link
Author

@koekeishiya Thanks for the suggestion. I managed to get the following working:

Extract and store the currently focused window with:
echo $(yabai -m query --windows --window | jq -r '.id') > /tmp/window-id

Move window to focused space, and focus window:
yabai -m window $(cat /tmp/window-id) --space $(yabai -m query --spaces --space | jq -r ' .index') \ && yabai -m window --focus $(cat /tmp/window-id)

🎉

@koekeishiya
Copy link
Owner

koekeishiya commented Apr 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants