#!/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\": 2/" /usr/share/kscreen/generic-config
sed -i "s/DSI-1/eDP-1/" /usr/share/kscreen/generic-config
sed -i "s/DSI-1/eDP-1/" /etc/xdg/kdeglobals

# udev rule
echo "ENV{IIO_SENSOR_PROXY_TYPE}==\"*accel*\", ENV{ACCEL_MOUNT_MATRIX}=\"0,-1,0;-1,0,0;0,0,1\"" > /etc/udev/rules.d/99-astra-mobile-orientation.rules
echo >> /etc/udev/rules.d/99-astra-mobile-orientation.rules

echo 'Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "Goodix Capacitive TouchScreen"
        Option  "Calibration"   "0 1200  0 1920"
        Option "TransformationMatrix"  "0 -1 1 1 0 0 0 0 1"
EndSection

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

sed -i "s/normal/left_side_up/g" /etc/default/grub
/usr/sbin/update-grub
