Fixing Aggressive Apps Stealing File Associations on Linux
The Problem
A common and frustrating issue on Linux desktops is when a newly installed application (frequently chat apps, mail clients, or apps built using Electron, like Element or Discord) violently hijacks your default file associations.
Symptoms:
- You double-click an HTML file (
.html), and instead of opening in your preferred web browser (like Brave, Firefox, or Chrome), it opens inside the chat app or a completely unrelated program. - Clicking a web link (
http://orhttps://) in any application opens the wrong program. - You go into your system settings and manually change the default browser back to your preference, but the next time you open the aggressive app, it stealthily steals the defaults back.
Why does this happen?
When these apps launch or update, their internal scripts may run commands (like update-desktop-database or xdg-mime) that forcefully register the app as capable of handling web links. If the desktop environment gets confused about priority, or if the app actively edits your configuration files, it can override your choices.
The Solution: Blacklisting via “Removed Associations”
Instead of locking your configuration files completely (which prevents you from changing defaults later) or fighting a constant tug-of-war, Linux provides an elegant, built-in solution. You can explicitly blacklist an app from ever opening a specific file type.
This works by editing your local MIME (Multipurpose Internet Mail Extensions) configuration file.
Step-by-Step Guide
- Open your configuration file:
Open your terminal and use a text editor to open your MIME configuration list:
nano ~/.config/mimeapps.list
- Find or create the Blacklist section:
Scroll all the way to the bottom of the file. Look for a section called[Removed Associations]. If it doesn’t exist, create it by typing exactly that on a new line. - Add the aggressive app to the blacklist:
Under[Removed Associations], you define the file type (liketext/html) followed by the desktop file name of the aggressive app. For example, to completely banish Element from opening web links and HTML files, add these lines:
[Removed Associations]
text/html=element-desktop.desktop;
x-scheme-handler/http=element-desktop.desktop;
x-scheme-handler/https=element-desktop.desktop;
(Note: The trailing semicolon ; is important according to the standard!)
- Save and Exit:
Save the file (innano, pressCtrl+O,Enter, thenCtrl+X).
Why this is the best approach:
- It is absolute: The Linux desktop environment (GNOME, Cinnamon, KDE, etc.) will read this blacklist and strictly enforce it. Even if the aggressive app claims it can open HTML files in its own configuration, the system will actively ignore it.
- You stay in control: Your configuration file is still writable, so you can freely change your default browser whenever you want via the normal system settings GUI.
- It is surgical: It only blocks the aggressive app from the specific file types you specify. The app will continue to function normally for its intended purposes.