As a packager, can you prevent a program from taking over as default for file associations?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As a packager, can you prevent a program from taking over as default for file associations?
Per the title, is it possible to ensure a program can't take over as the default application for file types? My experience is strictly with KDE4 (on 14.2), so I'm not sure if this is specifically a KDE issue or something within the OS itself.
Background
I'm the maintainer of mediainfo. When I install this package (with the GUI=yes option), mediainfo-gui becomes the default application for several different file types (I've changed the defaults on my system, so I couldn't tell you which ones).
This also happens with MusicBrainz's picard, taking over aac, ac3 and midi.
I also noticed that EasyTag has become the default application for flac and mp3.
I know I can change the defaults back, but it seems that there should be a way to prevent certain programs from ever being default (assuming another program is already registered to the system). I don't think anyone would ever want to double click a media file and have mediainfo open up (especially when it adds an entry to the context menu).
I maintain both mediainfo and picard on SBo and I'd love to be able to add something to the resulting packages to make sure I'm not mucking up with people's file associations.
Any ideas?
Last edited by bassmadrigal; 04-11-2021 at 02:02 PM.
if [ -x /usr/bin/update-desktop-database ]; then
/usr/bin/update-desktop-database -q usr/share/applications
fi
which is run by the doinst.sh of most desktop application packages.
From the manpage:
Code:
The update-desktop-database program is a tool to build a cache database of the MIME types handled by desktop files...
As I understand, the command scans for .desktop files in the directory /usr/share/applications and updates the MIME types database reading the variable "MimeType" in the .desktop files.
You can override these associations using various config files, usually in the home directory, and these are handled by KDE/Gnome/whatever-desktop coming with MIME types association editing tools.
To answer your question, you could try disabling that command in the doinst.sh and see what happens.
Disabling the command won't help in the long run because the next install of any desktop application will run it again. Unless you disable it in all software using GUI, that is.
A better approach would be creating Override.xml as described in the Shared MIME info specification. Or overriding the system MIME defaults via files in ~/.local/share/mime/ and/or /usr/local/share/mime/ because they take higher precedence.
Just right click the file and look at permissions..."Opens With"
DONE. All files with that suffix will open with that program selected.
KDE ? Dunno. Never will
if [ -x /usr/bin/update-desktop-database ]; then
/usr/bin/update-desktop-database -q usr/share/applications
fi
which is run by the doinst.sh of most desktop application packages.
--snip--
To answer your question, you could try disabling that command in the doinst.sh and see what happens.
The problem with this is I believe it removes the program from the "Open With" dialog. I want to allow users to still open the program, but I just don't want the program to take over existing defaults without the user specifying it.
Quote:
Originally Posted by shruggy
A better approach would be creating Override.xml as described in the Shared MIME info specification. Or overriding the system MIME defaults via files in ~/.local/share/mime/ and/or /usr/local/share/mime/ because they take higher precedence.
If I'm understanding this correctly, this would just be for individual users, right? Not something a software packager can (or should) do.
Quote:
Originally Posted by EdGr
The idea that the computer could correctly guess which program the user wants to run on a file was doomed from the beginning.
If you are writing software, I recommend avoiding the MIME database.
Ed
What's the alternative for a MIME database?
From my albeit limited understanding, MIME databases are still handy for GUI apps and to let users know what programs are able to open what. However, I was just hoping there was some setting to state that you don't want to have a program become a default over other existing programs. I don't foresee anyone installing EasyTag would want that to open up by default when they double-click on an mp3, yet that's what happened on my system after installing it. I then needed to go through and adjust the default program back to my original program.
[ Sorry, just realised that you are looking for something to add at a package level... please ignore the noise from here ]
Maybe try using a file ~/.config/mimeapps.list ?
This is what I set up for my students so that things open in the expected programs.
This is using XFCE, so it's possible it might not work under KDE.
Here is my default example:
(Where there are two options listed, the first one is the default)
If I'm understanding this correctly, this would just be for individual users, right? Not something a software packager can (or should) do.
Then I misunderstood your question. I thought you want it as a user, not as a packager.
Determining what is the default application for a given MIME type is managed by KDE via mimeapps.list. See this question at SE. The file is searched in this order:
From my albeit limited understanding, MIME databases are still handy for GUI apps and to let users know what programs are able to open what. However, I was just hoping there was some setting to state that you don't want to have a program become a default over other existing programs. I don't foresee anyone installing EasyTag would want that to open up by default when they double-click on an mp3, yet that's what happened on my system after installing it. I then needed to go through and adjust the default program back to my original program.
Let the user decide which program to run. This is most practical if one is writing new software. Otherwise, one needs to muck with mimeapps.list as shruggy described.
Ed
Then I misunderstood your question. I thought you want it as a user, not as a packager.
Determining what is the default application for a given MIME type is managed by KDE via mimeapps.list. See this question at SE. The file is searched in this order:
Unfortunately, none of this seems to help a packager prevent their program from becoming default. Also, none of those exist on my 14.2 system except for ~/.config/mimeapps.list
Based on this thread, it seems that as a packager, I'll just have no control over this and it'll be up to users to change it back if the system decides to change things. That's unfortunate.
Quote:
Originally Posted by EdGr
Let the user decide which program to run. This is most practical if one is writing new software. Otherwise, one needs to muck with mimeapps.list as shruggy described.
How does a user know what programs are able to run a file without a MIME database? And how does the WM/DE know to associate a program with a specific type of file? I do like having EasyTag show up as a program in the "Open With" submenu, and I don't think that is possible without some sort of MIME database...
How does a user know what programs are able to run a file without a MIME database? And how does the WM/DE know to associate a program with a specific type of file? I do like having EasyTag show up as a program in the "Open With" submenu, and I don't think that is possible without some sort of MIME database...
The user knows which program to run on a file. That works on the command line, and it works in GUI programs too.
At this point, I can't provide more help with MIME or KDE because I do not use them. One motivation for creating my own system was that I have a lot of file types that MIME and file sniffers don't recognize. The user (me) knows exactly what they are.
Ed
The user knows which program to run on a file. That works on the command line, and it works in GUI programs too.
On commandline, there's no easy way (that I'm aware of) for users to know what programs support what. They need to just try programs until they find one that works the way they want it to. If you're on an unfamiliar system and only have the CLI available, how do you know what can open up an mp3? I ask because I had to do this recently while trying to debug conty. Luckily, mpg123 was on there and I was able to find it after digging through the /usr/bin directory.
However, there's no reason to do that in a WM/DE. When you double click on an mp3, you expect it to play in a program. If you want to see what other programs may be available to play the file, you can right click and see what's in the "Open with" submenu. A MIME database is key to this functionality.
Anyway, my post was not to debate the positives or negatives of a MIME database. I simply wanted to know if it's possible for a packager to prevent their package from taking over defaults when a user installs it. If you want to keep debating whether people should use MIME databases, please open a new thread to discuss it. Thanks!
On commandline, there's no easy way (that I'm aware of) for users to know what programs support what. They need to just try programs until they find one that works the way they want it to. If you're on an unfamiliar system and only have the CLI available, how do you know what can open up an mp3?
The xdg-utils package is part of Slackware 14.2. Does
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.