LinuxCommandLibrary

gvfs-mime

Set or get default application for MIME type

SYNOPSIS

gvfs-mime [--help] [--version] [--query] <MIME-TYPE>

PARAMETERS

--help
    Display help and exit

--version
    Display version information and exit

--query
    Query default handler for the MIME type (default behavior)

DESCRIPTION

The gvfs-mime command is a utility from the GVFS (GNOME Virtual File System) package, used to query the default application or handler associated with a specific MIME type in GNOME environments. GVFS provides virtual filesystem backends for GIO, enabling access to resources like network shares, trash, and recent files.

By default, running gvfs-mime MIME-TYPE or with --query outputs the desktop file name of the preferred application for opening files of that type, as determined by the system's MIME database and user preferences (e.g., via xdg-mime defaults or GNOME settings). This is useful in scripts for launching apps dynamically, debugging MIME associations, or integrating with file managers like Nautilus.

For example, it respects settings from ~/.config/mimeapps.list or system-wide defaults. It relies on the GVFS daemon (gvfsd) being active, typically managed by GNOME session or systemd. Output is the .desktop file basename, like org.gnome.Nautilus.desktop.

This tool is lightweight, with minimal dependencies beyond libgio, making it ideal for shell automation without spawning full graphical apps.

CAVEATS

Requires running GVFS daemon (gvfsd); may not reflect graphical launchers accurately in non-GNOME desktops. Limited to .desktop file output only.

EXAMPLES

gvfs-mime --query image/jpeg
Outputs: org.gnome.gThumb.desktop

gvfs-mime application/pdf
Outputs: evince.desktop

EXIT CODES

0: Success (handler found or query completed)
1: Error (invalid MIME type, no daemon, etc.)

HISTORY

Part of gvfs-utils since GVFS 1.0 with GNOME 2.24 (September 2008); evolved with GIO MIME handling in later GNOME releases for better cross-desktop compatibility.

SEE ALSO

gio(1), xdg-mime(1), gvfs-info(1), mime-info(5)

Copied to clipboard