How to set default program file associations in KDE5 Plasma
One of the many tedious tasks when setting up a new system, or if you've just installed new software to replace something you used previously, is to change the default software used when opening up different types of files.
For example, I may have GIMP open when I click on a .png file, but Gwenview open for .jpg files, if I find myself editing .png files often but hardly doing more with .jpg's than viewing them. Or perhaps you want to set all python files to automatically open in Atom when you double click them?
Whatever your logic is, in KDE5 there are two main wats you could go about this using built-in graphical tools.
Change KDE File Associations: Method one
The first way, and in my opinion, the easiest, is to simply change the file association, each time you come across a file in your day-to-day happenings, where you encounter a change that is needed, by using the 'open with' right-click menu option.
For example, if you wanted to ensure that all .txt files are opened via KWrite according to this method, simply right click on the file, and select "Open with" and then "Other."
From here, you'll need to select the program that in the future, you wish to use as default for that specific filetype (.txt in our example.)
Important: Don't forget to click the little box at the bottom, signifying to remember this change for the future, or you'll have to redo this again!
Done! You can do this each time you come across a different file type in your day, until everything is done, without going out of your way too far.
Change KDE File Associations: Method two
This method is to manually search for, and change the file associations, one by one, from within the KDE settings application.
By clicking your applications menu in the (default) bottom left corner of your screen, followed by "Settings" and "System Settings" you'll be taken to the main settings application. We won't cover the other options here in this tutorial, so head down to "Applications" and you'll find our next step.
Next, you'll want to click "File associations" on the left side, as seen in the image below. From here, you can either browse or search for the file extension you want to change, select it, and on the right side of your screen select the application you wish to use.
I personally find this option less appealing, but some may want to get a bunch out of the way all at once, and I find this method might be more suiting to such end.
Last thoughts
No matter how you do it, it's a good idea to change your file associations as soon as you can, to avoid headache and annoyance when accidentally opening the wrong application for the job at hand.
Now you: Which method do you prefer, and why? Let us know in the comments!
Related articles
- A Look at Desktop Environments: KDE 5 Plasma
- Back to Basics Part 5 -- Working with archives in GNU/Linux
- Bypass System File Associations With Portable Extension Warlock
- Get to know Linux: Removing files
- Tips and Tricks for KDE 5 Dolphin File Manager
from the command line:
kcmshell5 filetypes componentchooser
(or kcmshell for KDE 4)
also:
# POSIX function to report the possible KDE handlers for a given file
whathandles ()
{
ktraderclient –mimetype $(xdg-mime query filetype ${1:?Must Specify File}) 2> /dev/null | grep ‘^Exec’
}
$ whathandles quicktips.docx
Exec : ‘libreoffice6.0 –writer %U’
Exec : ‘libreoffice5.4 –writer %U’
Exec : ‘ark %U’
And using FreeDesktop/XDG, report the MIME type of a file
$ xdg-mime query filetype quicktips.docx
application/vnd.openxmlformats-officedocument.wordprocessingml.document
and display the primary application bound to that mimetype
$ xdg-mime query default application/vnd.openxmlformats-officedocument.wordprocessingml.document
libreoffice6.0-writer.desktop
(this’ll be the same as the top ktraderclient entry)
Admiral Akbar’s image >
theory-of-everything.deviantart.com/art/Admiral-Akbar-s-Rhum-72309171