Usually, in Ubuntu 10.04 Netbook, if I want to open a program, it usually goes from this: An arbitrary open program
(An open program)

to this:
Using a program launcher to launch another program

(Opening another program using Kupfer)

to this:
The other program launches and ends up on top of the current program

How can I change the behavior so that after launching the program, the focus is set back to (and stays on) the original program, or in other words, make all new windows open in the background?

I'm using Ubuntu 10.04 Netbook using Mutter, though this happened when using Metacity also.

link|improve this question

feedback

3 Answers

up vote 2 down vote accepted
+100

Edit: Actually, there's a bug in GNOME that will allow you to achieve what you want quite simply. All you have to do is set a window, any window, to Always On Top. All windows subsequently opened will do so in the background and won't get focus. I recommend you make eg a terminal as small as possible, stick it out of the way eg in a corner, and set Always On Top.

Note that this fix is simple to implement, but in actuality is a messy workaround not a real solution, and will stop working as soon as the linked bug is fixed (though that could be 2+ release cycles away).


There is a gconf key for Mutter to prevent applications from stealing focus:

Launch gconf-editor, navigate to apps --> metacity --> general and set "focus new windows" to strict.

You may find that this is not enough, and that some or all apps are still launching with focus. At the very least the above will stop apps launched from the terminal from stealing focus, so you can workaround this by doing the below:

Pretend that menu items and panel buttons are launched from terminals, by modifying their "command" field.

So firefox becomes

gnome-terminal -e firefox

Some applications will not return the prompt immediately, therefore a further step is needed in the form of a script.

The command is gnome-terminal -e "/bin/bglaunch.sh firefox"

Where /bin/bglaunch.sh is the following script, which launches the application in background:

#!/bin/bash
nohup $1 >/dev/null & 
link|improve this answer
Did you get a chance to try this yet? – imoatama Sep 14 '10 at 0:38
@imoatama It pops up an ugly terminal when run, but nonetheless does make the thing open in the background. – digitxp Sep 14 '10 at 3:25
I don't have the time to do that to every menu entry though. – digitxp Sep 14 '10 at 3:25
Just setting it to strict wasn't enough? Ie if you don't start things via terminal they steal focus? – imoatama Sep 14 '10 at 14:03
See edited answer for a simpler workaround. – imoatama Sep 14 '10 at 14:22
show 1 more comment
feedback

From the Ubuntu Software Center, install "Advanced Desktop Effects Settings (ccsm)".

After the installation, a new menu item called "CompizConfig Settings Manager" will appear in the System->Preferences menu. Click on that and navigate to General->General Options->Focus and Raise Behaviour. Set the "Focus Prevention Level" to "High" or "Very High" to prevent new windows from opening in the foreground.

link|improve this answer
Does that work even using a different Window Manager? I'd be screwed if it replaced Mutter with Compiz because of the horrible graphics of the eeePC 1005HA. – digitxp Sep 12 '10 at 19:23
1  
This doesn't work with anything but Compiz. How bad graphics are we talking? From what I've heard Mutter is quite demanding as well, though admittedly at least a bit less than Compiz. – imoatama Sep 14 '10 at 14:04
Thanks mate, I did it for me :-) – Albus Dumbledore May 18 '11 at 7:11
feedback

One way is, in the main menu, to right-click on the top bar of the window, and set it to be always on top.

link|improve this answer
nice and simple! +1 – studiohack Sep 13 '10 at 1:59
1  
But I want that behavior to be for every window, so it won't work to have all those windows on top. – digitxp Sep 13 '10 at 10:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.