4

I use an i3 binding to execute the script

#!/bin/sh
i3-msg workspace web
/bin/chromium --start-fullscreen
sleep 5
i3-msg fullscreen disable

The last two lines are to disable the fullscreen (I don't know if the sleeping is necessary). The i3 fullscreen is enabled as a side-effect of the argument to chromium (which is intended to hide the address bar etc. only). But for some reason, it doesn't work, the fullscreen is not disabled. Only if I use the binding $mod+f to toggle fullscreen manually is it disabled. Why doesn't the script manage to do this?

(The reason I want to disable fullscreen is that, when I use chromium-vim to edit a text field externally, gvim doesn't show until fullscreen is disabled.)

1

The reason is quite simple, when you run chromium it does not return until it finishes, that is after you close Chromium. So sleep and i3-msg will only be run after the window is already gone.

To solve this, you just need to start chromium in the background, this can be done by appending & to the command. The sleep is required, without it i3-msg might run before Chromium even initialized its window. Five seconds might be a bit long, but it really depends on how fast Chromium opens on your system.

Additionally, I would suggest to add criteria to the i3-msg. That way it works on any Chromium window and not just the currently focused window, which might not actually be the desired Chromium window (obviously this might not be a desired behavior, in case you want some Chromium windows to be fullscreen).

#!/bin/sh
i3-msg workspace web
/bin/chromium --start-fullscreen &
sleep 2
i3-msg '[instance="^chromium$"] fullscreen disable'

Alternatively, if you want Chromium windows to always appear on the workspace "web", you can use the assign and for_window configuration directives in your i3 configuration to do the work:

assign [instance="^chromium$"] web
for_window [instance="^chromium$"] exec "sh -c 'sleep 2; i3-msg \[instance=chromium\] fullscreen disable'"

With that, you no longer need a script and every time you run chromium i3 will put it on "web" and two seconds later the window will drop out of fullscreen.
Note: Although it is theoretically possible to use fullscreen disable directly with for_window, it does not work with Chromium because the window does actually start in fullscreen. Chromium just enables fullscreen really fast; unfortunately i3 is even faster when running for_window. So i3 will disable fullscreen before Chromium even tries to enable it. That is why the detour with running sleep and i3-msg via exec is necessary.

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.