How to Create a .desktop File for a Document in Linux

A .desktop file is how Linux launches applications.
You can create a .desktop file to launch documents alongside your
your other applications, to launch your favorite documents, just as
if they were applications, shaving seconds off your workday.

For this example, I’m going to create a launcher for ProfitTracker.ods,
a Libre Calc spreadsheet.

You need only one file: a .desktop file.

I created a new file, ProfitTracker.desktop, with these contents:

[Desktop Entry]
Exec=libreoffice /home/johnk/Ebay/ProfitTracker.ods

The Icon property usually needs a path to a file, but in this
case, we used the default icon for Calc documents.

Note that the path to the document should be the complete path,
and yours will be different.

To install this:

mv ProfitTracker.desktop ~/.local/share/applications/

That’s all there is to it.

Leave a Reply