11

Where can I set CLI flags for Google Chrome on Unity?

1
  • Do you mean how to set command line options for Chrome?
    – N.N.
    Nov 13, 2011 at 9:33

8 Answers 8

6

Look in /opt/google/chrome/google-chrome.desktop or /usr/share/applications/google-chrome.desktop for the following line:

Exec=/opt/google/chrome/google-chrome %U

Add the flag you need in there, save it, then run Chrome again and pin it to your launcher, that should do the trick.

3
  • 4
    ...just until the next upgrade overwrites it :( Apr 28, 2013 at 10:48
  • 2
    I’m still looking for a permanent solution to this. Apr 28, 2013 at 10:51
  • Install menulibre as a way to get to the "launcher".
    – Rick James
    May 26, 2021 at 19:01
3

A way is to set flags in the environment variable CHROMIUM_USER_FLAGS:

export CHROMIUM_USER_FLAGS="insert_content_here"
4
  • This could be flagged as low quality. It will better if you can add a reference for this?
    – user.dz
    Aug 25, 2015 at 10:00
  • 1
    Welcome to Ask Ubuntu! I recommend editing this answer to expand it with specific details about how to do this. (See also How do I write a good answer? for general advice about what sorts of answers are considered most valuable on Ask Ubuntu.) Aug 25, 2015 at 11:00
  • CHROMIUM_USER_FLAGS seems to have no effect on Chrome 46.
    – Ivan Kozik
    Nov 13, 2015 at 19:16
  • 1
    Confirmed this still works as of Chromium 52.0, however, it is deprecated. Oct 3, 2016 at 14:36
3

For xubuntu/xfce4, though it might work similarly elsewhere:

cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/google-chrome.desktop

and modify the three Exec= lines in ~/.local/share/applications/google-chrome.desktop to include the arguments you want. Because it has the same filename, xfce4-whiskermenu will pick up only your modified google-chrome.desktop.

If Chrome is your default browser, another application opening a URL will still cause Chrome to launch without your arguments. To fix this, create a new file ~/bin/google-chrome with these contents:

/usr/bin/google-chrome YOUR_EXTRA_ARGS "$@"

and chmod +x ~/bin/google-chrome. Then, in Preferred Applications, set your Web Browser to Other... and enter:

/home/YOUR_USERNAME/bin/google-chrome "%s"

Also, to avoid having to change the arguments in four places in the future, you can point the Exec= lines in google-chrome.desktop to your /home/YOUR_USERNAME/bin/google-chrome.

2

I'm running Xubuntu and I was trying to figure this one out as well. I tried the solution to edit the .desktop file. I haven't updated, but I have the same concern as you (will it get overwritten). I tried a different option where I added an alias to my .bashrc file.

alias chromium-browser="/usr/bin/chromium-browser [FLAGS]"
2

For chromium, you can create a script in /etc/chromium-browser/customizations

For instance i have a script with one line

CHROMIUM_FLAGS="${CHROMIUM_FLAGS} --enable_hidpi=1 --process-per-site"

I imagine chrome has something similar.

1
  • This should be the accepted answer. It persists between package updates and doesn't involve any desktop file hackery.
    – jesjimher
    May 15, 2018 at 7:05
2

For Chromium, the method suggested by @errr is correct, however, it is deprecated as of Chromium 52 (or earlier):

┌ alex [~]
└──> export CHROMIUM_USER_FLAGS="--version"
┌ alex [~]
└──> chromium-browser
Using PPAPI flash.
WARNING: $CHROMIUM_USER_FLAGS is deprecated. Instead, update   CHROMIUM_FLAGS in ~/.chromium-browser.init or place configuration for all sers in /etc/chromium-browser/customizations/ .
WARNING: Ignoring system flags because $CHROMIUM_USER_FLAGS is set.
CHROMIUM_FLAGS= --ppapi-flash-path=/usr/lib/adobe-flashplugin/libpepflashplayer.so --ppapi-flash-version=
CHROMIUM_USER_FLAGS=--version
Chromium 52.0.2743.116 Built on Ubuntu , running on Ubuntu 16.04

As you can see, the solution is quite obvious however.

┌ alex [~]
└──> echo "CHROMIUM_FLAGS=\"--version\"" >> ~/.chromium-browser.init
chromium-browser
┌ alex [~]
└──> chromium
Using PPAPI flash.
Chromium 52.0.2743.116 Built on Ubuntu , running on Ubuntu 16.04

These changes will persist through upgrades, making it superior to solutions updating system files.

However, for Google Chrome, I have not found a single way other than modifying desktop files or writing custom launchers.

1
  1. Edit /usr/share/applications/google-chrome.desktop
  2. Add the desired flags to the Exec line
  3. Run sudo chattr +a /usr/share/applications/google-chrome.desktop to prevent your change from being overwritten on update.
2
  • This makes dpkg error out on upgrades of Chrome. unable to make backup link of './usr/share/applications/google-chrome.desktop' before installing new version: Operation not permitted followed by dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
    – Ivan Kozik
    Nov 13, 2015 at 18:04
  • Run sudo chattr -a /usr/share/applications/google-chrome.desktop then do the dpkg update, then re-do the steps above.
    – matt2000
    Nov 13, 2015 at 20:45
1

First, open up a terminal. Then type in google-chrome-(release-type) -(flag) Replace (release-type) with the release of google chrome you are using (stable,unstable,ect.) and (flag) with the flag that you want to run Google Chrome with.

To have the flags run when you click on the Google Chrome Unity icon in the launcher:

  • first install Unity Launcher Editor.
  • Open up a terminal window and type sudo apt-get install bzr.
  • When it is has finished installing, type bzr branch lp:unity-launcher-editor.
  • Next, launch Unity Launcher Editor by typing ~/unity-launcher-editor/unitylaunchereditor/main.py.
  • Now, click on the Google Chrome icon, and add the flag you want to run in the Command box.
4
  • I want the flag to be used every time I open Google Chrome from launcher.
    – user1419
    Nov 12, 2011 at 23:10
  • Isn't there just a .desktop file somewhere that I can edit?
    – user1419
    Nov 13, 2011 at 10:41
  • I am not currently aware of a .desktop file you can edit. I would suggest you use Unity Launcher Editor as explained above to add CLI flags to the Google Chrome Launcher icon.
    – Aaron Hill
    Nov 13, 2011 at 12:53
  • some problem with the project, answer need to be updated Nov 5, 2012 at 12:23

You must log in to answer this question.