In the case where I know a window is about to open, sometimes I want it to open normally (making other windows resize to make room), but other times I know I'll want it to float and avoid making things resize. One such scenario is when a lot of terminal windows are open, where resizing them will lead to their display getting messy, and I'll only briefly want the new window.

I don't want to configure rules per application or window class for this, at least not for the purposes of this question.

What I'd like is to be able to hold a key as I'm expecting the window to open, and if the key is being held the new window will be forced to float, so other windows do not resize.

Is such a thing possible? How might I achieve it?

1 Answer 1


This worked for me in sway, which is largely compatible with i3:

set $mod Mod4
set $float disable
bindsym $mod+f set $$float enable
for_window [title=".*"] floating $$float; set $$float disable

Now when I press Mod4+f, the next window opened will float, but any new windows after that will tile, until I press Mod4+f again. Note that swaymsg is equivalent to i3msg.

You asked about holding a key to engage the floating behavior. That seems tough to configure in a generic way, as there's no way to query the status of a modifier key within i3/sway (none that I'm aware of, anyway). If you have a small number of programs that you anticipate needing to run in floating mode, you could just configure the behavior separately for each, like so:

bindsym $mod+z exec evince
bindsym $mod+Shift+z set $$float enable; exec evince

Note the criteria in the first answer [title=".*"] will include every window. This might cause unexpected problems, e.g. by causing dialog boxes to no longer float by default. You would have to narrow down the criteria to exclude the types of windows you don't want to be affected. Alternatively, this might work:

set $float toggle
bindsym $mod+f set $$float enable
for_window [title=".*"] floating $$float, floating $$float, set $$float toggle

floating toggle, floating toggle should have no effect, thus preserving the original floating status.

  • Pressing a key first rather than holding one down would work just as well. I don't have time to try this just now but thank you very much for the answer and I hope I get a chance to try it soon.
    – tremby
    Commented Feb 21, 2021 at 2:57
  • Oh wait a sec -- in your example code you have a check against an app ID of "evince". Does that mean this wouldn't work for any arbitrary window which you are expecting to open, you have to target it to a specific application?
    – tremby
    Commented Feb 21, 2021 at 3:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .