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

Lift limitations in on-window-detected.run #20

Open
nikitabobko opened this issue Nov 19, 2023 · 37 comments
Open

Lift limitations in on-window-detected.run #20

nikitabobko opened this issue Nov 19, 2023 · 37 comments
Labels
problem Neither a bug, nor a feature request triaged The issue makes sense to maintainers

Comments

@nikitabobko
Copy link
Owner

nikitabobko commented Nov 19, 2023

The limitations are:

  • 'layout floating', 'layout tiling' and 'mode-node-to-workspace' are the only commands that are supported in 'on-window-detected'
  • 'move-node-to-workspace' must be the latest instruction in the callback (otherwise it's error-prone)
  • 'move-node-to-workspace' can be mentioned only once in 'run' callback
@nikitabobko nikitabobko changed the title Support exec commands in on-window-detected Support commands other than 'move-node-to-workspace' and 'layout' in on-window-detected Dec 2, 2023
@nikitabobko nikitabobko changed the title Support commands other than 'move-node-to-workspace' and 'layout' in on-window-detected Support commands other than move-node-to-workspace and layout in on-window-detected Dec 2, 2023
@nikitabobko nikitabobko changed the title Support commands other than move-node-to-workspace and layout in on-window-detected Lift limitations in on-window-detected Dec 3, 2023
@nikitabobko nikitabobko changed the title Lift limitations in on-window-detected Lift limitations in on-window-detected.run Dec 3, 2023
@wojciech-kulik
Copy link
Contributor

I would like to use resize width 250 to be able to force some layout. I'm using it to have terminal on the left and small iOS simulator on the right side. Probably move-through left would be useful as well.

@sizuf
Copy link

sizuf commented May 4, 2024

Being able to use the resize command inside on-window-detected would be useful. In my case, I'd like the mobile emulators to start with a smaller width.

@dekked
Copy link

dekked commented Jun 10, 2024

I'm using sketchybar and would like to only display those workspaces that are non empty + the currently focused one.

So far, there is no robust way to:

  • Detect a new window being openend, and signal sketchybar that it should recompute which workspaces are active.
  • Do the same thing when a window is closed, or conversely, when a workspace becomes empty.

I am solving it in a hacky and not foolproof way, basically with a trigger every time I change workspace or whenever an app is moved to another workspace, as well as when the front app changes.

I thought I could do part of it by detecting any new window being opened, but I can't run an execute-and-forget command to signal sketchybar :)

I understand the reason not to allow this would be not to execute any command that would create a window and suddenly we have an infinite cascade?

@vcooley
Copy link

vcooley commented Jun 17, 2024

I would like a "do nothing" command that just intercepts the event and stops further events from being called (with check-further-callbacks = false).

My use use case is that I'm often opening up Chrome debug windows, and my current setup has a rule to always send Chrome windows to a certain workspace when they're opened. I would like to setup a rule that just uses the default behavior of opening the dev tools window in the same workspace as the parent window so that I don't have to go looking for it.

@nikitabobko
Copy link
Owner Author

nikitabobko commented Jun 17, 2024

@vcooley have you tried to use empty array run = []?

@vcooley
Copy link

vcooley commented Jun 17, 2024

@nikitabobko I hadn't tried that, but had tried empty string. The empty array did the trick, thanks!

@tobiasgiese
Copy link

tobiasgiese commented Jul 26, 2024

I'm using sketchybar and would like to only display those workspaces that are non empty + the currently focused one.

I am doing the same (or at least I am trying). Do you have a workaround for this @dekked? Or is it possible to implement this in AeroSpace? cc @nikitabobko

@nikitabobko
Copy link
Owner Author

So far, there is no robust way to:

  • Detect a new window being openend, and signal sketchybar that it should recompute which workspaces are active.
  • Do the same thing when a window is closed, or conversely, when a workspace becomes empty.

@dekked @tobiasgiese your use case is better covered by #230 which will be implemented in the next version

@tobiasgiese
Copy link

tobiasgiese commented Aug 1, 2024

deleted
moved to #230 (comment)

@kingmatusevich
Copy link

It would be useful to be able to set the accordion layout for some of the workspaces, either in a workspace config or in the window detected be able to check if startup and set the right workspace layout

@tale
Copy link

tale commented Aug 13, 2024

I'd like the ability to set fullscreen for an application. I'm using it as a workaround to the big sur tabs issue in #68.

@magoz
Copy link

magoz commented Aug 16, 2024

I'd like to:

[[on-window-detected]]
run = ['join-with right', 'mode main']

So each new window is automatically merged.

Is there another way to do this?

@wanbinkimoon
Copy link

I'd love to

[[on-window-detected]]
if.app-id = 'com.foo.bar'
run = 'layout fullscreen'

so that a particular app is always open in apple fullscreen mode

@kronolynx
Copy link

kronolynx commented Aug 20, 2024

I'm using sketchybar and would like to only display those workspaces that are non empty + the currently focused one.

So far, there is no robust way to:

* Detect a new window being openend, and signal sketchybar that it should recompute which workspaces are active.

* Do the same thing when a window is closed, or conversely, when a workspace becomes empty.

I am solving it in a hacky and not foolproof way, basically with a trigger every time I change workspace or whenever an app is moved to another workspace, as well as when the front app changes.

I thought I could do part of it by detecting any new window being opened, but I can't run an execute-and-forget command to signal sketchybar :)

I understand the reason not to allow this would be not to execute any command that would create a window and suddenly we have an infinite cascade?

@dekked I'm currently using space_windows_change to update my workspaces on sketchybar when windows are created/destroyed, I haven't found a way yet to detect when a window is moved to a different workspace.

@tobiasgiese
Copy link

tobiasgiese commented Aug 20, 2024

@kronolynx I am using a dirty hack like

alt-shift-1 = ['move-node-to-workspace 1', 'exec-and-forget sketchybar --trigger aerospace_workspace_change NEW_WORKSPACE=1' ]

and a script that moves the workspace to the correct display workspace. Not the best, but it does the job

@samirettali
Copy link

Can floating windows be configured to always be on top? I don't know if it's more of a OS thing

@qskkk
Copy link

qskkk commented Aug 23, 2024

In a tile layout, I would like my windows to automatically arrange themselves in a tree structure. For example, if I have 2 windows in h_tiles and I add a third one, I want it to be positioned in the bottom right corner of my screen like this:

h_tiles
├── window 1
└── v_tiles
├── window 2
└── window 3
And when a fourth window is opened, it should resize into this layout:

h_tiles
└── v_tiles
├── window 1
└── window 4
└── v_tiles
├── window 2
└── window 3
I tried to achieve this using a bash script triggered by the command:

[[on-window-detected]]
check-further-callbacks = true
run = ['exec-and-forget ~/.scripts/layout.sh']
But I encountered this error:

on-window-detected[0]: For now, 'layout floating', 'layout tiling' and 'move-node-to-workspace' are the only commands that are supported in 'on-window-detected'. Please report your use cases to #20
If you need help with this issue or want to know how to work around it, let me know!

@0xwal
Copy link

0xwal commented Aug 24, 2024

[[on-window-detected]]
if.window-title-regex-substring = "Alert window"
run = ["layout floating", "move-node-to-monitor 2"]

I want it to appear on second monitor without taking the focus as the window is timed notification that will disappear in x seconds and sometime is not important.

@gservat
Copy link

gservat commented Aug 25, 2024

It would be useful to be able to set the accordion layout for some of the workspaces, either in a workspace config or in the window detected be able to check if startup and set the right workspace layout

Same. For some apps, like VS Code, I like using the accordion layout but I can't find a way to do that.

@foxswat
Copy link

foxswat commented Aug 30, 2024

would love it support close action so that it can auto close the non meeting zoom window when Zoom app is opened by a meeting link:

[[on-window-detected]]
if.app-id = 'us.zoom.xos'
if.window-title-regex-substring = 'Zoom Workplace'
run = 'close'

@silicakes
Copy link

silicakes commented Aug 31, 2024

I have a use case where one of my workspaces contains zellij + neovim on the entire screen.
I'd like to unbind most aerospace related keys as this is the only window in the workspace for me,
So doing something like:

[[on-window-detected]]
if.app-id = 'net.kovidgoyal.kitty'
run = ['mode terminal']

[mode.terminal.binding]
alt-h = []
alt-j = []
alt-k = []
alt-l = []
....

Can be very beneficial.

Also, this should probably be referenced with #412 as it will probably have a more complete solution for exiting the aforementioned terminal mode once the window is not the terminal and the mode is set to terminal

@nikitabobko nikitabobko added the problem Neither a bug, nor a feature request label Sep 1, 2024
@alex-belost
Copy link

I would like to have the option to set the accordion layout for a specific workspace.

[[on-window-detected]]
if.workspace = 'Z'
check-further-callbacks = true
run = 'layout accordion'

@edygar
Copy link

edygar commented Sep 2, 2024

I wanted to not only make it float, but also put it in the center with rectangle's help

[[on-window-detected]]
if.app-id = 'com.google.Chrome'
if.window-title-regex-substring = 'Sign In - Google Accounts'
run = ['layout floating', 'exec-and-forget open -g "rectangle://execute-action?name=center"']

@paulodiovani
Copy link

I have some examples of commands that could be run with it:

  • resize -- to allow set different sizes for windows, this is especially useful for floating windows, either to use custom sizes or create quake mode (e.g. Dropdown terminal).
  • move -- to place new window on specific position.
  • position -- (new) sets position for floating windows.
  • exec-and-forget -- for many custom commands, especially used with the upcoming tree command

@dellacf
Copy link

dellacf commented Sep 8, 2024

Can floating windows be configured to always be on top? I don't know if it's more of a OS thing

I would also love that. Sometimes my floating windows are lost/hidden behind other windows.

It would be useful to be able to set the accordion layout for some of the workspaces, either in a workspace config or in the window detected be able to check if startup and set the right workspace layout

Same for me: ms teams is opening windows in new windows, which is a bit annoying. To solve that I would like to change to accordion layout for this workspace whenever teams is opened:

[[on-window-detected]]
if.app-id = 'com.microsoft.teams2'
run = 'layout accordion'

Just in general: is there a reason why the actions that can be triggered by on-window-detected is so restricted?

@paulodiovani
Copy link

Can floating windows be configured to always be on top? I don't know if it's more of a OS thing

I would also love that. Sometimes my floating windows are lost/hidden behind other windows.

@dellacf the focus command allows to focus floating windows too, so you just need some shortcuts for it (defaults to alt-hjkl, I use cmd + arrows).

@dblum-analog
Copy link

[[on-window-detected]]
if.window-title-regex-substring = "Alert window"
run = ["layout floating", "move-node-to-monitor 2"]

I want it to appear on second monitor without taking the focus as the window is timed notification that will disappear in x seconds and sometime is not important.

Second this - I use the iTerm as a drop-down terminal and would love it to always be on the main monitor.

@dellacf
Copy link

dellacf commented Sep 12, 2024

@dellacf the focus command allows to focus floating windows too, so you just need some shortcuts for it (defaults to alt-hjkl, I use cmd + arrows).

I know, I just don't like that the floating windows are hidden behind my tilling windows.

nikitabobko added a commit that referenced this issue Sep 21, 2024
… CmdResult

This commit lays out the foundation for the following issues
- #186
- #278
- #20

Also the commit changes how focused window is tracked throught the chain
of executed commands.

- CommandMutableState was a mutable state that tracked the focused
  window, and the track had to be updated throught the chain of executed
  commands (for example, take a look at the `focus` command)
- CmdEnv is simplier. It just forces a particular window to be percieved
  as "focused".

CmdEnv approach makes things easier to understand and describe in the
docs (which I'm going to do later, CmdEnv will be exposed as
AEROSPACE_FOCUSED_WORKSPACE and AEROSPACE_FOCUSED_WINDOW_ID environment
variables)

Unlike CommandMutableState, CmdEnv approach disallows to change focused
window in on-window-detected, on-focus-changed, and other callbacks.
Which I think is not an issue at all. It maybe even considered a safety
mechanism.

If a user uses `close` in one of the mentioned callbacks, previously, a
random window could become focused and it would receive all the
following commands. Now, all the commands that go after `close` will
fail with "Invalid <window-id> \(windowId) specified in
AEROSPACE_FOCUSED_WINDOW_ID env variable"

- This commit is not a breaking change for on-window-detected thanks to
  limitations in #20
- But this commit is technically a breaking change for other mentioned
  callbacks, since no limitations were impoosed on those callbacks. But
  I don't believe that anyone in sane mind relied on it. And the docs
  are explicit that changing focus in those callbacks is a bad idea:

  > Changing the focus within these callbacks is a bad idea anyway, and the way it’s handled will probably change in future versions.

Currently, the "force focused state" in CmdEnv is immutable, and I hope
it will stay so. But hypothetically, it can be mutable in future
versions if we decide that the embedded language #278 should allow
chaning environment variables.
@denysav
Copy link

denysav commented Sep 28, 2024

I group apps by spaces. For instance, R stands for "reading" and apps like LiquidText, Kindle, Preview go there. I don't normally use those apps side-by-side (i.e., tiling layout), so ideally I'd want them to be fullscreen and the space R to have accordion layout, so I can quickly switch between those apps.

@ELLIOTTCABLE
Copy link

👍 on the 'resize'-related stuff that adjust layout and positioning.

One particular reason this is necessary is that lots of apps have "naturally small" windows for particular purposes; and sometimes I would like those to be in the tiled grid, but I don't want them zoomed up to taking up ⅓ of the space on a Pro Display XDR.

As a specific (but not the only) example, the Tags window in Things 3 is a separate window instead of a drawer, and I do want it open (and not occluding the main window / 'floating') during normal usage of the app:

Screenshot 2024-10-08 at 16 11 40

However, if I set it to layout tiling, I end up with this ridiculousness every time I open the app:

image

@albinjon
Copy link

I'd like to:

[[on-window-detected]]
run = ['join-with right', 'mode main']

So each new window is automatically merged.

Is there another way to do this?

Also extremely interested in this! Seems strange to me to need to manually join to nest windows.

@nikitabobko nikitabobko added the triaged The issue makes sense to maintainers label Oct 27, 2024
@hisbaan
Copy link

hisbaan commented Nov 3, 2024

Similar to @qskkk I'd like to implement an auto spiral/dwindle layout and there seems to be a pretty easy way to do this with the on-window-detected callback, but it's missing the ability to run join-with commands and the ability to check the layout of the current node. Something like:

[[on-window-detected]]
if.node.layout = 'horizontal'
run = ['join-with left']

[[on-window-detected]]
if.node.layout = 'vertical'
run = ['join-with up']

@ELLIOTTCABLE
Copy link

Another use:

There's (often?) bugs with some niche applications using application-hiding oddly (https://bluebird.app/), or a fullscreen-mode (many games), where that particular poorly-behaved application ends up leaving a "gap" in a tiled layout. With arbitrary commands, a workaround would be possible - detect the launch of those oddities, and set them to 'floating' mode, so they don't affect the grid.

@yuxb2
Copy link

yuxb2 commented Nov 17, 2024

Hi, would it be possible to add the resize option in the [on-window-detected] ? I would love to use it to set certain apps that are in floating to a certain size on my screen.
A simple option to center elements would also be great. I'm using Hammerspoon right now to re-center all the floating windows at the moment, but it would be much easier if you could add a 'center-window' option, furthermore than the resize option.
Thanks a lot, keep up the great work!

@dudeofawesome
Copy link

I would like to be able to automatically make secondary windows of a specific app accordion.

For example, if I'm in Firefox and hit cmd+n to open a new window, I'd like it to automatically join the original Firefox window's layout and vertically accordion with it.

@AlanWarren
Copy link

Just to add to what's already been mentioned.

Jetbrains IDE's allow you to combine/attach multiple windows into a single window on MacOS. (i.e Open new Project -> Attach Window) They appear as tabs above your editor tabs, which is a very nice feature.

Aerospace interprets these as individual windows and attempts to tile them, which results in large blank spaces where these windows would normally be. (they remain attached to a single window, but Aerospace will display a blank tile for each additional window)

A great way of handling this is to always join new jetbrains windows, and then put them in an accordion. It's really slick if you set the accordion gap to 0, and you essentially get to ALT-J/K through your open projects.

The only hassle is that you have to micro-manage it. It would be great if we could automatically join up all jetbrains windows and set them to a vertical accordion layout.

@oliversturm
Copy link

I believe that my use cases would be covered by suggestions made already, such as auto-full-screening and perhaps switching to accordion mode. But the use case I have has not been mentioned: running photo and video viewers from a file manager. I'm now using floating layout, but in i3 and sway I used to be able to run full-screen automatically and that was better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Neither a bug, nor a feature request triaged The issue makes sense to maintainers
Projects
None yet
Development

No branches or pull requests