Bug 488997 - Importing and exporting shortcuts ignores custom command shortcuts that take the form of .desktop files in ~/.local/share/applications
Summary: Importing and exporting shortcuts ignores custom command shortcuts that take ...
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_keys (show other bugs)
Version: 6.1.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-22 18:09 UTC by Will Styler
Modified: 2024-08-24 10:24 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Will Styler 2024-06-22 18:09:59 UTC
SUMMARY

Having migrated one computer to Plasma 6.1 (via Fedora Kinoite), I attempted to copy over my (~20) custom shortcuts which I use to launch applications and more. 

An example shortcut might be binding Meta+Ctrl+Alt+Shift+B to 'kitty neomutt'

I was unable to copy these shortcuts over, either by copying over ~/.config/khotkeysrc and ~/.config/kglobalhotkeysrc, nor by using the 'Export...' function, saving all of them (making sure they're selected), then 'Import...' on the new machine.  All of the other shortcuts (e.g. Khronkite) did copy, but those didn't.

OBSERVED RESULT

When Shortcuts -> 'Export...' then 'Import...' is used or kglobalhotkeysrc is copied over, no custom command shortcuts came with.

EXPECTED RESULT

Custom Command Shortcuts copied too.

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Fedora Linux 40 (Kinoite)
KDE Plasma Version: 6.1.0
KDE Frameworks Version: 6.3.0 
Qt Version: 6.7.1

ADDITIONAL INFORMATION
Comment 1 Will Styler 2024-06-22 18:22:22 UTC
So, a bit more poking has revealed the issue, and allowed me to accomplish the task. Apparently, the custom shortcut commands are stored in ~/.local/share/applicatons as .desktop files. If you copy those over first, then copy in .globalshortcutsrc, then restart, the commands will work as anticipated. This is wildly unintuitive, though, and I would suggest that either:

1) This behavior be modified so that one file contains all the information needed, for easier cross-machine syncing
2) The shortcut-related desktop files be placed in a subfolder, so they can be synced too
3) The import/export chain automatically creates these desktop files

Thanks!
Comment 2 Nate Graham 2024-06-25 21:00:25 UTC
Apparently your shortcuts were created using KHotkeys, which had been deprecated for 8 years and was removed with Plasma 6.1.

There was a migration script to move simple ones over to the newer KGlobalAccel system, but we're aware it's not perfect. And unfortunately it can never be due to different sets of functionality between the two systems.

It would probably be best to re-create them all from scratch to ensure they work properly with the newer KGlobalAccel system.
Comment 3 Will Styler 2024-06-25 21:37:08 UTC
(In reply to Nate Graham from comment #2)
> Apparently your shortcuts were created using KHotkeys, which had been
> deprecated for 8 years and was removed with Plasma 6.1.
> 
> There was a migration script to move simple ones over to the newer
> KGlobalAccel system, but we're aware it's not perfect. And unfortunately it
> can never be due to different sets of functionality between the two systems.
> 
> It would probably be best to re-create them all from scratch to ensure they
> work properly with the newer KGlobalAccel system.

It's true that old shortcuts don't migrate, and khotkeys is abandoned, but even creating a new shortcut on a fresh install with Plasma 6, it doesn't appear to be possible to import custom shortcuts created in Plasma 6 on a different machine.  So, this is not just an 'old shortcuts'. I recreated everything in Plasma 6, then went to migrate another machine to Fedora 40 and couldn't import without the desktop file hack below.
Comment 4 Nate Graham 2024-06-26 21:07:14 UTC
Let's back up. When you wrote ~/.config/kglobalhotkeysrc, did you mean ~/.config/kglobalshortcutsrc?
Comment 5 Will Styler 2024-06-27 07:30:42 UTC
(In reply to Nate Graham from comment #4)
> Let's back up. When you wrote ~/.config/kglobalhotkeysrc, did you mean
> ~/.config/kglobalshortcutsrc?

Yes, I'm sorry, I meant 'kglobalshortcutsrc', as I put in the title. I typoed later.
Comment 6 Nate Graham 2024-06-27 16:21:52 UTC
Got it. I thought you were talking exclusively about khotkeys.

Can confirm the issue.
Comment 7 Nate Graham 2024-08-19 18:54:16 UTC
In progress with https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/2447.
Comment 8 Akseli Lahtinen 2024-08-23 15:46:42 UTC
Git commit b88e3456c2499c73e520407959af31d4d45a1925 by Akseli Lahtinen.
Committed on 23/08/2024 at 15:46.
Pushed by akselmo into branch 'master'.

kcm_keys: fix importing custom commands

This adds new handling for Custom Commands, such as exporting
them as their own group.

It also adds a signal that's emitted when an application is
added to the list. When the signal is emitted, we re-import
our config file to add the missing data. This is because
otherwise we'll face asynchronicity issues.

Most of the work was done by David Redondo already, I just
applied his patch and modified it.
FIXED-IN: 6.2.0

M  +1    -1    kcms/keys/basemodel.cpp
M  +1    -0    kcms/keys/globalaccelmodel.cpp
M  +1    -0    kcms/keys/globalaccelmodel.h
M  +53   -2    kcms/keys/kcm_keys.cpp
M  +1    -1    kcms/keys/kcm_keys.h

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