]> git.pld-linux.org Git - packages/firefox.git/blob - mozilla-firefox.sh
870f8751bc50225d5d97906ec22cd7d0c61709fa
[packages/firefox.git] / mozilla-firefox.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"
5
6 # compreg.dat and/or chrome.rdf will screw things up if it's from an
7 # older version.  http://bugs.gentoo.org/show_bug.cgi?id=63999
8 for f in ~/{.,.mozilla/}firefox/*/{compreg.dat,chrome.rdf,XUL.mfasl}; do
9         if [[ -f ${f} && ${f} -ot /usr/bin/mozilla-firefox ]]; then
10                 echo "Removing ${f} leftover from older firefox"
11                 rm -f "${f}"
12         fi
13 done
14
15 FIREFOX="$LIBDIR/firefox"
16 PWD=${PWD:-$(pwd)}
17
18 if [ "$1" = "-remote" ]; then
19         exec $FIREFOX "$@"
20 else
21         if ! $FIREFOX -remote 'ping()' 2>/dev/null; then
22                 if [ -f "$PWD/$1" ]; then
23                         exec $FIREFOX "file://$PWD/$1"
24                 else
25                         exec $FIREFOX "$@"
26                 fi
27         else
28                 if [ -z "$1" ]; then
29                         exec $FIREFOX -remote 'xfeDoCommand(openBrowser)'
30                 elif [ "$1" = "-mail" ]; then
31                         exec $FIREFOX -remote 'xfeDoCommand(openInbox)'
32                 elif [ "$1" = "-compose" ]; then
33                         exec $FIREFOX -remote 'xfeDoCommand(composeMessage)'
34                 else
35                         if [ -f "$PWD/$1" ]; then
36                                 URL="file://$PWD/$1"
37                         else
38                                 URL="$1"
39                         fi
40                         if ! grep -q 'browser\.tabs\.opentabfor\.middleclick.*false' ~/.mozilla/firefox/*/prefs.js ; then
41                                 exec $FIREFOX -new-tab "$URL"
42                         else
43                                 exec $FIREFOX -new-window "$URL"
44                         fi
45                 fi
46         fi
47 fi
This page took 0.023649 seconds and 2 git commands to generate.