Ubuntu – Open URL in default browser (Chromium) from terminal and give browser focus

browsercommand linescripts

I am trying to open an URL from the terminal window in my default browser which is Chromium:

$ xdg-open 'https://www.google.no/?gws_rd=ssl#q=site:askubuntu.com+xdg-open' >/dev/null

This will open the URL in a new tab in Chromium browser, but focus is still in the terminal window. How can I also bring Chromium browser to the front of my desktop, and give it focus?

Best Answer

You can keep your command as is and change the way applications are getting automatic focus by changing the following settings.

Open a terminal and type:

dconf write /org/compiz/profiles/unity/plugins/core/focus-prevention-level 0

To restore the initial behaviour:

dconf write /org/compiz/profiles/unity/plugins/core/focus-prevention-level 1