How to create desktop file properly?

I use Fedora 35. I have to create desktop shortcut of application. When I start it from the folder using terminal by command ./metro it works. But when I placed .desktop file in /usr/share/applications with this content my application doesn’t start.

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/spym0nk/Games/Metro_Last_Light_Redux/metro
Name=Metro Last Light Redux
Comment=Metro Last Light Redux
Icon=/home/spym0nk/Games/Metro_Last_Light_Redux/icon.png

What should I do to start my application from shortcut?

General information/documentation:
Specifications for a desktop entry are here: Desktop Entry Specification. Jump to the description of possible keys: Recognized desktop entry keys. This page has a description of each key and also tells you if the entry is required.
An example can be found here: A. Example Desktop Entry File

Your case:
Your .desktop file looks fine, I don’t see any obvious issue there,

Just to be sure, the path to the executable is correct?

Not sure why it would make a difference to place it in your user directory instead of the system directory, but it’s worth a try. Move the file to ~/.local/share/applications/

You can use desktop-file-validate <your-desktop-file> to see if there are any complains about it.

Try

Exec=/home/spym0nk/Games/Metro_Last_Light_Redux/./metro

Can you change the exec line to Exec=sh -c "/home/spym0nk/Games/Metro_Last_Light_Redux/metro 2>/tmp/mymetrolog.txt" and examine the resulting log file? We are only capturing stderr because applications usually write error messages to standard error. If that application writes error messages to stdout instead of stderr, replace 2>/tmp/mymetrolog.txt with >/tmp/mymetrolog.txt.

Thanks for everybody answers. I’ve added string with path to metro file and it worked.

1 Like

Maybe it didn’t like the underscores in the filename.