Fatdog64 MIME Type Tips

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
step
Posts: 546
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 57 times
Been thanked: 198 times
Contact:

Fatdog64 MIME Type Tips

Post by step »

Damn! The same file opens with Program A when ROX activates the icon but with Program B when another application activates the file.
Has this kind of surprising file activation ever happened to you?
Do you wish that the file opened with the same program regardless of going through ROX or another application?
Can it be done? Yes, quite simply.

Main Article

In this article I will briefly explain how the Fatdog64 MIME-type system works, and how to fix a surprising file activation.
To minimize reading time, background material is covered in the Appendix section.

Fatdog64 MIME-type synchronization

In Fatdog64, and the historical Puppy Linux design, ROX Filer plays a central role. It provides a sober but functional desktop experience, and a non-conventional but extremely effective file manager, which - once one gets used to it - is hard to do without. (There also exists a ROX Desktop component, which isn't part of Fatdog64).

ROX Filer implements the freedesktop.org MIME-type standard to determine the "type" of a file (represented by its icon), consequently which "default application" should start when the icon is activated (clicked). ROX Filer also provides a method - and a database - to define and manage MIME types and default applications entirely with ROX Filer.
Unsurprisingly, ROX Filer prioritizes its MIME-type database higher than the freedesktop.org's database, ensuring coherence and no surprises to experienced ROX Filer users. Also Unsurprisingly, The Fatdog64 standard ISO, which includes ROX as The Only File Manager, relies on the ROX database to provide a smooth and consistent file browsing experience.

However, when another file manager is installed alongside ROX, the former is not aware of ROX's own MIME-type database. Moreover, when new application packages are installed, they usually add new MIME types to the freedesktop.org's MIME-type database, ignoring ROX MIME types. So things start diverging. For these reason, the Fatdog64 developers created fatdog-sync-mime.sh (2016-2023), a tool that synchronizes the ROX and freedesktop.org databases. fatdog-sync-mime.sh runs when the system boots. It can also be invoked on demand.

When confronted with the question of which database to prioritize, the Fatdog64 developers chose to prioritize ROX. Therefore, given the same file type, if the same file type is set to open with application A in ROX, and with application B in freedesktop.org, ROX will open the file with application A. Of course, other applications will open the file with application B, resulting in a "surprising" activation for ROX Filer users.

Fixing a surprising file activation for users of ROX Filer (all users)

You can teach fatdog-sync-mime.sh to import a ROX MIME-type into the freedesktop.org database. Once this is done, all freedesktop.org's compliant applications will open the file with the same program that ROX uses.

For example, on a pristine Fatdog64-9xx system, let's take a markdown document, /etc/xdg/Startup/README.md and compare how ROX Filer and gtkmenuplus open the file. (The gtkmenuplus application simply creates a popup menu from text directives. I could use another application for this example, but gtkmenuplus comes handy for the sake of this example because it is pre-installed).


ROX Filer icon opens with mdview application.

0001_rox-icon-and-mdview.png
0001_rox-icon-and-mdview.png (26.92 KiB) Viewed 805 times

.
.


With the default MIME type associations, gktmenuplus displays no icon and cannot even open the markdown document.

0002-gtkmenuplus-no-icon-no-open.png
0002-gtkmenuplus-no-icon-no-open.png (12.51 KiB) Viewed 805 times

.
.

To teach gtkmenuplus to use ROX's markdown icon and application, we need to create the following ".desktop" file, and run fatdog-sync-mime.sh.

The file name is arbitrary, but I prefer to use a naming scheme: start with _mt_rox_ and end with the MIME type text.

  1. Find the MIME type text. In a terminal window, type the following command and press Enter:
    rox -m /etc/xdg/Startup/README.md
    Output
    text/markdown

    "text/markdown" is the MIME-type text. You must replace / with _ to use it as a file name.
    So, create file /usr/share/applications/mt_rox_text_markdown.desktop, and write into it:

    Code: Select all

       [Desktop Entry]
       Type=Application
       # Anything will do
       Comment=text/markdown mime-type handler
       # Can be any icon type (full path, GTK stock icon, named icon in icon theme)
       Icon=/usr/local/apps/ROX-Filer-jun7/ROX/MIME/text-markdown.png
       # Must be the absolute path of the ROX MIME-type handler
       Exec=/etc/xdg/rox.sourceforge.net/MIME-types/text_markdown
       # Don't display this entry in the system menu
       NoDisplay=true
       # Must match the value that "rox -m FILE_OF_THIS_KIND" prints
       # Must also match the Exec= basename (replacing "/" for "_")
       MimeType=text/markdown;
  2. Now run fatdog-sync-mime.sh. Here is how gtkmenuplus icon and open-markdown application have changed.
    (See also the Notes section after the image).


After MIME synchronization gktmenuplus displays the ROX markdown icon, and opens the markdown document with mdview.

0003-gtkmenuplus-md-icon-and-mdview.png
0003-gtkmenuplus-md-icon-and-mdview.png (117.13 KiB) Viewed 805 times

Notes

  • If you did everything correctly, you should find the following line in file /usr/share/applications/mimeapps.list:

    Code: Select all

      text/markdown=bt_rox_text_markdown.desktop;

    If you can't find it then you missed something. Start over.

  • Icon= Any icon will work and affect gtkmenuplus but not ROX Filer. To display the same icon in both programs you must use ROX's icon for the given MIME-type. You can find icons for other MIME types in the same location.

  • Exec= To find the ROX MIME-type handler for a given MIME type, take the MIME-type text, make a file name by replacing _ for /, then look for this file in directory /etc/xdg/rox.sourceforge.net/MIME-types.

  • MimeType= Use rox -m to find the MIME type. (Likely it will not match the output of xdg-mime query filetype).

  • It should be possible to restrict the change to the current user only rather than to all users. The key is to replace system locations with current user's locations for ROX MIME-type ~/.config/rox.sourceforge.net and freedesktop.org ~/.local/share/applications.

Fixing a surprising file activation for users of file managers other than ROX

If a user never runs ROX Filer then they will never notice surprising file activations of the kinds described above. There is nothing to fix in this case!

Conclusions

You can adapt the above example to fix other annoying surprising activations. If you come up with a desktop file that you think can benefit other Fatdog64 users please share it in this thread.

Appendix

Background: Linux MIME-type handling

I will not spend much time on this subject because a search engine can return tutorial galore about the Linux MIME type system.
Just a few key points.

  • For historical reasons, a Linux system has not one but many databases that determine the "type" of a file (so called MIME type), and which "default application" should open it.

  • In an effort to coordinate the synchronization of the various databases, the freedesktop.org organization provides standard specifications of software components that handle the icons and applications of a modern Desktop Environment. Applications are expected to follows the standards.

  • For historical reasons, incomplete standards, non-conforming implementations, misconfigured software, etc. not all applications can follow the standard. Consequently, sometimes an unexpected icon shows up or the wrong application opens a data file, and several other similarly small but still annoying issues occur.

  • The following is a non-exhaustive list of tools that are involved in setting, getting and querying MIME types and default applications (leaving aside the additions brought by the major Desktop Environments, such as Gnome, KDE, Xfce, etc.)

    • Tools: update-desktop-database, update-mime-database, gtk-update-icon-cache, file, xdg-open, xdg-mime...

    • Files:
      /etc/mime.types, /etc/mailcap, /usr/share/applications/mimeapps.list, /usr/share/applications/mimeinfo.cache, /usr/share/applications/defaults.list,
      ~/.mime.types, ~/.mailcap, ~/.local/share/applications/mimeapps.list, ~/.local/share/applications/mimeinfo.cache, ~/.local/share/applications/defaults.list,
      /usr/share/misc/magic.mgc ~/.magic...

Clarity
Posts: 3823
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1621 times
Been thanked: 521 times

Re: Fatdog64 MIME Type Tips

Post by Clarity »

Hi @step This is an excellence description and write-up!

I am sure as time progresses, @fatdog will review for simplicity going forward with desktops and file-managers.

THANKS! :thumbup:

User avatar
p310don
Posts: 356
Joined: Tue Dec 03, 2019 7:17 am
Location: Brisbane, Australia
Has thanked: 72 times
Been thanked: 103 times

Re: Fatdog64 MIME Type Tips

Post by p310don »

It's been years. I use 8.13 at work still, and this "surprising" app thing has bugged me all the time.

I often have to use csv files downloaded from online sources in chrome. It always opened in a text editor, not in LO calc as I would like.

I followed your instructions @step and it now opens (it opens seamonkey first, and then opens LO).

step
Posts: 546
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 57 times
Been thanked: 198 times
Contact:

Re: Fatdog64 MIME Type Tips

Post by step »

p310don wrote: Tue Jun 25, 2024 7:28 am

I followed your instructions @step and it now opens (it opens seamonkey first, and then opens LO).

Glad it does! I don't know about the seamonkey intro. If you post what you did exactly, I can take a look to see if seamonkey can be prevented from starting.

Post Reply

Return to “FatDog”