Skip to main content

Crate hyprforge_mime

Crate hyprforge_mime 

Source
Expand description

What type a file is, which applications can open it, and which one does by default.

Nearly every question has a data file of its own, all of them freedesktop’s and all of them plain text:

QuestionFileModule
What type is part.3mf?mime/globs2globs
What is this file, with no name to go on?mime/magicmagic
Which of those two wins?—lookup
What is a model/3mf a kind of?mime/subclasses, mime/aliasestypes
Which icon does a model/3mf have?mime/icons, mime/generic-iconsicons
What can open a model/3mf?applications/mimeinfo.cacheapps
Which one does, normally?mimeapps.listdefaults

§Why this crate exists

A double-clicked STL opened in Firefox. Not because anything chose that — because xdg-open, on a desktop it does not recognise (Hyprland is one), asks file --mime-type, which reads bytes and not names. An STL is application/octet-stream to it, a 3MF is a zip, a .blend is a zstd stream; none of those has a default application, and xdg-open answers a lookup that found nothing by walking a built-in list of web browsers. Every .stl, .3mf, .uf2, .blend and .sh in a real Downloads folder went that way.

The database on the machine had the right answer the whole time. So this reads it.

§What this is not

Not a launcher, and not a fourth opinion about which application opens a file. It reads what the desktop already recorded and writes only what a person explicitly chose; running the thing is still gio launch with xdg-open behind it. Nothing here parses Exec= field codes, TryExec or Terminal=true — see apps for why that line is where it is.

§Layering

A leaf, like hyprforge-look: no iced, nothing Hyprland-shaped, two dependencies (hyprforge-paths, for the config directory and the atomic write; hyprforge-process, for the bounded wait hyprforge-mimeopen puts on gio launch). The file manager and the Settings app’s Default apps page read it today, and any future viewer needs the same answers.

Re-exports§

pub use apps::App;
pub use globs::Globs;
pub use lookup::Found;
pub use lookup::How;
pub use lookup::Lookup;
pub use magic::Magic;
pub use types::Types;

Modules§

apps
Which applications can open a type, and what they are called.
cli
The argument grammar mimetype and mimeopen share.
defaults
Which application opens a type, and changing it.
globs
What type a file is, decided by its name.
icons
Which icon name a type has — the half of “draw this file’s icon” that is the MIME database’s. Which file that name is belongs to the icon theme, and to hyprforge-icons.
lookup
Putting the name and the contents together: what is this file.
magic
What a file is, decided by its contents.
types
What the database knows about a type, as opposed to about a file: its other names, what it is a kind of, and what to call it in front of a person.

Structs§

Candidate
One application that could open a type, and why it is offered.
MimeDb
Everything the machine says about types and the applications that open them, read once.

Functions§

clear_default
Removes mime’s default from the user’s own mimeapps.list.
data_dirs
$XDG_DATA_HOME then $XDG_DATA_DIRS, in the order the spec gives them — public because the mimetype command needs the same list, and --database replaces exactly this — earlier is more specific. Flatpak puts its exported entries in here, which is how a flatpak application is offered at all.
mimeapps_paths
Every mimeapps.list that applies, most specific first. Public because the mimeopen command loads the database the same way.
set_default
Makes app the default for mime, in the user’s own mimeapps.list.
user_mimeapps_path
The one file this crate writes.