0

I've already tried the other answers to this question with no success. I'm using Ubuntu 16.04. I'm just trying to create some custom actions for Terminator, but I've decided to go back to basics and see if I can get something to work. Here's what I've tried:

  1. Copied and pasted the example desktop entry file from https://standards.freedesktop.org/desktop-entry-spec/latest/apa.html into a file called $HOME/foo.desktop
  2. Ran desktop-file-validate $HOME/foo.desktop. No output.
  3. Ran desktop-file-install --dir=$HOME/.local/share/applications $HOME/foo.desktop
  4. chmod 755 $HOME/.local/share/applications/foo.desktop
  5. Logged out and back in again.

The new launcher does not appear. What am I missing? Is there some log that would explain why the desktop file does not appear?

Andrew Marshall
  • 545
  • 1
  • 5
  • 12
  • 1
    May be a sample of that `.desktop` file would help? – George Udosen Sep 04 '17 at 11:13
  • It's exactly as it appears in the link to the specification. – Andrew Marshall Sep 04 '17 at 12:05
  • Another set of eyes can really help to see if you made an error. – Organic Marble Sep 04 '17 at 13:09
  • Indeed, if the file is in the right location, and has the right format, then one needs to see the contents to be able to determine why it does not appear. Of course, you tried logging out and logging back in, although it should be picked up very shortly without needing to log out. You confirm you use Unity? It is not the default desktop in Ubuntu 18.04, so putting only the tag may not be enough. – vanadium Jul 14 '20 at 15:17

1 Answers1

1

This is the example desktop entry file:

[Desktop Entry]
Version=1.0
Type=Application
Name=Foo Viewer
Comment=The best viewer for Foo objects available!
TryExec=fooview
Exec=fooview %F
Icon=fooview
MimeType=image/x-foo;
Actions=Gallery;Create;

[Desktop Action Gallery]
Exec=fooview --gallery
Name=Browse Gallery

[Desktop Action Create]
Exec=fooview --create-new
Name=Create a new Foo!
Icon=fooview-new

https://specifications.freedesktop.org/desktop-entry-spec/latest/apa.html

Note the TryExec=fooview field. Here is what the desktop entry standard says:

TryExec

Path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example).

We note that fooview is not an absolute path, so let's see if it's in $PATH:

$ type -P fooview
$ type -a fooview
bash: type: fooview: not found

Here's another way to test this:

$ gtk-launch foo.desktop
gtk-launch: no such application foo.desktop

Compare with e.g. gtk-launch eog.desktop.

Since there is no fooview executable, this means that "the entry may be ignored (not be used in menus, for example)", which is why Unity is not showing it in the menus; it thinks the application has not been installed.

To fix this, you must replace the TryExec key with either an absolute path or an executable somewhere in $PATH.

Related:

Nathaniel M. Beaver
  • 1,478
  • 12
  • 32