-
Notifications
You must be signed in to change notification settings - Fork 70
/
install.sh
executable file
·144 lines (125 loc) · 3.6 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# Checking if the script is runned as root (via sudo or other)
if [[ $(id -u) != 0 ]]
then
echo "Please run the installation script as root (using sudo for example)"
exit 1
fi
if [[ $(sudo apt install 2>/dev/null) ]]; then
echo 'apt is here' && sudo apt -y install libevdev2 python3-libevdev i2c-tools git
elif [[ $(sudo pacman -h 2>/dev/null) ]]; then
echo 'pacman is here' && sudo pacman --noconfirm -S libevdev python-libevdev i2c-tools git
elif [[ $(sudo dnf install 2>/dev/null) ]]; then
echo 'dnf is here' && sudo dnf -y install libevdev python-libevdev i2c-tools git
fi
modprobe i2c-dev
# Checking if the i2c-dev module is successfuly loaded
if [[ $? != 0 ]]
then
echo "i2c-dev module cannot be loaded correctly. Make sur you have installed i2c-tools package"
exit 1
fi
interfaces=$(for i in $(i2cdetect -l | grep DesignWare | sed -r "s/^(i2c\-[0-9]+).*/\1/"); do echo $i; done)
if [ -z "$interfaces" ]
then
echo "No interface i2c found. Make sure you have installed libevdev packages"
exit 1
fi
touchpad_detected=false;
for i in $interfaces; do
echo -n "Testing interface $i : ";
number=$(echo -n $i | cut -d'-' -f2)
offTouchpadCmd="i2ctransfer -f -y $number w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x00 0xad"
i2c_test=$($offTouchpadCmd 2>&1)
if [ -z "$i2c_test" ]
then
echo "sucess"
touchpad_detected=true;
break
else
echo "failed"
fi
done;
if [ "$touchpad_detected" = false ] ; then
echo 'The detection was not successful. Touchpad not found.'
exit 1
fi
if [[ -d numpad_layouts/__pycache__ ]] ; then
rm -rf numpad_layouts/__pycache__
fi
echo
echo "Select models keypad layout:"
PS3='Please enter your choice '
options=($(ls numpad_layouts) "Quit")
select opt in "${options[@]}"
do
opt=${opt::-3}
case $opt in
"gx701" )
model=gx701
break
;;
"m433ia")
model=m433ia
break
;;
"ux433fa")
model=ux433fa
break
;;
"ux581l" )
model=ux581l
break
;;
"Q")
exit 0
;;
*)
echo "invalid option $REPLY";;
esac
done
echo
echo "What is your keyboard layout?"
PS3='Please enter your choice [1-3]: '
options=("Qwerty" "Azerty" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Qwerty")
percentage_key=6 # Number 5
break
;;
"Azerty")
percentage_key=40 # Apostrophe key
break
;;
"Quit")
exit 0
;;
*) echo "invalid option $REPLY";;
esac
done
echo "Add asus touchpad service in /etc/systemd/system/"
cat asus_touchpad.service | LAYOUT=$model PERCENTAGE_KEY=$percentage_key envsubst '$LAYOUT $PERCENTAGE_KEY' > /etc/systemd/system/asus_touchpad_numpad.service
mkdir -p /usr/share/asus_touchpad_numpad-driver/numpad_layouts
mkdir -p /var/log/asus_touchpad_numpad-driver
install asus_touchpad.py /usr/share/asus_touchpad_numpad-driver/
install -t /usr/share/asus_touchpad_numpad-driver/numpad_layouts numpad_layouts/*.py
echo "i2c-dev" | tee /etc/modules-load.d/i2c-dev.conf >/dev/null
systemctl enable asus_touchpad_numpad
if [[ $? != 0 ]]
then
echo "Something gone wrong while enabling asus_touchpad_numpad.service"
exit 1
else
echo "Asus touchpad service enabled"
fi
systemctl restart asus_touchpad_numpad
if [[ $? != 0 ]]
then
echo "Something gone wrong while enabling asus_touchpad_numpad.service"
exit 1
else
echo "Asus touchpad service started"
fi
exit 0