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