- don't conflict with iceweasel (parrallel installation is now possible)
[packages/mozilla-firefox-bin.git] / mozilla-firefox-bin.sh
1 #!/bin/sh
2 # based on script by (c) vip at linux.pl, wolf at pld-linux.org
3
4 LIBDIR="@LIBDIR@/mozilla-firefox-bin"
5
6 MOZILLA_FIVE_HOME=$LIBDIR
7
8 MOZARGS=
9 MOZLOCALE="$(/usr/bin/locale | grep "^LC_MESSAGES=" | \
10                 sed -e "s|LC_MESSAGES=||g" -e "s|\"||g" )"
11 for MOZLANG in $(echo $LANGUAGE | tr ":" " ") $MOZLOCALE; do
12         eval MOZLANG="$(echo $MOZLANG | sed -e "s|_\([^.]*\).*|-\1|g")"
13
14         if [ -f $MOZILLA_FIVE_HOME/chrome/$MOZLANG.jar ]; then
15                 MOZARGS="-UILocale $MOZLANG"
16                 break
17         fi
18 done
19
20 if [ -z "$MOZARGS" ]; then
21         # try harder
22         for MOZLANG in $(echo $LANGUAGE | tr ":" " ") $MOZLOCALE; do
23                 eval MOZLANG="$(echo $MOZLANG | sed -e "s|_.*||g")"
24
25                 LANGFILE=$(echo ${MOZILLA_FIVE_HOME}/chrome/${MOZLANG}*.jar \
26                                 | sed 's/\s.*//g' )
27                 if [ -f "$LANGFILE" ]; then
28                         MOZLANG=$(basename "$LANGFILE" | sed 's/\.jar//')
29                         MOZARGS="-UILocale $MOZLANG"
30                         break
31                 fi
32         done
33 fi
34
35 # compreg.dat and/or chrome.rdf will screw things up if it's from an
36 # older version.  http://bugs.gentoo.org/show_bug.cgi?id=63999
37 for f in ~/{.,.mozilla/}firefox/*/{compreg.dat,chrome.rdf,XUL.mfasl}; do
38         if [[ -f ${f} && ${f} -ot /usr/bin/mozilla-firefox-bin ]]; then
39                 echo "Removing ${f} leftover from older firefox"
40                 rm -f "${f}"
41         fi
42 done
43
44 if [ -n "$MOZARGS" ]; then
45         FIREFOX="$LIBDIR/firefox $MOZARGS"
46 else
47         FIREFOX="$LIBDIR/firefox"
48 fi
49
50 if [ "$1" == "-remote" ]; then
51         exec $FIREFOX "$@"
52 else
53         PING=`$FIREFOX -remote 'ping()' 2>&1 >/dev/null`
54         if [ -n "$PING" ]; then
55                 if [ -f "`pwd`/$1" ]; then
56                         exec $FIREFOX "file://`pwd`/$1"
57                 else
58                         exec $FIREFOX "$@"
59                 fi
60         else
61                 if [ -z "$1" ]; then
62                         exec $FIREFOX -remote 'xfeDoCommand(openBrowser)'
63                 elif [ "$1" == "-mail" ]; then
64                         exec $FIREFOX -remote 'xfeDoCommand(openInbox)'
65                 elif [ "$1" == "-compose" ]; then
66                         exec $FIREFOX -remote 'xfeDoCommand(composeMessage)'
67                 else
68                         if [ -f "`pwd`/$1" ]; then
69                                 URL="file://`pwd`/$1"
70                         else
71                                 URL="$1"
72                         fi
73                         grep browser.tabs.opentabfor.middleclick ~/.mozilla/firefox/*/prefs.js | grep false > /dev/null
74                         if [ $? -ne 0 ]; then
75                                 exec $FIREFOX -new-tab "$URL"
76                         else
77                                 exec $FIREFOX -new-window "$URL"
78                         fi
79                 fi
80         fi
81 fi
This page took 0.03849 seconds and 3 git commands to generate.