Linux Touch Screen Settings | Gechic
Search Question and Find Solutions
< All Topics

Linux Touch Screen Settings

Linux has supported touchscreen input since Kernal 3.8, and the most popular Linux distributions, such as Debian, Ubuntu, and Manjaro, all support USB touchscreen plug-and-play. However, while these Linux distributions come with a display setup interface for resolution and orientation, they do not have a graphical interface for setting touch input and calibration. Therefore, users may find that the touch responsed position is not accurate in extended displays and a vertical display. In these cases, please do the touch input settings manually according to the the followings.

Linux Touchscreen Settings of a Vertical Display

If you are using a single touch screen for portrait display application in Linux system, please find the 40-libinput profile to set up the transformation matrix of touch.

① Open the 40-libinput file

Input command cd /usr/share/X11/xorg.conf.d in Termail to enter the org.conf.d folder.
Input comman ls to list all the files inside this folder and make sure there is one called 40-libinput.conf.

② Add Transformation Matrix in

Input the following command to open and edit 40-libinput.conf

sudo nano 40-libinput.conf

Find the section of touchscreen , add a new raw Option “TransformationMatrix” “0 -1 1 1 0 0 0 0 1”
Press “Ctl+X”➜ press “y” to save the file.

Reboot and Done!Test with a finger on touchscreen, the response position is correct.

Input the command sudo reboot,the settings is done after rebooting.

Value of ”TransformationMatrix” varies depending on touchscreen models.,For Gechic touch monitor, please take the following values for portrait display.
Rotate 90° = Option “TransformationMatrix” “0 1 0 -1 0 1 0 0 1”
Totate 270° = Option “TransformationMatrix” “0 -1 1 1 0 0 0 0 1”

For example, the value of rotate 270° applies to the display orientation setting of 【Portrait Right】in Ubuntu desktop.

Linux Touchscreen Settings of Extended Displays

If the connected touch monitor is set as “Extended” , you shall use xinput’s map-to-output command to specify the touch mapping to the external display, regardless of whether the touchscreen is horizontal or vertical. Since the recent Debian and Ubuntu distributions run wayland by default, you must disable wayland on your desktop before using xinput. Please refer to the followings for configuration:

Debian-Gnome Desktop

① Disable wayland

Input the following command in Termianl to oppen the daemon.conf file.【Note: This is the config file of Debian12. The config file of Debian11 is named as custom.conf】

sudo nano /etc/gdm3/daemon.conf

Find the line of #waylandenable=false. Delete # mark, save the file and reboot

②Run xinput list

Input the command xinput list to list all the connected devices and find out the device ID of touch montior (The device name of Gechic touch monitor is shown as ILITEK-TP ). In this example, the external connected touch monitor is 22.

③ Run xrandr

Input the command xrandr to list all the connected displays and find out the name of touch monitor. ( In this example, the connected extended touch monitor is named as “HDMI-1” and its resolution is recognized as 1920*1080+1366*0 )

④ Run xinput map-to-output

Input the following command to assign the xinput device ID 22 mapping to the display HDMI-1.

xinput map-to-output 22 “HDMI-1”

Done!Test with a finger on touchscreen, the response position is correct.

Debian-Plasma Desktop

① Disable wayland

🔵Click 【System settings】 icon in the left bottom cornor➜ click【Startup and Shutdown】➜ click【Behavior】 button➜ select 【Plasma (X11)】in the “log in session”
🔵Click【Background Services】in the left column➜drag in the right coloumn to find and uncheck【KScreen 2】➜ click 【Apply】   ( Plasma has its own windows manager called “KScreen”, please disable KScreen function as well. )
🔵Reboot the system, and choose 【Plasma(X11)】in the right bottom cornor and log in

Run xinput list

Input the command xinput list in Konsole to list all the connected devices and find out the device ID of touch monitor. (Note: The device name of Gechic touch monitor is shown as ILITEK-TP ). In this example, the device ID of the external connected touch monitor is 11.

③ Run xrandr

Input the command xrandr to to list all the connected displays and find out the name of touch monitor. ( In this example, the connected extended touch monitor is named as “HDMI-1” and its resolution is recognized as 1920*1080+1366*0 )

④ Run xinput map-to-output

Input the following command to assign xinput device ID 11 mappting to display HDMI-1.

xinput map-to-output 11 “HDMI-1”

Done!Test with a finger on touchscreen, the response position is correct.

Ubuntu Desktop

① Disable wayland

Input the following command in Terminal to open the custom.conf file. Find the row of waylandenable=enable and add# at the begining. Save the file and reboot.

sudo nano /etc/gdm3/custom.conf

Run xinput list

Input the command xinput list in Terminal to list all the connected devices and find out the device ID of touch monitor. (Note: The device name of Gechic touch monitor is shown as ILITEK-TP ). In this example, the device ID of the external connected touch monitor is 11.

③ Run xrandr

Input the command xrandr to list all the connected displays and find out the name of touch monitor. ( In this example, the connected extended touch monitor is named as “HDMI-1” and its resolution is recognized as 1920*1080+0*0 )

④ Run xinput map-to-output

Input the following command to assign xinput device ID 11 mapping to display HDMI-1

xinput map-to-output 11 “HDMI-1”

Done!Test with a finger on touchscreen, the response position is correct.

Set map-to-output Autorun

The touch mapping will be disabled after rebooting or re-plugging the USB cable of the external monitor, and you must enter the map-to-output scripts again to set the mapping position of the USB device. For your convenience, we suggest that you set the scripts of mapping to run automatically when your desktop is started.

① Find the device Name of Touch Monitor

We got the device ID of the touch monitor is 11. However, this ID can be changed due to rebooting or changing the USB port. Therefore, we recommend using the device name instead of the device ID when setting up the auto-execute file.
Enter the following scripts in Terminal to display all the attribute data of the touch monitor and we find out the name of the device as “ILITEK       ILITEK-TP   ” (all data between single quotes, including spaces).

Add a new script file

Enter the following scripts in Terminal to add a file named touchscreen.sh under the folder .config.

sudo nano ~/.config/touchscreen.sh

Enter the following scripts in the file and press ctrl+x to save.
#! /bin/bash
xinput map-to-output “ILITEK ILITEK-TP “ HDMI-1

Enter the following scripts to set the file executable.
sudo chmod+x ~/.config/touchscreen.sh

Add an autorun file on the desktop

Enter the following scripts in Terminal to add a file named touch.desktop under the folder .config/autostart. (If you can’t find an “autostart” folder inside .config folder, please add one by yourself)
sudo nano ~/.config/autostart/touch.desktop
Enter the following scripts in the file, save and exit. (Note: The location of the executable file should be your actual file location.)
[Desktop Entry]
Type=Application
Name=touch
Exec=/home/gechic/.config/touchscreen.sh

Reboot

After rebooting, test on the external touch monitor. And it shall react correctly.