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.
.
.
With the default MIME type associations, gktmenuplus displays no icon and cannot even open the markdown document.
.
.
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.
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;
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.
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=
Userox -m
to find the MIME type. (Likely it will not match the output ofxdg-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...