Add mime type linux

Add mime type linux DEFAULT

Add a custom MIME type for individual users

  • Create the ~/.local/share/mime/packages/application-x-newtype.xml file:

    <?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/x-newtype"> <comment>new mime type</comment> <glob pattern="*.xyz"/> </mime-type> </mime-info>

    The sample application-x-newtype.xml file above defines a new MIME type application/x-newtype and assigns file names with the .xyz extension to that MIME type.

  • Create a new .desktop file named, for example, myapplication1.desktop, and place it in the ~/.local/share/applications/ directory:

    [Desktop Entry] Type=Application MimeType=application/x-newtype Name=My Application 1 Exec=myapplication1

    The sample myapplication1.desktop file above associates the application/x-newtype MIME type with an application named My Application 1, which is run by a command myapplication1.

  • Update the MIME database for your changes to take effect:

    $ update-mime-database ~/.local/share/mime
  • Update the application database:

    $ update-desktop-database ~/.local/share/applications
  • To verify that you have successfully associated *.xyz files with the application/x-newtype MIME type, first create an empty file, for example test.xyz:

    Then run the gio info command:

    $ gio info test.xyz | grep "standard::content-type" standard::content-type: application/x-newtype
  • To verify that myapplication1.desktop has been correctly set as the default registered application for the application/x-newtype MIME type, run the gio mime command:

    $ gio mime application/x-newtype Default application for “application/x-newtype”: myapplication1.desktop Registered applications: myapplication1.desktop Recommended applications: myapplication1.desktop
  • Sours: https://help.gnome.org/admin/system-admin-guide/stable/mime-types-custom-user.html.en

    Adding and Removing MIME Types

    Multipurpose Internet Mail Exchange (MIME) types instruct a web browser or mail application how to handle files received from a server. For example, when a web browser requests an item on a server, it also requests the MIME type of the object. Some MIME types, like graphics, can be displayed inside the browser. Others, such as word processing documents, require an external application to be displayed.

    When a web server delivers a web page to a client web browser, it also sends the MIME type of the data it is sending. If there is an attached or embedded file in a specific format, IIS also tells the client application the MIME type of the embedded or attached file. The client application then knows how to process or display the data being received from IIS.

    IIS can only operate files of registered MIME types. These types could be defined both on the global IIS level and on the website or virtual directory level. Globally-defined MIME types are inherited by all websites and virtual directories while ones defined on the website main or virtual directory level are used only for the area where they are defined. Otherwise, if the web server receives request for a file with unregistered MIME type, it returns the 404.3 (Not Found) error.

    To add a MIME type for a virtual directory within a website:

    1. Go to Websites & Domains and find the website’s domain name.
    2. Click Virtual Directories.
    3. Navigate to the required virtual directory and click the corresponding link with its name.
    4. Click the MIME Types tab.
    5. Click Add MIME Type.
    6. Specify the following:
      • Type the file name extension in the Extension field. File name extension should begin with a dot (.), or a wildcard (*) to serve all files regardless of file name extension.
      • Specify the file content type in the Content field.
      • You can either select the appropriate value from the list or define a new content type. To do this, select Custom and enter the content type in the input box provided.
    7. Click OK to finish the creation.

    To edit a MIME type for a virtual directory within a website:

    1. Go to Websites & Domains and find the website’s domain name.
    2. Click Virtual Directories.
    3. Navigate to the required virtual directory and click the corresponding link with its name.
    4. Select the MIME Types tab.
    5. Select the required MIME type in the list.
      • Type the file name extension in the Extension field. File name extension should begin with a dot (.), or a wildcard (*) to serve all files regardless of file name extension.
      • Specify the file content type in the Content field.
      • You can either select the appropriate value from the list or define a new content type. To do this, select Custom and enter the content type in the input box provided.
    6. Click OK to save changes.

    To remove a MIME type for a virtual directory within a website:

    1. Go to Websites & Domains and find the website’s domain name.
    2. Click Virtual Directories.
    3. Navigate to the required virtual directory and click the corresponding link with its name.
    4. Select the MIME Types tab.
    5. Select the checkbox corresponding to the MIME type you want to remove.
    6. Click Remove.
    7. Confirm removal and click OK.
    Sours: https://docs.plesk.com/en-US/obsidian/administrator-guide/website-management/websites-and-domains/extended-website-management/using-virtual-directories-windows/adding-and-removing-mime-types.65216/
    1. Jitney bus paterson nj
    2. Cute shark drawing
    3. Avenged sevenfold hoodie
    4. Subaru legacy premium

    How to install a new (custom) mime type on my Linux system using CLI tools?

    I would like know the full steps to create and register a new custom mime type on my system. If it matters, I am running KDE on Arch Linux.

    The steps should include writing the XML file and associating an icon with the file type and anything else I need to do. I prefer to use command line utilities only.

    I wish to understand both adding this mime association for 1) my user account as well as 2) system-wide.

    For the example, let's say I want to open certificate files with a custom application I will call MyCertInspector. I believe the XML should look similar to this:

    As I understand it, when including in a user-local definition, it removes any existing system-wide mime associations. I would like to confirm that my understanding is correct.

    I also understand that the first step in this process is to check for the existence of a mime-type with the file extension I plan to use. I'm not sure exactly how to do that on Arch because there is no /usr/share/applications/defaults.list on Arch and (at least on my system) there is no system-wide file.

    For the answer, I am hoping for a step by step guide that covers every needed step and that mentions the specific directories where things should be located on an Arch Linux system.

    From my research so far, I believe the general steps are:

    1. check for the existence of a mime-type with the file extension I plan to use
    2. create an XML file for my desired mime-type.
    3. register my XML file using (and we should address both system mode and local user mode.
    4. associate the new mime-type with the application(s) used to open it.
    5. register the icon for the mime-type.
    6. anything else (such as checks & verification steps a person should do)

    My goal is that anyone who reads the answer to this question will be able to master all the complete process of creating and installing a custom mime-type on their system.

    asked Jan 29 '20 at 23:03

    MountainXMountainX

    14.2k4646 gold badges131131 silver badges214214 bronze badges

    Sours: https://unix.stackexchange.com/questions/564816/how-to-install-a-new-custom-mime-type-on-my-linux-system-using-cli-tools

    Chapter 4 MIME Types

    This chapter describes how applications detect MIME types, how to register MIME types, and how to add applications to the GNOME Desktop.

    A Multipurpose Internet Mail Extension (MIME) type identifies the format of a file. The MIME type enables applications to read the file. Applications such as Internet browsers and email applications use the MIME type to handle files of different types. For example, an email application can use the MIME type to detect what type of file is in a file attached to an email.

    The file manager uses MIME types to identify the type of a file. The file manager needs to know the MIME type of a file to perform the following tasks:

    • Open the file in an appropriate application.

    • Display a string that describes the type of file.

    • Display an appropriate icon to represent the file.

    • Display a list of other applications that can open the file.

    If you add a new application, you must ensure that other applications can recognize the files associated with the application. You must perform several tasks to enable other applications to detect the MIME type of the application files.

    This section describes how applications detect the MIME types of files, and how applications are associated with MIME types. This chapter also describes the procedure that you must follow to add a new application.

    Applications can detect the MIME type of a file as follows:

    1. The application uses file content sniffers to search for a particular pattern in the file. A file content sniffer associates a specific pattern in a file with a MIME type. If the application finds a match for the pattern, the MIME type associated with the pattern is the MIME type of the file.

    2. If file content sniffers do not identify the MIME type, then the application can check the filename. The application checks the filename against the MIME type registry. The MIME type registry associates particular file extensions and filename patterns, with particular MIME types. If a match for the filename is found, the MIME type associated with the extension or pattern is the MIME type of the file.

    The following sections provide further information on file content sniffers and the MIME type registry.

    File Content Sniffers

    File content sniffers are specified in the file . The following is an example of a file content sniffer:

    0 string \x89PNG image/png

    The syntax for file content sniffers is as follows:

    offset_start[:offset_end] pattern_type pattern [&pattern_mask] type

    Table 4–1 describes the fields in a file content sniffer.

    Table 4–1 Fields in a File Content Sniffer

    Field 

    Description 

    Specifies the number of characters to ignore in the file before searching for a text pattern. 

    Specifies the type of pattern to search for. The pattern type is the only pattern type that is supported at the time of publication of this guide.

    Specifies the pattern to search for.  

    Specifies a pattern mask, in hexadecimal format. For more information on pattern masks, see the next section.

    This field is optional. This field is not present in the example. 

    Specifies the MIME type to associate with files that match this entry. 

    Pattern Masks

    A pattern mask identifies bits in the pattern to ignore when searching for a pattern in a file. The following is an example of a file content sniffer with a pattern mask:

    0 string BMxxxx\000\000 &0xffff00000000ffff image/bmp

    The pattern and mask in the example are as follows:

    Pattern 

    Mask 

    The pattern and mask specify a file with the following characteristics:

    1. The file begins with .

    2. is followed by four bytes with any values.

    3. The four bytes are followed by .

    The file content sniffer specifies that the MIME type of files that match the pattern and mask is .

    MIME Type Registry

    The MIME type registry is located in . The MIME type registry contains the following files:

    File 

    File Extension 

    MIME information file 

    MIME keys file 

    The following sections describe MIME information files and MIME keys files.

    MIME Information Files

    MIME information files associate MIME types with one or both of the following:

    • File extensions

    • Filename patterns

    When an application searches for the MIME type of a file, the application checks the filename against the MIME information files. If a match for the filename is found, the MIME type associated with the extension or pattern is the MIME type of the file.

    In MIME information files, the filename pattern to search for is written as a regular expression.

    The format of MIME type entries in MIME information files is as follows:

    ext[,priority]: regex[,priority]:

    You can specify a priority value for the file extension and the regular expression. You can use the priority value to differentiate composite filenames. For example, you can assign a priority of to the extension, and assign a higher priority of to the extension. In this case, the file takes the MIME type for .


    Note –

    You must indent the field and the field with a tab character ().


    The following MIME type entries are samples from the MIME information file:

    application/x-compressed-tar regex,2: tar\.gz$ ext: tgz audio/x-real-audio ext: rm ra ram image/jpeg ext: jpe jpeg jpg image/png ext: png text/html ext: html htm HTML text/plain ext: asc txt TXT text/x-readme regex: README.*
    Note –

    The file manager reads the MIME information files alphabetically. The alphabetical order determines the order in which MIME types are assigned to file extensions or regular expressions. For example, if the same file extension is assigned to different MIME types in the files and , the MIME type in is used.


    MIME Keys Files

    MIME keys file provide information about a MIME type that is used in the user interface. For example, the MIME keys file provides a description of a MIME type, and specifies an icon to represent files of that MIME type.

    The following is a sample from a MIME keys file:

    text/html description=HTML page icon_filename=gnome-text-html default_action_type=application short_list_application_ids_for_novice_user_level=mozilla,netscape,galeon category=Documents/World Wide Web
    Note –

    You must indent the keys in a MIME keys file with a tab character ().


    Table 4–2 describes the most important keys in MIME keys files. Typically, the key and the key are localized.

    Table 4–2 Keys in MIME Keys Files

    Key 

    Description 

    Specifies whether files of this MIME type can be executed. 

    Describes the MIME type. This description can be displayed in the file manager and other applications. 

    Specifies the filename of an icon to represent the MIME type. Does not specify the path to the filename, or the file extension.  

    This icon can be displayed in the file manager and other applications. 

    Specifies the category of action to take when a file of this MIME type is opened by the user. Enter for this MIME type for most applications.

    short_list_application_ids _for_novice_user_level

    Specifies the application to use when a file of this MIME type is opened by a user. Specify one or more applications, in order of priority. The applications must also be registered in the application registry. 

    Specifies a category for the MIME type. The value of this key determines the location of the MIME type in the preference tool.

    The application registry contains text files that register applications. The application registration files contain a series of key-value pairs that specify details for applications. For example, the application registration files contain the following information:

    • The command to use to start the application.

    • MIME types to associate with the application.

    An application registration file can contain one or more application registrations. Application registration files have a extension.

    The location of the application registry is . This directory contains a default application registration file that is called .

    To register an application, add a registration file for the application to the application registry.

    The following is an example of an application registration:

    eog command=eog name=Eye of Gnome can_open_multiple_files=true expects_uris=false requires_terminal=false mime_types=image/bmp,image/gif,image/jpeg,image/png,image/tiff, image/x-xpixmap,image/x-bmp,image/x-png,image/x-portable-anymap, image/x-portable-bitmap,image/x-portable-graymap, image/x-portable-pixmap

    Table 4–3 describes the keys in application registration files.

    Table 4–3 Keys for an Application Registration

    Key 

    Description 

    Application identifier 

    Specifies a unique identifier for the application. This identifier must be the same as the identifier in the short_list_application_ids_for_novice_user_level key in the MIME keys file for the application. 

    Specifies the command to use to start the application, and any options to use with the command. 

    Specifies a name for the application. The name is used in the user interface. For example, the name is used in the Open With submenu in the file manager.

    Specifies whether the application can open several files at the same time. 

    Specifies whether the application can process URIs. If the value of this key is , the application registration entry must also contain a key.

    Specifies the URI schemes that the application can process. 

    Specifies whether to run the application in a terminal window. Enter for this field for an application that does not create a window in which to run.

    Specifies the MIME types that the application can use. 

    To add an application to the GNOME Desktop, perform the following steps:

    1. Add a menu item for the application. For more information on how to add an item to a menu, see Chapter 2, Customizing Menus.

    2. Add an icon for the application to . For more information on icons and themes, see Chapter 3, Installing Themes.

    3. If the application uses a new MIME type, add a file content sniffer for the new MIME type. For more information on file content sniffers, see File Content Sniffers.

    4. If the application uses a new MIME type, add a MIME information file for the application to the MIME type registry. For more information on MIME information files, see MIME Information Files.

    5. Add a MIME keys file for the application to the MIME type registry. For more information on MIME keys files, see MIME Keys Files.

    6. If the application uses a new MIME type, add an icon for the MIME type to . For more information on icons and themes, see Chapter 3, Installing Themes.

    7. To associate the application with a MIME type, add an application registration file to the application registry. For more information on the application registry, see Registering Applications for MIME Types.

    • © 2010, Oracle Corporation and/or its affiliates
    Sours: https://docs.oracle.com/cd/E19957-01/817-5310/6mkpbn3tu/index.html

    Linux type add mime

    AddingMimeTypes

    Introduction

    MIME types are a sort of identification card for files on Ubuntu. A file's MIME type is usually determined by the extension of its filename; for example, a text file may end in .txt, and image file might end in .png or .jpg. This tells Ubuntu what icon should be used to represent it and what programs should open it by default.

    Unfortunately, the obvious options for editing MIME types in Ubuntu are shallow. You can teach Ubuntu to open a certain file extension with a certain program using the Properties window, but you cannot set an icon for that extension as a whole: only for the individual file. This can be annoying if you are say, a Python programmer. Ubuntu does not include a special icon for Python files, and it is hard to visually differentiate .py and .pyc files.

    This guide will both teach you to add new MIME types and to associate icons with existing types. We will use .py files as an example.

    Adding a MIME Type

    To start out, we must be assure that the MIME type for our file extension does not already exist. Open a command line and enter the line below, replacing the letters py with your extension.

    grep 'py' /etc/mime.types

    Analysing results

    This particular command will output two lines. If your extension does not output any lines, or if the lines outputed do not include your extension, you must create a new MIME type. Otherwise, look at the right side of this output, find your file extension, and copy the corresponding text to the far right. For 'py', we must copy down 'text/x-python'.

    application/x-python-code pyc pyo text/x-python py

    Creating the MIME type, if needed

    If there was no output, or the output given did not include your extension, we must add a MIME type.

    gksudo gedit /etc/mime.types

    Modify the following text so that the word "extension" is replaced with your file extension (no period mark), add the line to the end of the mime.types file, and save.

    text/extension extension

    And copy the modified 'text/extension' part.

    Another way to add a MIME Type

    On 12.04LTS, I edited the /etc/mime.types file and it had no effect. What worked for me was to add xml files in /usr/share/mime/application; for example here's a file (scad.xml) to describe scad files:

    <?xml version="1.0" encoding="utf-8"?> <mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/scad"> <glob pattern="*.scad"/> </mime-type>

    After you've added or modified whatever you need, run the command

    sudo update-mime-database /usr/share/mime

    Adding an Icon

    Now we need to associate an icon with the MIME type. Get an SVG icon and name it "text-extension.svg", or whatever your modified MIME type is named; this will be the icon to represent all instances of the MIME type on your system. For our python example, this is a good choice. Rename the .svg file so that the it matches "text-x-python.svg" (or "insertYourMIMEtype.svg") so that the slashes are replaced with "-" and there are no capital letters.

    Then simply run the following commands, with 'text-x-python' replaced with your MIME type.

    sudo cp text-x-python.svg /usr/share/icons/gnome/scalable/mimetypes sudo gtk-update-icon-cache /usr/share/icons/gnome/ -f

    Relogin and all files ending in the MIME extension will display with that icon.

    Sours: https://help.ubuntu.com/community/AddingMimeTypes
    Ubuntu: Adding mime type

    Adding A Custom MIME Type & Icon In Ubuntu 20.04

    2021-05-09 - By Robert Elder

         In this article, I will discuss the steps that I took to successfully create a new MIME type association in Ubuntu 20.04 that would match any files that end with the '*.kdenlive' file extension.  This article complements a related topic, Adding A Custom 'Open With' Program In Ubuntu 20.04.

         By creating this new MIME type and installing it, other programs on your system will be able to automatically identify files of this type and do special things with them (like showing a specific icon, or opening with a specific program).  If we run the 'mimetype' command on our project file before installing the MIME type:

         we'll get the following result:

         but after the MIME type is installed, we'll get this result:

         The first step is to identify the location of the 'packages' directory where you need to put your MIME type definition.  In my case, I'm installing this MIME type globally so it's accessible to all users, so I'll use the directory '/usr/share/mime/packages/'.  If you're installing an MIME type for a specific user, you might want to use '/home/THE_USER/.local/share/mime/packages/'.  If you're on a different system, you might want to read this article on the MIME Database.  In the article, they state that MIME types are found in the directories found in the environment variable '$XDG_DATA_HOME' with 'mime' appended to the end of the path of each.  Just for fun, if I run this command:

         I'll see a listing of all those directories:

         As previously noted, the one I'm going to use is '/usr/share'.  After appending 'mime' and 'packages' to the path, I get '/usr/share/mime/packages/'.

         Now, let's create the actual new MIME type(s) in the file 'roberts-custom-mime-types.xml':

         And here is the actual MIME type(s) description:

         You can also add instructions to identify files based on the type of contents they have as opposed to just by the file extension.  These are often called 'magic values' and you can read more about how to do this GNOME Library Help - Adding MIME types.

         Take note that the contents of 'type=' is actually two parts separated by a '/' character.  The first part is 'roberts-custom-mime-types' and the second part is 'custom-kdenlive-project-file-mime-type'.  The first part is the same as the filename of 'roberts-custom-mime-types.xml'.  That's important as we'll see in the next section.

         If this worked, it should auto-generate a file at '/usr/share/mime/roberts-custom-mime-types/custom-kdenlive-project-file-mime-type.xml'.  If you decide to add additional MIME types to your 'roberts-custom-mime-types.xml' file and then run 'update-mime-database' again, they should all show up in this corresponding 'roberts-custom-mime-types' directory.

         Now it should be possible to immediately use commands like 'mimetype' to query for your new MIME type (in my case, no relog or restart was necessary):

         will output the following:

         We can also query the MIME type using the 'xdg-mime' command:

         which gives this output:

         But, if we try using the file command:

         we get this result:

         which isn't what we want!  It turns out, that there's another file that keeps track of file extension/MIME type associations in '/etc/mime.types'.  The 'file' command uses this file in determining MIME type, but it also uses a completely separate database (at '/usr/share/file/magic') for finding 'magic' values too!  You can read more at debian MIME, and also by checking the 'man' page on 'magic':

         For my use case, I didn't bother adding the MIME type support for the file command and nothing bad happened.  Doing all the steps above was enough to make the MIME association work through the graphical file manager.

         Here is a simple SVG Icon:

         Here is the literal SVG XML that will produce the image for this icon:

         Now, copy and paste the above SVG XML into a file called 'my_cusom_icon.svg':

         In my case on Ubuntu 20.04, I found that if I copy this file to '/usr/share/icons/hicolor/scalable/mimetypes/THE_MIME_TYPE.svg' this will set the icon for that MIME type as it shows in the graphical file manager.  For the 'THE_MIME_TYPE' part, just replace the '/' character that separates the MIME type group (in this case 'roberts-custom-mime-types') from the individual MIME type (in this case 'custom-kdenlive-project-file-mime-type') with a '-':

         For me, the change was immediately visible and I didn't have to re-log or restart:

    Custom MIME Type

         I did, however, notice that after running 'update-icon-caches' I don't always immediately see the changes in real-time if I have a window open with files of that type.  I need to re-open that folder in file manager, or even just clicking on something in that folder seems to be enough to trigger the repainting and redrawing of the updated icons.

    Join My Mailing ListPrivacy PolicyWhy Bother Subscribing?
    • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
    • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
    • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
    Sours: https://blog.robertelder.org/custom-mime-type-ubuntu/

    You will also be interested:

    12.3. Configuring File Associations

    12.3.1. What Are MIME Types?

    In GNOME, MIME (Multipurpose Internet Mail Extension) types are used to identify the format of a file. The GNOME Desktop uses MIME types to:

    • Determine which application should open a specific file format by default.

    • Register other applications that can also open a specific file format.

    • Provide a string describing the type of a file, for example, in a file properties dialog of the Files application.

    • Provide an icon representing a specific file format, for example, in a file properties dialog of the Files application.

    MIME type names follow a given format:

    media-type/subtype-identifier

    Example 12.7. MIME Types Format

    is an example of a MIME type where is the media type, and is the subtype identifier.

    GNOME follows the freedesktop.org Shared MIME Info specification to determine:

    • The machine-wide and user-specific location to store all MIME type specification files.

    • How to register a MIME type so that the desktop environment knows which applications can be used to open a specific file format.

    • How the user can change which applications should open what file formats.

    12.3.1.1. What Is the MIME Database?

    The MIME database is a collection of all MIME type specification files that GNOME uses to store information about known MIME types.

    The most important part of the MIME database from the system administrator's point of view is the directory where the MIME type related files specifying information on known MIME types are stored. One example of such a file is , specifying information about the standard MIME types available on the system by default. That file is provided by the shared-mime-info package.

    Getting More Information

    For detailed information describing the MIME type system, see the freedesktop.org Shared MIME Info specification located at the freedesktop.org website:

    http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/

    12.3.2. Adding a Custom MIME Type for All Users

    To add a custom MIME type for all users on the system and register a default application for that MIME type, you need to create a new MIME type specification file in the directory and a file in the directory.

    Procedure 12.3. Adding a Custom MIME Type for All Users

    1. Create the file:

      <?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/x-newtype"> <comment>new mime type</comment> <glob pattern="*.xyz"/> </mime-type> </mime-info>

      The sample file above defines a new MIME type and assigns file names with the extension to that MIME type.

    2. Create a new file named, for example, , and place it in the directory:

      [Desktop Entry] Type=Application MimeType=application/x-newtype Name=My Application 1 Exec=myapplication1

      The sample file above associates the MIME type with an application named My Application 1, which is run by a command .

    3. As root, update the MIME database for your changes to take effect:

    4. As root, update the application database:

    5. To verify that you have successfully associated files with the MIME type, first create an empty file, for example :

      Then run the command:

      standard::content-type: application/x-newtype
    6. To verify that has been correctly set as the default registered application for the MIME type, run the command:

      Default application for 'application/x-newtype': myapplication1.desktop Registered applications: myapplication1.desktop Recommended applications: myapplication1.desktop

    12.3.3. Adding a Custom MIME Type for Individual Users

    To add a custom MIME type for individual users and register a default application for that MIME type, you need to create a new MIME type specification file in the directory and a file in the directory.

    Procedure 12.4. Adding a Custom MIME Type for Individual Users

    1. Create the file:

      <?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/x-newtype"> <comment>new mime type</comment> <glob pattern="*.xyz"/> </mime-type> </mime-info>

      The sample file above defines a new MIME type and assigns file names with the extension to that MIME type.

    2. Create a new file named, for example, , and place it in the directory:

      [Desktop Entry] Type=Application MimeType=application/x-newtype Name=My Application 1 Exec=myapplication1

      The sample file above associates the MIME type with an application named My Application 1, which is run by a command .

    3. Update the MIME database for your changes to take effect:

    4. Update the application database:

    5. To verify that you have successfully associated files with the MIME type, first create an empty file, for example :

      Then run the command:

      standard::content-type: application/x-newtype
    6. To verify that has been correctly set as the default registered application for the MIME type, run the command:

      Default application for 'application/x-newtype': myapplication1.desktop Registered applications: myapplication1.desktop Recommended applications: myapplication1.desktop

    12.3.4. Overriding the Default Registered Application for All Users

    The and file are the package-installed defaults, which specify which application is registered to open specific MIME types by default.

    To override the system defaults for all users on the system, system administrators need to create the or file with a list of MIME types for which they want to override the default registered application.

    The order in which the configurations are applied is as follows:

    Within a particular location, the configurations are applied in this order:

    System administrator's configuration thus takes precedence over package configuration. And within each, desktop-specific configuration takes precedence over the configuration that does not specify the desktop environment.

    Red Hat Enterprise Linux versions prior to 7.5 used the file instead of the file.

    Procedure 12.5. Overriding the Default Registered Application for All Users

    1. Consult the file to determine the MIME types for which you want to change the default registered application. For example, the following sample of the file specifies the default registered application for the and MIME types:

      [Default Applications] text/html=firefox.desktop application/xhtml+xml=firefox.desktop

      The default application (Firefox) is defined by specifying its corresponding file (). The default location for other applications' files is .

    2. Create the file. In the file, specify the MIME types and their corresponding default registered applications:

      [Default Applications] text/html=myapplication1.desktop application/xhtml+xml=myapplication2.desktop

      This sets the default registered application for the MIME type to , and the default registered application for the MIME type to .

      For these settings to function properly, ensure that both the and files are placed in the directory.

    3. You can use the command to verify that the default registered application has been set correctly:

      Default application for 'text/html': myapplication1.desktop Registered applications: myapplication1.desktop firefox.desktop Recommended applications: myapplication1.desktop firefox.desktop

    12.3.5. Overriding the Default Registered Application for Individual Users

    The and file are the package-installed defaults, which specify which application is registered to open specific MIME types by default.

    To override the system defaults for individual users, you need to create the or file with a list of MIME types for which you want to override the default registered application.

    The order in which the configurations are applied is as follows:

    Within a particular location, the configurations are applied in this order:

    User's configuration thus takes precedence over system administrator's configuration, and system administrator's configuration takes precedence over package configuration. And within each, desktop-specific configuration takes precedence over the configuration that does not specify the desktop environment.

    Red Hat Enterprise Linux versions prior to 7.5 used the file instead of the file.

    Procedure 12.6. Overriding the Default Registered Application for Individual Users

    1. Consult the file to determine the MIME types for which you want to change the default registered application. For example, the following sample of the file specifies the default registered application for the and MIME types:

      [Default Applications] text/html=firefox.desktop application/xhtml+xml=firefox.desktop

      The default application (Firefox) is defined by specifying its corresponding file (). The system default location for other applications' files is . Individual users' files can be stored in .

    2. Create the file. In the file, specify the MIME types and their corresponding default registered applications:

      [Default Applications] text/html=myapplication1.desktop application/xhtml+xml=myapplication2.desktop

      This sets the default registered application for the MIME type to , and the default registered application for the MIME type to .

      For these settings to function properly, ensure that both the and files are placed in the directory.

    3. You can use the command to verify that the default registered application has been set correctly:

      Default application for 'text/html': myapplication1.desktop Registered applications: myapplication1.desktop firefox.desktop Recommended applications: myapplication1.desktop firefox.desktop
    Sours: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/desktop_migration_and_administration_guide/file_formats


    833 834 835 836 837