#!/bin/sh
# Do a root check
if [ $(id -u) -ne 0 ]; then
echo "This script must be run as root.";
exit 99;
fi
# Install device-specific tools
apt install -y ethtool flashrom intel-gpu-tools inxi iw lm-sensors powertop rfkill thinkfan wavemon wireless-tools xserver-xorg-video-intel
# Add early kms to initramfs
echo '
drm
i915' >> /etc/initramfs-tools/modules
echo 'options i915 fastboot=1' > /etc/modprobe.d/i915.conf
update-initramfs -u
# Use DRI2
mkdir -p /etc/X11/xorg.conf.d/
echo 'Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "AccelMethod" "uxa"
Option "SwapbuffersWait" "true"
EndSection
' > /etc/X11/xorg.conf.d/20-intel.conf
# Set wlan led blink
echo 'options ath9k blink=1' > /etc/modprobe.d/ath9k.conf
# Disable pcspkr beeps
echo 'blacklist pcspkr' > /etc/modprobe.d/pcspkr.conf
# Enable kernel fan control
echo 'options thinkpad_acpi fan_control=1' > /etc/modprobe.d/thinkpad_acpi.conf