Jump to content

Disable/toggle touchscreen when pen/stylus is near the Display

I would like to make it so that when I'm holding the pen above the screen it disables touch input so that I can rest my hand on the screen while I'm writing.

My laptop does have the ability to detect the pen when it's near the display, and I'm pretty sure it used to disable touch input on Windows, but it doesn't seem to do that on Ubuntu, meaning I have to hold my hand in the air while writing, which is uncomfortable.

I would be grateful if anyone could provide any advice on either how I could achieve this, or just disable the touchscreen in general so I can create my own script to disable it when the pen is detected

--- System Details ---

Laptop: Thinkpad Yoga S1
OS: Ubuntu 22.10
Gnome Version: 43.1
Windowing System: Wayland
Wacom: Wacom ISDv4 EC

Link to comment
Share on other sites

Link to post
Share on other sites

Right, I can't write the solution to this here, but I can tell you where too look.

Quote

My laptop does have the ability to detect the pen when it's near the display

This detection is going to show up in udev if your laptop is configured correctly, so 

udevadm monitor

run in a terminal is going to show what udev knows about "seeing the pen above the screen" or not.

At this point I'd start scripting /usr/bin/xinput to find, identify, and disable the touchpad, but you are using wayland, so you'll need someone familiar with wayland to help with that.

 

Once you have a script(s) to switch the touchpad on and off you just need to tie it to the events generated in udev when you move them pen in/out of range by adding custom rules in /etc/udev/rules.d/

 

This isn't newbie stuff, but it's totally doable (assuming wayland is capable of disabling/re-enabling the touchpad), and a worthy endeavour.

Link to comment
Share on other sites

Link to post
Share on other sites

On 2/6/2023 at 11:41 PM, Ralphred said:

Right, I can't write the solution to this here, but I can tell you where too look.

This detection is going to show up in udev if your laptop is configured correctly, so 

udevadm monitor

run in a terminal is going to show what udev knows about "seeing the pen above the screen" or not.

At this point I'd start scripting /usr/bin/xinput to find, identify, and disable the touchpad, but you are using wayland, so you'll need someone familiar with wayland to help with that.

 

Once you have a script(s) to switch the touchpad on and off you just need to tie it to the events generated in udev when you move them pen in/out of range by adding custom rules in /etc/udev/rules.d/

 

This isn't newbie stuff, but it's totally doable (assuming wayland is capable of disabling/re-enabling the touchpad), and a worthy endeavour.

Thank you for your response.  udev does seem like the way to go for detecting the pen being above the screen.  The difficult part now is trying to find out how to disable the touchscreen with Wayland.

Link to comment
Share on other sites

Link to post
Share on other sites

On 2/6/2023 at 11:41 PM, Ralphred said:

Right, I can't write the solution to this here, but I can tell you where too look.

This detection is going to show up in udev if your laptop is configured correctly, so 

udevadm monitor

run in a terminal is going to show what udev knows about "seeing the pen above the screen" or not.

At this point I'd start scripting /usr/bin/xinput to find, identify, and disable the touchpad, but you are using wayland, so you'll need someone familiar with wayland to help with that.

 

Once you have a script(s) to switch the touchpad on and off you just need to tie it to the events generated in udev when you move them pen in/out of range by adding custom rules in /etc/udev/rules.d/

 

This isn't newbie stuff, but it's totally doable (assuming wayland is capable of disabling/re-enabling the touchpad), and a worthy endeavour.

I found a script someone else made which allowed them to toggle touch input on Wayland, which I can modify to fit my use case.

I tested the command

udevadm monitor

but it the only thing it seems to show is the screen brightness changing, and nothing else.  Which is strange, as I thought I used udevadm before to detect when the laptop went into tablet mode.  Do you know if there's anything I can do to get udevadm monitor to work properly @Ralphred?

Link to comment
Share on other sites

Link to post
Share on other sites

On 2/8/2023 at 6:18 PM, Bonk Cypher said:

Do you know if there's anything I can do to get udevadm monitor to work properly @Ralphred?

The only thing you can do is check it by plugging in/attaching or removing a device.

If it's not a hotplug event, then (sounding like a broken record) you are going to want to look for wayland's equivalent of `xev` (X Event Viewer), see there if the proximity event is detected there. However, unless you know of a program that "run scripts on defined X events" you are going to end up writing something that runs in the background that does it for you...

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×