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: on-focus-changed callback #230

Closed
nikitabobko opened this issue May 17, 2024 · 6 comments
Closed

Feature: on-focus-changed callback #230

nikitabobko opened this issue May 17, 2024 · 6 comments

Comments

@nikitabobko
Copy link
Owner

AeroSpace already has two callbacks: on-window-detected and exec-on-workspace-changed

It'd be cool to have one more callback to track when the focus changes

@garo
Copy link

garo commented Jun 10, 2024

I have another use case where this would probably be useful: I'd like to define a minimum window size for some applications, so that on-focus event would enlarge the app window to be at least the defined minimum size. I guess this would also require an additional command or an option to resize command to support the at-least principle.

@nikitabobko
Copy link
Owner Author

@garo why can't you use on-window-detected for that? Set the minimum size once and don't touch it anymore

@garo
Copy link

garo commented Jun 10, 2024

@garo why can't you use on-window-detected for that? Set the minimum size once and don't touch it anymore

I have this especially with how I'm using Slack: I like to keep Slack in one Workspace together with a browser and I'm often shrinking Slack to have more space for the browser. Then when I do focus Slack I'd like it to grow bigger. I've just switched from Amethyst and that somehow supported this out-of-the-box and I noticed I'm missing this feature. I figured out I probably could emulate this with the hypotechical on-focus callback and move command.

@nikitabobko
Copy link
Owner Author

Implemented in 0.13.0-Beta

@tobiasgiese
Copy link

tobiasgiese commented Aug 1, 2024

@nikitabobko using on-focus-changed in combination with aerospace list-windows --workspace $ws is pretty slow as it uses alot of resources.
My current implementation is:

.aerospace.toml

on-focus-changed = [
    'exec-and-forget sketchybar --trigger aerospace_workspace_change FOCUS_CHANGE=true'
]

my event script:

if [[ "$FOCUS_CHANGE" == "true" ]]; then
    FOCUSED_WORKSPACE="$(aerospace list-workspaces --focused)"
    if [[ "$NAME" = "space.$FOCUSED_WORKSPACE" ]]; then
        rewriteSketchybar "$FOCUSED_WORKSPACE"
    fi
fi

Is it maybe possible to add the focused workspace to every event? This would reduce alot of aerospace queries.
Also the focused monitor would be helpful. WDYT?

@nikitabobko
Copy link
Owner Author

Is it maybe possible to add the focused workspace to every event? This would reduce alot of aerospace queries.
Also the focused monitor would be helpful. WDYT?

Yes, that makes sense. I planned to expose it to the callbacks as an environment variable. Feel free to open a tracking issue for it

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