If I type these two commands in a terminal:

xfce4-terminal --hide-menubar --hide-borders --hide-toolbars --title=dt
wmctrl -r dt -e 0,10,10,720,720

I get the desired result (position and resize of window with title dt, noting than unlike gnome-terminal, xfce4-terminal doesn't rewrite manually assigned titles)

Naturally I would expect this to work:

#! /bin/bash
xfce4-terminal --hide-menubar --hide-borders --hide-toolbars --title=dt && wmctrl -r dt -e 0,10,10,720,720

The terminal displays itself with the correct settings and title but wmctrl is having no effect whatsoever.


The && concatenation operator causes the second command not to be executed until after the first command (xfce4-terminal) exits (and only if the exit status indicates success, since it is a short-circuit logical operator).

You should get the behavior you expect if you change && to ; or simply place the wmctrl command on a separate line of your script.

  • Thanks you gave me the answer. Technically you're right but the reason I put && was because wmctrl needs to run once the terminal window is up and ready so I replace && by & sleep 0.5 and my wmctrl on the next line and it worked – Juicy Nov 2 '14 at 2:13

You run wmctrl directly after the xfce4-terminal command exits. But if there is already an open instance of the Xfce Terminal, xfce4-terminal puts itself in the background and immediately returns the command prompt while still in the process of setting up the actual terminal screen. So by the time wmctrl is started the window with title rd might not be there yet.

If you don't have to type the command, as in the example with &&, then wmctrl is started too fast. In the first example the typing, or selecting from history, is enough delay to have the terminal window with the right title available.

If you cut and paste the two command-line inputs from the first example, you probably will encounter the problem as well.

You should put a sleep command before invoking wmctrl. You can experiment with the duration, 1 second should be enough as the terminal's title will be set before the shell that is started needs to have processed its startup files. (If you start Firefox/Chrom with an URL that needs retrieving, waiting for the expected title can take several seconds, and it might never come when there are network errors).

To get uniform behavior, launch xfce4-terminal in the background so that it won't block even if this is the first instance you start.

xfce4-terminal --hide-menubar --hide-borders --hide-toolbars --title=dt &
sleep 1
wmctrl -r dt -e 0,10,10,720,720

Anthon's answer explains what's doing on. Using wmctrl to resize or move a window after the fact is problematic though; you need to rely on a timer, so the window will appear in the wrong position for a brief time then move (or, if the machine is really slow, the window won't move because wmctrl runs too early). Furthermore, you might have another window with the same title (unless you generate guaranteed-unique titles, for example with a random string or a timestamp).

Fortunately xfce4-terminal has an option to set its initial position and size. It follows the standard X11 geometry syntax. Use it instead of calling wmctrl. Note that the size is expressed in character cells, not in pixels.

xfce4-terminal --geometry 80x40+10+10 --hide-menubar --hide-borders --hide-toolbars --title=dt

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.