Artificial intelligent assistant

Are any events generated when stylus proximity is detected? I trying to configure my laptop's touchscreen + stylus so that the touch device is turned off when the stylus is detected, so that I can rest my hand on the screen while writing. I can write a script that does this by checking for 'proximity' in the xinput output, but this script would have to check a few times per second to have a good response time. I was wondering whether the stylus proximity generates an event that can be captured somehow to avoid watching the xinput output all the time... I don't see anything in acpi_listen. Any hints? Thanks, Stefano

The following works for me:


STYLUS_ID=11 # replace with ID or name of your stylus
TOUCH_ID=9 # replace with ID or name of your touch screen

xinput test -proximity "$STYLUS_ID" |
while read line; do
if [[ $line == *out* ]]; then
xinput enable "$TOUCH_ID"
else
xinput disable "$TOUCH_ID"
fi
done


Instead of polling the state of the stylus, it relies on the option `test` of `xinput`, which enters an endless loop displaying `proximity` events for the device. From `xinput`'s man page:


test [-proximity] device
Register all extended events from device and enter an endless loop
displaying events received. If the -proximity is given, ProximityIn
and ProximityOut are registered.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 0d9e1b681e32ce8aedc7f218e67f4a89