[kde-linux] Remove file association for many file types

Duncan 1i5t5.duncan at cox.net
Wed Nov 27 21:49:27 UTC 2013


Klaus Slott posted on Wed, 27 Nov 2013 21:25:15 +0100 as excerpted:

> For some time now VLC seems to be default selection on my kde profile no
> matter what kind of file I open. At first I did not really care that
> much as I am mostly a console user. The few times I launch something
> from gui I just corrected the association for file type in question.
> 
> But it is getting annoying, there is so many file types and bloody VLC
> seems to have associated itself with every file type on my system!
> 
> I have googled but found no solution, please tell me there is some
> common way to remove VLC from all file associations.

The GUI method (one by one but all in the same place, at least):

KDE settings (unfortunately called system settings, when with a few 
exceptions like system time they're user-specific kde-specific settings 
having *NOTHING* to do with global system settings!), common appearance 
and behavior, file associations.

Take a look at the various video/* and audio/* types, and possibly some 
image/* types as well.


Direct-edit text-config-files method:

The list is derived from several places, both system level and user 
level.  I don't have time to go thru and check all this out ATM, and you 
should be able to do about the same thing I would anyway, so... But try 
the following:

First, query your package installation database (here on gentoo I use 
equery files, but that's gentoo specific; it'll depend on your distro and 
the package manager it uses) for the files installed by the vlc package.  
Based on the results I get here, the following files look interesting:

/usr/share/applications/vlc.desktop

This is the main *.desktop file with the menu entry and mimetype list for 
vlc.  Note that near the bottom it has a looonngg MimeType= line.  This 
is the default list.  Also note the X-KDE-Protocols line.

Check /usr/share/mime/video/*, and also audio/*.  These are the system's 
main mimetype lists.  They should be generic lists, not listing any app.  
Likely they aren't owned by a package, because they're created by update-
mime-database (as noted in the files themselves).

At the user level, check ~/.local/share/applications/defaults.list .  
This may or may not exist.  If it does, it will likely override the 
system stuff.

*** THIS ***
In the same ~/.local/share/applications/ subdir, look for any vlc*.desktop 
files.  Again, this will override system defaults.  I don't know how to 
"whiteout" mimetype entries, but I suspect if you use the GUI to remove 
vlc from one association, it'll show up in this file as a whiteout, and 
you can use that pattern to whiteout others via direct-edit.
***/ THIS***

Also of interest if your distro includes them:

/usr/share/vlc/utils/audio-vlc-default.sh , video-vlc-default.sh , and 
gnome-vlc-default.sh .  These actually set vlc as the default for 
mimetypes found in /usr/share/mime/video or audio using the user-specific 
defaults.list file mentioned above.  But presumably you could edit the 
script to set mimetype whiteout entries or something instead.


One thing I've done here is... (Unless your distro patches it out, gentoo 
tries to but I patch it back in) kde has a couple useful mimetype 
"pseudotypes", including all/allfiles.  Using the GUI, I associated vlc 
with all/allfiles, but at a lower priority than a couple other entries I 
have there (including kwrite, for editing text files), so it's not the 
left-click action, but is still available in the context-menu open-with.  
That way I can use open-with to open an arbitrary file, say a tempfile 
that's still downloading for use in another program, with vlc.  (Here, I 
sometimes use it with youtube files downloaded by minitube.  Minitube's a 
great youtube player, but sometimes I want to play the file with 
something else.  Since minitube downloads the files to $TMP, I can open 
$TMP in dolphin or whatever, then find the minitube tmpfile and use open-
with to open it in smplayer2 or vlc or whatever.)

What I've /not/ done, but what would be /possible/, would be to 
disassociate vlc from all mimetypes, and simply keep it associated with 
the all/allfiles pseudomimetype, so it can still be used via open-with on 
anything.

What I don't know is kde's mechanism for prioritizing mimetype 
associations.  If I was interested in editing those en-mass, I'd probably 
strace a GUI mimetype edit session and see what files it opened, using 
something like

strace -eopen kcmshell4 filetypes 2>&1 | grep /home/user > 
filetypes.output

That'd dump quite a list, which you could then go thru (or further grep
-v filter before the dump), deleting the uninteresting font/icon/
unrelated-config fileopens, and see what files remain.  Then check them 
and see what it actually does when you change an open-with priority, so 
you can do the same thing via direct text-file edit.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman




More information about the kde-linux mailing list