summaryrefslogtreecommitdiffstats
path: root/thunderbird-open-browser.sh
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-05-30 19:23:18 +0200
committerRemi Collet <fedora@famillecollet.com>2010-05-30 19:23:18 +0200
commitc5886e4c1519a2105b4ddd1882664c5dc47f6cc0 (patch)
treece7d021a004d8b16e65c42fae2ab1c04a4848746 /thunderbird-open-browser.sh
Import thunderbird 3.0.4
Diffstat (limited to 'thunderbird-open-browser.sh')
-rw-r--r--thunderbird-open-browser.sh76
1 files changed, 76 insertions, 0 deletions
diff --git a/thunderbird-open-browser.sh b/thunderbird-open-browser.sh
new file mode 100644
index 0000000..c9cefb4
--- /dev/null
+++ b/thunderbird-open-browser.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+## Copyright (C) 2004 Warren Togami <wtogami@redhat.com>
+## Contributors: David Hill <djh[at]ii.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#
+# open-browser.sh for MozillaThunderbird
+# Release 5
+#
+# This script is called by MozillaThunderbird in order to launch the web
+# browser specified in gconf key /desktop/gnome/url-handlers/http/command
+#
+
+# Exit with Error Message
+function error_exit() {
+ echo "$1"
+ if [ -a /usr/bin/zenity ]; then
+ /usr/bin/zenity --error --text="$1"
+ else
+ xmessage "$1" &
+ fi
+ exit 1
+}
+
+# No URL specified so set to blank
+url=$1
+if [ -z $url ]; then
+ url=about:blank
+fi
+
+# Use xdg-open if it exists (Gnome 2.6+ only)
+if [ -f /usr/bin/xdg-open ]; then
+ OUTPUT="$(/usr/bin/xdg-open "$url" 2>&1)"
+ if [ $? -ne 0 ]; then
+ error_exit "$OUTPUT"
+ fi
+ exit 0
+fi
+
+# Pull key from gconf, remove %s or "%s", trim leading & trailing spaces
+GCONF=$(gconftool-2 -g /desktop/gnome/url-handlers/http/command 2>/dev/null | sed -e 's/%s//; s/\"\"//; s/^\ *//; s/\ *$//')
+NEEDTERM=$(gconftool-2 -g /desktop/gnome/url-handlers/http/need-terminal 2>/dev/null | sed -e 's/^\ *//; s/\ *$//')
+
+# Check if browser really exists
+which $GCONF 2> /dev/null > /dev/null
+if [ $? -ne 0 ]; then
+ error_exit "ERROR: The browser $GCONF specified in Preferences -> Preferred Applications does not exist."
+fi
+
+# Check if text-mode browser
+if [ "$NEEDTERM" == "true" ]; then
+ PREFTERM=$(gconftool-2 -g /desktop/gnome/applications/terminal/exec 2>/dev/null | sed -e 's/^\ *//; s/\ *$//')
+ TERMARGS=$(gconftool-2 -g /desktop/gnome/applications/terminal/exec_arg 2>/dev/null | sed -e 's/^\ *//; s/\ *$//')
+ # Check if terminal exists
+ which $PREFTERM 2> /dev/null > /dev/null
+ if [ $? -ne 0 ]; then
+ error_exit "ERROR: The terminal $GCONF specified in Preferences -> Preferred Applications does not exist."
+ fi
+ # Execute
+ exec $PREFTERM $TERMARGS $GCONF "$url"
+fi
+
+exec $GCONF "$url"
+