I am try to modify my keyboard shortcuts using kwriteconfig5
The default value in ~/.config/kglobalshortcutsrc
to lock the screen is
Lock Session=Meta+L\tCtrl+Alt+L\tScreensaver,Meta+L\tCtrl+Alt+L\tScreensaver,Lock Session
This maps to this in the System Settings -> Shortcuts - Session Management
The format of the file seems to be :
- "Shortcut name="
- each option separated by
\t
- ","
- each option repeated again to indicate that it is ticked
- any option missing in the second set indicates not ticked
- ","
- "Shortcut name"
I can set the row in the file to empty with
kwriteconfig5 --file kglobalshortcutsrc --group ksmserver --key "Lock Session" ""
So in order to remove the Ctrl+Alt+L I tried:
kwriteconfig5 --file kglobalshortcutsrc --group ksmserver --key "Lock Session" "Meta+L\tCtrl+Alt+L\tScreensaver,Meta+L\tScreensaver,Lock Session"
However, the \t
in the final option appears in the file as \\t
.
I have used several combinations of escaping and single/double quotes and it doesn't make a difference so it doesn't appear to be a normal escaping process.
The second issue is that even after changing the file, the shortcuts don't seem to stick in the System Settings.
One of the following appears to make the settings change:
qdbus org.kde.keyboard /modules/khotkeys reread_configuration
kquitapp5 kglobalaccel && sleep 2s && kglobalaccel5 &
However, I'm not 100% sure which one was doing it and what the real difference is between the two.
I can't find any documentation on how to do use kwriteconfig5 correctly.
Does anyone know the correct way to do this and has actually tested it out and got it to work?
sed -i 's/\\\\t/\\t/' ~/.config/kglobalshortcutsrc
seems to work fine. I took a backup before running it and the only thing that got changed was the bad double slash, so if one has more values with tabs to set, it should be more convenient. – Rafał G. Jun 09 '23 at 11:32