Skip to main content

Module defaults

Module defaults 

Source
Expand description

Which application opens a type, and changing it.

mimeapps.list is the freedesktop file that records the choice. It is read from several places (the user’s own, then the system’s) and written in exactly one: $XDG_CONFIG_HOME/mimeapps.list.

§This file is hand-edited, so it is edited by hand

CLAUDE.md’s rule about files-config.toml applies here with more force, because this file is not ours: people put comments in it, group related types together, and keep sections this code has never heard of. with_default therefore changes one line and copies every other byte through — no parse-and-reserialise, which would silently reorder a person’s file and drop their notes the first time they changed a default from a menu.

[Added Associations] and [Removed Associations] are read — they change what a chooser may offer — and never written: adding or removing an association is not something this suite has a reason to do on anyone’s behalf. A section beyond those three is neither read nor touched, which is the only safe thing to do with it.

Constants§

ADDED_SECTION
Applications a user added for a type beyond what the desktop entries themselves registered.
REMOVED_SECTION
Applications a user does not want offered for a type, whatever the desktop entry claims.

Functions§

parse
The [Default Applications] entries of one mimeapps.list.
parse_section
Any one section of a mimeapps.list — or of mimeinfo.cache, which has the same shape and is read by this too (see crate::apps::parse_cache).
with_default
text with mime set to open in app — the whole file back, one line different.
without_default
text with mime’s default removed, or None when it had none.