As indicated in the comment by PretzelJones you don't need to run those files like that, as they can be launched from Slingshot if you put them in ~/.local/share/applications
.
Even more, as explained here by the developer the change is intended to avoid file manager being tricked into executing arbitrary code: therefore, use the below solutions with caution, especially the one intended to execute the desktop file without asking by just clicking (solution no 1), and favor solution 3.
So, if you have some files in ~/.local/share/applications
or other places that you must or want to run from Files for any reason, there must be different ways to do it, and the most obvious is to use other file managers to handle the .desktop
files through Pantheon Files, either
- by creating a
~/.local/share/applications/run-desktop.desktop
file and make that "application" the default for .desktop
files and thus executing them as before with one or double click, or
- by creating a
contract
file to add a special context menu entry in Pantheon Files or, even better
- by creating a
~/.local/share/applications/run-or-edit.desktop
file (also using a zenity
script), making that "application" the default for .desktop
files and thus getting a pop-up window asking if you want to run or edit that file.
I have both Thunar and PCManFM installed, and they are both light enough, coming with no supplementary dependencies. (These file managers could be used directly when dealing with the desktop files, and not through Pantheon Files, but that's another matter.)
So:
sudo apt install pcmanfm
or
sudo apt install thunar
1. To run .desktop
files by double click without asking - by changing the default application for that type of files (the less safe solution):
gedit ~/.local/share/applications/run-desktop.desktop
with:
[Desktop Entry]
Type=Application
Icon=system-file-manager
Name=PCManFM to Run desktop file
Categories=System;FileTools;FileManager;Utility;Core;GTK;
Exec=pcmanfm %f
Terminal=false
MimeType=application/x-desktop
Then make it executable:
sudo chmod a+x ~/.local/share/applications/run-desktop.desktop
(or maybe you could try my option here)
Then, selecting any .desktop
file, right-click, 'Properties', and under 'Open with' select that new "application":
You should consider the fact that the above is risky, as already indicated, while the solutions below are safer.
2. To add a context menu entry in Files to execute desktop files by creating a contract file:
gedit ~/.local/share/contractor/run_desktop_launcher.contract
with:
[Contractor Entry]
Name=Run the desktop file
MimeType=application/x-desktop
Exec=pcmanfm %f
and you should see the "Run" right-click custom menu:
(To make that context menu option show a "Run or edit" option instead of simply running the file: replace the line Exec=pcmanfm %f
with Exec=bash -c '/path/to/your/scripts/location/run_or_edit_.sh %f'
according to the the next solution below.)
3. To get a pop-up window asking you to chose between run or edit (safest option):
sudo apt-get install zenity
and then
gedit /path/to/your/scripts/location/run_or_edit_.sh
add this:
#!/bin/bash
zenity --question --text="What to do?" \
--ok-label=Run \
--cancel-label=Edit
case $? in
0)pcmanfm "$1"
;;
1)gedit $1
;;
esac
Make that script executable.
Then:
gedit ~/.local/share/applications/run-or-edit.desktop
with:
[Desktop Entry]
Type=Application
Name=Run or edit
Icon=gedit
Categories=Utility;TextEditor;
MimeType=application/x-desktop;
Exec=bash -c '/path/to/your/scripts/location/run_or_edit_.sh %f'
Make that executable, then selecting any .desktop
file, right-click, 'Properties', and under 'Open with' select that new "application" called 'Run or edit'.
Now when you click a .desktop
file you will get this:
Thunar can be used in the same way as PCManFM.
I find these file managers useful on the system for other purposes too, like for instance to add Thunar's bulk-renaming tool in Pantheon Files and to get pop-up options upon insertion of removable media with PCManFM daemon.