kwriteconfig6 to a group containing square brackets

Hello, I’m trying to use kwriteconfig to enable and disable ‘on button down scrolling’, however, this config is on a group whose name contains square brackets which are being escaped by the tool.

This is my ~/.config/kcminputrc file:

[Libinput][5426][92][Razer Razer DeathAdder Elite]
PointerAcceleration=0.200
PointerAccelerationProfile=1
ScrollMethod=4

I’m attempting to update the ScrollMethod value with
kwriteconfig6 --file kcminputrc --group "Libinput][5426][92][Razer Razer DeathAdder Elite" --key ScrollMethod 0

But all that does is create a new group with the escaped brackets:

[Libinput][5426][92][Razer Razer DeathAdder Elite]
PointerAcceleration=0.200
PointerAccelerationProfile=1
ScrollMethod=4

[Libinput\x5d\x5b5426\x5d\x5b92\x5d\x5bRazer Razer DeathAdder Elite]
ScrollMethod=0

Is there a way to circunvent this escaping? If not, what’s the standard way to notify applications of the change if I were to manually edit the file?

kwriteconfig6 --help says:

  --group <group>  Group to look in. Use "<default>" for the root group, or use
                   repeatedly for nested groups.

I tried the following with a dummy file and it works:

kwriteconfig6 \
--file bleprc \
--group Libinput \
--group 5426 \
--group 92 \
--group 'Razer Razer DeathAdder Elite' \
--key ScrollMethod 0
~  → bat ~/.config/bleprc 
───────┬────────────────────────────────────────────────────────
       │ File: /home/blumen/.config/bleprc
───────┼────────────────────────────────────────────────────────
   1   │ [Libinput][5426][92][Razer Razer DeathAdder Elite]
   2   │ ScrollMethod=0
───────┴────────────────────────────────────────────────────────
1 Like

The group name does not contain square brackets (that is a character not allowed in group names).
What you are seeing is nested groups

LibInput
    5426
        92
            Razer Razer DeathAdder Elite
                PointerAcceleration=0.200

See comment by @Herzenschein on how to instruct kwriteconfig to address them :slight_smile:

1 Like

Thank you! The above solves that issue, however, the --notify flag does not make applications aware of the change as I expected… Not even restarting plasmashell worked, only signing out of my session and signing back in made the system aware of the change. How can I replicate the effect the settings’ ‘Apply’ button has? Immediately making the changes take effect?

Hmm, assuming this is managed by KWin (I suspect this is the case based on some MRs on Invent), then reconfigure should work, I have an example in an old script of mine: meta-overview.bash · master · Thiago Sueto / kdialogscripts · GitLab

So like this, but the actual qdbus binary might vary depending on your distro:

qdbus org.kde.KWin /KWin reconfigure

If this were managed by Plasma you could call:

qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.refreshCurrentShell

But since it doesn’t work when restarting plasmashell, that’s probably not the case.

Yeah sadly no dice with either of those. From your script I’ve installed and tried the qdbus and the qdbus-qt5 binaries for testing.

Something I noticed is that, when manually editing this specific setting via the settings GUI, the respective file isn’t updated at all (flushed) until I logoff and login again, if that’s any use.

I am running Fedora.