3

I installed one application in /opt (simply untarring) and had to create my own .desktop file:

[Desktop Entry]
Type=Application
Terminal=false
Name=IntelliJ IDEA
Icon=/opt/IntelliJ/bin/idea.svg
Exec=/opt/IntelliJ/bin/idea.sh

However, the application icon in the side bar does not offer Add to Favorites when right-clicked.

enter image description here

How can I enable that option?

amphibient
  • 1,257
  • 4
  • 14
  • 21
  • I don't have an answer, but some people may benefit from this documentation on the format of desktop files: https://developer-old.gnome.org/desktop-entry-spec/

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

    – James Newton May 11 '23 at 18:31

3 Answers3

3

I was facing this problem and I will share my notes in case it helps someone.

  • If the .desktop file is for all users to use then it should be placed under /usr/local/share/applications.
  • If the .desktop file is only for the current user then it should be placed under ~/.local/share/applications.
  • The .desktop file placed as above does not need execute permissions. It can be 0644.
  • If the .desktop file has a key Hidden then it should be Hidden=false.
  • If the .desktop file has a key NoDisplay then it should be NoDisplay=false.
  • The Exec key should have a valid command. Bash commands may not work as detailed in this answer.

With these settings in place the desktop entry should be searchable using the Super key, and from there using the Right Click -> Add to Favorites option, it can be setup as a favorite on the dash.

Note: In the above bullet points, "Has a key" means if the key is present in the config file. Alternatively, it can be absent, in which case the default value for that key takes effect.

  • What does "has a key" mean in this context? As in, If the .desktop file has a key Hidden then ... – Stewart Nov 26 '23 at 17:22
  • 1
    @Stewart - Since .desktop files are configuration files they have key value pairs like SomeKey=SomeValue. That's what is referred to as key. Has a key means if the key is present in the config file. Alternatively, it can be absent, in which case the default value for that key takes effect. – Dhwani Katagade Dec 06 '23 at 11:08
1

Your .desktop file should reside in ~/.local/share/applications or in an applications folders under one of the directories in the XDG_DATA_DIRS environmental variable.

Thus, for your custom application, install the file under ~/.local/share/applications if you are the only one needing to see the application in your user menu, or in /usr/local/share/applications to make it available for all users.

Once properly installed, you will also be able to add the launcher to your favorites.

vanadium
  • 88,010
  • I don't even have applications under my /usr/local/share – amphibient Jan 16 '22 at 17:38
  • Nobody said you would. If you don't, make it. Indeed it is not there by default. – vanadium Jan 16 '22 at 17:41
  • 1
    moving it to /usr/local/share/applications and logging back in to reload the KDE -- did not work. – amphibient Jan 16 '22 at 20:35
  • 1
    This advice does not work on Ubuntu 18.04 – James Newton May 10 '23 at 02:13
  • @vanadium I literally used a working desktop file which I could set as a favorite, did nothing more than change the executable to a different (and very executable) program in the same folder, and copied it to /usr/local/share/ which is in my XDG_DATA_DIRS path. And after running that executable, there is no option to set it as a favorite. I ended up renaming the new program to the same name as the old program so that I could use the working desktop file. – James Newton May 11 '23 at 16:56
0

You can manually add your launcher using the command line.

dconf read /org/gnome/shell/favorite-apps to output a string representing the current favorites, e.g. ['firefox.desktop', 'org.gnome.Nautilus.desktop']

Copy the string and add your new launcher to the list. Run this to update your favorites:

dconf write /org/gnome/shell/favorite-apps "['firefox.desktop', 'org.gnome.Nautilus.desktop', 'YourManualApp.desktop']"