Error with ".desktop" file, it doesn't show on applications menu

Hello, I’m a new user on Fedora workstation 37. Somethings doesn’t work for me, like “flatpack” or “flathub” in the app “Software” so I have to install the app “Discord” manually, well, it wasn’t a problem to me because I only need to enter to the file that I download and execute it. But my family doesn’t now how to do it so I want that the executable appears on “Applications menu” I try to make an .desktop file but it doesn’t work and I don’t know why. I’ve trying for hours and didn’t find any solution. Here is the code for my “discord.desktop”:

Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
TryExec="/home/valdiviaricardo/Downloads/discord/Discord/Discord.executable"
Icon="/home/valdiviaricardo/Downloads/discord/Discord/discord.png"
Type=Application
Terminal=false
Keywords=Discord;discord
Categories=Network;InstantMessaging;

I saved it into /home/.local/share/applications

I hope that was a typo and you meant /home/USER/.local/share/applications.

You can take a look at any of the .desktop files in /usr/share/applications and see the structure required for a .desktop file.
For example, the one for a small app I have named makeMKV is

$ cat /usr/share/applications/makemkv.desktop
[Desktop Entry]
Version=1.0
Name=MakeMKV
Comment=DVD and Blu-ray to MKV converter and network streamer
Exec=makemkv
Icon=makemkv
Terminal=false
Type=Application
Categories=AudioVideo;Qt;

Note the [Desktop Entry] section header. Once it is working for you then you need to address the issues for other users.

Be aware that it seems that other users may not be able to see or execute a file under your users home directory unless you have given them permissions to read and execute every directory in the path, as well as they would need a copy of the .desktop file where they could access it. This applies to linux filesystem permissions as well as SELinux context.

It may be simpler for you to create a directory under /opt for your app such as /opt/Discord, and for you to put the .desktop file under /user/share/applications so it is accessible to all the users.

Hello!, well I follow your instructions, so I have these new configurations:

[Desktop Entry]
Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Exec="/opt/Discord/Discord.executable"
Icon="/opt/Discord/discord.png"
Type=Application
Keywords=Discord;discord
Categories=Network;InstantMessaging;

I move the whole application to opt like you said “/opt/Discord/”, and I save the .desktop into “/usr/share/applications/”. still not working :frowning:

Did you get it working for the main user (from that .desktop file) before you started relocating things?
Did you verify that the file system ownership & permissions on all the files were proper for their location and intended use?
Did you either disable SELinux or set the SELinux context according to the intended use?

The .desktop works only one time, it appears on Application menu but when I clicked it once, it disappears. I’m a new Linux users, not only a new fedora user so I don’t have any idea that I need to give permissions or disable or enable SELinux.

Edit= It works once time again. I change the

Exec="/opt/Discord/Discord.executable"

to

Exec=/opt/Discord/Discord.extension

and it appears on application menu but when I clicked it once it disappears again

You need to specify a valid executable file on the “Exec=” line. Does Discord correctly start when you give the command

/opt/Discord/Discord.executable

in the terminal? If not, what is the error message?

Hello!, I’ve already solved it, I follow the instructions to read the .desktop that I’ve already had in my /usr/share/applications and after that I have the following code:

[Desktop Entry]
Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Exec=/opt/Discord/Discord --unity-launch %F
Icon=/opt/Discord/discord.png
Type=Application
Keywords=Discord;discord
Categories=Network;InstantMessaging

I hope that this will help people, thanks. (Srry for my english)

1 Like