]> git.pld-linux.org Git - packages/chromium-browser.git/blame - chromium-browser.sh
- pl
[packages/chromium-browser.git] / chromium-browser.sh
CommitLineData
bd7a3039 1#!/bin/sh
8e8572a6
ER
2APPNAME=chromium-browser
3LIBDIR=@libdir@
4GDB=/usr/bin/gdb
bd7a3039 5
37ceaf05
ER
6# Allow the user to override command-line flags, http://bugs.gentoo.org/357629
7# This is based on Debian's chromium-browser package, and is intended
8# to be consistent with Debian.
535cb410 9if [ -f /etc/$APPNAME/default ]; then
8e8572a6 10 . /etc/$APPNAME/default
37ceaf05 11fi
4edced9c 12
8e8572a6
ER
13die() {
14 echo >&2 "$*"
15 exit 1
16}
17
18usage() {
535cb410
ER
19 cat <<EOF
20$APPNAME [-h|--help] [-g|--debug] [--temp-profile] [options] [URL]
21
22 -g or --debug Start within $GDB
23 -h or --help This help screen
24 --temp-profile Start with a new and temporary profile
25
26Other supported options are:
27
28@OPTIONS@
29See 'man $APPNAME' for more details
30EOF
8e8572a6
ER
31}
32
33export LD_LIBRARY_PATH=$LIBDIR${LD_LIBRARY_PATH:+:"$LD_LIBRARY_PATH"}
4edced9c
ER
34
35# for to find xdg-settings
8e8572a6 36export PATH=$LIBDIR${PATH:+:"$PATH"}
4edced9c
ER
37
38# chromium needs /dev/shm being mounted
39m=$(awk '$2 == "/dev/shm" && $3 == "tmpfs" {print}' /proc/mounts)
40if [ -z "$m" ]; then
41 cat >&2 <<-'EOF'
42 Chromium needs /dev/shm being mounted for Shared Memory access.
43
44 To do so, invoke (as root):
45 mount -t tmpfs -o rw,nosuid,nodev,noexec none /dev/shm
46
47 EOF
bd7a3039 48fi
4edced9c 49
07e314b1
ER
50# lsb_release is slow so try to source the static file /etc/lsb-release
51# instead, and fallback to lsb_release if we didn't get the information we need
535cb410 52if [ -e /etc/lsb-release ]; then
07e314b1
ER
53 . /etc/lsb-release
54fi
55DIST=${DISTRIB_ID:-$(lsb_release -si)}
56RELEASE=${DISTRIB_CODENAME:-$(lsb_release -sc)}
57
4edced9c 58# Set CHROME_VERSION_EXTRA visible in the About dialog and in about:version
07e314b1 59export CHROME_VERSION_EXTRA="$DIST Linux $RELEASE"
4edced9c 60
a153aaeb
AM
61# Let the wrapped binary know that it has been run through the wrapper
62export CHROME_WRAPPER="$(readlink -f "$0")"
63
aa6a00d6
ER
64# Google Chrome has a number of command line switches which change the behavior of Chrome
65# This param allows you to set extra args for browser startup.
1693275a 66# See: http://peter.sh/experiments/chromium-command-line-switches/
aa6a00d6
ER
67CHROME_FLAGS_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/chromium/Chrome Flags"
68if [ -f "$CHROME_FLAGS_FILE" ]; then
69 # All lines starting with # are ignored
37ceaf05 70 CHROMIUM_USER_FLAGS=$(grep -v '^#' "$CHROME_FLAGS_FILE")
aa6a00d6
ER
71fi
72
37ceaf05
ER
73# Prefer user defined CHROMIUM_USER_FLAGS (from env) over system
74# default CHROMIUM_FLAGS (from /etc/chromium-browser/default).
75CHROMIUM_FLAGS=${CHROMIUM_USER_FLAGS:-"$CHROMIUM_FLAGS"}
76
1693275a 77# Google guys cannot properly handle comma, so download speed/est is shown
6a2c5f4d 78# as not a number (NaN). Workaround that with LC_NUMERIC=C
1693275a 79export LC_NUMERIC=C
6a2c5f4d 80
bc4d0afe 81# load PepperFlash if present
8e8572a6 82PEPFLASH=$(readlink -f $LIBDIR/../browser-plugins/PepperFlash)
8fc86c7a
ER
83if [ -f $PEPFLASH/manifest.ver ]; then
84 . $PEPFLASH/manifest.ver
8e8572a6 85 CHROMIUM_FLAGS="$CHROMIUM_FLAGS --ppapi-flash-path=$PEPFLASH/libpepflashplayer.so --ppapi-flash-version=$version"
bc4d0afe
ER
86fi
87
8e8572a6
ER
88want_debug=0
89want_temp_profile=0
90while [ $# -gt 0 ]; do
91 case "$1" in
92 -h | --help | -help)
93 usage
94 exit 0 ;;
95 -g | --debug)
96 want_debug=1
97 shift ;;
98 --temp-profile)
99 want_temp_profile=1
100 shift ;;
101 -- ) # Stop option prcessing
102 shift
103 break ;;
104 *)
105 break ;;
106 esac
107done
108
109if [ $want_temp_profile -eq 1 ]; then
110 TEMP_PROFILE=$(mktemp -d) || exit 1
111 CHROMIUM_FLAGS="$CHROMIUM_FLAGS --user-data-dir=$TEMP_PROFILE"
112fi
113
114if [ $want_debug -eq 1 ]; then
535cb410 115 if [ ! -x $GDB ]; then
8e8572a6
ER
116 die "Sorry, can't find usable $GDB. Please install it."
117 fi
118
119 tmpfile=$(mktemp /tmp/chromiumargs.XXXXXX) || die "Cannot create temporary file"
120 trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
121 echo "set args $CHROMIUM_FLAGS ${1+"$@"}" > $tmpfile
122 echo "# Env:"
123 echo "# LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
124 echo "# PATH=$PATH"
125 echo "# GTK_PATH=$GTK_PATH"
126 echo "# CHROMIUM_USER_FLAGS=$CHROMIUM_USER_FLAGS"
127 echo "# CHROMIUM_FLAGS=$CHROMIUM_FLAGS"
128 echo "$GDB $LIBDIR/$APPNAME -x $tmpfile"
129 $GDB "$LIBDIR/$APPNAME" -x $tmpfile
130 rc=$?
131 if [ $want_temp_profile -eq 1 ]; then
132 rm -rf $TEMP_PROFILE
133 fi
134 exit $rc
135else
136 if [ $want_temp_profile -eq 0 ]; then
137 exec $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@"
138 else
139 # we can't exec here as we need to clean-up the temporary profile
140 $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@"
141 rm -rf $TEMP_PROFILE
142 fi
143fi
This page took 0.106169 seconds and 4 git commands to generate.