ede/ede-help/ede-help.in

83 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/sh
help_dir="@ededocdir@/manual"
browser_list="firefox mozilla konqueror opera navigator dillo"
2008-09-22 17:48:03 +04:00
program="ede-help"
url=""
if [ "$1" = "--help" ]; then
cat <<EOF
Usage: $program [OPTIONS] [TITLE]
Display EDE Manual in the web browser
Options:
--help Show this help
--titles Show known titles
Example:
$program evoke - display evoke help
EOF
exit 1
fi
if [ "$1" = "--titles" ]; then
echo "Known titles:"
content=`ls $help_dir/ | sort -f | sed 's/^images$//'`
for c in $content; do
# show only files (readable), stripping extension
[ -r "$help_dir/$c" ] && echo " " $c | sed 's/\.html//g'
done
exit 0
fi
if [ "x$1" = "x" ]; then
url="$help_dir/index.html"
else
url="$help_dir/$1.html"
if [ ! -r "$url" ]; then
echo "Unable to open $1. Going to start page..."
url="$help_dir/index.html"
fi
fi
# let browser knows it is a file
url="file://$url"
# try to find browser
if [ "x$BROWSER" = "x" ]; then
for i in $browser_list; do
if which $i > /dev/null 2>&1; then
BROWSER="$i"
break;
fi
done
fi
if [ "x$BROWSER" = "x" ]; then
xmessage -title "$program error" -center -buttons "Close" -file - <<EOF
Failed to find any of known browsers!
If you thing that I made mistake, please try to set
BROWSER environment variable with full path pointing
to the browser binary
EOF
exit 1
fi
# run browser
$BROWSER $url
if [ $? -ne 0 ]; then
xmessage -title "$program error" -center -buttons "Close" -file - <<EOF
Unable to run '$BROWSER'!
Please check if program path is correct or
adjust BROWSER environment variable pointing
to the correct binary
EOF
exit 1
fi
exit 0