xdg-mime default nvim.desktop text/plain

pixiv/artworks/86432825

Default Applications

Using CLI Utils

1
2
xdg-mime query filetype /path/to/file
xdg-mime default <application> <mimetype(s)>

We can get the file’s mime-type through xdg-mime query filetype /path/to/the/file, and using xdg-mime default <application> <mimetype(s)> to set the default application for those files.

Note: application is a .desktop file.

(Alternative) Edit mimeapps.list Manually

If you want to edit configuration manually or feel really desperate, just modify the ~/.config/mimeapps.list manually.

Format:

1
application/TYPE=LAUNCHER.desktop

Just add it under the [Default Applications] section if you
want to be default, or under the [Added Associations]
section if it shouldn’t be default.

Note: Some programs still use the now deprecated ~/.local/share/applications/mimeapps.list, however the best is to make that a symlink to ~/.config/mimeapps.list to have a single config for this:

1
2
3
cat ~/.local/share/applications/mimeapps.list >> ~/.config/mimeapps.list
rm ~/.local/share/applications/mimeapps.list
ln -s ~/.config/mimeapps.list ~/.local/share/applications/mimeapps.list

Reference

Default Applications — Arch Wiki

How do I set the default program?


Change Default Applications
http://example.com/2022/10/06/default_applications/
Author
mistgc
Posted on
October 6, 2022
Licensed under