13

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?

Zanna
  • 70,465
Nick Hope
  • 613
  • 1
  • 6
  • 7
  • 2
    You can pin only Application to Gnome Dock.. But you can found some similar solution in this thread: https://askubuntu.com/questions/966740/how-do-i-pin-my-favorite-folders-in-ubuntu-dock-like-in-windows – slava Nov 07 '18 at 08:32

2 Answers2

21

Follow the steps below.

  1. Create a .desktop file (say spreadsheet1.desktop) in ~/.local/share/applications/ directory. You can do that by running the following command in Terminal:

    touch ~/.local/share/applications/spreadsheet1.desktop
    
  2. Open the file with a text editor, for example by running

    gedit ~/.local/share/applications/spreadsheet1.desktop
    

    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
    
  3. Save the file.
  4. Click on "Activities" or "Show Applications" and search for "XYZ spreadsheet". It should appear.

  5. Right click on it and mark as favourite.

Note: The xdg-open command opens the file with the default application associated with the file-type. You can alternatively set

Exec=libreoffice /full/path/to/XYZ-spreadsheet.ods

in the .desktop file to always open the file with LibreOffice Calc.

pomsky
  • 68,507
3

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

https://commons.wikimedia.org/wiki/GNOME_Desktop_icons#/media/File:Gnome-emblem-favorite.svg,

then replace the Icon value with emblem-favorite.

Hiro
  • 153
  • 6