I have a RPi 2 set up as a kiosk with the official touch screen.

On startup, the user will need to enter some input using the touch screen, but then I want to display an external web page in full screen mode. This site shows a map, and I want the user to be able to drag the map, but not to click in it. Note that the website is external so I can't use javascript to catch events.

How can I catch/disable touch screen events from bash? An acceptable, but not ideal, solution would be to disable touch functionality altogether after the user logs in.

  • Do you want to control the behaviour of the browser from bash?
    – Bex
    Apr 10 '16 at 12:17
  • I want to catch touch input before it reaches the browser so I can intercept a click but pass dragging through. Apr 10 '16 at 15:36

I ended up installing xinput, getting the touch screen's ID using

xinput --list

and then:

exec('xinput disable 6');

Where 6 is the touch device ID.

This disables all touch input so the user is not able to drag or click.


What you want can probably not be easily achieved from bash, as such.

You probably want to operate on the driver.

One idea would be to unload the input driver all together. You will have to identify it, using lsmod, and then remove it with rmmod. You can reinsert it with insmod if needed.

  • 1
    Note that some poorly written drivers behave erratically when you unload them while their device file is in use. I've seen a system where disabling the touchpad / touchscreen this way would crash the system every second time or so. Aug 14 '17 at 7:58

While it is possible to disable individual input events in X (e.g. using xmodmap), it's pretty much impossible to disable a click while leaving a drag enabled. Both actions are transmitted to the window via ButtonPress and ButtonRelease events, and those are translated to clicks or drags by the widget library, such as QT or GTK. Theoretically, you could patch the library to disable the "onClick" callback, leaving only the drag functionality, but that would require a non-trivial level of programming knowledge.

That leaves you with the option of disabling the input device altogether, which you already know how to do.

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.