#!/usr/bin/env ./defaulter # # SPDX-FileCopyrightText: 2023 Pavel 'LEdoian' Turinský # SPDX-License-Identifier: CC0-1.0 # # This file describes patterns for the [Default Applications] part of # mimeapps.list. Each line consists of a pattern, '=', and a list of desktop # files to be used for any type matching the pattern. # # The desktop files are read in order for each pattern and according to their # MimeType= directive, matching lines of mimeapps.list with proper types are # created. The resulting file contains only the desktop files which claim to # support the type, in order they matched a pattern. # # In order to read the desktop files, they must be present in the filesystem. # Currently, only /usr/share/applications/ folder is used for finding the # files. # # Patterns are matched against full MIME types, not just prefixes, so if a # pattern contains no "active" characters, it just serves as an exact match. # # Limitations: Patterns cannot contain '#', which introduces comments anywhere # and '=' which separates the pattern from the list. (Neither of those # characters are likely to be a part of a MIME type.) Also, this file does not # support section headers (they would be hard to distinguish from a bracket # pattern), so a mimeapps.list file, while similar, is in fact not a valid # input for defaulter. # # As an example: the following line uses geeqie for any images it supports, # then tries eog, etc. If eog supports a file geeqie does not, it becomes the # default, for files suported by both it becomes a fallback. The resulting # lines of mimeapps.list would be: # image/x-just-geeqie=geeqie.desktop; # image/x-supported-by-both=geeqie.desktop;org.gnome.eog.desktop; # image/x-just-eog=org.gnome.eog.desktop; # Any pattern not matching 'image/.*' is not considered and this line will not # contribute any such line to the output. image/.*=geeqie.desktop;org.gnome.eog.desktop;feh.desktop; application/pdf=org.gnome.Evince.desktop;okularApplication_pdf.desktop;mupdf.desktop; text/.*=org.gnome.gedit.desktop;org.kde.kate.desktop;mousepad.desktop;gvim.desktop; audio/.*=vlc.desktop;mpv.desktop;audacity.desktop; video/.*=vlc.desktop;mpv.desktop; x-scheme-handler/http=chromium.desktop;firefox-esr.desktop; x-scheme-handler/https=chromium.desktop;firefox-esr.desktop; x-scheme-handler/mailto=thunderbird.desktop;org.gnome.Evolution.desktop;org.kde.kmail2.desktop;