open-dynaMIX / raiseorlaunch

A run-or-raise-application-launcher for i3 window manager.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Run script immediately after launching (raising) a program

petobens opened this issue · comments

Is it possible to launch a script immediately after raising (but not when focusing a program)? My use case is as follows: I wrote a resize.py script to resize my floating windows. Now whenever I launch a program, let's say chromium, I would like the script to be executed on the newly generated/raised window.

For instance I would like top open chromium maximised by doing something like:

bindsym $mod+Control+i $nexec raiseorlaunch -c Chromium -W $ws1 -m browser & resize.py Full

Obviously the & resize.py Full part doesn't work in the snippet above. Is there a way to achieve this? Note: that the script should only be applied when launching/raising a program and not when focusing it.
Thanks!

BTW: raiseorlaunch has been a life saver (coming from OSX and hammerspoon).

Great to hear raiseorlaunch is useful for you 😃

I'm not sure, if I understand you correctly. launch refers to running the application, while raise is referring to focusing. I don't think raiseorlaunch is a great name, but runorraise was already taken and naming things is hard ;)

I think you can achieve what you want without raiseorlaunch, just with i3s for_window:

for_window [class="Chromium"] exec --no-startup-id resize.py Full

This will trigger the script as soon as the new window is encountered by i3. Because your script uses the focused window, you have to make sure the new window really is the focused one. I'd say in most, if not in all cases, i3 handles this correctly. If this would be done within raiseorlaunch, you couldn't be sure of that (maybe it would work, can't say for sure). Especially with the new feature, where we move windows to the expected workspace.

If you go with for_window (which acts on the matched window), you could also directly set position, geometry, etc. there:

for_window [class="Chromium"] fullscreen disable, floating enable, move position $x $y, resize set $w $h

Then you could set variables like this in your i3 config:

set $Full fullscreen disable, floating enable, move position $x $y, resize set $w $h

and use them.

I'm not sure, if I understand you correctly. launch refers to running the application, while raise is referring to focusing. I don't think raiseorlaunch is a great name, but runorraise was already taken and naming things is hard ;)

Yeah I meant launching (i.e running the application) and not raising. Sorry about the mixup

I think you can achieve what you want without raiseorlaunch, just with i3s for_window:

This is exactly what I needed! I should've read the docs a bit more carefully (I didn't know that for_window applied only the first time that i3 encounters a window)

Thanks once again! :)