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

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

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

# defaultbrowser help
exec defaultbrowser file://$HTML_HELP_PATH
