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

Add <SPACE_SEL> to yabai -m space --move #127

Closed
sweenu opened this issue Jul 14, 2019 · 4 comments
Closed

Add <SPACE_SEL> to yabai -m space --move #127

sweenu opened this issue Jul 14, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@sweenu
Copy link

sweenu commented Jul 14, 2019

Feature request

I'd like to be able to swap the focused space with any other space (not only previous and next space).

Maybe another, more portable solution would be to have a --swap <SPACE_SEL> <SPACE_SEL> option that swaps any two spaces.

Let me know what you think :)

@dominiklohmann
Copy link
Collaborator

dominiklohmann commented Jul 14, 2019

I think this is a good idea, and swap should be a separate thing as well. Note though that these are different operations:

  • Move 4 to 1: 1 2 3 44 1 2 3
  • Swap 4 to 1: 1 2 3 44 2 3 1

Also it only needs to accept one space selector, as you can always set the optional space selector before the command.

As a workaround for move, you can use this script.

Edit Updated the script at 21:30 CEST to be more robust.

#! /usr/bin/env zsh

# invoke like this: path/to/script [from-selector] to-selector
# examples: 
# - move current space to end: path/to/script last
# - move 2nd space to previous: path/to/script 2 prev

index_from_sel() {
	yabai -m query --spaces --space $@ \
		| jq -re '.index'
}

if [ $# -eq 1 ]; then
	from_sel="$(index_from_sel)"
	to_sel="$(index_from_sel $1)"
elif [ $# -eq 2 ]; then
	from_sel="$(index_from_sel $1)"
	to_sel="$(index_from_sel $2)"
else
	exit 1
fi
	
if [ $to_sel -lt $from_sel ]; then
	direction="prev"
elif [ $to_sel -gt $from_sel ]; then
	direction="next"
else
	exit 1
fi

seq $from_sel $to_sel \
	| sed '$d' \
	| xargs -I{} yabai -m space {} --move $direction

@koekeishiya koekeishiya added the suggestion Request for new feature or some form of enhancement label Jul 14, 2019
@koekeishiya
Copy link
Owner

Implemented partial support for this - not sure if I want to deal with the complexity of allowing move across display boundaries..

--move <SPACE_SEL>
  Move position of the selected space to the position of the given space. 
  The selected space and given space must both belong to the same display.

@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label Feb 13, 2020
koekeishiya added a commit that referenced this issue Feb 13, 2020
@koekeishiya
Copy link
Owner

There is also a new command yabai -m space --swap SPACE_SEL which will swap the position of the selected space and the given space. Same caveat as with move - both the selected space and the given space must belong to the same display.

--swap <SPACE_SEL>
    Swap the selected space with the given space. 
    The selected space and given space must both belong to the same display.

@koekeishiya koekeishiya added enhancement New feature or request and removed suggestion Request for new feature or some form of enhancement labels Feb 13, 2020
koekeishiya added a commit that referenced this issue Feb 13, 2020
koekeishiya added a commit that referenced this issue Feb 13, 2020
@koekeishiya
Copy link
Owner

I experimented a bit with allowing swap across displays because it seemed like a useful feature, but there is just a whole bunch of complexity that it was hard to get it working correctly in every possible scenario. Leaving it with the constraint of spaces having to belong to the same display for now. Part of v2.3.0

@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Feb 14, 2020
JDKardia pushed a commit to JDKardia/yabai that referenced this issue Apr 7, 2023
JDKardia pushed a commit to JDKardia/yabai that referenced this issue Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants