To register a new URL scheme handler with XDG, first create a Desktop Entry which specifies the
x-scheme-handler/... MIME type:
Name=DDG Scheme Handler
%u passes the URL (e.g.
ddg://query%20terms) as a single parameter, according to the Desktop Entry Specification.
Once you have created this Desktop Entry and installed it (i.e. put it in the local or system
applications directory for XDG, like
/usr/share/applications/), then you must register the application with the MIME type (assuming you had named your Desktop Entry
xdg-mime default ddg-opener.desktop x-scheme-handler/ddg
A reference implementation of the
# bash and not just sh because we are using some bash-specific syntax
if [[ "$1" == "ddg:"* ]]; then
#ref=$(python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv)" "$ref") # If you want decoding
xdg-open "$1" # Just open with the default handler