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

Return non-zero exit code when per-space config value cannot be read #69

Closed
dominiklohmann opened this issue Jun 25, 2019 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@dominiklohmann
Copy link
Collaborator

Issue

Currently, querying a per-space config value prints -1 to stdout when there is no value configured and exits successfully.

yabai -m config --space 2 left_padding

Proposed fix

The function should return a non-zero exit code so a fallback value can easily be read by scripts. Error messages should also be printed to stderr.

# currently, this would be -1 instead of the desired value
default_left_padding=$(yabai -m config --space 2 left_padding || yabai -m config left_padding)
@koekeishiya
Copy link
Owner

So the config settings that modify space properties are different from all other settings. Space settings must be set before a space / view is created, and only then are they used.

All other config settings can be modified live at any time and their change will take effect immediately.
I don't like that these space settings differ in that way, and I'd rather try to solve that issue instead.

The reason they are -1 by default, is that is the default value that means this space uses the global space settings, in which I think rather than returning an exit code, or -1, yabai should simply return the global padding value for the given setting. However, this will not be relevant if I handle the underlaying issue that I mentioned before this paragraph.

@koekeishiya koekeishiya added the enhancement New feature or request label Jun 25, 2019
@dominiklohmann
Copy link
Collaborator Author

That's fine by me. I was playing around with a script that increases left and right padding if there's only a single monitor available. The proposed fix is just what came to my mind first.

I don't like that these space settings differ in that way, and I'd rather try to solve that issue instead.

Do you think it makes sense to also allow a --display override then? With priority dynamically set > space > display > global?

@koekeishiya
Copy link
Owner

Do you think it makes sense to also allow a --display override then? With priority dynamically set > space > display > global?

Might take a look at this in the future. I think the first step is to store space specific settings internally by using the CGSSpaceId rather than the mission-control index. After this has been resolved, and spaces are working properly - maybe there will be a simple way to extend that to support a display override.

@koekeishiya
Copy link
Owner

koekeishiya commented Jun 25, 2019

All config settings can now be edited at runtime and have their changes reflect immediately, except for status_bar settings.

Edit:

Changing global space settings at runtime will affect all spaces that inherited that value.
Querying space settings will now properly return the actual value for that setting.
Space settings are stored internally at the CGSSpaceId level.

yabai -m config --space 2 top_padding 30
yabai -m config --space 3 top_padding 50

# space 2 is focused, and we move it one to the right so that it swaps places with space 3
yabai -m space --move next

# this will return 50
yabai -m query --space 2 top_padding

# this will return 30
yabai -m query --space 3 top_padding

@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label Jun 25, 2019
@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Jun 25, 2019
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

2 participants