I would like to pin a file's shortcut to the dock in the Ubuntu 18.04 GNOME desktop so that the file opens directly when I click it, for example a spreadsheet file that opens with LibreOffice Calc. Is this possible?
Follow the steps below.
~/.local/share/applications/directory. You can do that by running the following command in Terminal:
Open the file with a text editor, for example by running
Then add the following lines:
[Desktop Entry] Name=XYZ spreadsheet Exec=xdg-open /full/path/to/XYZ-spreadsheet.ods Comment=Launch XYZ spreadsheet Terminal=false Type=Application Icon=x-office-spreadsheet
- Save the file.
Click on "Activities" or "Show Applications" and search for "XYZ spreadsheet". It should appear.
Right click on it and mark as favourite.
xdg-open command opens the file with the default application associated with the file-type. You can alternatively set
.desktop file to always open the file with LibreOffice Calc.
To add to the answer from @pomsky, if you want to change the icon, refer to this page.
For example, if you click the icon and the referred url is
then replace the
Icon value with