feat(mc): open files with their configured app via xdg-open
Ship `mc.ext.ini` as the `local.mc.extIni` option (like `local.mc.menu`): Enter browses archives in-place as before and delegates every other type to `xdg-open`. Add public `mime.nix` with `xdg.mimeApps` defaults (pdf -> zathura, images -> imv, audio/video -> mpv, office -> libreoffice) -- public because those handlers are; personal browser/mail defaults stay private. Also document, at the Hyprland swallow config, how swallowing differs from an app opening fullscreen/maximized (LibreOffice restores its own maximized state and looks swallowed but isn't).
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
# 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"
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user