#!/bin/dash
HELP_PATH=/usr/share/doc/fd-help
HTML_HELP_PATH=/usr/share/doc/home.html

# markdown help
TITLE="$(grep "^Name\[${LANG%.*}\]=" /usr/share/applications/fatdog-help.desktop | cut -d'=' -f2)"
[ "$TITLE" ] || TITLE="$(grep "^Name\[${LANG%_*}\]=" /usr/share/applications/fatdog-help.desktop | cut -d'=' -f2)"
[ "$TITLE" ] || TITLE="$(grep "^Name=" /usr/share/applications/fatdog-help.desktop | cut -d'=' -f2)"
type mdview > /dev/null && [ -e $HELP_PATH ] &&
exec mdview $HELP_PATH index.md "$TITLE"

# htmlviewer help
type htmlviewer > /dev/null &&
exec htmlviewer file://$HTML_HELP_PATH

# defaultbrowser help
exec defaultbrowser file://$HTML_HELP_PATH
