elementary / elementary/applications-menu
Desktop entries with pkexec do not work
- Dominant language
- Vala
- Stars
- 103
- Forks
- 40
- Avg merge
- 32m
- Merged PRs (30d)
- 2
Description
### What Happened?
The Applications menu picks up on desktop entries located in `/usr/share/applications` (plus other locations).
If the `Exec` line of a desktop entry is of the form `Exec=pkexec ` then attempting to launch the application from the Applications menu does not work.
Some applications such as [Timeshift](https://github.com/teejee2008/timeshift) install a desktop entry which calls `pkexec`. For example, the Timeshifts desktop entry has the line:
```
Exec=pkexec timeshift-gtk
```
Now I agree that desktop entries probably shouldn't use `pkexec` like this, however, it should still be supported by the Applications menu because it is not uncommon.
Note that double-clicking the Timeshift desktop entry from the Nemo file manager launches Timeshift correctly. (The elementary OS Files file manager does not support launching applications by double-clicking the desktop entry it seems.)
### Steps to Reproduce
Create a file `Example.desktop` with the following contents:
```
[Desktop Entry]
Name=Example
Exec=pkexec io.elementary.photos
Type=Application
Terminal=false
Categories=Utility;
```
Again, I agree that this is not the best way to use `pkexec` but it should work regardless. I am using `io.elementary.photos` only for the example (I do know that Photos shouldn't be ordinarily used with `pkexec`).
Copy this file to `/usr/share/applications`. You will now see an application named "Example" in the Accessories category of the Applications menu.
If you click it, then an icon will appear in the dock and then disappear a few seconds later. You will not get the pkexec prompt to ask you for your password.
Now if you change the line:
```
Exec=pkexec io.elementary.photos
```
to
```
Exec=io.elementary.photos
```
and then go back to the Applications menu, this time Photos will launch as usual. So it was the `pkexec` entry that caused the issue.
### Expected Behavior
The Applications menu should support desktop entries with `Exec` lines such as
```
Exec=pkexec timeshift-gtk
```
This should launch the user/password prompt as usual:

### OS Version
6.x (Odin)
### Software Version
Latest release (I have run all updates)
### Log Output
_No response_
### Hardware Info
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.