Add custom keyboard shortcuts from terminal

Hello everyone,

I am using Manjaro Linux with kernel 5.4 LTS and KDE Plasma.

I am creating a bash script to automate some software setup on Manjaro Linux. This script is a “post-installation script” which will set up some things for me a lot quicker than doing it manually.

Since I have a few custom keyboard shortcuts, I was wondering if it is possible to set the shortcuts from the bash script, preferably without using additional packages.

For example, I want to set up Flameshot to open on Ctrl+Shift+PrtScr.

Can I also change system shortcuts? For instance, I want to switch to a new virtual desktop by using Ctrl+Alt+RightArrow.

I know I can set this up easily from the KDE Plasma Settings, but I would like to automate the setup as much as possible.

Thank you in advance!

It can be done – global shortcuts are in ~/.config/kglobalshortcutsrc file. You probably need add new entry. KDE provide tools for it – kreadconfig5 for reading entries and kwriteconfig5 for writing new options or changing them. Of course, you can use other tools like sed if you want.

If you want to change local app shortcuts you need to find config file for this app and change shortcuts settings here.

I hope it will help.

Your answer led me to finding ~/.config/khotkeysrc which is another file where I had custom shortcuts.

Thank you very much!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.