Score:0

Desktop Entry doesn't do anything

lu flag

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

Terrance avatar
id flag
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.
Score:2
cn flag

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.

Score:0
id flag

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.

vanadium avatar
cn flag
Categories is not needed for a launcher - should also work without.
Terrance avatar
id flag
@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.
Score:0
mx flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.