setup.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/bin/sh
  2. LX_BASE=""
  3. LX_VERSION=""
  4. if [ -r /etc/os-release ]; then
  5. . /etc/os-release
  6. if [ $ID = arch ]; then
  7. LX_BASE=$ID
  8. elif [ $ID = ubuntu ]; then
  9. LX_BASE=$ID
  10. LX_VERSION=$VERSION_ID
  11. elif [ ! -z "$UBUNTU_CODENAME" ] ; then
  12. LX_BASE="ubuntu"
  13. LX_VERSION=$VERSION_ID
  14. else
  15. LX_BASE=$ID
  16. LX_VERSION=$VERSION
  17. fi
  18. else
  19. echo "Could not identify your distro. Please open script and run commands manually."
  20. exit
  21. fi
  22. SUR_MODEL="$(dmidecode | grep "Product Name" -m 1 | xargs | sed -e 's/Product Name: //g')"
  23. SUR_SKU="$(dmidecode | grep "SKU Number" -m 1 | xargs | sed -e 's/SKU Number: //g')"
  24. echo "\nRunning $LX_BASE version $LX_VERSION on a $SUR_MODEL.\n"
  25. read -rp "Press enter if this is correct, or CTRL-C to cancel." cont;echo
  26. echo "\nContinuing setup...\n"
  27. echo "Copying the config files under root to where they belong...\n"
  28. for dir in $(ls root/); do cp -Rb root/$dir/* /$dir/; done
  29. echo "Copying firmware files under root...\n"
  30. cp -r firmware/* /lib/firmware/
  31. echo "Making /lib/systemd/system-sleep/sleep executable...\n"
  32. chmod a+x /lib/systemd/system-sleep/sleep
  33. echo "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"
  34. read -rp "Do you want to replace suspend with hibernate? (type yes or no) " usehibernate;echo
  35. if [ "$usehibernate" = "yes" ]; then
  36. if [ "$LX_BASE" = "ubuntu" ] && [ 1 -eq "$(echo "${LX_VERSION} >= 17.10" | bc)" ]; then
  37. echo "Using Hibernate instead of Suspend...\n"
  38. ln -sfb /lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target && sudo ln -sfb /lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service
  39. else
  40. echo "Using Hibernate instead of Suspend...\n"
  41. ln -sfb /usr/lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target && sudo ln -sfb /usr/lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service
  42. fi
  43. else
  44. echo "Not touching Suspend\n"
  45. fi
  46. echo "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"
  47. read -rp "Do you want to install the patched libwacom packages? (type yes or no) " uselibwacom;echo
  48. if [ "$uselibwacom" = "yes" ]; then
  49. echo "Installing patched libwacom packages..."
  50. dpkg -i packages/libwacom/*.deb
  51. apt-mark hold libwacom
  52. else
  53. echo "Not touching libwacom"
  54. fi
  55. echo "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"
  56. read -rp "Do you want to remove the example intel xorg config? (type yes or no) " removexorg;echo
  57. if [ "$removexorg" = "yes" ]; then
  58. echo "Removing the example intel xorg config..."
  59. rm /etc/X11/xorg.conf.d/20-intel_example.conf
  60. else
  61. echo "Not touching example intel xorg config (/etc/X11/xorg.conf.d/20-intel_example.conf)"
  62. fi
  63. read -rp "Do you want to remove the example pulse audio config files? (type yes or no) " removepulse;echo
  64. if [ "$removepulse" = "yes" ]; then
  65. echo "Removing the example pulse audio config files..."
  66. rm /etc/pulse/daemon_example.conf
  67. rm /etc/pulse/default_example.pa
  68. else
  69. echo "Not touching example pulse audio config files (/etc/pulse/*_example.*)"
  70. fi
  71. if [ "$SUR_MODEL" = "Surface Pro 3" ]; then
  72. echo "\nRemove unneeded udev rules for Surface Pro 3...\n"
  73. rm /etc/udev/rules.d/98-keyboardscovers.rules
  74. fi
  75. if [ "$SUR_MODEL" = "Surface Go" ]; then
  76. if [ ! -f "/etc/init.d/surfacego-touchscreen" ]; then
  77. echo "\nPatching power control for Surface Go touchscreen...\n"
  78. echo "echo \"on\" > /sys/devices/pci0000:00/0000:00:15.1/i2c_designware.1/power/control" > /etc/init.d/surfacego-touchscreen
  79. chmod 755 /etc/init.d/surfacego-touchscreen
  80. update-rc.d surfacego-touchscreen defaults
  81. fi
  82. fi
  83. 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
  84. if [ "$uselocaltime" = "yes" ]; then
  85. echo "Setting clock to local time...\n"
  86. timedatectl set-local-rtc 1
  87. hwclock --systohc --localtime
  88. else
  89. echo "Not setting clock"
  90. fi
  91. read -rp "Do you want this script to download and install the latest kernel for you? (type yes or no) " autoinstallkernel;echo
  92. if [ "$autoinstallkernel" = "yes" ]; then
  93. echo "Downloading latest kernel...\n"
  94. 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$')
  95. resp=$(wget -P tmp $urls)
  96. echo "Installing latest kernel...\n"
  97. dpkg -i tmp/*.deb
  98. rm -rf tmp
  99. else
  100. echo "Not downloading latest kernel"
  101. fi
  102. echo "\nAll done! Please reboot."