4

I would like to open .txt files with Text Editor by default but .tex files with Texmaker. However, if I change the default programme for .tex files to Text Editor by editing the properties of the file, Ubuntu apparently sets this as the default to open ALL plain text files, including .tex files with Text Editor.

Does anyone know how to solve this issue?

I am using Ubuntu 18.04

1 Answers1

2

You can try manually modifying the mimeapps.list file which contains all custom file associations.

This file can be found in ~/.local/share/applications or ~/.config (I'm using Ubuntu 20.04 and the file is in ~/.config. I'm not sure about 18.04, though).

Here is how you can proceed:

  1. Find the name of the desktop entry for your Texmaker program:

    Run this command in a terminal:

    ls /usr/share/applications | grep -i tex
    

    Look at the output and find something like:

    texmaker.desktop
    
  2. Open the mimeapps.list file with a text editor. You will see something like this:

    [Default Applications]  
    audio/mpeg=vlc.desktop
    image/jpeg=qView.desktop
    

    [Added Associations] audio/ogg=vlc.desktop;celluloid.desktop;

  3. Add the following line to the [Default Applications] part:

    text/x-tex=texmaker.desktop
    

    The part would then look like this:

    [Default Applications]  
    audio/mpeg=vlc.desktop
    image/jpeg=qView.desktop
    text/x-tex=texmaker.desktop
    
  4. Save the file and you're done (remember to change texmaker.desktop to the name that you found).

For reference, the line for .txt files will be something like:

text/plain=org.gnome.gedit.desktop
Calico Cat
  • 1,296
  • Hi thank you for your help! Which mimeapps.list file are you referring to? There are multiple in different directories – Pentaquark Oct 02 '20 at 15:03
  • @Pentaquark can you find it in /home/.local/share/applications? If you can, then open that file. But I think it's been moved to home/.config. – Calico Cat Oct 02 '20 at 15:07
  • The file was in home/.config and your solution worked perfectly. Thanks! – Pentaquark Oct 02 '20 at 15:20
  • You're welcome! I had this problem before when trying to open jpg and gif with different image viewers. Setting the viewer for jpg turned that program into the default image viewer and overrode my setting for gif. Manually editing the mimeapps.list file was the solution that I found. Glad it helps! – Calico Cat Oct 02 '20 at 15:25
  • Isn't there a GUI tool to do this? It seems like such as basic feature. For example, there are multiple GUI tools to edit .application files, something that Linux also painfully lacks. – Mark Jeronimus Jul 21 '22 at 09:37