EOF
}
if [ $# -ne 0 ] ; then
cat <searchproviders.html
You can define SEARCHPROVIDERS_PATH in the environment if your search provider
files (.desktop) are not at the default location.
EOF
exit 1
fi
if [ -z "$SEARCHPROVIDERS_PATH" ] ; then
SEARCHPROVIDERS_PATH="$HOME/.local/share/kde5/services/searchproviders"
printf 'SEARCHPROVIDERS_PATH not set in the environment, using "%s".' \
"$SEARCHPROVIDERS_PATH"
fi
print_header
for FILE in "$SEARCHPROVIDERS_PATH"/*.desktop ; do
printf 'Processing "%s"...\n' "$FILE" >&2
# Get the title
TITLE=$(sed -n 's/^Name=//p' "$FILE")
# Get the URL and replace \\{@} with %s
URL=$(sed -n -e 's/^Query=//' -e 's/\\\\{@}/%s/p' "$FILE")
# Retain only the first shortcut, as Firfox only handles one
SHORTCUT=$(sed -n 's/^Keys=//p' "$FILE" | sed 's/,.*//')
# Uncomment the following line for debugging
#printf 'TITLE="%s"\nURL="%s"\nSHORTCUT="%s"\n\n' "$TITLE" "$URL" "$SHORTCUT" >&2
print_bookmark
done
print_footer