Default Applications on Linux
If you are using nnn
and you want to open mp3, mp4, text or audio files with command line programs then this small article will help you.
NOTE: this also works for GUI programs, but usually they include some .desktop
file in their package.
Create a file for every command line program at ~/.local/share/applications/cli-prog.desktop
and then you can use it in ~/.local/share/applications/mimeapps.list
as a reference.
Example
Here's an example for vim and text files:
~/.local/share/applications/vim.desktop
:
[Desktop Entry]
Exec=vim
Name=vim
Type=Application
- See here for more information on the .desktop file format: freedesktop.org
and inside ~/.local/share/applications/mimeapps.list
add the following line:
...
text/plain=vim.desktop;
...
now nnn
will use vim
(actually xdg-open
will handle this)
Get correct MIME type of a file
If you need to get the filetype of a file to associate it with an application you can use this command:
xdg-mime query filetype FILE.EXT
Then you have to add RESULT/cli-prog.desktop
to ~/.local/share/applications/mimeapps.list