~/config/mimeapps.list not setting defaults

Hello, I’d like to get some help with an issue I’m facing, xdg-open opens pdf docs and plain text in firefox. Tried editing the ~/.config/mimeapps.list with no luck

[Default Applications]
x-scheme-handler/fcade=fcade-quark.desktop;
video/mp4=mpv.desktop;
video/x-matroska=mpv.desktop;
video/webm=mpv.desktop;
text/plain=nano.desktop;
application/pdf=org.pwmt.zathura-pdf-poppler.desktop;

[Added Associations]
video/mp4=mpv.desktop;
video/x-matroska=mpv.desktop;
video/webm=mpv.desktop;

I’m on Manjaro Sway Edition

What am I doing wrong?

Show the full file, not the part you think is relevant.

Oh, that’s the full file


Moderator edit: Removed screenshot. Paste text with proper formatting instead.

Then I would guess SWAY doesn’t use this file for file association.

Sorry, “not working” doesn’t tell us anything. Please edit your topic title to be clear and concise about the issue you’re having.

What did you edit? You should normally not edit that file as it’s automatically generated.

Either way, you posted the wrong section of the file. application/pdf is under [Added Associations], not [Default Applications].

By the way, there’s no reason to post a whole section of the file if all you’re concerned about is one file type. grep is your friend. :wink:

Example on my system:

❯ grep pdf ~/.config/mimeapps.list
application/pdf=org.gnome.Evince.desktop;

In the future, please use proper formatting, using blockquote for terminal or file output is not appropriate. Neither is posting screenshots. I’ve removed your screenshot above.

Tip: The more effort you put into your topic, the more effort helpful volunteers will provide. :wink:

Please see:

1 Like

Thanks for your response. Edited the previous post and also edited the mimeapps.list

[Default Applications]
x-scheme-handler/fcade=fcade-quark.desktop;
video/mp4=mpv.desktop;
video/x-matroska=mpv.desktop;
video/webm=mpv.desktop;

[Added Associations]
video/mp4=mpv.desktop;
video/x-matroska=mpv.desktop;
video/webm=mpv.desktop;
application/pdf=org.pwmt.zathura-pdf-poppler.desktop
text/plain=nano.desktop;

Tried rebooting the system but firefox is still opening pdf docs and plain text files

Apparently at one point you allowed Firefox to open PDF files by default. See the Use a different PDF viewer for downloaded PDF files section here:

1 Like

Just for clarity, what is the output from

xdg-mime query default text/plain
xdg-mime query default application/pdf
❯ xdg-mime query default text/plain
❯ xdg-mime query default application/pdf
firefox.desktop

Seems that the query for default text/plain returns empty
How can I edit the firefox.desktop entry since ~/.config/mimeapps.list is not working?

You don’t.

/me clears throat loudly…

By the way, no more forum for me today. :wave:

1 Like
  1. Where is the location, and what is the content, of your nano.desktop?
  2. Can you try: xdg-mime default nano.desktop text/plain

Looked for a nano.desktop file and there isn’t one, found several .desktop files inside
/usr/share/applications

ran xdg-mime default nano.desktop text/plain succesfully but xdg-mime query default text/plain returns empty still.

When trying to open plain text with xdg-open I get this:

/usr/bin/xdg-open: line 1045: x-www-browser: command not found

Forgive me for stating the obvious, but if you do not have a nano.desktop file (typically in /usr/share/applications/ or ~/.local/share/applications/), then of course you will be unable to use xdg-open to open text files with nano.

Can I create one? Or there’s no use in doing that?

nano is a terminal command.

1 Like

I have no experience with Sway, so I do not know the best approach for your situation. But sure, just follow the Desktop Entry Specification.

You may be able to use another application’s existing .desktop file as a guide. As omano noted, nano is a terminal application, so may require an approach like in these Arch Linux forum threads about vim.

How is vim different from nano? Both are cli text editors. I’m pretty new to all of this so I’m learning a lot right now.

Thanks for pointing that out, I just pretty much copied vim’s desktop entry and created a nano.desktop file. I had to change the corresponding entries:

[Desktop Entry]
Name=Nano
TryExec=nano
Exec=nano %F
Terminal=true
Type=Application
Icon=terminal
Categories=Utility;TextEditor;
StartupNotify=false
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;

After that I set:
xdg-mime default nano.desktop text/plain
And when running:
xdg-mime query default text/plain
I get:
nano.desktop
Now xdg-open file.txt works with nano

Thank you very much for your help, the problem was that there was no nano.desktop file created. Don’t know why though.

Hello:
xdg-mime default org.pwmt.zathura.desktop application/pdf
Set zathura as default pdf viewer. Firefox does not open pdf files by default anymore. Thank you very much for your help.

You mean: it does not by default - zathura is used instead.

The firefox.desktop file is in /usr/share/applications
~/.local/share/applications is the corresponding place

1 Like