Bug 475056 - [Plasma 6] Deleting and recreating a command keyboard shortcut generates a new .desktop file every time
Summary: [Plasma 6] Deleting and recreating a command keyboard shortcut generates a ne...
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_keys (show other bugs)
Version: 5.27.8
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-30 15:59 UTC by Thiago Sueto
Modified: 2023-11-01 14:54 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Sueto 2023-09-30 15:59:19 UTC
SUMMARY
If you create a new keyboard shortcut that triggers a command, assign it a shortcut (so it appears in ~/.config/kglobalshortcutsrc), delete it, and recreate it, it generates a new .desktop file in ~/.local/share/applications following the naming scheme executable{,-1,-2,-3,...,-n}.desktop.

The curious thing is that the entries in ~/.config/kglobalshortcutsrc do disappear fine when you delete a shortcut, it's just the .desktop file that doesn't.

So if the user keeps testing to figure whether a command works well or not, they might end up with several redundant .desktop files.

STEPS TO REPRODUCE
1. Go to Shortcuts -> Add Command...
2. Create a new command /usr/bin/kdialog --msgbox "Sup"
3. Assign a shortcut to it, for example, Meta+K
4. Click Apply
5. Verify that ~/.config/kglobalshortcutsrc contains a kdialog entry, it should point to kdialog.desktop
6. Delete the shortcut via System Settings
7. Create a new one that also uses kdialog
8. Verify that ~/.config/kglobalshortcutsrc contains a kdialog entry, it should point to kdialog-2.desktop

OBSERVED RESULT
Every time you recreate the shortcut, a new desktop entry gets added to ~/.local/share/applications without removing the original.

EXPECTED RESULT
Every time you delete the shortcut, the original desktop entry gets deleted, and every time you create a new shortcut using the same executable, the new desktop entry reuses its name.
Comment 1 Bug Janitor Service 2023-10-31 22:50:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1788
Comment 2 Nate Graham 2023-11-01 14:53:51 UTC
Git commit dd0d33398549d482605e7373459e2b0d8bf52fd8 by Nate Graham, on behalf of Bharadwaj Raju.
Committed on 01/11/2023 at 15:53.
Pushed by ngraham into branch 'master'.

kcms/keys: Make deleting a command shortcut delete the corresponding .desktop file

Since the desktop files created by "Add Command" are `NoDisplay` and `X-KDE-GlobalAccel-CommandShortcut`, we can safely assume that no one else is using them and remove them.

M  +8    -0    kcms/keys/globalaccelmodel.cpp

https://invent.kde.org/plasma/plasma-desktop/-/commit/dd0d33398549d482605e7373459e2b0d8bf52fd8