Disable Mouse Buttons While Typing?

With current Manjaro and a 7-inch UMPC (no touchpad, just a pointer/mouse buttons), I’d like to disable the built-in mouse buttons while typing, much the way users can disable the touchpad while typing.

Is that available in gsettings or elsewhere?

Thanks.

Isn’t there this option?

Thank you for the very quick post. Since there is no touchpad, the only device listed in “Mouse and Touchpad” is:

SYNA3602:00 0911:5288 Mouse

and that does not provide an option for disabling while typing.

Well, maybe have look at your device:

sudo libinput list-devices

By default the touchpad is disabled while typing if not disabled by the DE Settings.

If there is written: Disable-w-typing: n/a, then I guess you are out of luck by driver support. If you really need this, then you have to try some kind of custom solution.

Maybe have a look at:

man libinput-debug-events 

or

https://wiki.archlinux.org/title/libinput#Enable_the_touchpad_while_typing

Otherwise no idea :man_shrugging:

What’s your opinion of a toggle script? All credit goes to Brodie Robertson scripts/toggletouch at master · BrodieRobertson/scripts · GitHub and I just changed the ID from touchpad to mouse. Seems to work okay, it’s manual activation rather than convenience of “disable while typing”

#!/bin/sh
# Script to toggle my laptops touchpad
id="$(xinput list | grep -Eo 'Mouse.*id=[0-9]*' | grep -Eo '[0-9]*')"
mode="$(echo "$id" | xargs -I % xinput --list-props % | grep 'Device Enabled' | grep -Eo ':.*[0|1]' | grep -Eo '[0|1]')"

if [ "$mode" -eq "1" ]; then
  xinput set-prop "$id" "Device Enabled" 0 && notify-send "Mouse" "Mouse has been disabled"
else
  xinput set-prop "$id" "Device Enabled" 1 && notify-send "Mouse" "Mouse has been enabled"
fi

If that works for you, why not. I cannot test it, have to use a VM, since I use sway which is wayland and not xorg.

Now you can add a function to watch keyboard input and disable or enable on input. But to have device access, you need root permissions. I didn’t need it in the past, so I don’t have any solution for that.

1 Like

You’re moving a bit above my paygrade. I do have root throughout via an edited /etc/sudoers, but how can I set up keyboard watch/input?

Appreciate you sticking with this.

I tried a bit… at least that is a working draft. So it disables the mouse on input, sleep 10 seconds and then check again if there is input. Maybe try it, but obviously it needs root access.

#!/usr/bin/env bash
# Get the path by this command: ls -la /dev/input/by-path/
KEYBOARD="platform-i8042-serio-0-event-kbd"

fkbd(){ sudo --shell --user root libinput debug-events --device "/dev/input/by-path/$1" | head -2 | grep -o "pressed"; }
toggle(){ [[ "${1}" == "disable" ]] && echo -e "\nDisable Mouse"; [[ "${1}" == "enable" ]] && echo -e "\nEnable Mouse";  }
check() { [[ "${1}" == "pressed" ]] && return 0 || return 1; }

while true; do
    toggle "enable"
    input=$(fkbd "${KEYBOARD}")
    [[ -z $input ]] && continue

    check "$input"

    [[ $? == 0 ]] && toggle "disable"

    for nb in $(seq 1 3); do echo -n "${nb}" && sleep 1; done 

done

EDIT: Updated the draft. Maybe this is slightly better.

1 Like

What a kind thing to do on your free Sunday. I can’t thank you enough. I’m getting a start-up error of:

libinput error: client bug: Invalid path /dev/input/by-id/usb-Logitech_USB_Receiver-event-kbd
Failed to initialize device /dev/input/by-id/usb-Logitech_USB_Receiver-event-kbd

Which makes sense because I don’t have the keyboard. But after querying xinput --list and finding and substituting my keyboard: Virtual core XTEST keyboard

I’m getting:

libinput error: client bug: Invalid path /dev/input/by-id/Virtual
Failed to initialize device /dev/input/by-id/Virtual

I don’t seem to be inserting the proper name for the kb. Any handle to jiggle?

Again, thank you, thank you.

Edit: when I looked in /dev/input/by-id/, all I found was usb-BRS_2Mp_Camera_BRS_2Mp_Camera-event-if00

:arrow_down:

1 Like

We crossed posts.

[jake@usa ~]$ ls -la /dev/input/by-id/
total 0
drwxr-xr-x 2 root root  60 Mar 26 15:59 .
drwxr-xr-x 4 root root 440 Mar 26 15:59 ..
lrwxrwxrwx 1 root root   9 Mar 26 15:38 usb-BRS_2Mp_Camera_BRS_2Mp_Camera-event-if00 -> ../event3
ls -la /dev/input/by-path/

:question:

1 Like
[jake@usa ~]$ ls -la /dev/input/by-path/
total 0
drwxr-xr-x 2 root root 260 Mar 26 16:03 .
drwxr-xr-x 4 root root 480 Mar 26 16:03 ..
lrwxrwxrwx 1 root root  10 Mar 26 15:38 pci-0000:00:0e.0-platform-sof-essx8336-event -> ../event12
lrwxrwxrwx 1 root root  10 Mar 26 16:03 pci-0000:00:15.0-usb-0:4:1.0-event-mouse -> ../event15
lrwxrwxrwx 1 root root   9 Mar 26 16:03 pci-0000:00:15.0-usb-0:4:1.0-mouse -> ../mouse2
lrwxrwxrwx 1 root root   9 Mar 26 15:38 pci-0000:00:15.0-usb-0:8:1.0-event -> ../event3
lrwxrwxrwx 1 root root   9 Mar 26 15:38 pci-0000:00:17.0-platform-i2c_designware.4-event -> ../event6
lrwxrwxrwx 1 root root   9 Mar 26 15:38 pci-0000:00:17.3-platform-i2c_designware.7-event -> ../event9
lrwxrwxrwx 1 root root   9 Mar 26 15:38 pci-0000:00:17.3-platform-i2c_designware.7-event-mouse -> ../event8
lrwxrwxrwx 1 root root   9 Mar 26 15:38 pci-0000:00:17.3-platform-i2c_designware.7-mouse -> ../mouse1
lrwxrwxrwx 1 root root   9 Mar 26 15:38 platform-i8042-serio-0-event-kbd -> ../event2
lrwxrwxrwx 1 root root   9 Mar 26 15:38 platform-INT33D5:00-event -> ../event5
lrwxrwxrwx 1 root root   9 Mar 26 15:38 platform-pcspkr-event-spkr -> ../event7

Looks like this your keyboard, because of kbd at the end. One sec I update the script above.

EDIT: Updated.

1 Like

Wonderful. Script loads. It shows Disabled Mouse as soon as I type, but neither the mouse nor the buttons are disabled.

For instance, if I type in terminal, OnlyOffice, or Word97/WINE, I can type with one hand and move pointer and activate buttons as I type.

Am I doing something wrong here?

No, as I wrote: It is a draft Therefore it does not disable the mouse, it just prints what it would do. Call it a simulation. You need to adapt the script from brodie and use it combined. You would need to replace the toggle function.

Understood. I’ll play with it to the best of my abilities. Thank you for all your help.

1 Like