20

I have a touchscreen laptop and I want to hide the pointer whenever I touch the screen. I am aware of solutions like unclutter and startx -nocursor but I want the pointer to hide/show dynamically, hiding if I use the touchscreen and showing when I use a hardware mouse.

I thought about making two separate pointers and applying one of the two above solutions to the touchscreen pointer, but neither of those solutions mention how to target a single pointer, and having multiple pointers makes things act weird, and that wouldn't hide the hardware mouse cursor.

I figure I can most reasonably do this doing something like this, keeping track of the current input mechanism and executing xinput -cursor [transparent cursor] whenever the touchscreen is used and xinput -cursor [normal cursor] whenever a normal mouse is used.

I looked at xinput though and it looks like since both the hardware mouse and touchscreen are slaved to the same pointer, both of them register the same events in xev so I'm not really sure where I would get the information needed to differentiate a touch from a mouseclick. is it possible?

migrated from askubuntu.com May 13 '15 at 18:16

This question came from our site for Ubuntu users and developers.

5

You could use

To use, install it

sudo apt-get install unclutter

then run it

unclutter -idle 0.01 -root

Note that the number after idle means the time before it hides. In this case its set to 1/100 of a second. You could try change it to a value that it would always be hidden.

This will hide the cursor when you don't move it. I'm sure there is also an option to completely hide it.

  • I've seen solutions using unclutter but this doesn't differentiate between using a touchsreen and a mouse. – erp Sep 23 '15 at 20:20
2

I suppose you use the touchscreen when you don't have a mouse, and plug one in the system when you want to use it. In this case, you could use udev rules to manage your pointer accordingly:

ACTION=="add", ATTRS{bInterfaceProtocol}=="02", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceSubClass}=="01", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/user/.Xauthority", ENV{REMOVE_CMD}="/usr/bin/xinput -cursor [transparent cursor]", RUN+="/usr/bin/xinput -cursor [normal cursor]"

Conditions used to distinguish a mouse are borrowed from this answer.

Keep in mind that individual applications are free to redefine the cursor dynamically, so your cursor may become visible again when you hover their windows. You can start/stop unclutter instead if you want all cursors to be hidden everywhere:

ACTION=="add", ATTRS{bInterfaceProtocol}=="02", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceSubClass}=="01", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/user/.Xauthority", ENV{REMOVE_CMD}="/bin/sh -c unclutter&", RUN+="/usr/bin/killall unclutter"

Personally I would also disable the touchscreen altogether when the mouse is plugged, so that accidentally touching it doesn't disturb the cursor when you expect it to follow the mouse.

  • this is a good option except that i want this behavior for my trackpad, not only for plugged-in mice. I believe udev only affects devices that are dynamically added/removed? – erp Oct 20 '15 at 16:22
  • You mean your trackpad is your "hardware mouse"? I'd say you'll have to try and see if it works. The touchpad may actually be seen by udev as removed when you disable it using Fn button (assuming you have one). – Dmitry Grigoryev Oct 21 '15 at 7:33
0

There is a fork of the unclutter-fixes tool by nowrep available here. This version adds a -touch option to automatically hide the cursor whenever a touch input is detected. (The original unclutter-xfixes repository is here)

One thing to be aware of is that it still includes the behavior of hiding the cursor after a specified time period. You can just set the --timeout option to a very high value to work around that.

This should work perfectly for you. In my case I had an externally attached touchscreen and when I move back to the regular monitor the cursor will be on the touchscreen, so I have to move it back to the monitor from where I touched. The nice thing is that after I start moving the mouse the cursor will show up so I know where it's at.

A nice benefit of this option is that I can still use my mouse like normal on the touchscreen if I want to but hides it when I don't.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.