2019-12-02 21:00:21 +00:00
|
|
|
#!/bin/bash
|
2018-04-29 23:36:59 +00:00
|
|
|
|
|
|
|
LX_BASE=""
|
|
|
|
LX_VERSION=""
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
if [ -r "/etc/os-release" ]; then
|
|
|
|
. "/etc/os-release"
|
|
|
|
if [ "$ID" = "arch" ]; then
|
|
|
|
LX_BASE="$ID"
|
|
|
|
elif [ "$ID" = "ubuntu" ]; then
|
|
|
|
LX_BASE="$ID"
|
|
|
|
LX_VERSION=$VERSION_ID
|
|
|
|
elif [ -n "$UBUNTU_CODENAME" ] ; then
|
|
|
|
LX_BASE="ubuntu"
|
|
|
|
LX_VERSION="$VERSION_ID"
|
2018-04-29 23:36:59 +00:00
|
|
|
else
|
2019-12-02 21:00:21 +00:00
|
|
|
LX_BASE="$ID"
|
|
|
|
LX_VERSION="$VERSION"
|
2018-04-29 23:36:59 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Could not identify your distro. Please open script and run commands manually."
|
2019-12-02 21:00:21 +00:00
|
|
|
exit
|
2018-04-29 23:36:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
SUR_MODEL="$(dmidecode | grep "Product Name" -m 1 | xargs | sed -e 's/Product Name: //g')"
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "Running $LX_BASE version $LX_VERSION on a $LX_MODEL."
|
|
|
|
read -rp "Press enter if this is correct, or CTRL-C to cancel." tmp; echo
|
|
|
|
echo "Continuing setup..."
|
2018-04-29 23:36:59 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Copying the config files under root to where they belong..."
|
|
|
|
for dir in $(ls root/); do cp -Rbv "root/$dir/"* "/$dir/"; done
|
|
|
|
echo
|
2018-04-29 23:36:59 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Copying firmware files under root..."
|
|
|
|
cp -rv firmware/* /lib/firmware/
|
|
|
|
echo
|
2018-04-29 23:36:59 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Making /lib/systemd/system-sleep/sleep executable..."
|
|
|
|
chmod -v a+x /lib/systemd/system-sleep/sleep
|
2018-04-29 23:36:59 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
printf "
|
|
|
|
Suspend is recommended over hibernate. If you chose to use hibernate, please
|
|
|
|
make sure you've setup your swap file per the instructions in the README.\n\n"
|
|
|
|
read -rp "Do you want to replace suspend with hibernate? (type yes or no): " \
|
|
|
|
usehibernate;echo
|
2018-04-29 23:36:59 +00:00
|
|
|
|
|
|
|
if [ "$usehibernate" = "yes" ]; then
|
2019-12-02 21:00:21 +00:00
|
|
|
if [ "$LX_BASE" = "ubuntu" ] && [ 1 -eq "$(echo "${LX_VERSION} >= 17.10" | bc)" ]; then
|
|
|
|
echo "==> Using Hibernate instead of Suspend..."
|
|
|
|
ln -vsfb /lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target
|
|
|
|
sudo ln -vsfb /lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service
|
|
|
|
else
|
|
|
|
echo "==> Using Hibernate instead of Suspend..."
|
|
|
|
ln -vsfb /usr/lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target
|
|
|
|
sudo ln -vsfb /usr/lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service
|
|
|
|
fi
|
2018-04-29 23:36:59 +00:00
|
|
|
else
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Not touching Suspend"
|
2018-04-29 23:36:59 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
printf "
|
|
|
|
Patched libwacom packages are available to better support the pen. If you
|
|
|
|
intend to use the pen, it's recommended that you install them!\n\n"
|
|
|
|
read -rp "Do you want to install the patched libwacom packages? (type yes or no): " \
|
|
|
|
uselibwacom;echo
|
2018-04-29 23:36:59 +00:00
|
|
|
|
|
|
|
if [ "$uselibwacom" = "yes" ]; then
|
2019-12-02 21:12:08 +00:00
|
|
|
echo "==> Downloading latest libwacom-surface..."
|
|
|
|
|
|
|
|
urls=$(curl --silent "https://api.github.com/repos/qzed/libwacom-surface-deb/releases/latest" \
|
|
|
|
| tr ',' '\n' \
|
|
|
|
| grep '"browser_download_url":' \
|
|
|
|
| sed -E 's/.*"([^"]+)".*/\1/' \
|
|
|
|
| grep '.deb$')
|
|
|
|
|
|
|
|
wget -P tmp $urls
|
|
|
|
|
|
|
|
echo "==> Installing latest libwacom-surface..."
|
|
|
|
|
|
|
|
dpkg -i tmp/*.deb
|
|
|
|
rm -rf tmp
|
2018-04-29 23:36:59 +00:00
|
|
|
else
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Not touching libwacom"
|
2018-04-29 23:36:59 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
printf "
|
|
|
|
This repo comes with example xorg and pulse audio configs. If you chose to
|
|
|
|
keep them, be sure to rename them and uncomment out what you'd like to
|
|
|
|
keep!\n\n"
|
|
|
|
read -rp "Do you want to remove the example intel xorg config? (type yes or no): " \
|
|
|
|
removexorg;echo
|
2018-12-30 14:49:42 +00:00
|
|
|
|
|
|
|
if [ "$removexorg" = "yes" ]; then
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Removing the example intel xorg config..."
|
|
|
|
rm -v /etc/X11/xorg.conf.d/20-intel_example.conf
|
2018-12-30 14:49:42 +00:00
|
|
|
else
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Not touching example intel xorg config" \
|
2019-12-02 21:12:08 +00:00
|
|
|
"(/etc/X11/xorg.conf.d/20-intel_example.conf)"
|
2019-01-28 16:51:03 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
echo
|
|
|
|
read -rp "Do you want to remove the example pulse audio config files? (type yes or no): "\
|
|
|
|
removepulse;echo
|
2019-01-28 16:51:03 +00:00
|
|
|
|
|
|
|
if [ "$removepulse" = "yes" ]; then
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Removing the example pulse audio config files..."
|
|
|
|
rm -v /etc/pulse/daemon_example.conf
|
|
|
|
rm -v /etc/pulse/default_example.pa
|
2019-01-28 16:51:03 +00:00
|
|
|
else
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Not touching example pulse audio config files" \
|
|
|
|
" (/etc/pulse/*_example.*)"
|
2018-12-30 14:49:42 +00:00
|
|
|
fi
|
|
|
|
|
2018-04-29 23:36:59 +00:00
|
|
|
if [ "$SUR_MODEL" = "Surface Pro 3" ]; then
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Remove unneeded udev rules for Surface Pro 3..."
|
|
|
|
rm -v /etc/udev/rules.d/98-keyboardscovers.rules
|
2018-04-29 23:36:59 +00:00
|
|
|
fi
|
|
|
|
|
2018-09-10 16:33:19 +00:00
|
|
|
if [ "$SUR_MODEL" = "Surface Go" ]; then
|
2019-12-02 21:00:21 +00:00
|
|
|
if [ ! -f "/etc/init.d/surfacego-touchscreen" ]; then
|
|
|
|
echo "==> Patching power control for Surface Go touchscreen..."
|
|
|
|
echo "echo \"on\" > /sys/devices/pci0000:00/0000:00:15.1/i2c_designware.1/power/control" \
|
|
|
|
> /etc/init.d/surfacego-touchscreen
|
|
|
|
chmod -v 755 /etc/init.d/surfacego-touchscreen
|
|
|
|
update-rc.d surfacego-touchscreen defaults
|
|
|
|
fi
|
2018-09-10 16:33:19 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
read -rp "
|
|
|
|
Do you want to set your clock to local time instead of UTC? This fixes
|
|
|
|
issues when dual booting with Windows. (type yes or no): " \
|
|
|
|
uselocaltime;echo
|
2018-06-07 21:52:02 +00:00
|
|
|
|
|
|
|
if [ "$uselocaltime" = "yes" ]; then
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Setting clock to local time..."
|
|
|
|
timedatectl set-local-rtc 1
|
|
|
|
hwclock --systohc --localtime
|
2018-06-07 21:52:02 +00:00
|
|
|
else
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Not setting clock"
|
2018-06-07 21:52:02 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
read -rp "
|
|
|
|
Do you want this script to download and install the latest kernel for you?
|
|
|
|
(type yes or no): " autoinstallkernel;echo
|
2018-06-07 02:15:26 +00:00
|
|
|
|
|
|
|
if [ "$autoinstallkernel" = "yes" ]; then
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Downloading latest kernel..."
|
2018-06-07 02:15:26 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
urls=$(curl --silent "https://api.github.com/repos/qzed/linux-surface/releases/latest" \
|
|
|
|
| tr ',' '\n' \
|
|
|
|
| grep '"browser_download_url":' \
|
|
|
|
| sed -E 's/.*"([^"]+)".*/\1/' \
|
|
|
|
| grep '.deb$')
|
2018-06-07 02:15:26 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
wget -P tmp $urls
|
2018-06-07 02:15:26 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
echo
|
|
|
|
echo "==> Installing latest kernel..."
|
2018-06-07 02:15:26 +00:00
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
dpkg -i tmp/*.deb
|
|
|
|
rm -rf tmp
|
2018-06-07 02:15:26 +00:00
|
|
|
else
|
2019-12-02 21:00:21 +00:00
|
|
|
echo "==> Not downloading latest kernel"
|
2018-06-07 02:15:26 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-02 21:00:21 +00:00
|
|
|
echo
|
|
|
|
echo "All done! Please reboot."
|