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 command to programatically run all on-window-detected callbacks #107

Open
carlosflorencio opened this issue Jan 8, 2024 · 8 comments

Comments

@carlosflorencio
Copy link

carlosflorencio commented Jan 8, 2024

Hi,

It's possible to have a command that runs all the on-window-detected callbacks?

Use-case:
I have the apps <> workspaces affinities setup like:

# apps to workspaces
[[on-window-detected]]
if.app-id = 'com.microsoft.VSCode'
run = ['move-node-to-workspace 1']

[[on-window-detected]]
if.app-id = 'com.vivaldi.Vivaldi'
run = ['move-node-to-workspace 2']

...

Sometimes I move apps between workspaces and then have the need to reposition them back to the initial workspaces. So it would be useful to have a command like aerospace force-window-detected to run all the rules the move the windows back to their original workspace.

Also a different request/question, it's possible to assign layouts to workspaces in the config file? e.g workspace 1 to start with the h_accordion layout.

@nikitabobko
Copy link
Owner

nikitabobko commented Jan 8, 2024

So it would be useful to have a command like aerospace force-window-detected to run all the rules the move the windows back to their original workspace.

Nice. I like the suggestion. The hardest part here is to come up with a good name for the command

Brainstorming:

  1. force-window-detected (the suggested name)
  2. run-on-window-detected-callbacks
  3. force-run-on-window-detected-callbacks
  4. redetect-windows

Right now, 2 and 3 are my favorite. IMO, they are the most clear. Ideas are welcome

Also a different request/question, it's possible to assign layouts to workspaces in the config file? e.g workspace 1 to start with the h_accordion layout.

Right now. it's not possible, but probably it'd be nice to have. What is your use case?

I'm curious if it were possible to run layout command in on-window-detected callback, would it resolve your issue? (this way you will apply the layout only if the specific window is detected, but maybe it's exactly what you want to, I don't know your use cases)

The hardest part is to come up with a good syntax

Brainstorming:

# (a)
default-root-container-layout = 'tiles'
workspace.1.default-root-container-layout = 'tiles'

# (b)
[default-root-container-layout]
workspace.1 = 'tiles'
workspace.2 = 'accordion'
workspace.all = 'tiles' # 'all' will be a reserved name for workspaces since 0.8.0, anyway

# (c)
[default-root-container-layout]
workspace.1 = 'tiles'
workspace.2 = 'accordion'
other = 'tiles'

@carlosflorencio
Copy link
Author

Regarding the command name, I think the second option is good: run-on-window-detected-callbacks!

Right now. it's not possible, but probably it'd be nice to have. What is your use case?

The use case is to fast switch maximised apps in the same workspace. E.g I like to have a workspace for IDEs where I have multiple instances (different folders/projects opened) and I like a stacked/accordion layout for that.

I'm curious if it were possible to run layout command in on-window-detected callback, would it resolve your issue?

Yes sort of, but when using different apps I would need a rule for each of them to set the layout. It feels more natural to set the layout at the workspace configuration level.

Regarding the syntax, I like your options (a) and (b).
Another approach would be to set the layout also in callback style on-workspace-changed (#87):

[[on-workspace-changed]]
if.workspace-id = '1'
if.during-aerospace-startup = true  # only run this once
run = ['layout h_accordion']

@GraemeARobinson
Copy link
Sponsor

+1 for this feature request

@nikitabobko
Copy link
Owner

Also a different request/question, it's possible to assign layouts to workspaces in the config file? e.g workspace 1 to start with the h_accordion layout.

I just realized that it's already possible with after-startup-command

after-startup-command = [
    'workspace 1', 'layout h_accordion',
    'workspace 2', 'layout h_accordion'
]

@carlosflorencio
Copy link
Author

@nikitabobko yeah nice catch. Just tested and works well :). Could be useful to have an example in the docs as a reminder.

@quulah
Copy link

quulah commented Aug 8, 2024

I'm guessing this combined with after-startup-command might help with the issues I'm having with startup order.

Aerospace, among many other apps, starts automatically. Depending on the order, and I think when Aerospace starts up last, it won't move apps to workspaces nor tile them automatically.

I have to restart many of the applications that end up sadly floating around.

@nikitabobko
Copy link
Owner

it won't move apps to workspaces nor tile them automatically.

@quulah No, it shouldn't matter. Do you have if.during-aerospace-startup = false in your config by any chance?

@quulah
Copy link

quulah commented Aug 8, 2024

Hmm. No, I don't have that. 🤔

My intention is to have a few workspaces with tiling and specific applications assigned to those, and then one without as a dump for everything else.

The config looks like this for (hopefully) the relevant bits:

start-at-login = true
after-startup-command = []
after-login-command = []
default-root-container-layout = 'tiles'
...
# Default - 1
[[on-window-detected]]
if.workspace = '1:default'
check-further-callbacks = true
run = 'layout floating'

[[on-window-detected]]
check-further-callbacks = true
run = 'move-node-to-workspace 1:default'

...

# Messaging - 4
[[on-window-detected]]
if.workspace = '4:messaging'
check-further-callbacks = true
run = 'layout tiling'

[[on-window-detected]]
if.app-id = 'com.tinyspeck.slackmacgap'
run = 'move-node-to-workspace 4:messaging'

[[on-window-detected]]
if.app-id = 'com.microsoft.teams2'
run = 'move-node-to-workspace 4:messaging'

And it sort of works, except for the startup problem. Not sure if I'm doing something too funky. :)

If this seems like something that should work I can open another issue to track that.

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

4 participants