I want to open a programme in a floating window. I tried exec emacsclient -c ; floating enable, but that made the window that was active before float, not the new window.


This is how I did it for my Galculator application:


for_window [class="Galculator" instance="galculator"] floating enable

To find out what goes in your class="..." and instance="...", type xprop in terminal, then click on the window you want to float. You will find the info somewhere on the bottom under WM_CLASS(STRING)="instance", "Class".

  • 3
    This is fine if we want all windows of that class to float. I usually find that I don't. – Raphael Oct 9 '18 at 17:17

The proper way to make the currently focused window float in i3 is to run

i3-msg floating enable

This is what your config line does.

The problem now is that i3-msg runs before the window is in focus (if it even grabs focus). Peter O. explains over here how to get a window in focus based on its PID. We can use this as such:

our_application &

# Wait for the window to open and grab its window ID
while : ; do
    winid="`wmctrl -lp | awk -vpid=$pid '$3==pid {print $1; exit}'`"
    [[ -z "${winid}" ]] || break

# Focus the window we found
wmctrl -ia "${winid}"

# Make it float
i3-msg floating enable > /dev/null;

# Move it to the center for good measure
i3-msg move position center > /dev/null;

# Wait for the application to quit
wait "${pid}";

Nota bene:

  • If the application does grab focus by itself, it may be sufficient to just wait for that to happen. See here for ways to determine the currently focused window.
  • I didn't work through it, but it should be possible to extend the script to return focus to where it was before we changed it.
  • wmctrl can not always figure out the PID for all windows; ImageMagick's display always has PID 0 in its listing, for example. See here for modified approach that uses the window title.
  • Wrapping the salient parts of above solution in a script, it should be possible to write something like

    exec our_command; grab_focus; floating enable

    in the i3 config.


I would like to sum up HubbleTs post with some other dirty workarounds added information:

TLDR: Append && i3-msg "[id=$(xdotool getactivewindow)] floating enable" to your shortcut definition (requires xdotool). E.g. bindsym $mod+button exec program && i3-msg "[id=$(xdotool getactivewindow)] floating enable"

You can set up rules for all windows that match a list of criteria that can be set up within your i3-config or equivalently send using i3-msg.

The syntax is for_window [ criteria ] command. You can read more about it here. If you want it to work only on a single window, you might ensure uniqueness of your criteria.

There is not just


Compares the window class (the second part of WM_CLASS). Use the special value focused to match all windows having the same window class as the currently focused window.


Compares the window instance (the first part of WM_CLASS). Use the special value focused to match all windows having the same window instance as the currently focused window.

but way more, like title or id:


Compares the X11 window title (_NET_WM_NAME or WM_NAME as fallback). Use the special value __focused__ to match all windows having the same window title as the currently focused window.


Compares the X11 window ID, which you can get via xwininfo for example.

Assuming emacsclient to be a command line program, you could hence add

for_window [ title="uniquetitle" ] floating enable

to your i3 config and open your favorite terminal using

termite -e emacsclient -t uniquetitle

and it would directly open in floating mode.

If it is not a command line program and has no title options, you could play around with the other criteria or e.g. (using xdotool and i3-msg):

bindsym $mod+button exec program && xdotool getactivewindow set_window --name uniquetitle

or less dirty

bindsym $mod+t exec program && i3-msg "[id=$(xdotool getactivewindow)] floating enable"
  • 1
    This doesn't work, the "&&" waits for the first half (the exec) to complete before it runs the second half (the floating enable on the current window). What actually happens is that the new program window is opened, and once it's closed the window focus returns to is made floating. Adding --no-startup-id also doesn't solve that issue. – mtalexan Feb 4 '20 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.