MyNixOS website logo

Scripts located in w3m's cgi-bin directory. For security reasons, w3m can only read scripts from here and ${pkgs.w3m}/libexec/w3m/cgi-bin/ (referenceable as $LIB in w3m). The cgi-bin scripts can be written in any language and have access to the query provided to them through the QUERY_STRING environment variable. A cgi-bin script can send commands back to w3m via stdout with the form "W3m-control: ".

See https://git.sr.ht/~rkta/w3m/tree/master/item/doc/MANUAL.html for more information.

As of w3m v0.5.5, the option cgi_bin isn't defined by default. If you want to use any cgi-bin scripts in w3m then set programs.w3m.settings.cgi_bin.

Declarations
Type
attribute set of (submodule)
Default
{ }
Example
{
  "search.cgi" = {
    text = ''
      #!/usr/bin/env sh
      
      PREFIX=$(echo "$QUERY_STRING" | cut -d ':' -f1)
      INPUT=$(echo "$QUERY_STRING" | cut -d ':' -f2-)
      
      case $PREFIX in
        aw) echo "W3m-control: GOTO https://wiki.archlinux.org/index.php?search=$INPUT";;
        ddg) echo "W3m-control: GOTO https://lite.duckduckgo.com/lite/?q=$INPUT";;
      esac
      
      echo "W3m-control: DELETE_PREVBUF"
    '';
  };
}