up to 80.0
[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 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBDIR
7
8 MOZILLA_FIVE_HOME=$LIBDIR
9
10 MOZARGS=
11 MOZLOCALE="$(/usr/bin/locale | grep "^LC_MESSAGES=" | \
12                 sed -e "s|LC_MESSAGES=||g" -e "s|\"||g" )"
13 for MOZLANG in $(echo $LANGUAGE | tr ":" " ") $MOZLOCALE; do
14         eval MOZLANG="$(echo $MOZLANG | sed -e "s|_\([^.]*\).*|-\1|g")"
15
16         if [ -f $MOZILLA_FIVE_HOME/chrome/$MOZLANG.jar ]; then
17                 MOZARGS="-UILocale $MOZLANG"
18                 break
19         fi
20 done
21
22 if [ -z "$MOZARGS" ]; then
23         # try harder
24         for MOZLANG in $(echo $LANGUAGE | tr ":" " ") $MOZLOCALE; do
25                 eval MOZLANG="$(echo $MOZLANG | sed -e "s|_.*||g")"
26
27                 LANGFILE=$(echo ${MOZILLA_FIVE_HOME}/chrome/${MOZLANG}*.jar \
28                                 | sed 's/\s.*//g' )
29                 if [ -f "$LANGFILE" ]; then
30                         MOZLANG=$(basename "$LANGFILE" | sed 's/\.jar//')
31                         MOZARGS="-UILocale $MOZLANG"
32                         break
33                 fi
34         done
35 fi
36
37 # compreg.dat and/or chrome.rdf will screw things up if it's from an
38 # older version.  http://bugs.gentoo.org/show_bug.cgi?id=63999
39 for f in ~/{.,.mozilla/}firefox/*/{compreg.dat,chrome.rdf,XUL.mfasl}; do
40         if [[ -f ${f} && ${f} -ot /usr/bin/mozilla-firefox-bin ]]; then
41                 echo "Removing ${f} leftover from older firefox"
42                 rm -f "${f}"
43         fi
44 done
45
46 if [ -n "$MOZARGS" ]; then
47         FIREFOX="$LIBDIR/firefox $MOZARGS"
48 else
49         FIREFOX="$LIBDIR/firefox"
50 fi
51
52 if [ -f "`pwd`/$1" ]; then
53         URL="file://`pwd`/$1"
54 else
55         URL="$1"
56 fi
57 grep browser.tabs.opentabfor.middleclick ~/.mozilla/firefox/*/prefs.js | grep false > /dev/null
58 if [ $? -ne 0 ]; then
59         exec $FIREFOX -new-tab "$URL"
60 else
61         exec $FIREFOX -new-window "$URL"
62 fi
This page took 0.077985 seconds and 3 git commands to generate.