Best way to toggle touchpad "Disable while typing" on and off with keyboard shortcut

I would like to be able to toggle the setting “Disable while typing” on and off with a keyboard shortcut. So far I’ve found that using kwriteconfig5 I can edit the config file for kcminputrc, and while the changes are reflected in the file they don’t seem to take effect until I logout.

kwriteconfig5 --file $HOME/.config/kcminputrc --group "Libinput" --group "2362" --group "628" --group "PIXA3854:00 093A:0274 Touchpad" --key "DisableWhileTyping" "false"

I was hoping to be able to use this command to toggle it on and off with the press of a button, however I can’t figure out how to get it to take effect without logging out. Its obviously possible to change the settings since they can be changed from the system settings GUI after pressing the apply button. So if anyone knows of some way to either have these changes immediately recognized, or even some other way of accomplishing the same goal I’d love to know!

You could try the following command:

qdbus org.kde.KWin /KWin reconfigure

It should reload kwin without re-login.

Thanks for the suggestion! Gave it a try but doesn’t seem like it makes a difference unfortunately

In case anyone else is looking to do something similar, the best solution I have found so far is kwin_wayland --replace which takes only a couple seconds to apply. It is described as

Exits this instance so it can be restarted by kwin_wayland_wrapper.

You may need to have session restore enabled in order for this to work without closing any applications you have open, I haven’t tested this for myself.

If anyone has an idea for a better way to do this I’m all ears!

You can change the ‘disable while typing’ setting of your touchpad directly via dbus.

Example:

qdbus org.kde.kglobalaccel /org/kde/KWin/InputDevice/event6 \
      org.freedesktop.DBus.Properties.Set org.kde.KWin.InputDevice \
      disableWhileTyping false

You can determine the device name (event6 in the example) like this:

grep touchpad /sys/class/input/event*/device/name -i

If you want to change the setting of all connected touchpads:

for i in $(grep touchpad /sys/class/input/event*/device/name -li); do
    e=$(echo $i | cut -d/ -f5)
    qdbus org.kde.kglobalaccel /org/kde/KWin/InputDevice/$e org.freedesktop.DBus.Properties.Set org.kde.KWin.InputDevice disableWhileTyping false
done

Note that the change of the dbus property is immediately effective and persisted into ~/.config/kcminputrc, i.e. DisableWhileTyping= entries are created/updated there.

However, if you have the Hardware Input Devices Touchpad KDE Settings dialog open while changing that dbus property, the corresponding checkbox is NOT immediately updated in that UI.
You can work around this by switching to another input device in the settings UI and when switching back to the Touchpad panel you see the update.

1 Like

Thanks so much. Your explanation is very detailed and worked perfectly!