websearch()
{
  # See <https://duckduckgo.com/bangs>.
  xdg-open "https://duckduckgo.com/lite/?q=!ducky ${2+site:}$*"
}

webdebian()
{
  xdg-open "https://packages.debian.org/search?searchon=names&section=all&keywords=$*"
}

webubuntu()
{
  xdg-open "https://packages.ubuntu.com/search?searchon=names&section=all&keywords=$*"
}

webcpp()
{
  websearch "https://cppreference.com/w/cpp/" "$@"
}

webc()
{
  websearch "https://cppreference.com/w/c/" "$@"
}

webwin32()
{
  # websearch "https://learn.microsoft.com/en-us/windows/win32/api/" "$@"
  websearch "https://learn.microsoft.com/en-us/windows/" "win32/api" "$@"
}

webopengl()
{
  websearch "https://registry.khronos.org/OpenGL-Refpages/" "$@"
}

webvulkan()
{
  websearch "https://docs.vulkan.org/refpages/" "$@"
}

# TODO: The `man -` makes this require two ^Z presses to background.
webman()
(
  # See also <https://wiki.archlinux.org/title/Man_page#Online_man_pages>.
  # websearch "https://man7.org/linux/man-pages/" "$1${sect+.$sect}"
  # xdg-open "https://man.archlinux.org/search?go=Go&q=$1${sect+.$sect}"
  # xdg-open "https://manpages.debian.org/$1${sect+.$sect}"
  # xdg-open "https://man.cx/$1${sect+($sect)}"
  # xdg-open "https://man.he.net/?section=${sect-all}&topic=$1"

  # See <https://man.archlinux.org/#USAGE>.
  # curl -sfL "https://man.archlinux.org/man/$1.raw" | man -l -
  # curl -sfL "https://man.archlinux.org/man/$1.txt" | less

  # See <https://manpages.debian.org/>.
  # curl -sfL "https://manpages.debian.org/$1.gz" | man -l -

  [ "$2" ] && sect="$1" && shift || true
  for url in \
    "https://man.archlinux.org/man/$1${sect+.$sect}.raw" \
    "https://manpages.debian.org/$1${sect+.$sect}.gz"
  do
    page="$(curl -sfL "$url")"
    [ "$page" ] || continue
    printf '%s\n' "$page" | man -l -
    break
  done
)
