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.
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.
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.
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.
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
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.