Just stumbled into another quirk.
When I try to open my QGIS project files, which are markup text files with the ending .qgs, it detects them as HTML files and tries to open them in Firefox. To open them correctly I have to right click --> Open with... and manually scroll down all the way to QGIS, because apparently it wouldn't ever consider to suggest that at the top.
So I set QGIS as the standard program to open them with. Now all my HTML files open with QGIS. .html, .htm, .qgs, the lot. Annoying, to say the least. How do I associate a specific file ending like .qgs, with a certain program like QGIS? I can't find anywhere to change it. And why is Linux Mint trying to be smart with the filetypes, instead of going by the file ending like Windows? I use 20.2, Cinnamon.
How to associate different file endings with different programs?
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
How to associate different file endings with different programs?
Last edited by LockBot on Wed May 24, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
- Pjotr
- Level 24
- Posts: 20142
- Joined: Mon Mar 07, 2011 10:18 am
- Location: The Netherlands (Holland) 🇳🇱
- Contact:
Re: How to associate different file endings with different programs?
Might be a Cinnamon bug. Try an in-place upgrade to Mint 20.3 and take it from there.
If that doesn't help: create a live USB with the iso of Mint 21 Cinnamon, boot from it and test in the live environment. When that does work as it should, consider a fresh clean installation of Mint 21.
If that doesn't help: create a live USB with the iso of Mint 21 Cinnamon, boot from it and test in the live environment. When that does work as it should, consider a fresh clean installation of Mint 21.
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Re: How to associate different file endings with different programs?
Generally speaking you can't, it's extremely difficult and complicated on Linux. Because on Linux there are no file extensions. There are MIME types, but it's messy and complicated.How do I associate a specific file ending like .qgs, with a certain program like QGIS? I can't find anywhere to change it.
On Linux, there are no file extensions. It just doesn't work like Windows. So when you see a file, say,And why is Linux Mint trying to be smart with the filetypes, instead of going by the file ending like Windows?
book.pdf
, the part .pdf
is NOT a file extension. It's part of the filename. You could rename that to whatever you want, Linux will still see it as a PDF because it looks at the first few bits of the file header to determine the file type.But Desktop Environments (such as Cinnamon) try to imitate Windows-like behavior, at least cosmetically. So this creates a lot of confusion for newcomers. When you use the "Open With..." then "Set as default" options, the system is actually changing the default application for the MIME type without telling you.
I'll explain the MIME type stuff below.
Yes, because the system sees the MIME types of those files as the same. You can see it with theNow all my HTML files open with QGIS. .html, .htm, .qgs, the lot.
xdg-mime
command. Let's say you have the file myproject.qgs
. Run this command in the folder where that file is:
Code: Select all
xdg-mime query filetype myproject.qgs
text/html
.This is because THERE IS NO FILE EXTENSION.
.qgs
means nothing. My guess is that the .qgs
files are actually HTML files in disguise.To make sure of this, I downloaded some sample
.qgs
data from here https://download.qgis.org/downloads/dat ... e_data.zipI unzipped it and found a file
relations.qgs
. I opened that file in a NORMAL TEXT EDITOR, like Geany. And yes, it's an HTML file!
Code: Select all
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis projectname="" version="2.2.0-Valmiera">
<title></title>
<relations>
<relation referencingLayer="airports20140502155725153" referencedLayer="regions20140502145258447" id="airport_region_fk" name="airport_regions">
<fieldRef referencedField="ID" referencingField="fk_region"/>
</relation>
</relations>
...
xdg-mime
on that file...
Code: Select all
➜ xdg-mime query filetype relations.qgs
text/html
.qgs
files", it's actually changing the "default app for the text/html
MIME type".There is a way to create your own custom MIME types, update the MIME database with it, create a custom default app entry for that type, and update the desktop database with it. But it would require a long and complicated tutorial to explain. I've done it once or twice, with mixed results. I don't fully understand it myself so I won't give instructions here.
Re: How to associate different file endings with different programs?
Ok, I figured it out. Apparently, QGIS does contain a MIME type specification file (https://github.com/qgis/QGIS/blob/maste ... s-mime.xml), but why my installation has been exempt from this blessed file remains a mystery. So I downloaded the file and installed it, by the instructions of a good fellow Minter (viewtopic.php?t=363837). Problem solved.
Although, I'm still curious why Linux has decided to walk this path. The big advantage of file endings is that it becomes so easy for anyone to change which program is associated with a file. This is the very reason that there are lots of file endings for different type of text files, which are in fact essentially not different, they are still text files. Conflicts such as the one between .html and .qgs files are bound to arise when file endings have no effect, and fixing it becomes much harder. Welp, it's hard trying to understand this world of Linux. Guess I'm learning at least.
Re: How to associate different file endings with different programs?
Unix has been like that for decades. It's not something Linux "chose" on purpose. It's for historical reasons. It's just fundamentally different in how it works compared to Windows. It wasn't made with graphical user interfaces in mind. There are pros and cons to both approaches. (Relying on part of a file name brings other issues with it.)Although, I'm still curious why Linux has decided to walk this path.
Take my advice: never expect Linux to work like Windows, even in the most basic things. Expect everything to be completely different. I'm not defending Linux here (Linux sucks!), just saying that's how it is.
That tutorial is nice, I was about to make one myself! Glad someone else had it already. Although I'd consider it half finished. There is a second part, if the application you want to open those files is not already registered. By adding a
.desktop
file to ~/.local/share/applications
for a specific application that you want, and then using update-desktop-database
to have that application associated with that file type... I guess that can be done graphically. Anyway.Re: How to associate different file endings with different programs?
Good advice. I'm not expecting Linux to be like Windows, but I'm expecting it to be... logical. But I guess it is in some sense, although I'm quite far from understanding just how yet