Launch multiple Chromium browser windows from the command line

Here's one way to open multiple Chromium browser windows using the shell, with each window using a separate temporary profile, and with each window using specified dimensions (in this example, windows are sized such that two rows of three windows will fill a 1920x1080 display).

Command line switches for reference: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/chrome_switches.cc

Shell function to create a temporary profile directory with a random string:

GetTempDir()
{
  rand=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w20 | head -n1)
  temp="/tmp/chromium-tmp-$rand"
}

Shell function to launch browser window using Chromium command line switches:

LaunchBrowser()
{
  chromium-browser \
    --no-first-run \
    --new-window \
    --disable-restore-session-state \
    --no-default-browser-check \
    --disable-java \
    --disable-client-side-phishing-detection \
    --window-size=639,530 \
    --user-data-dir=$temp \
  $url &
}

Open six new windows:

for n in {1..6}; do
  GetTempDir
  LaunchBrowser
done

Open six windows each with a different website:

sites="
http://example.com/page/1
http://example.com/page/2
http://example.com/page/3
http://example.com/page/4
http://example.com/page/5
http://example.com/page/6
"
for site in $sites; do
  GetTempDir
  LaunchBrowser
done

Kill all browser processes started using this method:

pkill -f /tmp/chromium-tmp-

Remove temporary profile directories:

rm -r /tmp/chromium-tmp-*

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).