Difference between revisions of "Chromium/Tips and tricks"

From ArchWiki
Jump to: navigation, search
m (Memory usage)
m (Changed the trust flags to "P,," as advised by Chromium's linux cert management site. The earlier command didn't have the desired result.)
 
(88 intermediate revisions by 28 users not shown)
Line 1: Line 1:
[[Category:Web Browser]]
+
[[Category:Web browser]]
[[zh-CN:Chromium Tips and Tweaks]]
+
[[ja:Chromium 設定]]
{{Article summary start}}
+
[[zh-cn:Chromium/Tips and tricks]]
{{Article summary text|Tips and Tweaks for Chromium are captured in this article.}}
+
{{Related articles start}}
{{Article summary heading|Related}}
+
{{Related|Chromium}}
{{Article summary wiki|Chromium}}
+
{{Related|Firefox tweaks}}
{{Article summary wiki|Firefox Tweaks}}
+
{{Related articles end}}
{{Article summary end}}
+
  
 
== Browsing experience ==
 
== Browsing experience ==
=== about:xxx ===
+
=== chrome://xxx ===
A number of tweaks can be accessed via typing ''about:xxx'' in the URL field.  A complete list is available by typing '''about:chrome-urls''' into the URL field.  Some of note are listed below:
+
A number of tweaks can be accessed via typing ''chrome://xxx'' in the URL field.  A complete list is available by typing '''chrome://chrome-urls''' into the URL field.  Some of note are listed below:
  
* '''about:flags''' - access experimental features such as WebGL and rendering webpages with GPU, etc.
+
* '''chrome://flags''' - access experimental features such as WebGL and rendering webpages with GPU, etc.
* '''about:plugins''' - view, enable and disable the currently used Chromium plugins.
+
* '''chrome://plugins''' - view, enable and disable the currently used Chromium plugins.
* '''about:gpu-internals''' - status of different GPU options.
+
* '''chrome://gpu''' - status of different GPU options.
* '''about:sandbox''' - indicate sandbox status.
+
* '''chrome://sandbox''' - indicate sandbox status.
* '''about:version''' - display version and switches used to invoke the active {{ic|/usr/bin/chromium}}.
+
* '''chrome://version''' - display version and switches used to invoke the active {{ic|/usr/bin/chromium}}.
  
 
An automatically updated, complete listing of Chromium switches is available [http://peter.sh/experiments/chromium-command-line-switches/ here].
 
An automatically updated, complete listing of Chromium switches is available [http://peter.sh/experiments/chromium-command-line-switches/ here].
  
=== Broken icons in Download Tab ===
+
=== Broken icons in Download tab ===
If Chromium shows icon placeholders (icons representing broken documents) instead of appropriate icons in its download tab, the likely cause is that the {{Pkg|gnome-icon-theme}} package is not installed.
+
If Chromium shows icon placeholders (icons representing broken documents) instead of appropriate icons in its Download tab, the likely cause is that the {{Pkg|gnome-icon-theme}} package is not installed.
  
 
=== Chromium overrides/overwrites Preferences file ===
 
=== Chromium overrides/overwrites Preferences file ===
  
If you enabled syncing with a Google Account, then Chromium will tend to override any edits made by hand to the Preferences file found under {{ic|$HOME/.config/google-chrome/Default/Preferences}}. To work around this, start Chromium with the {{ic|--disable-sync-preferences}} switch:
+
If you enabled syncing with a Google Account, then Chromium will override any direct edits to the Preferences file found under {{ic|$HOME/.config/chromium/Default/Preferences}}. To work around this, start Chromium with the {{ic|--disable-sync-preferences}} switch:
 
  $ chromium --disable-sync-preferences
 
  $ chromium --disable-sync-preferences
  
If Chromium is started in the background when you login to your desktop environment, make sure the command your desktop environment uses is
+
If Chromium is started in the background when you login in to your desktop environment, make sure the command your desktop environment uses is:
 
  $ chromium --disable-sync-preferences --no-startup-window
 
  $ chromium --disable-sync-preferences --no-startup-window
  
=== Memory usage ===
+
=== Search engines ===
{{Out of date|Now chromium no longer support --memory-model option.}}
+
Make sites like [https://wiki.archlinux.org wiki.archlinux.org] and [https://en.wikipedia.org wikipedia.org] easily searchable by first executing a search on those pages, then going to ''Settings > Search'' and click the ''Manage search engines..'' button. From there, "Edit" the Wikipedia entry and change its keyword to '''w''' (or some other shortcut you prefer). Now searching Wikipedia for "Arch Linux" from the address bar is done simply by entering "'''w arch linux'''".
Chromium offers some command-line options to help control how efficient it is with system memory, by determining how often it should release memory back to the operating system.  It is done with the flag {{ic|1=--memory-model=X}}, where X is one of the following:
+
 
+
* '''high''' - Never voluntarily relinquish memory.
+
* '''medium''' - Voluntarily reduce working set when switching tabs.
+
* '''low''' - Voluntarily reduce working set when switching tabs and also when the browser is not actively being used.
+
 
+
It is also possible to manually force Chromium to purge its memory. The flag {{ic|--purge-memory-button}} enables a button in the task manager (available in ''Tools > Task Manager'', or by pressing {{keypress|Shift+Esc}}) to do this.
+
 
+
=== Scroll speed of mouse wheel ===
+
{{Note|1=As of 22-Feb-2013, this method is deprecate upstream. See [https://code.google.com/p/chromium/issues/detail?id=154776 this].}}
+
{{AUR|chromium-scroll-pixels}} in the AUR reverses this patch.
+
 
+
[https://wiki.archlinux.org/index.php/User:Graysky Graysky] provides this package compiled for x86_64 only on his unofficial repo, [[Repo-ck]].
+
 
+
The following switch can be used to set the scroll speed of the wheel mouse: {{ic|--scroll-pixels=X}}
+
 
+
$ chromium --scroll-pixels=320
+
 
+
=== Search Engines ===
+
Make sites like wiki.archlinux.org and wikipedia.org easily searchable by first executing a search on those pages, then going to ''Settings > Search'' and click the ''Manage search engines..'' button. From there, "Edit" the Wikipedia entry and change its keyword to "w" (or some other shortcut you prefer). Now searching Wikipedia for "Arch Linux" from the address bar is done simply by entering "w arch linux".
+
  
 
{{Note| Google search is used automatically when typing something into the URL bar. A hard-coded keyword trigger is also available using the '''?''' prefix.}}
 
{{Note| Google search is used automatically when typing something into the URL bar. A hard-coded keyword trigger is also available using the '''?''' prefix.}}
Line 63: Line 42:
 
  $ chromium --disk-cache-dir=/tmp/cache
 
  $ chromium --disk-cache-dir=/tmp/cache
  
Cache should be considered temporary and will '''not''' be saved after a reboot or hard lock.
+
Cache should be considered temporary and will '''not''' be saved after a reboot or hard lock. Alternatively, use:
  
Alternative way, in {{ic|/etc/fstab}}:
+
{{hc|/etc/fstab|2=
tmpfs /home/<USER>/.cache tmpfs noatime,nodev,nosuid,size=400M 0 0
+
tmpfs /home/''username''/.cache tmpfs noatime,nodev,nosuid,size=400M 0 0
 +
}}
  
{{Note|Adjust the size as needed.}}
+
{{Warning|Adjust the size as needed and be careful. If the size is too large and you are using a sync daemon such as [[psd]] on a conventional HDD, it will likely result in very slow start-up times of your graphical system due to long sync back times of the daemon. }}
  
 
==== Profile in tmpfs ====
 
==== Profile in tmpfs ====
Line 77: Line 57:
 
{{AUR|profile-sync-daemon}} is such a script and is directly available from the [[AUR]]. It symlinks and syncs the browser profile directories to RAM. Refer to the [[Profile-sync-daemon]] wiki article for additional information on it.
 
{{AUR|profile-sync-daemon}} is such a script and is directly available from the [[AUR]]. It symlinks and syncs the browser profile directories to RAM. Refer to the [[Profile-sync-daemon]] wiki article for additional information on it.
  
==Profile Maintenance ==
+
===Launch a new browser instance===
Chromium uses [[Sqlite]] databases to manage history and the like.  Sqlite databases become fragmented over time and empty spaces appear all around. But, since there are no managing processes checking and optimizing the database, these factors eventually result in a performance hit. A good way to improve startup and some other bookmarks and history related tasks is to defragment and trim unused space from these databases.
+
When you launch the browser, it first checks if another instance using the same profile is already running. If there is one, the new window is associated with the old instance. To prevent this, you can specifically ask the browser to run with a different profile.
  
{{AUR|profile-cleaner}} and {{AUR|browser-vacuum}} in the [[AUR]] do just this.
+
$ chromium --user-data-dir=<PATH TO A PROFILE>
  
== Security ==
+
{{Note|It will not work if you specify a link or even a symlink to your regular Chromium profile (typically {{ic|~/.config/chromium/Default}}). If you want to use the same profile as your current one for this new instance, first copy the folder {{ic|~/.config/chromium/Default}} to a directory of your choice, keeping the same {{ic|Default}} name, and launch the browser using the following command by specifying the parent folder of the {{ic|Default}} folder you have just copied.
=== Run in a Sandbox ===
+
For example, if you copied the Default folder to {{ic|~/Downloads}}:
Run chromium in a sandbox for added security:
+
 
  $ chromium --enable-seccomp-sandbox
+
{{bc|1=$ chromium --user-data-dir=~/Downloads}}
 +
}}
 +
 
 +
===Directly open *.torrent files and magnet links with a torrent client===
 +
 
 +
By default, Chromium downloads {{ic|*.torrent}} files directly and you need to click the notification from the bottom-left corner of the screen in order for the file to be opened with your default torrent client. This can be avoided with the following method:
 +
 
 +
* Download a {{ic|*.torrent}} file.
 +
* Right-click the notification displayed at the bottom-left corner of the screen.
 +
* Check the "''Always Open Files of This Type''" checkbox.
 +
 
 +
See [[xdg-open]] to change the default assocation.
 +
 
 +
=== Touch Scrolling on touchscreen devices ===
 +
Chrome and Chromium do not support touchscreen by default. There are a couple settings you can change in the "Flags" portion of Chrome to potentially make it work for your device. This has been tested in {{Pkg|chromium}} from the [[official repositories]] and {{AUR|google-chrome}} from the [[AUR]].
 +
 
 +
* Browse to '''chrome://flags''' and set everything to default
 +
* Switch "''Enable Touch events''" to "''Enabled''" ('''chrome://flags/#touch-events''')
 +
* Restart Chrome and touch scrolling should work. If it does not, it is worth trying the other modes that are available.
 +
* You may need to specify which touch device to use. Find your touchscreen device with {{ic| xinput list}} then launch Chromium with the {{ic|1=--touch-devices='''x'''}} parameter, where "'''x'''" is the id of your device. {{Note|If the device is designated as a slave pointer, using this may not work, use the master pointer's ID instead.}}
 +
 
 +
=== Disable system tray icon ===
 +
 
 +
Open the URL {{ic|chrome://flags}} in the browser. Disable this flag:
 +
 
 +
* {{ic|device-discovery-notifications}}
 +
 
 +
Click the restart button at the bottom of the page.
 +
 
 +
=== Reduce memory usage ===
 +
 
 +
By default, Chromium uses a separate OS process for each ''instance'' of a visited web site. [https://www.chromium.org/developers/design-documents/process-models#Supported_Models] However, you can specify command-line switches when starting Chromium to modify this behaviour.
 +
 
 +
For example, to share one process for all instances of a website:
 +
 
 +
  $ chromium --process-per-site
 +
 
 +
To use a single process model:
 +
 
 +
$ chromium --single-process
 +
 
 +
{{Warning|While the single-process model is the default in [[Firefox]] [https://wiki.mozilla.org/Electrolysis] and other browsers, it may contain bugs not present in other models. [https://www.chromium.org/developers/design-documents/process-models#TOC-Single-process]}}
 +
 
 +
In addition, you can suspend or store inactive Tabs with extensions such as [https://chrome.google.com/webstore/detail/tab-suspender/fiabciakcmgepblmdkmemdbbkilneeeh?hl=en Tab Suspender] and [https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall?hl=en OneTab].
  
 
=== User Agent===
 
=== User Agent===
By default Chromium already sends an excessively detailed User Agent, as is viewable via the EFF's [https://panopticlick.eff.org/ Panopticlick] test. That alone makes each browser readily identifiable with high accuracy — and is further exacerbated by the use of non-stable versions, ones not recently provided by Google's release channels, ones customized e.g. by a distribution (such as the AUR's {{AUR|chromium-browser-ppa}}), etc.
 
  
However, this User Agent can be arbitrarily modified at the start of Chromium's base instance via its {{Ic|<nowiki>--user-agent="[string]"</nowiki>}} parameter.
+
The User Agent can be arbitrarily modified at the start of Chromium's base instance via its {{Ic|<nowiki>--user-agent="[string]"</nowiki>}} parameter.
  
For the same User Agent as the stable Chrome release for Linux i686 (at the time of writing the most popular Linux edition of Chrome) one would use:
+
For the same User Agent as the stable Chrome release for Linux i686 (at the time of writing, the most popular Linux edition of Chrome) one would use:
 
  --user-agent="Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11"
 
  --user-agent="Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11"
  
 
An official, automatically updated listing of Chromium releases which also shows the included WebKit version is available as the [https://omahaproxy.appspot.com/ OmahaProxy Viewer].
 
An official, automatically updated listing of Chromium releases which also shows the included WebKit version is available as the [https://omahaproxy.appspot.com/ OmahaProxy Viewer].
  
=== Making it all persistent ===
+
==Profile maintenance ==
You can export your flags from {{ic|~/.profile}}:
+
Chromium uses [[SQLite]] databases to manage history and the likeSqlite databases become fragmented over time and empty spaces appear all around. But, since there are no managing processes checking and optimizing the database, these factors eventually result in a performance hit. A good way to improve startup and some other bookmarks- and history-related tasks is to defragment and trim unused space from these databases.
  export CHROMIUM_USER_FLAGS="--disk-cache-dir=/tmp --disk-cache-size=50000000"
+
  
Or add them to {{ic|/etc/chromium/default}}:
+
{{AUR|profile-cleaner}} and {{AUR|browser-vacuum}} in the [[AUR]] do just this.
{{bc|<nowiki>
+
 
# Default settings for chromium. This file is sourced by /usr/bin/chromium
+
== Security ==
#
+
=== WebRTC ===
# Options to pass to chromium
+
WebRTC is a communication protocol that relies on JavaScript that can leak one's actual IP address from behind a VPN. While software like NoScript prevents this, it's probably a good idea to block this protocol directly as well, just to be safe.  An [https://code.google.com/p/chromium/issues/detail?id=457492 option to disable it] is available via an [https://chrome.google.com/webstore/detail/webrtc-network-limiter/npeicpdbkakmehahjeeohfdhnlpdklia extension].
CHROMIUM_FLAGS="--scroll-pixels=200"</nowiki>
+
}}
+
  
Chromium will prefer the user defined flags in {{ic|CHROMIUM_USER_FLAGS}} to those defined in {{ic|/etc/chromium/default}}.
+
One can test this via [https://www.privacytools.io/webrtc.html this page].
  
If you want to use {{ic|CHROMIUM_USER_FLAGS}} and Pepperflash, you should add Chromium Pepperflash arguments to your {{ic|~/.profile}} file.  
+
=== SSL certificates ===
  export CHROMIUM_USER_FLAGS="--ppapi-flash-path=/usr/lib/PepperFlash/libpepflashplayer.so --ppapi-flash-version=11.7.700.141"
+
Chromium does not have an SSL certificate manager.  It relies on the NSS Shared DB {{ic|~/.pki.nssdb}}.  In order to add SSL certificates to the database, users will have to use the shell.  
  
=== SSL Certificates ===
+
==== Adding CAcert certificates for self-signed certificates ====
Unfortunately, Chromium doesn't have a SSL certificate manager.  It relies on the NSS Shared DB {{ic|~/.pki.nssdb}}.  In order to add SSL certificates to the database, users will have to use the shell.
+
Grab the CAcerts and create an {{ic|nssdb}}, if one does not already existTo do this, first install the {{Pkg|nss}} package, then complete these steps:
  
==== Adding CAcert Certificates for Self-Signed Certificates ====
+
  $ mkdir -p $HOME/.pki/nssdb
Grab the CAcerts and create a nssdb if one does not already exist. To do this, first install the {{Pkg|nss}} package, then complete these steps:
+
$ cd $HOME/.pki/nssdb
{{bc|<nowiki>[[ ! -e $HOME/.pki/nssdb ]] && mkdir -p $HOME/.pki/nssdb && cd $HOME/.pki/nssdb && certutil -N -d sql:.</nowiki>}}
+
$ certutil -N -d sql:.
{{Note|Users will need to create a password for the database should it not exist.}}
+
  
{{bc|<nowiki>curl -k -o "cacert-root.crt" "http://www.cacert.org/certs/root.crt"
+
$ curl -k -o "cacert-root.crt" "http://www.cacert.org/certs/root.crt"
curl -k -o "cacert-class3.crt" "http://www.cacert.org/certs/class3.crt"
+
$ curl -k -o "cacert-class3.crt" "http://www.cacert.org/certs/class3.crt"
certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org" -i cacert-root.crt  
+
$ certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org" -i cacert-root.crt  
certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org Class 3" -i cacert-class3.crt
+
$ certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org Class 3" -i cacert-class3.crt
</nowiki>}}
+
  
{{Note|Users will need to create a password for the database should it not exist.}}
+
{{Note|Users will need to create a password for the database, if it does not exist.}}
  
 
Now users may manually import a self-signed certificate.
 
Now users may manually import a self-signed certificate.
  
==== Example 1: Using a Shell Script Isolate the Certificate from TomatoUSB ====
+
==== Example 1: Using a shell script to isolate the certificate from TomatoUSB ====
Below is a simple script that will extract and add a certificate to the user's nssdb:
+
Below is a simple script that will extract and add a certificate to the user's {{ic|nssdb}}:
  
 
  #!/bin/sh
 
  #!/bin/sh
Line 144: Line 161:
 
  exec > $REMHOST
 
  exec > $REMHOST
 
  echo | openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
 
  echo | openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
  certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "$REMHOST" -i $REMHOST  
+
  certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n "$REMHOST" -i $REMHOST  
 
  exec 1>&6 6>&-
 
  exec 1>&6 6>&-
  
 
Syntax is advertised in the commented lines.
 
Syntax is advertised in the commented lines.
  
Reference:
+
References:
 
*http://blog.avirtualhome.com/adding-ssl-certificates-to-google-chrome-linux-ubuntu
 
*http://blog.avirtualhome.com/adding-ssl-certificates-to-google-chrome-linux-ubuntu
 +
*https://chromium.googlesource.com/chromium/src/+/master/docs/linux_cert_management.md
  
==== Example 2: Using Firefox to Isolate the Certificate from TomatoUSB ====
+
==== Example 2: Using Firefox to isolate the certificate from TomatoUSB ====
The {{Pkg|firefox}} browser can used to save the certificate to a file for manunal import into the DB.
+
The {{Pkg|firefox}} browser can be used to save the certificate to a file for manual import into the database.
  
 
Using firefox:
 
Using firefox:
 
#Browse to the target URL.
 
#Browse to the target URL.
#Upon seeing the "This Connection is Untrusted" warning screen, click I understand the Risks>Add Exception...
+
#Upon seeing the "This Connection is Untrusted" warning screen, click: ''I understand the Risks > Add Exception...''
#Click View>Details>Export and save the certificate to a temporary location ({{ic|/tmp/easy.pem}} in this example).
+
#Click: ''View > Details > Export'' and save the certificate to a temporary location ({{ic|/tmp/easy.pem}} in this example).
  
 
Now import the certificate for use in Chromium:
 
Now import the certificate for use in Chromium:
  certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "easy" -i /tmp/easy.pem
+
  $ certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "easy" -i /tmp/easy.pem
  
{{Note|Adjust the name to match that of the certificate. In the example above, "easy" is the name on the certificate.}}
+
{{Note|Adjust the name to match that of the certificate. In the example above, "easy" is the name of the certificate.}}
  
 
Reference:
 
Reference:
 
*http://sahissam.blogspot.com/2012/06/new-ssl-certificates-for-tomatousb-and.html
 
*http://sahissam.blogspot.com/2012/06/new-ssl-certificates-for-tomatousb-and.html
  
 +
== Making flags persistent ==
 +
{{Note|Starting with {{ic|chromium 42.0.2311.90-1}} only per-user flags are supported.}}
 +
 +
You can put your flags in a {{ic|chromium-flags.conf}} file under {{ic|$HOME/.config/}} (or under {{ic|$XDG_CONFIG_HOME}} if you have configured that environment variable).
 +
 +
No special syntax is used; flags are defined as if they were written in a terminal.
 +
 +
* The arguments are split on whitespace and shell quoting rules apply, but no further parsing is performed.
 +
* In case of improper quoting anywhere in the file, a fatal error is raised.
 +
* Flags can be placed in separate lines for readability, but this is not required.
 +
* Lines starting with a hash symbol (#) are skipped.
 +
 +
Below is an example {{ic|chromium-flags.conf}} file that defines the flags {{ic|--start-maximized --incognito}}:
 +
 +
# This line will be ignored.
 +
--start-maximized
 +
--incognito
 +
 +
{{Tip|If you have Pepper Flash installed, the launcher will automatically pass the correct flags to Chromium so you do not need to define any {{ic|--ppapi-flash-*}} flags.}}
 +
 +
{{Note|The {{ic|chromium-flags.conf}} file is specific to Arch Linux and is supported via a custom launcher script that was added in {{ic|chromium 42.0.2311.90-1}}.}}
  
 
== See also ==
 
== See also ==
 +
 
* [[Profile-sync-daemon]] - Systemd service that saves Chromium profile in tmpfs and syncs to disk
 
* [[Profile-sync-daemon]] - Systemd service that saves Chromium profile in tmpfs and syncs to disk
* [[Tmpfs#tmpfs|Tmpfs]] - Tmpfs Filesystem in {{ic|/etc/fstab}}
+
* [[Tmpfs]] - Tmpfs Filesystem in {{ic|/etc/fstab}}
 
* [https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt Official tmpfs kernel Documentation]
 
* [https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt Official tmpfs kernel Documentation]

Latest revision as of 20:51, 21 August 2016

Related articles

Browsing experience

chrome://xxx

A number of tweaks can be accessed via typing chrome://xxx in the URL field. A complete list is available by typing chrome://chrome-urls into the URL field. Some of note are listed below:

  • chrome://flags - access experimental features such as WebGL and rendering webpages with GPU, etc.
  • chrome://plugins - view, enable and disable the currently used Chromium plugins.
  • chrome://gpu - status of different GPU options.
  • chrome://sandbox - indicate sandbox status.
  • chrome://version - display version and switches used to invoke the active /usr/bin/chromium.

An automatically updated, complete listing of Chromium switches is available here.

Broken icons in Download tab

If Chromium shows icon placeholders (icons representing broken documents) instead of appropriate icons in its Download tab, the likely cause is that the gnome-icon-theme package is not installed.

Chromium overrides/overwrites Preferences file

If you enabled syncing with a Google Account, then Chromium will override any direct edits to the Preferences file found under $HOME/.config/chromium/Default/Preferences. To work around this, start Chromium with the --disable-sync-preferences switch:

$ chromium --disable-sync-preferences

If Chromium is started in the background when you login in to your desktop environment, make sure the command your desktop environment uses is:

$ chromium --disable-sync-preferences --no-startup-window

Search engines

Make sites like wiki.archlinux.org and wikipedia.org easily searchable by first executing a search on those pages, then going to Settings > Search and click the Manage search engines.. button. From there, "Edit" the Wikipedia entry and change its keyword to w (or some other shortcut you prefer). Now searching Wikipedia for "Arch Linux" from the address bar is done simply by entering "w arch linux".

Note: Google search is used automatically when typing something into the URL bar. A hard-coded keyword trigger is also available using the ? prefix.

Tmpfs

Cache in tmpfs

Note: Chromium actually keeps its cache directory separate from its browser profile directory.

To limit Chromium from writing its cache to a physical disk, one can define an alternative location via the --disk-cache-dir=/foo/bar flag:

$ chromium --disk-cache-dir=/tmp/cache

Cache should be considered temporary and will not be saved after a reboot or hard lock. Alternatively, use:

/etc/fstab
tmpfs	/home/username/.cache	tmpfs	noatime,nodev,nosuid,size=400M	0	0
Warning: Adjust the size as needed and be careful. If the size is too large and you are using a sync daemon such as psd on a conventional HDD, it will likely result in very slow start-up times of your graphical system due to long sync back times of the daemon.

Profile in tmpfs

Relocate the browser profile to a tmpfs filesystem, including /tmp, or /dev/shm for improvements in application response as the entire profile is now stored in RAM.

Use an active profile management script for maximal reliability and ease of use.

profile-sync-daemonAUR is such a script and is directly available from the AUR. It symlinks and syncs the browser profile directories to RAM. Refer to the Profile-sync-daemon wiki article for additional information on it.

Launch a new browser instance

When you launch the browser, it first checks if another instance using the same profile is already running. If there is one, the new window is associated with the old instance. To prevent this, you can specifically ask the browser to run with a different profile.

$ chromium --user-data-dir=<PATH TO A PROFILE>
Note: It will not work if you specify a link or even a symlink to your regular Chromium profile (typically ~/.config/chromium/Default). If you want to use the same profile as your current one for this new instance, first copy the folder ~/.config/chromium/Default to a directory of your choice, keeping the same Default name, and launch the browser using the following command by specifying the parent folder of the Default folder you have just copied.

For example, if you copied the Default folder to ~/Downloads:

$ chromium --user-data-dir=~/Downloads

Directly open *.torrent files and magnet links with a torrent client

By default, Chromium downloads *.torrent files directly and you need to click the notification from the bottom-left corner of the screen in order for the file to be opened with your default torrent client. This can be avoided with the following method:

  • Download a *.torrent file.
  • Right-click the notification displayed at the bottom-left corner of the screen.
  • Check the "Always Open Files of This Type" checkbox.

See xdg-open to change the default assocation.

Touch Scrolling on touchscreen devices

Chrome and Chromium do not support touchscreen by default. There are a couple settings you can change in the "Flags" portion of Chrome to potentially make it work for your device. This has been tested in chromium from the official repositories and google-chromeAUR from the AUR.

  • Browse to chrome://flags and set everything to default
  • Switch "Enable Touch events" to "Enabled" (chrome://flags/#touch-events)
  • Restart Chrome and touch scrolling should work. If it does not, it is worth trying the other modes that are available.
  • You may need to specify which touch device to use. Find your touchscreen device with xinput list then launch Chromium with the --touch-devices=x parameter, where "x" is the id of your device.
    Note: If the device is designated as a slave pointer, using this may not work, use the master pointer's ID instead.

Disable system tray icon

Open the URL chrome://flags in the browser. Disable this flag:

  • device-discovery-notifications

Click the restart button at the bottom of the page.

Reduce memory usage

By default, Chromium uses a separate OS process for each instance of a visited web site. [1] However, you can specify command-line switches when starting Chromium to modify this behaviour.

For example, to share one process for all instances of a website:

$ chromium --process-per-site

To use a single process model:

$ chromium --single-process
Warning: While the single-process model is the default in Firefox [2] and other browsers, it may contain bugs not present in other models. [3]

In addition, you can suspend or store inactive Tabs with extensions such as Tab Suspender and OneTab.

User Agent

The User Agent can be arbitrarily modified at the start of Chromium's base instance via its --user-agent="[string]" parameter.

For the same User Agent as the stable Chrome release for Linux i686 (at the time of writing, the most popular Linux edition of Chrome) one would use:

--user-agent="Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11"

An official, automatically updated listing of Chromium releases which also shows the included WebKit version is available as the OmahaProxy Viewer.

Profile maintenance

Chromium uses SQLite databases to manage history and the like. Sqlite databases become fragmented over time and empty spaces appear all around. But, since there are no managing processes checking and optimizing the database, these factors eventually result in a performance hit. A good way to improve startup and some other bookmarks- and history-related tasks is to defragment and trim unused space from these databases.

profile-cleanerAUR and browser-vacuumAUR in the AUR do just this.

Security

WebRTC

WebRTC is a communication protocol that relies on JavaScript that can leak one's actual IP address from behind a VPN. While software like NoScript prevents this, it's probably a good idea to block this protocol directly as well, just to be safe. An option to disable it is available via an extension.

One can test this via this page.

SSL certificates

Chromium does not have an SSL certificate manager. It relies on the NSS Shared DB ~/.pki.nssdb. In order to add SSL certificates to the database, users will have to use the shell.

Adding CAcert certificates for self-signed certificates

Grab the CAcerts and create an nssdb, if one does not already exist. To do this, first install the nss package, then complete these steps:

$ mkdir -p $HOME/.pki/nssdb
$ cd $HOME/.pki/nssdb
$ certutil -N -d sql:.
$ curl -k -o "cacert-root.crt" "http://www.cacert.org/certs/root.crt"
$ curl -k -o "cacert-class3.crt" "http://www.cacert.org/certs/class3.crt"
$ certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org" -i cacert-root.crt 
$ certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "CAcert.org Class 3" -i cacert-class3.crt
Note: Users will need to create a password for the database, if it does not exist.

Now users may manually import a self-signed certificate.

Example 1: Using a shell script to isolate the certificate from TomatoUSB

Below is a simple script that will extract and add a certificate to the user's nssdb:

#!/bin/sh
#
# usage:  import-cert.sh remote.host.name [port]
#
REMHOST=$1
REMPORT=${2:-443}
exec 6>&1
exec > $REMHOST
echo | openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n "$REMHOST" -i $REMHOST 
exec 1>&6 6>&-

Syntax is advertised in the commented lines.

References:

Example 2: Using Firefox to isolate the certificate from TomatoUSB

The firefox browser can be used to save the certificate to a file for manual import into the database.

Using firefox:

  1. Browse to the target URL.
  2. Upon seeing the "This Connection is Untrusted" warning screen, click: I understand the Risks > Add Exception...
  3. Click: View > Details > Export and save the certificate to a temporary location (/tmp/easy.pem in this example).

Now import the certificate for use in Chromium:

$ certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "easy" -i /tmp/easy.pem
Note: Adjust the name to match that of the certificate. In the example above, "easy" is the name of the certificate.

Reference:

Making flags persistent

Note: Starting with chromium 42.0.2311.90-1 only per-user flags are supported.

You can put your flags in a chromium-flags.conf file under $HOME/.config/ (or under $XDG_CONFIG_HOME if you have configured that environment variable).

No special syntax is used; flags are defined as if they were written in a terminal.

  • The arguments are split on whitespace and shell quoting rules apply, but no further parsing is performed.
  • In case of improper quoting anywhere in the file, a fatal error is raised.
  • Flags can be placed in separate lines for readability, but this is not required.
  • Lines starting with a hash symbol (#) are skipped.

Below is an example chromium-flags.conf file that defines the flags --start-maximized --incognito:

# This line will be ignored.
--start-maximized
--incognito
Tip: If you have Pepper Flash installed, the launcher will automatically pass the correct flags to Chromium so you do not need to define any --ppapi-flash-* flags.
Note: The chromium-flags.conf file is specific to Arch Linux and is supported via a custom launcher script that was added in chromium 42.0.2311.90-1.

See also