-
Notifications
You must be signed in to change notification settings - Fork 8
/
install.sh
165 lines (126 loc) · 4.16 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# MACCEL_ENABLE_USBMOUSE=0
# MACCEL_DEBUG_INSTALL=0
# MACCEL_BRANCH
bold_start() {
printf "\e[1m"
}
bold_end() {
printf "\e[22m"
}
print_bold() {
bold_start
printf "$1"
bold_end
}
print_yellow() {
printf "\e[33m$1\e[0m"
}
print_green() {
printf "\e[32m$1\e[0m"
}
underline_start() {
printf "\e[4m"
}
underline_end() {
printf "\e[24m\n"
}
get_current_version(){
if ! which maccel &>/dev/null; then
return
fi
maccel -V | awk '{ print $2 }'
}
CURR_VERSION=$(get_current_version)
set -e
setup_dirs() {
rm -rf /opt/maccel && mkdir -p /opt/maccel
cd /opt/maccel
if [[ -n $MACCEL_BRANCH ]]; then
print_bold "Will do an install, using the branch: $MACCEL_BRANCH\n"
git clone --depth 1 --no-single-branch https://github.com/Gnarus-G/maccel.git .
git switch $MACCEL_BRANCH
else
git clone --depth 1 https://github.com/Gnarus-G/maccel.git .
fi
}
version_update_warning() {
if [[ -n $CURR_VERSION && "$CURR_VERSION" < "0.1.3" ]]; then
print_yellow $(print_bold "ATTENTION!")
printf "\n\n"
print_yellow "The precision for the processed values has been updated since version '$CURR_VERSION';\n"
EMPHASIS=$(print_bold "MUST re-enter your parameter values in maccel")
print_yellow "This means that you $EMPHASIS.\n"
print_yellow "Otherwise your curve and mouse movement won't behave as expected.\n"
printf "\nHere were your values as maccel understands them in '$CURR_VERSION':\n"
print_bold "SENS MULT: "
maccel get sens-mult
print_bold "ACCEL: "
maccel get accel
print_bold "OFFSET: "
maccel get offset
print_bold "OUTPUT CAP: "
maccel get output-cap
fi
}
install_driver() {
make uninstall || true
if [[ $MACCEL_DEBUG_INSTALL -eq 1 ]]; then
print_bold "Will do a debug install as requested, MACCEL_DEBUG_INSTALL=1\n"
make debug_install
else
make install
fi
}
install_cli() {
VERSION=$(wget -qO- https://github.com/Gnarus-G/maccel/releases/latest | grep -oP 'v\d+\.\d+\.\d+' | tail -n 1)
curl -fsSL https://github.com/Gnarus-G/maccel/releases/download/$VERSION/maccel-cli.tar.gz -o maccel-cli.tar.gz
tar -zxvf maccel-cli.tar.gz maccel_$VERSION/maccel
mkdir -p bin
sudo install -m 755 -v -D maccel_$VERSION/maccel* bin/
sudo ln -vfs $(pwd)/bin/maccel* /usr/local/bin/
}
install_udev_rules() {
sudo rm -f /usr/lib/udev/rules.d/99-maccel*.rules /usr/lib/udev/maccel_*
sudo install -m 644 -v -D $(pwd)/udev_rules/99-maccel.rules /usr/lib/udev/rules.d/99-maccel.rules
sudo install -m 755 -v -D $(pwd)/udev_rules/maccel_param_ownership_and_resets /usr/lib/udev/maccel_param_ownership_and_resets
# We must maintain the usbmouse driver with its binding rules if an old maccel version is installed.
if [[ -n "$CURR_VERSION" && "$CURR_VERSION" < "0.1.5" ]]; then
sudo install -m 755 -v -D $(pwd)/udev_rules/maccel_bind /usr/lib/udev/maccel_bind
sudo install -m 644 -v -D $(pwd)/udev_rules/99-maccel-bind.rules /usr/lib/udev/rules.d/99-maccel-bind.rules
fi
}
trigger_udev_rules() {
udevadm control --reload-rules
udevadm trigger --subsystem-match=usb --subsystem-match=input --subsystem-match=hid --attr-match=bInterfaceClass=03 --attr-match=bInterfaceSubClass=01 --attr-match=bInterfaceProtocol=02
}
# ---- Install Process ----
ATTENTION=$(version_update_warning)
underline_start
print_bold "\nFetching the maccel github repo"
underline_end
setup_dirs
underline_start
print_bold "\nInstalling the driver (kernel module)"
underline_end
install_driver
underline_start
print_bold "\nInstalling the CLI"
underline_end
install_cli
underline_start
print_bold "\nInstalling udev rules..."
underline_end
install_udev_rules
trigger_udev_rules
print_bold $(print_green "[Recommended]")
print_bold ' Add yourself to the "maccel" group\n'
print_bold $(print_green "[Recommended]")
print_bold ' usermod -aG maccel $USER\n'
if [[ -n "$ATTENTION" ]]; then
printf "\n$ATTENTION\n"
fi
if [[ -n "$CURR_VERSION" && "$CURR_VERSION" < "0.2.0" ]]; then
bold_start
print_yellow "\nNOTE: There are two drivers now, and the new (default) one has better compatibility. For more info, see https://github.com/Gnarus-G/maccel/blob/main/TWO_IMPLEMENTATIONS.md.md\n"
bold_end
fi