2

Ubuntu 12.04, xfce4. I run commands from the command line, not from a launcher. (This shouldn't make a difference, but some replies have assumed I want to click on a launcher and that's not the point.)

What I want: when I run the program /usr/bin/zathura (a PDF viewer), I'd like to see the icon zathura.png appear for each window in the windows menu (the menu triggered by middle-mouse on background, or the one triggered by control-Tab to cycle through windows).

This isn't happening! Instead I'm getting a generic icon.

What I've done:

  • Placed the icon zathura.png in /usr/share/app-install/icons (which already contains the icon okular.png, which shows properly when I run okular).

  • Added the line Icon=zathura to the file /usr/share/applications/zathura.desktop (again in imitation of a similar file, okular.png). NOTE: following Tim's suggest I've replaced the imitative Icon=zathura by a full pathname. The file, in its entirety, is this:

    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Zathura
    Comment=A minimalistic document viewer
    Exec=zathura %f
    Terminal=false
    Categories=Office;Viewer;
    Icon=/usr/share/app-install/icons/zathura.png
    Keywords=PDF;PS;PostScript;DjVU;document;presentation;
    
  • Restarted the window manager (logged out and back in).

Made not the slightest difference!

I then set out to try to break the okular icon to see if I can find where the icon gets associated to an executable. I can't break it! For instance, if I copy /usr/bin/okular to /usr/bin/fooooo and call that new executable, the window thus created still gets the okular icon, even though there is no fooooo.png or fooooo.desktop, or any .desktop with Name=fooooo or Exec=fooooo.

Where is the association between the executable and the icon made?


NOTE: The point is not for the icon to appear on the desktop. It makes no difference to me whether it appears there or not.
(My desktop shows the contents of my home directory.)

Silvio Levy
  • 277
  • 3
  • 8
  • The .desktop file can go anywhere. For it to show in search, put it in /usr/share/applications. http://askubuntu.com/questions/281293/creating-a-desktop-file-for-a-new-application – Tim Aug 27 '14 at 09:49
  • Thanks, but this isn't quite what I want and it isn't working; I've rewritten the question to clarify. – Silvio Levy Aug 29 '14 at 07:24
  • I think you need to give the absolute path to the image, so your icon line is Icon=/usr/share/app-install/icons/zathura.png – Tim Aug 29 '14 at 07:29
  • Thanks for the loving editing of the code. I tend to forget to do that. – Silvio Levy Aug 29 '14 at 07:39

1 Answers1

2

This isn't happening! Instead I'm getting a generic icon.

What I've done:

Placed the icon zathura.png in /usr/share/app-install/icons (which already contains the icon okular.png, which shows properly when I run okular).

That's the right thing to do.

  • Added the line Icon=zathura to the file /usr/share/applications/zathura.desktop (again in imitation of a similar file, okular.png). The file, in its entirety, is this:

    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Zathura
    Comment=A minimalistic document viewer
    Exec=zathura %f
    Terminal=false
    Categories=Office;Viewer;
    Icon=zathura
    Keywords=PDF;PS;PostScript;DjVU;document;presentation;

This is the problem. I believe that it need as absolute path - or at least a file extension. This is because you don't know where the appplication looks by default. For example, cairo-dock is in /usr/share/cairo-dock. So give it the full path like so.

[Desktop Entry]
Version=1.0
Type=Application
Name=Zathura
Comment=A minimalistic document viewer
Exec=zathura %f
Terminal=false
Categories=Office;Viewer;
Icon=/usr/share/app-install/icons/zartha.png
Keywords=PDF;PS;PostScript;DjVU;document;presentation;

I then set out to try to break the okular icon to see if I can find where the icon gets associated to an executable. I can't break it! For instance, if I copy /usr/bin/okular to /usr/bin/fooooo and call that new executable, the window thus created still gets the okular icon, even though there is no fooooo.png or fooooo.desktop, or any .desktop with Name=fooooo or Exec=fooooo.

That's because the link isn't between the name, or executable name, it is with the icon line. Try deleting that, and it will break.

Tim
  • 32,861
  • 27
  • 118
  • 178
  • Alas, having Icon= didn't help. – Silvio Levy Aug 29 '14 at 07:41
  • "the link isn't between the name, or executable name, it is with the icon line" -- the icon line where? In okular.desktop? How is the executable (now called fooooo) associated with okular.desktop? – Silvio Levy Aug 29 '14 at 07:42
  • Okay, open up that foo.desktop file with gedit, and look at it. One of the lines will still say Icon=/usr/share/app-install/icons/ocular.png. – Tim Aug 29 '14 at 07:43
  • I think you are a bit confused. From now on, the .desktop is called a launcher, and the exec command that it runs is the command. So the launcher (foo.desktop) is still linked to the command occular [someoptions. – Tim Aug 29 '14 at 07:44
  • I never created a fooooo.desktop -- that's why I'm puzzled. There is only the old okular.desktop, with Icon=okular in it, and somehow the command (now called fooooo) seems to be associated with okular.desktop. – Silvio Levy Aug 29 '14 at 07:45
  • No, the executable (occular) that you copied to be foo has just been renamed. That isn't calling the .desktop file, that is running the whole ocular program in the same way as if you ran the ocular executable. – Tim Aug 29 '14 at 07:47
  • OK, we can call okular.desktop a launcher (though I'm running all executables from the command line). So the question is, how does the executable /usr/bin/fooooo get associated with the launcher okular.desktop? – Silvio Levy Aug 29 '14 at 07:48