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

Expand query system to allow getting selected attribute only #18

Closed
dominiklohmann opened this issue Jun 3, 2019 · 7 comments
Closed

Comments

@dominiklohmann
Copy link
Collaborator

I'm trying to re-implement chunkc tiling::query --monitor-for-desktop <id> and have done so using text replacements:

yabai -m query --spaces --space 2 | sed -n -e 's/^.*"monitor":\(.*\),/\1/p'

The syntax I'm proposing as a replacement is

yabai -m query --spaces --space 2 monitor

which should return just the monitor id of space 2 (and a newline at the end of the output).

@acmcelwee
Copy link

FWIW, jq is a much simpler way to process the existing query outputs than sed. Example:

$ yabai -m query --spaces --space 2 | jq .monitor
1

@dominiklohmann
Copy link
Collaborator Author

Didn't know jq. Lovely little tool. Thanks!

@koekeishiya
Copy link
Owner

Just for info, I'm going to rename the "monitor" key to "display" to remain consistent with the rest of the program. Not sure how I made that mistake here..

@koekeishiya
Copy link
Owner

Oh and you could also use yabai -m query --displays --space | jq .index to get the display of the active space.

@dominiklohmann
Copy link
Collaborator Author

dominiklohmann commented Jun 3, 2019

On a similar note, I noticed that I can do stuff like this with jq:

# get all known open windows in a "app: window title" format
yabai -m query --windows | jq '.[] | .app + ": " + .title'

# get the space count of all displays
yabai -m query --displays | jq '.[].spaces'

Really amazing tool, makes this stuff so easy once you grok the syntax.

@koekeishiya
Copy link
Owner

On a related note - has anyone looked into how Spotlight works and if it is possible to create custom searchable text and commands for it? As focusing the proper window has now been resolved using the scripting addition, and with the information provided through the query system in yabai I think it would be handy to create a fuzzy-seach mechanism for focusing windows - this could let you filter windows visible on the current space, current display(?) or all known windows, or whatever.

@dominiklohmann
Copy link
Collaborator Author

dominiklohmann commented Jun 3, 2019

There's Flashlight, which basically is an extension to Spotlight, but I'm not sure if it still works. It's never been running smoothly for me, although I've only tried it after it first came out. I since switched back to Alfred—they recently released v4—, which has workflows that are very easy to configure. It's basically Spotlight on steroids and much better in every regard, especially responsiveness.

Edit: Apparently Flashlight is completely broken on macOS Mojave, so scratch that. Alfred is definitely worth the small amount of money it costs, anyways.

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

3 participants