Skip to content

Instantly share code, notes, and snippets.

@valeryan
Last active February 5, 2019 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valeryan/50c0529ec7ac0e3c31f0a3ce861124e2 to your computer and use it in GitHub Desktop.
Save valeryan/50c0529ec7ac0e3c31f0a3ce861124e2 to your computer and use it in GitHub Desktop.
Script to setup ubuntu 18.10 on the xps 9570
#!/usr/bin/env bash
# from https://raw.githubusercontent.com/JackHack96/dell-xps-9570-ubuntu-respin/master/xps-tweaks.sh
# Check if the script is running under Ubuntu 18.10 Cosmic Cuttlefish
if [ $(lsb_release -c -s) != "cosmic" ]; then
>&2 echo "This script is made for Ubuntu 18.10!"
exit 1
fi
# Check if the script is running as root
if [ "$EUID" -ne 0 ]; then
>&2 echo "Please run xps-tweaks as root!"
exit 2
fi
# Fix issues with ipv6 not working
sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
# Enable universe and proposed
add-apt-repository -y universe
apt -y update
apt -y full-upgrade
# Add Gawk in 18.10
apt -y install gawk
# Install all the power management tools
add-apt-repository -y ppa:linrunner/tlp
apt -y update
apt -y install thermald tlp tlp-rdw powertop
# Fix Sleep/Wake Bluetooth Bug
sed -i '/RESTORE_DEVICE_STATE_ON_STARTUP/s/=.*/=1/' /etc/default/tlp
systemctl restart tlp
# Install the latest nVidia driver and codecs
add-apt-repository -y ppa:graphics-drivers/ppa
apt -y update
ubuntu-drivers autoinstall
# Install codecs
echo "Do you wish to install video codecs for encoding and playing videos?"
select yn in "Yes" "No"; do
case $yn in
Yes ) apt -y install ubuntu-restricted-extras va-driver-all vainfo libva2 gstreamer1.0-libav gstreamer1.0-vaapi; break;;
No ) break;;
esac
done
# Enable high quality audio
echo "Do you wish to enable high quality audio? (may impact on battery life)"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for
## more information. Default values are commented out. Use either ; or # for
## commenting.
daemonize = no
; fail = yes
; allow-module-loading = yes
; allow-exit = yes
; use-pid-file = yes
; system-instance = no
; local-server-type = user
; enable-shm = yes
; enable-memfd = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
; lock-memory = no
; cpu-limit = no
high-priority = yes
; nice-level = -11
; realtime-scheduling = yes
realtime-priority = 9
; exit-idle-time = 20
; scache-idle-time = 20
; dl-search-path = (depends on architecture)
; load-default-script-file = yes
; default-script-file = /etc/pulse/default.pa
; log-target = auto
; log-level = notice
; log-meta = no
; log-time = no
; log-backtrace = 0
resample-method = soxr-vhq
; avoid-resampling = false
; enable-remixing = yes
; remixing-use-all-sink-channels = yes
enable-lfe-remixing = yes
; lfe-crossover-freq = 0
flat-volumes = no
; rlimit-fsize = -1
; rlimit-data = -1
; rlimit-stack = -1
; rlimit-core = -1
; rlimit-as = -1
; rlimit-rss = -1
; rlimit-nproc = -1
; rlimit-nofile = 256
; rlimit-memlock = -1
; rlimit-locks = -1
; rlimit-sigpending = -1
; rlimit-msgqueue = -1
; rlimit-nice = 31
rlimit-rtprio = 9
; rlimit-rttime = 200000
default-sample-format = float32le
default-sample-rate = 48000
alternate-sample-rate = 44100
default-sample-channels = 2
default-channel-map = front-left,front-right
default-fragments = 2
default-fragment-size-msec = 125
; enable-deferred-volume = yes
deferred-volume-safety-margin-usec = 1
; deferred-volume-extra-delay-usec = 0" > /etc/pulse/daemon.conf; break;;
No ) break;;
esac
done
# Enable LDAC, APTX, APTX-HD, AAC support in PulseAudio Bluetooth
add-apt-repository ppa:eh5/pulseaudio-a2dp
apt-get update
apt-get install libavcodec-dev libldac pulseaudio-module-bluetooth
# Other packages
apt -y install intel-microcode
# Install wifi drivers
rm -f /lib/firmware/ath10k/QCA6174/hw3.0/*
wget -O /lib/firmware/ath10k/QCA6174/hw3.0/board.bin https://github.com/kvalo/ath10k-firmware/blob/master/QCA6174/hw3.0/board.bin?raw=true
wget -O /lib/firmware/ath10k/QCA6174/hw3.0/board-2.bin https://github.com/kvalo/ath10k-firmware/blob/master/QCA6174/hw3.0/board-2.bin?raw=true
wget -O /lib/firmware/ath10k/QCA6174/hw3.0/firmware-4.bin https://github.com/kvalo/ath10k-firmware/blob/master/QCA6174/hw3.0/firmware-4.bin_WLAN.RM.2.0-00180-QCARMSWPZ-1?raw=true
# Load and enable systemd units
systemctl daemon-reload
# systemctl disable nvidia-fallback
# Enable power saving tweaks for Intel chip
if [[ $(uname -r) == *"4.15"* ]]; then
echo "options i915 enable_fbc=1 enable_guc_loading=1 enable_guc_submission=1 disable_power_well=0 fastboot=1" > /etc/modprobe.d/i915.conf
else
echo "options i915 enable_fbc=1 enable_guc=3 disable_power_well=0 fastboot=1" > /etc/modprobe.d/i915.conf
fi
# Let users check fan speed with lm-sensors
echo "options dell-smm-hwmon restricted=0 force=1" > /etc/modprobe.d/dell-smm-hwmon.conf
if cat /etc/modules | grep "dell-smm-hwmon" &>/dev/null
then
echo "dell-smm-hwmon is already in /etc/modules!"
else
echo "dell-smm-hwmon" >> /etc/modules
fi
update-initramfs -u
# Switch to Intel card
prime-select intel 2>/dev/null
# Tweak grub defaults
GRUB_OPTIONS_VAR_NAME="GRUB_CMDLINE_LINUX_DEFAULT"
GRUB_OPTIONS="quiet splash acpi_rev_override=1 acpi_osi=Linux nouveau.modeset=0 pcie_aspm=force drm.vblankoffdelay=1 scsi_mod.use_blk_mq=1 nouveau.runpm=0 mem_sleep_default=deep "
echo "Do you wish to disable SPECTRE/Meltdown patches for performance?"
select yn in "Yes" "No"; do
case $yn in
Yes ) GRUB_OPTIONS+="pti=off spectre_v2=off l1tf=off nospec_store_bypass_disable no_stf_barrier"; break;;
No ) break;;
esac
done
GRUB_OPTIONS_VAR="$GRUB_OPTIONS_VAR_NAME=\"$GRUB_OPTIONS\""
if cat /etc/default/grub | grep "$GRUB_OPTIONS_VAR" &>/dev/null
then
echo "Grub is already tweaked!"
else
sed -i "s/^$GRUB_OPTIONS_VAR_NAME/# $GRUB_OPTIONS_VAR_NAME/g" /etc/default/grub
awk -i inplace -v INPLACE_SUFFIX=.bak '/# '"$GRUB_OPTIONS_VAR_NAME"'/{print;print "'"$GRUB_OPTIONS_VAR_NAME"'=\"'"$GRUB_OPTIONS"'\"";next}1' /etc/default/grub
update-grub
fi
echo "FINISHED! Please reboot the machine!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment