2011-08-03. User or system-wide selection of an application for all of a group of mimetypes. A common annoyance when running KDE on various systems and (particularly) for multiple users, is configuring the assocation of mimetypes with applications. This is needed to allow e.g. konqueror (or dolphin, in KDE4) to open a file with a chosen default player, rather than requiring the user to choose. It can of course easily be done by a single user who knows where to find the settings (Konqueror, Settings, Configure konqueror, File management, File assocications) and knows what to choose. Or, users can tolerate whatever ends up as default. But a common situation is that there are plenty of non-savvy users who want (surprise surprise) to /use/ the computers, getting familiar applications when they open files, and not have to think about these details. As there are always likely to be applications with overlap of which types they can open, and users who want different applications, it's not a solution just to remove everything but the one desired application. It's impractical to change settings for every user for every type. One can find a system-list of types in: /etc/mime.types , e.g. video/ogg ogv Some detail of standards that the major desktops now strive to follow can be found at http://standards.freedesktop.org/ The files in $HOME/.local/ contain general configuration, i.e. details that aren't just specific to KDE or Gnome or whatever. By making a few mime-type changes in konqueror then searching for the most recently modified files in the home-directory settings: find ~/.??* -mmin -1 one notes that files here have been modified, for example ~/.local/share/applications/mplayer.desktop after asking for MPlayer to open other types of video files. The structure of such files is clear from: cat ~/.local/share/applications/mplayer.desktop [Desktop Entry] Comment=Media Player For Linux Exec[$e]=mplayer GenericName= Name=MPlayer InitialPreference=10 Icon=mplayer MimeType=application/vnd.ms-asf;application/vnd.rn-realmedia;application/x-flash-video;application/x-matroska;application/x-mplayer2;application/x-ogg;audio/mp4;audio/mpeg;audio/mpegurl;audio/x-mpegurl;video/3gpp;video/3gpp-encrypted;video/3gpp2;video/annodex;video/avi;video/dv;video/fli;video/flv;video/isivideo;video/mediaplayer;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/wavelet;video/webm;video/x-anim;video/x-annodex;video/x-avi;video/x-fli;video/x-flic;video/x-flv;video/x-javafx;video/x-m4v;video/x-matroska;video/x-mng;video/x-ms-asf;video/x-ms-wm;video/x-ms-wmp;video/x-ms-wmv;video/x-msvideo;video/x-nsv;video/x-ogg;video/x-ogm;video/x-ogm+ogg;video/x-real-video;video/x-sgi-movie;video/x-theora;video/x-theora+ogg Path= StartupNotify=false Terminal=false TerminalOptions= Type=Application X-DCOP-ServiceType= X-KDE-SubstituteUID=false X-KDE-Username= which shows the state of the file after I'd done the following things to make a comprehensive list of "possibly video" mime-types. A very important point is the "InitialPreference", which I had seen in another desktop config file, but is usually omitted. This was a useful description of the process by which an application is selected to open a particular file, using the InitialPreference, https://forums.mageia.org/en/viewtopic.php?f=8&t=531 By find /usr/share/applications/ | xargs grep InitialPreference some system-wide files containing this instruction were found: they are only a small proportion, 28/400, of the total of files there; typical values of this parameter are 1 to 10, but I don't know if there's a practical limit. To try to find all video mimetypes supported by any application, this was done: user@box ~ $ grep type= /usr/share/mime/video/* | sed -e 's/.*type="//' -e 's/".*//' | sort | uniq application/annodex application/ogg application/vnd.ms-asf application/x-flash-video application/x-matroska application/x-mplayer2 audio/3gpp audio/3gpp-encrypted audio/3gpp2 audio/amr audio/amr-encrypted audio/amr-wb audio/amr-wb-encrypted audio/x-rn-3gpp-amr audio/x-rn-3gpp-amr-encrypted audio/x-rn-3gpp-amr-wb audio/x-rn-3gpp-amr-wb-encrypted flv-application/octet-stream video/3gpp video/3gpp-encrypted video/3gpp2 video/annodex video/avi video/dv video/fli video/flv video/isivideo video/mediaplayer video/mp2t video/mp4 video/mp4v-es video/mpeg video/ogg video/quicktime video/vivo video/vnd.divx video/vnd.rn-realvideo video/vnd.vivo video/wavelet video/webm video/x-anim video/x-annodex video/x-avi video/x-fli video/x-flic video/x-flv video/x-javafx video/x-m4v video/x-matroska video/x-mng video/x-ms-asf video/x-ms-wm video/x-ms-wmp video/x-ms-wmv video/x-msvideo video/x-nsv video/x-ogg video/x-ogm video/x-ogm+ogg video/x-real-video video/x-sgi-movie video/x-theora video/x-theora+ogg After storing in a file and editing to remove things quite clearly mainly audio-related, the file was converted to the format for the mplayer.desktop file: cat file.txt | xargs | sed -e 's/ /;/g' No icon was definied in the mplayer.desktop file initially. A search for mention of icons revealed the (simple) format, find /usr/share/applications -type f | xargs grep -i icon an example of the output being /usr/share/applications/smplayer.desktop:Icon=smplayer An icon called "mplayer"-something was found, find /usr/share/icons/ | grep -i mplay one example being /usr/share/icons/nuvola/64x64/apps/mplayer.png (there were others in other sizes, but not from any other family than nuvola). So: a finished .desktop config file in my ~/.local/ and copied to a few others. Now mplayer always comes first. Wouldn't it be nice to have a system-wide one? One could copy it as mplayer.desktop under /usr/share/applications/ on all systems; in this case there would be no problem as mplayer itself created no such file. But in the more general case, files in /usr/ could be overwritten by an update to a package, reverting to their usual format. That would annoy users. The nicely-behaved application picks up configuration from its "manufacturer", in /usr, then from system-wide configs in /etc (set by the admin, not the package), then from the calling user's homedir (e.g. ~/.appname/ or ~/.config/appname/ ) and then from the command line, in order of increasing priority for any parameters set more than once. Is there somewhere under /etc where one can put .desktop config files? find /etc/ -name \*.desktop revealed just some display-manager and autostart files, on my Gentoo system, e.g. /etc/xdg/autostart/* The package xdg-utils contains the handy command xdg-mime, that can show and set some relations between mime-types and applications (without the user having to find and grep and edit desktop files), e.g. xdg-mime query default video/x-matroska returns mplayer.desktop But I don't see a way to get an "all" or "verbose" list that would show all the sources of information that it has checked to arrive at the victor. Until I find something such, I'll note the most convenient way of system-wide setting an application preference for all current and future users who don't make their own overrides, as the following: 1) Copy a .desktop config file to the ~/.local/..../ (as seen above for mplayer) 2) Edit to change mimetypes and InitialPreference (note: only KDE) 3) When happy for this user-account, copy to the system-wide directory under /usr 4) If there's already a file of that name and you want to avoid overwrites from later updates, or cheats such as chattr +i /.../file , then give it another name ... for example, call the file and its "Name=" field M_Player to avoid clashing with MPlayer, but keep the "Command=" the same, mplayer.