#!/bin/bash

if [[ `id -u` != 0 ]]; then
    echo "Script will work only with root rights"
    exit 1
fi

#default orientation
sed -i "s/rotation\": 8/rotation\": 1/" /usr/share/kscreen/generic-config
sed -i "s/scale\": 2/scale\": 2.55/" /usr/share/kscreen/generic-config

# udev rule
echo "ATTRS{name}==\"Goodix Berlin Capacitive TouchScreen\", ENV{LIBINPUT_CALIBRATION_MATRIX}=\"25.5 0 0.004455 0 40.116421 0.000625 0 0 1\"" > /etc/udev/rules.d/99-astra-mobile-touch.rules
echo >> /etc/udev/rules.d/99-astra-mobile-touch.rules
udevadm trigger

echo 'Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "Goodix Berlin Capacitive TouchScreen"
        Option  "Calibration"   "-28 2549 7 1591"
        Option  "SwapAxes"      "0"
EndSection

' > /etc/X11/xorg.conf.d/99-calibration.conf
