Files
Nomarchy/modules/home/mime.nix
Bernardo Magri 355d8cb1a4
All checks were successful
Check / eval (push) Successful in 4m5s
fix(mime): text/plain falls through to Text Editor on live (#119)
A singleton default naming code.desktop left the live ISO with no text
handler — GIO skips missing .desktop files and offers nothing. Prefer
vscode when present, then org.gnome.TextEditor.desktop. Live also gains
mpv (video defaults had the same hole; free via the template pin).

checks.live-baseline-apps now requires every Default Applications key
to resolve to a present .desktop on live (HM + system path) and on the
default template install. Proved to fail on a vscode-only text/plain.

Verified: V2 (live-baseline-apps green + prove-to-fail); V0 flake check.
2026-07-15 09:24:48 +01:00

69 lines
3.1 KiB
Nix

# Default applications (xdg mimeapps.list) — without this, "open a
# PDF/photo" falls to whatever GTK guesses first (GIMP for images).
# Every association is mkDefault AND degrades gracefully by design: an
# entry whose .desktop file isn't installed is skipped by GIO/xdg-open,
# which then falls through to whatever else claims the type — so
# deleting an app from the template suite (or never uncommenting the
# browser) leaves no broken "open" behaviour, just the old guessing.
{ config, lib, ... }:
lib.mkIf config.nomarchy.mime.enable {
xdg.mimeApps = {
enable = lib.mkDefault true;
defaultApplications = lib.mapAttrs (_: v: lib.mkDefault v) {
"application/pdf" = "org.pwmt.zathura.desktop";
"image/png" = "imv.desktop";
"image/jpeg" = "imv.desktop";
"image/gif" = "imv.desktop";
"image/webp" = "imv.desktop";
"image/avif" = "imv.desktop";
"image/bmp" = "imv.desktop";
"image/tiff" = "imv.desktop";
"image/svg+xml" = "imv.desktop";
# Video → mpv (the template's media player).
"video/mp4" = "mpv.desktop";
"video/webm" = "mpv.desktop";
"video/x-matroska" = "mpv.desktop";
"video/quicktime" = "mpv.desktop";
# Audio → Amberol (the template's GTK4 music player). Amberol
# registers these types itself, so this only sets the preference over
# mpv, which also claims them. Both x- and canonical names because
# files report either. Degrades to mpv/whatever if Amberol is dropped.
"audio/mpeg" = "io.bassi.Amberol.desktop";
"audio/flac" = "io.bassi.Amberol.desktop";
"audio/x-flac" = "io.bassi.Amberol.desktop";
"audio/ogg" = "io.bassi.Amberol.desktop";
"audio/x-vorbis+ogg" = "io.bassi.Amberol.desktop";
"audio/opus" = "io.bassi.Amberol.desktop";
"audio/wav" = "io.bassi.Amberol.desktop";
"audio/x-wav" = "io.bassi.Amberol.desktop";
"audio/mp4" = "io.bassi.Amberol.desktop";
"audio/x-m4a" = "io.bassi.Amberol.desktop";
"audio/aac" = "io.bassi.Amberol.desktop";
# Prefer the template's vscode; fall through to gnome-text-editor
# (ships on the live ISO after #103, and is the only editor there).
# A singleton that names an absent .desktop is silently skipped by
# GIO and leaves no handler at all — the #94 / #119 trap. HM tries
# the next entry when the preferred one is missing.
"text/plain" = [ "code.desktop" "org.gnome.TextEditor.desktop" ];
# The system-side Thunar (nomarchy.system.fileManager).
"inode/directory" = "thunar.desktop";
# Template ships chromium (chromium-browser.desktop), and since #103
# so does the live ISO — an entry naming a package nothing installs is
# silently skipped by GIO, which is exactly how the live session ended
# up with no default browser at all (#94). Delete the package and the
# entry goes quiet again; install another browser and/or override these
# keys to retarget.
"text/html" = "chromium-browser.desktop";
"x-scheme-handler/http" = "chromium-browser.desktop";
"x-scheme-handler/https" = "chromium-browser.desktop";
};
};
}