Bug 477041

Summary: registerShortcut() is not registering many shortcuts
Product: [Plasma] kwin Reporter: Nico Dorn <nicodorn>
Component: scriptingAssignee: KWin default assignee <kwin-bugs-null>
Status: REPORTED ---    
Severity: normal CC: nate, pgnd
Priority: NOR    
Version: 5.27.9   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nico Dorn 2023-11-15 12:29:44 UTC
Nearly no shortcut is working with registerShortcut(). There are some, though, but it seems that every letter shortcut is rejected. Among the ones I tested are "Meta+I", "Meta+Ctrl+I", "Meta+N", "Meta+B", "Ctrl+Alt+B" … I made sure to test shortcuts that were not registered yet.

But some shortcuts do work, for example "Meta+F4" or "Meta+Num+8" (if NumPad is enabled). A working example:

  print("started");
  registerShortcut("Test", "Test", "Meta+F4", () => print("works"));

"started" is always printed to the journal, "works" only after a shortcut that was really registered (like "Meta+F4") is triggered. There is never any error message in the journal.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.27
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11
Kernel Version: 6.2.0-36-generic (64-bit)
Graphics Platform: X11
Processors: 16 × Intel® Core™ i7-10875H CPU @ 2.30GHz
Memory: 62.5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Manufacturer: TUXEDO
Product Name: TUXEDO Book XC1711
System Version: Not Applicable
Comment 1 Nico Dorn 2023-11-15 14:16:03 UTC
I got it up and running, but honestly, I don't know how. Mayby the shortcuts list was all messed up due to all my testing and this did the trick:

    qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.cleanUp

That might be it, as uninstalling or updating a script via UI (System Settings > Window Management > KWin Scripts) does not expunge the shortcuts list in ~/.config/kglobalshortcutsrc. But that doesn't explain why it didn't work in the first place. Hm, weird…