4

I have a script that recompiles and relaunches a software project I am building in linux. However, I don't usually want to see my program's window immediately after it has launched, as I want to keep my keyboard focus on my vim window.

Normally, my program launches, is automatically given focus, and appears on top of the other windows on my workspace.

Is it possible in linux to launch a program but not have it steal focus, and not have it appear on top of all other windows?

Note: If it matters, I am running Fedora 13, GNOME, compiz, and use Emerald themes.

Cory Klein
  • 18,391
  • 26
  • 81
  • 93

2 Answers2

6

Some Window Managers have a lot of customizability to do stuff like this, but a lot more recent ones including metacity and compiz have lost this kind of customization. I used to use fvwm to do stuff like that. A simpler WM independent approach would be to try and reassign focus back to the right window. Look at the xdotool http://www.semicomplete.com/projects/xdotool/xdotool. It should be available in your distro repository. It can, among other things, assign focus to specific Windows. I assume your running a script from a Terminal that you don't want to loose focus. If so, you should be able to use $WINDOWID to retrieve the Window ID for your terminal and use xdotool at the end of the script to refocus your Terminal.

penguin359
  • 11,877
  • 4
  • 42
  • 45
2

An alternative is to have the program connect to a different X server. You can either

  1. run a separate instance of X on a different virtual console. Switch with e.g. Ctrl-alt-F8.
  2. run Xnest to have an X server acting as a client to the main Xserver

Either way, your testing script should set DISPLAY to redirect the program to the other X server (it will probably be named :1).

wnoise
  • 1,951
  • 1
  • 16
  • 14