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

Feature Request: Add command to focus window by id #173

Closed
refnode opened this issue Mar 1, 2024 · 4 comments
Closed

Feature Request: Add command to focus window by id #173

refnode opened this issue Mar 1, 2024 · 4 comments

Comments

@refnode
Copy link

refnode commented Mar 1, 2024

👍 have read the docs
👍 have searched for existing issues

I'm testing to switch from the yabai/skhd combination to aerospace.

As I work with a 49" screen now for years, I typically have three windows in 30/40/30% or two 50/50 on a virtual screen. My normal behaviour is to have shortcuts for my most important applications like browser, terminal, chat, ... and to switch directly to that window.

I handled this in the past with the Hammerspoon launch or focus API https://www.hammerspoon.org/docs/hs.application.html and with yabai/skhd it was possible to query yabai with json output and to wrap some cmdc into a script triggered by skhd, see given example.

#!/bin/sh

APP="$1"

TARGET=$(yabai -m query --windows | jq '.[] | "\(.id);\(.app)"' | grep "$APP" | sed -e 's/"//g')

if [ "z" != "z$TARGET" ]; then
    TARGET_ID=$(echo $TARGET | cut -d';' -f1)
    TARGET_APP=$(echo $TARGET | cut -d';' -f2)
    yabai -m window --focus "$TARGET_ID"
else
    open -n -a "$APP.app"
fi

It would be great to have a subcmd in aerospace to focus an application with a given id.

Thanks in advance.

@nikitabobko
Copy link
Owner

I agree that it'd be nice to be able to focus windows by window-id or app-id

My proposal is:

aerospace focus-window [--window-id <window-id>] [--app-id <app-id>]

In the future, it may be even improved to add options like [--window-title <window-title-regex-substring>] [--dialog]

@nikitabobko nikitabobko changed the title Feature Request: Add subcmd to focus a window Feature Request: Add command to focus window by id Mar 3, 2024
@refnode
Copy link
Author

refnode commented Mar 3, 2024

Sounds great, with your proposed Cli the skhd style window focusing is possible.

@nikitabobko
Copy link
Owner

Fixed in 0.10.0. focus command now accepts --window-id option

@refnode
Copy link
Author

refnode commented Apr 23, 2024

Hey thank you! Works like a charm.

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