# Default applications per file type -- the single source of truth for "open # with" across the desktop: xdg-open, file pickers, and Enter in mc (whose # mc.ext.ini delegates every non-archive type to xdg-open; see mc.nix). # # These belong in the public baseline because the handlers do too: zathura, imv # and mpv come from media.nix, libreoffice from home.nix. So "PDF opens in # zathura", "images in imv", etc. are the natural defaults of this baseline, not # personal choices -- every entry is mkDefault, so a consumer overrides one type # by setting the same key (their definition wins), or flips enable off entirely. # # Personal handlers -- web browser, mail -- are NOT here; they map to a specific # browser profile / mail client and live in the private inventory, merging into # the same defaultApplications attrset. { lib, ... }: let # Map every mime in the list to one .desktop id, at mkDefault priority. forAll = desktop: mimes: lib.genAttrs mimes (_: lib.mkDefault desktop); zathura = "org.pwmt.zathura.desktop"; imv = "imv.desktop"; mpv = "mpv.desktop"; writer = "writer.desktop"; calc = "calc.desktop"; impress = "impress.desktop"; in { xdg.mimeApps.enable = lib.mkDefault true; xdg.mimeApps.defaultApplications = (forAll zathura [ "application/pdf" "application/epub+zip" "application/oxps" "application/postscript" ]) // (forAll imv [ "image/png" "image/jpeg" "image/gif" "image/webp" "image/bmp" "image/tiff" ]) // (forAll mpv [ "video/mp4" "video/x-matroska" "video/webm" "video/x-msvideo" "video/quicktime" "video/mpeg" "audio/mpeg" "audio/flac" "audio/ogg" "audio/x-wav" "audio/mp4" "audio/x-opus+ogg" ]) // (forAll writer [ "application/vnd.openxmlformats-officedocument.wordprocessingml.document" "application/msword" "application/vnd.oasis.opendocument.text" "application/rtf" ]) // (forAll calc [ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" "application/vnd.ms-excel" "application/vnd.oasis.opendocument.spreadsheet" ]) // (forAll impress [ "application/vnd.openxmlformats-officedocument.presentationml.presentation" "application/vnd.ms-powerpoint" "application/vnd.oasis.opendocument.presentation" ]); }