LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-10-2021, 06:56 PM   #1
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
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.
 
Old 04-11-2021, 07:38 AM   #2
giomat
Member
 
Registered: Jul 2017
Posts: 337

Rep: Reputation: 238Reputation: 238Reputation: 238
So the culprit seems to be this command
Code:
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.

For example, gvim.desktop contains the following
Code:
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
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.
 
Old 04-11-2021, 08:05 AM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
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.

Last edited by shruggy; 04-11-2021 at 08:10 AM.
 
Old 04-11-2021, 08:48 AM   #4
Bonzoo
Member
 
Registered: Sep 2018
Location: Costa Rica
Distribution: Antix21a2,Parrot rolling,MXfce19.4,Sparky Openbox
Posts: 233

Rep: Reputation: 48
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
 
Old 04-11-2021, 08:51 AM   #5
Bonzoo
Member
 
Registered: Sep 2018
Location: Costa Rica
Distribution: Antix21a2,Parrot rolling,MXfce19.4,Sparky Openbox
Posts: 233

Rep: Reputation: 48
Maybe if the Gates desktop environment gives a fit you could sudo dolphin in the terminal ?
 
Old 04-11-2021, 10:08 AM   #6
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 997

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
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
 
1 members found this post helpful.
Old 04-11-2021, 01:49 PM   #7
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Original Poster
Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by giomat View Post
So the culprit seems to be this command
Code:
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 View Post
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 View Post
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.
 
Old 04-11-2021, 01:58 PM   #8
Loomx
Member
 
Registered: Sep 2012
Distribution: Slackware
Posts: 184

Rep: Reputation: Disabled
[ 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)
Code:
[Default Applications]
image/jpeg=gthumb.desktop;
image/png=gthumb.desktop;
video/mp4=vlc.desktop;shotcut.desktop;
video/x-matroska=vlc.desktop;shotcut.desktop;
text/plain=mousepad.desktop
application/x-shellscript=mousepad.desktop;
application/pdf=atril.desktop;
application/octet-stream=soffice.desktop;
audio/mpeg=audacious.desktop;
audio/x-mpegurl=audacious.desktop;

[Added Associations]

Last edited by Loomx; 04-11-2021 at 02:00 PM.
 
Old 04-11-2021, 02:03 PM   #9
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Original Poster
Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by Loomx View Post
[ Sorry, just realised that you are looking for something to add at a package level... please ignore the noise from here ]
I renamed the title to hopefully clear it up better.

But your post might help someone searching for how to do it on their end... Thanks for keeping it!
 
Old 04-11-2021, 02:26 PM   #10
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by bassmadrigal View Post
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:
Code:
~/.config/kde-mimeapps.list
~/.config/mimeapps.list
/etc/xdg/kde-mimeapps.list
/etc/xdg/mimeapps.list
/usr/share/applications/kde-mimeapps.list
/usr/share/applications/mimeapps.list
Its format is described in MIME apps spec.

Last edited by shruggy; 04-11-2021 at 02:30 PM.
 
1 members found this post helpful.
Old 04-11-2021, 03:02 PM   #11
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 997

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Quote:
Originally Posted by bassmadrigal View Post
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.
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
 
Old 04-11-2021, 03:23 PM   #12
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Original Poster
Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by shruggy View Post
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:
Code:
~/.config/kde-mimeapps.list
~/.config/mimeapps.list
/etc/xdg/kde-mimeapps.list
/etc/xdg/mimeapps.list
/usr/share/applications/kde-mimeapps.list
/usr/share/applications/mimeapps.list
Its format is described in MIME apps spec.
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 View Post
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...
 
Old 04-11-2021, 03:37 PM   #13
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 997

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Quote:
Originally Posted by bassmadrigal View Post
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
 
Old 04-11-2021, 07:21 PM   #14
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Original Poster
Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by EdGr View Post
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!
 
1 members found this post helpful.
Old 04-12-2021, 02:44 AM   #15
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by bassmadrigal View Post
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
Code:
xdg-mime query default audio/mp3
or
Code:
xdg-mime query default audio/mpeg
not work in Slackware?

BTW,
Code:
xdg-mime default org.kde.amarok.desktop audio/mpeg
is the command line way to set the default application for a MIME type.

Last edited by shruggy; 04-12-2021 at 02:49 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] what instruction to prevent one OS's boot taking over computer solarwarrior Linux - Desktop 4 02-16-2018 02:04 PM
File associations in Gnome Commander vs. associations in Nautilus taylorkh Linux - Software 0 01-01-2010 05:18 PM
File type associations with default applications in Gnome/FC3 mjbrej Fedora 3 12-25-2004 05:28 PM
Program Associations rkid Linux - Software 3 10-11-2003 12:06 PM
Program associations in Gnome jsin Linux - Newbie 4 09-26-2003 10:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration