Bug 441197 - Custom Shortcuts Don't Exec .Desktop files that exec sh
Summary: Custom Shortcuts Don't Exec .Desktop files that exec sh
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kglobalaccel
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.85.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-19 21:35 UTC by Lukas Sabota
Modified: 2022-08-19 00:29 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Sabota 2021-08-19 21:35:07 UTC
SUMMARY
When a custom shortcut is configured to use a user desktop entry that utilizes "sh" in the desktop file's Exec line, the shortcut does not spawn the program.

Desktop files can use /bin/sh to resolve common variables, such as $HOME, that can be very useful to execute applications that are stored within a user's home directory.  Here is an example of a desktop file for qrdp, a custom qt application that is located in a user's home directory:

---
qrdp.desktop
---
[Desktop Entry]
Version=1.0
Name=QRdp
Comment=Connect to an RDP server
Keywords=Internet
Exec=sh -c "~/.bin/qrdp"
Icon=Qrdp
Terminal=false
X-MultipleArgs=false
Type=Application
Categories=Network;

This file can be placed in ~/.local/share/applications and it properly parsed by the plasma start menu and krunner, as well as gtk-launch and dex.  It can be validated with desktop-file-validate.

However, if this desktop file is used in a custom shortcut, the program will not launch when the shortcut is pressed.

Changing the exec line from 'Exec=sh -c "~/.bin/qrdp"' to a hardcoded home directory will allow the desktop file to be launched from a kglobalaccel shortcut:

Exec=/home/mySpecificUser/.bin/qrdp

STEPS TO REPRODUCE
1. Install a desktop file that utilizes /bin/sh in the Exec= line to ~/.local/share/applications
2. Add a shortcut for this desktop file in plasma shortcuts
3. Attempt to use the shortcut, notice the application does not launch

OBSERVED RESULT
The application contained in the desktop file does not launch when launched via a kglobalaccel shortcut

EXPECTED RESULT
The application contained in the desktop file is launched when configured as a kglobalaccel shortcut and the shortcut key is pressed

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Kernel Version: 5.13.10-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 5800H with Radeon Graphics
Memory: 15.5 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2

ADDITIONAL INFORMATION