0

I'm trying to create a desktop entry for an app. Here's what I've tried:

  1. I created a .desktop file with the code:
    [Desktop Entry]
    Name=clash for windows
    Icon=/home/nadeko/Documents/Clash/Clash.png
    Exec=/home/nadeko/Documents/Clash/cfw
    Type=Application

I got both the location for Icon and Exec by right clicking and "copy" on the original file

This .desktop file is placed in "/home/nadeko/.local/share/applications"

  1. Set both the application and .desktop file "allow executing"

  2. Search in "search applications", but didn't see "clash for windows"

  3. When right click on the .desktop file, there's no "Allow Launch" option.

What have I done wrong? Can anybody please help?

Screenshot

Serg
  • 824
  • 7
  • 14
momoko
  • 1
  • 1
    Try adding a Categories=Game line to the bottom of your .desktop file. There is a chance that it may not be needed, but in an experiment I ran my .desktop file did not show up when I had it in the ~/.local/share/applications/ directory without it. – Terrance Apr 18 '23 at 14:24

3 Answers3

2

Just make sure the file path to your executable is correct.

The information you included is in principle sufficient to have a working .desktop launcher. The only "fatal" error, i.e., preventing the launcher to be displayed in the desktop's application menu, is the validity of your executable. There is no need, nor is it recommended, to mark the .desktop file as executable for it to appear in the desktop's application menu.

vanadium
  • 88,010
0

Since your Step 3 says "Search in "search applications", but didn't see "clash for windows"", you might need a Categories= in your .desktop for it to show up. Not sure how Chrome Apps shows up since the .desktop files for it doesn't have a Categories= line. You can see https://specifications.freedesktop.org/menu-spec/latest/apa.html to determine what category you want to set your .desktop file in.

Note: Categories= is not needed if the file is actually in the $HOME/Desktop directory.

As a test, I have a Whatsapp.desktop file that I will use for an example. It looks like the following:

[Desktop Entry]
Version=1.0
Type=Application
Name=WhatsApp
Comment=WhatsApp
Exec=google-chrome --app="https://web.whatsapp.com/"
Icon=/home/terrance/.local/share/icons/WhatsApp.svg.png
Path=
Terminal=false
StartupNotify=false
Categories=Network

enter image description here

If I remove the Categories=Network line, we can see it no longer shows up in my menus:

terrance@terrance-ubuntu:~$ cat .local/share/applications/Whatsapp.desktop 
[Desktop Entry]
Version=1.0
Type=Application
Name=WhatsApp
Comment=WhatsApp
Exec=google-chrome --app="https://web.whatsapp.com/"
Icon=/home/terrance/.local/share/icons/WhatsApp.svg.png
Path=
Terminal=false
StartupNotify=false

enter image description here

So, in your case add a line at the bottom that says Categories=Game and it should now show up.

Terrance
  • 41,612
  • 7
  • 124
  • 183
  • Categories is not needed for a launcher - should also work without. – vanadium Apr 18 '23 at 14:16
  • @vanadium It is not needed if the desktop file is on the actual Desktop. The test here shows that it doesn't show up if the line doesn't exist if it is in the ~/.local/share/applications/ directory. – Terrance Apr 18 '23 at 14:17
0

If the .desktop file can't find the executable then it won't show up in the search.

I know you say you got the path by copying it but the screenshots show a different file-path to what's in your .desktop file.

Try the following:

[Desktop Entry]
Name=clash for windows
Icon=/home/nadeko/Documents/Clash\ for\ Windows/Clash.png
Exec=/home/nadeko/Documents/Clash\ for\ Windows/cfw
Type=Application

You can also try running gio launch <path to .desktop file> and it will tell you more info about what's wrong.

Baa
  • 3,452