updated on Tue Jan 10 08:08:34 UTC 2012
[aur-mirror.git] / chromium-browser-bin / chromium-browser.sh
blob94abdd7156bae3d5fc636319e7a55b35a9c953ca
1 #!/bin/sh
3 # Chromium launcher
5 # Authors:
6 # Fabien Tassin <fta@sofaraway.org>
7 # Modified: Balwinder S "bsd" Dheeman (bdheeman AT gmail.com)
8 # for adaption on ArchLinux, Gentoo, Slackware and T2
9 # License: GPLv2 or later
11 APPNAME=chromium-browser
12 LIBDIR=/opt/chromium-browser
13 GDB=/usr/bin/gdb
15 usage () {
16 echo "$APPNAME [-h|--help] [-g|--debug] [options] [URL]"
17 echo
18 echo " -g or --debug Start within $GDB"
19 echo " -h or --help This help screen"
20 echo
21 echo " Other supported options are:"
22 MANWIDTH=80 man chromium-browser | sed -e '1,/OPTIONS/d; /ENVIRONMENT/,$d'
23 echo " See 'man chromium-browser' for more details"
26 if [ -f /etc/$APPNAME/default ] ; then
27 . /etc/$APPNAME/default
30 # Prefer user defined CHROMIUM_USER_FLAGS (fron env) over system
31 # default CHROMIUM_FLAGS (from /etc/$APPNAME/default)
32 CHROMIUM_FLAGS=${CHROMIUM_USER_FLAGS:-"$CHROMIUM_FLAGS"}
34 # FFmpeg needs to know where its libs are located
35 if [ "Z$LD_LIBRARY_PATH" != Z ] ; then
36 LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH
37 else
38 LD_LIBRARY_PATH=$LIBDIR:/lib:/usr/lib:/usr/local/lib
40 export LD_LIBRARY_PATH
42 # For the Default Browser detection to work, we need to give access
43 # to xdg-settings. Also set CHROME_WRAPPER in case xdg-settings is
44 # not able to do anything useful
45 export PATH="$LIBDIR:$PATH"
46 export CHROME_WRAPPER=true
48 want_debug=0
49 while [ $# -gt 0 ]; do
50 case "$1" in
51 -h | --help | -help )
52 usage
53 exit 0 ;;
54 -g | --debug )
55 want_debug=1
56 shift ;;
57 -- ) # Stop option prcessing
58 shift
59 break ;;
60 * )
61 break ;;
62 esac
63 done
65 if [ $want_debug -eq 1 ] ; then
66 if [ ! -x $GDB ] ; then
67 echo "Sorry, can't find usable $GDB. Please install it."
68 exit 1
70 tmpfile=`mktemp /tmp/chromiumargs.XXXXXX` || { echo "Cannot create temporary file" >&2; exit 1; }
71 trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
72 echo "set args $CHROMIUM_FLAGS ${1+"$@"}" > $tmpfile
73 echo "# Env:"
74 echo "# LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
75 echo "# PATH=$PATH"
76 echo "# GTK_PATH=$GTK_PATH"
77 echo "# CHROMIUM_USER_FLAGS=$CHROMIUM_USER_FLAGS"
78 echo "# CHROMIUM_FLAGS=$CHROMIUM_FLAGS"
79 echo "$GDB $LIBDIR/chrome -x $tmpfile"
80 $GDB "$LIBDIR/chrome" -x $tmpfile
81 exit $?
82 else
83 exec $LIBDIR/chrome $CHROMIUM_FLAGS "$@"