Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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...

share|improve this question
add comment

1 Answer

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.

-iconic

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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