clevo-keyboard/kb.sh

56 lines
2 KiB
Bash
Raw Permalink Normal View History

2023-09-12 13:43:37 +02:00
#!/bin/bash
2023-09-16 17:04:37 +02:00
if [ "$EUID" -ne 0 ]; then
echo "This script requires root rights. Execute it with sudo."
exit 1
fi
2024-04-14 06:31:03 +02:00
# Function to detect Linux distribution and install packages accordingly
install_packages() {
if [ -f /etc/arch-release ]; then
echo "Detected Arch Linux or derivative"
pacman -Sy --noconfirm git dkms base-devel
pacman install $(pacman list --quiet --installed | grep "^linux[0-9]*[-rt]*$" | awk '{print $1"-headers"}' ORS=' ')
elif [ -f /etc/debian_version ]; then
echo "Detected Debian/Ubuntu or derivative"
apt update && apt install -y git dkms build-essential linux-headers-$(uname -r)
elif [ -f /etc/redhat-release ]; then
echo "Detected Fedora/RHEL/CentOS or derivative"
dnf -y group install "C Development Tools and Libraries"
dnf -y group install "Development Tools"
dnf -y install git dkms kernel-headers kernel-devel
else
echo "Unsupported Linux distribution."
exit 1
fi
}
# Install required packages
install_packages
2023-09-12 15:03:37 +02:00
rm -rf ~/clevo-keyboard
2023-09-12 13:43:37 +02:00
rmmod clevo_acpi
rmmod clevo_wmi
rmmod tuxedo_io
rmmod tuxedo_keyboard
2023-09-16 17:04:37 +02:00
rm /etc/modprobe.d/tuxedo_keyboard.conf
2023-09-12 13:43:37 +02:00
git clone https://github.com/wessel-novacustom/clevo-keyboard
2023-09-12 15:03:37 +02:00
cd clevo-keyboard/
2023-09-12 13:43:37 +02:00
make clean
2023-09-16 17:04:37 +02:00
cd src
file="tuxedo_keyboard.c"
output=$(dmidecode | grep Manufacturer)
sysvendor=$(echo "$output" | awk -F 'Manufacturer: ' 'NR==1{print $2}')
boardvendor=$(echo "$output" | awk -F 'Manufacturer: ' 'NR==2{print $2}')
chassisvendor=$(echo "$output" | awk -F 'Manufacturer: ' 'NR==3{print $2}')
sed -i "s/DMI_MATCH(DMI_SYS_VENDOR, .*)/DMI_MATCH(DMI_SYS_VENDOR, \"$sysvendor\")/g" "$file"
sed -i "s/DMI_MATCH(DMI_BOARD_VENDOR, .*)/DMI_MATCH(DMI_BOARD_VENDOR, \"$boardvendor\")/g" "$file"
sed -i "s/DMI_MATCH(DMI_CHASSIS_VENDOR, .*)/DMI_MATCH(DMI_CHASSIS_VENDOR, \"$chassisvendor\")/g" "$file"
cat $file
cd ..
make dkmsinstall
2023-09-12 13:43:37 +02:00
echo tuxedo_keyboard >> /etc/modules
modprobe tuxedo_keyboard
echo "options tuxedo_keyboard color=WHITE" > /etc/modprobe.d/tuxedo_keyboard.conf
2023-09-12 15:03:37 +02:00
rm -rf ~/clevo-keyboard
2023-09-12 13:43:37 +02:00
exit 0