20

I can't find the way to add a custom menu entry to a .desktop launcher.

In Unity I was able to add custom menu entries to launcher like "Open customfile.txt" or "Open somespreadsheet.ods". Is that possible in Ubuntu Dock?

razor7
  • 1,559

1 Answers1

15

Follow the steps below.

  1. Copy .desktop file associated to your preferred application, say app-name.desktop from /usr/share/applications/ to ~/.local/share/applications/. You can do this by running the following command in Terminal

    cp /usr/share/applications/app-name.desktop ~/.local/share/applications/
    
  2. Open the .desktop file using a text-editor, for example by running

    gedit ~/.local/share/applications/app-name.desktop
    
  3. Look for a line beginning with Actions=. If there is one, append My-Custom-Action; to it. Otherwise, add the following line

    Actions=My-Custom-Action;
    
  4. Write the following lines at end of the file:

    [Desktop Action My-Custom-Action]
    Name=Name of the Option
    Exec=command-you-want-to-run
    

    For example, if you want to open Text editor, put gedit in place of command-you-want-ro-run.

  5. Save the file.

  6. Click on "Activities" and search for the application.

  7. Right-click on the application icon and select "Add to Favourites". It should be added to the Ubuntu dock.

Now if you right-click on the newly added application icon in the dock, you should see a "Name of the Option" entry in the context menu which should work as expected.

Similarly, you can other options by adding new Desktop Actions and adding the name of the action to the Actions= line. For more info see this.

pomsky
  • 68,507
  • what does "name of the option" mean? – Andy Apr 26 '20 at 07:40
  • It simply means the name/title you would like to see in the context-menu (right-click menu) for the action. For example, for an action to launch the folder containing photos from your holidays, you may use the name "Photos from holidays" or "Open holiday photos" or "Holiday pics" or whatever else you like. – pomsky Apr 26 '20 at 09:29