Cannot launch .desktop files (opens with Text Editor instead)

For some reason, I cannot launch .desktop files. When I double-click the file, it opens the Text Editor. The desktop file has "Allow executing file as program" turned on (-rwx). In the tab "Open with", the Text Editor is the default application. Clicking reset in that tab changes it to the Text Editor, so it basically does nothing.

Any way to solve this?


Basically, I found that the Files/Nautilus application does not allow executing .desktop files anymore. Instead there are 2 options we can do.

  1. Enable 'Desktop icons' using GNOME Tweaks and create the .desktop file inside the Desktop folder. Then it will appear on the desktop (without its icon). Then right click on the desktop icon and choose "Allow launching" and the icon will appear and it will be executable.

  2. Add the .desktop file inside the ~/.local/share/applications and then it will appear in the App launcher, so you can add it to the Dock (add to favorites) and copy to the Desktop folder to add to Desktop.