You need:
- to define an app
- to define a mime type
- set default
To define an app create a new file in ~/.local/share/applications
. For example: atril.desktop
(the .desktop
extension is required)
Add this content inside:
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Atril
Exec=atril
Icon=application-pdf
StartupWMClass=crx_mdpkiolbdkhdjpekfbkbmhigcaggjagi
MimeType=application/pdf
To do this you have to create a file anywhere on your computer with this structure: mimeType.xml where mimeType should be replaced with the desired mime type but with -
instead of /
. For example for html it would be text-html.xml
.
In our example we will associate pdf files with atril app so our file will be named: application-pdf.xml
because mime type of the pdf file is application/pdf
. If you don't know what's the mime type of a certain file type this:
xdg-mime query filetype path-to-file.pdf
This is an example content of the application-pdf.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/pdf">
<comment>a pdf file</comment>
<glob pattern="*.pdf"/>
</mime-type>
The final step in defining a mime type is to install it. You can do it with this command:
xdg-mime install application-pdf.xml
The final step is to associate the mime type with the application (mark it as default app). You can do it with the command:
xdg-mime default atril.desktop application/pdf