{ pkgs, lib, config, ... }: let w3m = lib.getExe pkgs.w3m; zathura = lib.getExe config.programs.zathura.package; # term = lib.getExe config.programs.kitty.package; term = lib.getExe config.programs.wezterm.package; in { options.custom.email = with lib; { mailcap = mkEnableOption "Enable mailcap"; }; config = lib.mkIf config.custom.email.mailcap { home.packages = with pkgs; [ mailcap ]; home.file.".mailcap" = { text = '' # HTML text/html; ${w3m} -sixel -o tmp_dir=~/.cache/w3m -o auto_image=TRUE -o display_image=1 -T text/html %s; nametemplate=%s.html # text/html; ${w3m} -o inline_img_protocol=4 -o tmp_dir=~/.cache/w3m -o auto_image=TRUE -o display_image=1 -T text/html %s; nametemplate=%s.html # This second one is chosen by auto_view due to the copiousoutput tag text/html; ${w3m} -I %{charset} -T text/html -cols 140 -o tmp_dir=~/.cache/w3m -o display_link_number=1 -dump; copiousoutput text/plain; nvim %s #PDFs application/x-pdf; ${zathura} '%s'; test=test -n "$DISPLAY" application/pdf; ${zathura} '%s'; test=test -n "$DISPLAY" message/rfc822; nvim %s #Images # image/png; /usr/bin/feh %s # image/jpeg; /usr/bin/feh %s # image/*; (clear && ${term} +kitten icat %s); needsterminal image/*; (clear && ${term} imgcat %s); needsterminal ''; }; }; }