Skip to content

Instantly share code, notes, and snippets.

@AngryMane
Last active April 10, 2023 00:08
Show Gist options
  • Save AngryMane/610fa8b2bc7deaf0e55dbb6f588b1116 to your computer and use it in GitHub Desktop.
Save AngryMane/610fa8b2bc7deaf0e55dbb6f588b1116 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
##################################################################################################################
# NOTE!
# If the touch does not work after running this script,
# please check if the "Coordinate Transformation Matrix" is updated with the following command.
# $ xinput --list-props "ILITEK ILITEK-TP"
# If the update is not reflected properly, try running the script several times repeatedly.
##################################################################################################################
# Please check device name with xinput command
TOUCH_DEVICE_NAME="ILITEK ILITEK-TP"
# Please check screen info with xrandr command
TOTAL_WIDTH=3840
TOTAL_HEIGHT=2160
TOUCH_AREA_WIDTH=1920
TOUCH_AREA_HEIGHT=1080
# If touch screen is left bottom like below.
# oo
# xo
TOUCH_AREA_X_OFFSET=0
TOUCH_AREA_Y_OFFSET=1080
# If touch screen is right top below.
# ox
# oo
#TOUCH_AREA_X_OFFSET=1920
#TOUCH_AREA_Y_OFFSET=0
C0=$(python3 -c "print(${TOUCH_AREA_WIDTH}/${TOTAL_WIDTH})")
C1=$(python3 -c "print(${TOUCH_AREA_X_OFFSET}/${TOTAL_WIDTH})")
C2=$(python3 -c "print(${TOUCH_AREA_HEIGHT}/${TOTAL_HEIGHT})")
C3=$(python3 -c "print(${TOUCH_AREA_Y_OFFSET}/${TOTAL_HEIGHT})")
function mirror-display() {
xrandr --output DP-5 --same-as DP-1
xrandr --output HDMI-0 --same-as DP-1
}
function unmirror-display() {
xrandr --output HDMI-0 --left-of DP-1
xrandr --output DP-5 --above DP-1
xinput set-prop "${TOUCH_DEVICE_NAME}" --type=float "Coordinate Transformation Matrix" $C0 0 $C1 0 $C2 $C3 0 0 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment