community.general.xdg_mime module – Set default handler for MIME types, for applications using XDG tools

Note

This module is part of the community.general collection (version 11.3.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.xdg_mime.

New in community.general 10.7.0

Synopsis

  • This module allows configuring the default handler for specific MIME types when you use applications that rely on XDG.

Parameters

Parameter

Comments

handler

string / required

Sets the default handler for the specified MIME types.

The desktop file must be installed in the system. If the desktop file is not installed, the module does not fail, but the handler is not set either.

You must pass a handler in the form *.desktop, otherwise the module fails.

mime_types

list / elements=string / required

One or more MIME types for which a default handler is set.

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Notes

Note

  • This module is a thin wrapper around xdg-mime tool.

  • See man xdg-mime(1) for more details.

See Also

See also

C(xdg-mime) command manual page

Manual page for the command.

xdg-utils Documentation

Reference documentation for xdg-utils.

Examples

- name: Set Chrome as the default handler for HTTPS
  community.general.xdg_mime:
    mime_types: x-scheme-handler/https
    handler: google-chrome.desktop
  register: result

- name: Set Chrome as the default handler for both HTTP and HTTPS
  community.general.xdg_mime:
    mime_types:
      - x-scheme-handler/http
      - x-scheme-handler/https
    handler: google-chrome.desktop
  register: result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

current_handlers

list / elements=string

Currently set handlers for the passed MIME types.

Returned: success

Sample: ["google-chrome.desktop", "firefox.desktop"]

version

string

Version of the xdg-mime tool.

Returned: always

Sample: "1.2.1"

Authors

  • Marcos Alano (@mhalano)