Files
nixos-config/modules/assets/mc/mc.ext.ini
T
daniil-berg 4be1c4fb67 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).
2026-07-12 22:09:01 +02:00

82 lines
2.5 KiB
INI

# Midnight Commander file associations (public baseline).
#
# mc reads a SINGLE mc.ext.ini; this user copy fully replaces the system one
# (they are not merged), so it must also carry the archive entries we keep.
#
# Policy: Enter (Open) on an archive mounts it as a virtual filesystem (mc
# built-in, no external helper). Every other file falls through to [Default],
# which runs `xdg-open` -- so the app is whatever the XDG mimeapps default
# resolves to (set those in the private inventory's xdg.mimeApps). One source of
# truth, shared with every other launcher; nothing app-specific baked in here.
#
# Note: office documents (.docx/.odt/.xlsx/...) are ZIP containers, so they are
# deliberately absent from the [zip] entry below -- otherwise Enter would mount
# them as archives instead of handing them to LibreOffice via xdg-open.
#
# Override contract (this is a types.lines option shipped as mkBefore): append a
# same-named section to override one key -- mc merges same-named sections and
# the last key wins -- e.g. add a [Default] with a different Open to change the
# fallback, or add [pdf] Type=^PDF / Open=mupdf %f & to force one type to a
# specific app. lib.mkForce "..." replaces this baseline wholesale.
[mc.ext.ini]
Version=4.0
### Archives: Enter mounts them as a virtual filesystem (F3/F4 unaffected) ###
[tar]
Regex=\\.(tar(\\.(gz|bz2|xz|zst|lz|lz4|lzo|Z))?|t(gz|az|bz2?|xz|zst|lz))$
Open=%cd %p/utar://
[zip]
Regex=\\.(zip|jar|xpi|whl|egg|apk|war|ear)$
Open=%cd %p/uzip://
[7z]
Shell=.7z
Open=%cd %p/u7z://
[rar]
Regex=\\.r(ar|[0-9][0-9])$
Open=%cd %p/urar://
[arj]
Regex=\\.a(rj|[0-9][0-9])$
Open=%cd %p/uarj://
[cab]
Shell=.cab
Open=%cd %p/ucab://
[cpio]
Regex=\\.cpio(\\.(gz|xz|bz2|zst|lz|lz4|lzo|Z))?$
Open=%cd %p/ucpio://
[deb]
Regex=\\.u?deb$
Open=%cd %p/deb://
[rpm]
Regex=\\.(rpm|src\\.rpm|spm)$
Open=%cd %p/rpm://
[iso]
Shell=.iso
Open=%cd %p/iso9660://
[patch]
Regex=\\.(diff|patch)(\\.(gz|bz2|xz|zst|Z))?$
Open=%cd %p/patchfs://
### Everything else: hand off to the desktop's configured default app ###
# `&` backgrounds xdg-open so mc's shell returns and the launched GUI is orphaned
# to init. Hyprland only swallows the terminal when the new window's parent-PID
# chain still has a foot ancestor (getSwallower in Hyprland's Window.cpp), so an
# orphaned app opens as its own tile instead of swallowing mc (zathura, imv, ...).
# %f MUST stay unquoted: mc already backslash-escapes the path, so quoting turns
# those backslashes literal and breaks filenames with spaces.
[Default]
Open=xdg-open %f &