I am writing a terminal file manager, and I would want that when a user issues a command to open an image file, that the image viewing application use the terminal emulator's x window for rendering and input. While the image viewing application is running, the terminal emulator shouldn't render or receive input. When the image viewer is closed, the terminal emulator should reclaim it's x window.

Is achieving this possible without writing a window manager or a terminal emulator? Would this be easier if I were writing a gui file manager?

1 Answer 1


What you're asking is probably doable if you can determine the window-id's involved and use wmctrl to ask the window manager to do the moving and stacking operations on your behalf.

That is,

  • your terminal program would start the image viewer
  • it would obtain the window-id of the image viewer
  • using that information, it would ask the window manager to move the window on top of the terminal

Further reading:

  • I'd think that any working solution along those lines would probably be extremely window-manager specific. I tried to solve a similar requirement back in the Solaris 2.5/OpenLook days, and even the two or three different window managers in use back then (olwm, olvwn, and one or two others) were all subtly different. One of them would "walk" the window down and right 4 pixels each iconify/restore cycle when I would try using X hints to tell the window manager where to put the window. Apr 17, 2016 at 19:30
  • Sure: doable, but not simple. If it were simple, I'd show in detail how to do it :-) Apr 17, 2016 at 19:34
  • Well, if you start by assuming Gnome and gnome-terminal as the terminal emulator, you do get the WINDOWID environment variable defined. That's a lot better than the alternatives... Apr 17, 2016 at 19:46
  • OP doesn't start with the WINDOWID of the image viewer. Apr 17, 2016 at 19:46
  • True, but he's starting the image viewer so has some control. And at least in the Gnome case OP would have a definitive ID for the terminal window he needs to overlay (ignoring frames and terminal emulators with multiple tabs...). That's a whole lot easier and much more accurate than trying to determine the correct window to overlay from either the parent process tree or the window that currently has focus. That is assuming by "terminal file manager" he means something running command-line in a terminal window. If he's running a full app with direct X connections, he knows his windows. Apr 17, 2016 at 19:58

You must log in to answer this question.

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