For those familiar with OSX, the behavior I'm looking for is open -g http://google.com, which will open a google webpage in the default browser in the background, without switching focus to it at all.

I've been testing on stock Natty (Gnome, Unity...) with Chrome and then Firefox set to the default browser. I've tried both gnome-open http://google.com and xdg-open http://google.com, and with or without appending &>/dev/null & to the end, the browser window always gets focused. The only case where the browser doesn't get focus is when the default is Firefox and there is already a Firefox window open. I've also tried just calling firefox or google-chrome directly, and neither of them work.

Is there some combination of commands or a package I could use to get the desired behavior more reliably, regardless of whether the default browser is Chrome or Firefox, or whether there's already a window open? This is for software to be installed on others' machines, so modifying their browser profiles is not really a solution...


From what I understand most applications that run under X accept options on the command line that allow you to modify the behavior, I've found two options that may be of use:

-xrm resourcestring

Resources can also be specified from the command line. The resourcestring is a single resource name and value as shown above. Note that if the string contains characters interpreted by the shell (e.g., asterisk), they must be quoted.


This option indicates that the user would prefer that the application's windows initially not be visible as if the windows had be immediately iconified by the user. Window managers may choose not to honor the application's request.

The first option will allow you to set properties on the command line, the only issue is I can't find the right string to use that would prevent focus or minimize the window.

The second option should start the program minimized however in my limited set of trials I was unable to get Firefox to honor the iconic option under XFCE leading me to believe that implementation of that flag is dependent on the program.

Your best option is to look into setting Xresources using xrm, I will update this post if I find a good option for xrm.

Sidenote: From a UI/UX standpoint there is a good article on focus stealing, Please Don't Steal My Focus by Jeff Atwood if you haven't read it already it presents a good approach to focusing.

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.