3

Is there a command or setting in the X Toolkit to start xterm minimized?

Having read (1) and man xterm, I tried to start xterm minimized from a gnome-terminal via:

xterm -iconic

or calling the X resource directly xterm -xrm 'xterm*iconic: 1'

However, the argument did not have an effect. xterm did not start minimized.

  • OS: Ubuntu 18.04
  • Gnome: 3.28
  • xterm(330)
Oscillon
  • 154

1 Answers1

1

I've wanted to do the same thing for debugging. The problem seems to be that window manager is overriding the provided old-style requests. I can give you a kludgy answer, but it will work (sort of).

First, you need the xdotool, a utility that executes X actions from the command line. E.g.

sudo apt install xdotool

Then, you can start an xterm minimized as follows:

(xterm &); xdotool windowminimize $(xdotool search --sync --class xterm |head -1)

Some explanation . . . obviously, the first command starts the xterm. You could start the terminal with a command or whatever. The second command minimizes the window with a supplied window id. The window id is supplied by nested call to xdotool that returns all window ids matching the xterm class. We use the first on the stack, which should almost certainly be the one that we just created. The --sync option is necessary to make xdotool pause until there is an id that is of the xterm window class.

This kludge could fail if you are planning on launching multiple xterm windows in this fashion. In that case, you could add some sleep before the call to xdotool.

Yeah, I know this is a disgusting solution. But it's the only one I know.

Martin W
  • 2,675