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.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1788
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