Automate setup of keyboard shortcuts in KDE5

3

0

Can the configuration of keybindings in KDE be scripted? I know the shortcuts are probably stored somewhere in ~./config, but the files doesn't appear to be in a stable or easily scriptable format. So a script that modifies those files directly would likely break in the next point release of KDE.

The keybindings I'm trying to add are among others Ctrl+t to open a new tab in konsole, Win+d to focus desktop and Alt+F5 to maximize window.

I've looked at the commands qdbus and kwriteconfig5 which seems like they could work. But I haven't found the right way to call them to setup keybindings.

Björn Lindqvist

Posted 2015-09-26T08:35:57.813

Reputation: 321

Answers

2

The shortcuts for KDE use to be located in kdeglobals, but at some point in the past they changed location. I have now found them in

          $HOME/.kde/share/config/kglobalshortcutsrc

It is a file with many different sections, I will show just one:

      [plasma-desktop]
      Next Activity=Meta+Tab,Meta+Tab,Next Activity
      Previous Activity=Meta+Shift+Tab,Meta+Shift+Tab,Previous    Activity
      Show Dashboard=Ctrl+F12,Ctrl+F12,Show Dashboard
      Stop Activity=Meta+S,Meta+S,Stop Current Activity
      SystemTray-Klipper-32=,Ctrl+Alt+V,
      SystemTray-Klipper-6=Ctrl+Alt+V,Ctrl+Alt+V,
      SystemTray-Klipper-80=,Ctrl+Alt+V,
      _k_friendly_name=Plasma Desktop Shell
      manage activities=Meta+Q,Meta+Q,Activities...

MariusMatutiae

Posted 2015-09-26T08:35:57.813

Reputation: 41 321

I don't have that file, but a similar one in ~/.config/kglobalshortcutsrc. It doesn't look suitable to scripting for me because it contains internationalized strings. – Björn Lindqvist – 2015-09-26T16:55:44.727

@BjörnLindqvist What are internazionalized strings? – MariusMatutiae – 2015-09-26T17:50:08.303