Adding powersave, audio, and screenlock options

This commit is contained in:
DarkFeather 2017-10-26 01:11:53 -05:00
parent ce9d50ab0c
commit b33a8f98fd

View File

@ -9,23 +9,27 @@ function header () {
}
function help() {
echo Usage: ${0} '[OPTIONS]'
echo '\-A -- Audio optimizations from the Arch Wiki'
echo '\-d DISK -- Use the disk.'
echo '\-e -- Encrypt the root partition'
echo '\-g -- GUI packages and setup'
echo '\-h -- This helptext'
echo '\-k -- Kali Linux-like package additions'
echo '\-p -- Productivity package additions'
echo '\-P -- Power saving for laptops'
echo '\-s -- Create a layout for an AniNIX::Spartacus'
echo '\-m -- Skip disk operations and assume storage is mounted on /mnt'
echo '\-z -- Try to add all the packages on AniNIX::Core'
exit 1;
}
audio=0;
spartacus=0;
encrypt=0;
gui=0;
kali=0;
kitchensink=0;
powersave=0;
productivity=0;
disk="/dev/sda"
nodiskbuild=0;
@ -36,11 +40,13 @@ datapart=99;
while getopts "d:egkpmsz" OPTION
do
case $OPTION in
A) audio=1 ;;
d) disk=${OPTARG} ;;
e) encrypt=1 ;;
g) gui=1 ;;
k) kali=1 ;;
p) productivity=1; gui=1 ;;
P) powersave=1 ;;
m) nodiskbuild=1 ;;
s) spartacus=1 ;;
z) kitchensink=1 ;;
@ -127,7 +133,7 @@ fi
header Installing ArchLinux to device\(s\) on /mnt
export pkglist="base base-devel parted net-tools bind-tools git openssh make lynx irssi vim wget tor torsocks grub os-prober rsync openntpd tmux"
if [ "$gui" -eq 1 ]; then
export pkglist="$pkglist"" xorg-server xfce4 chromium conky tigervnc"
export pkglist="$pkglist"" xorg-server xfce4 chromium conky tigervnc xtrlock"
fi
if [ "$spartacus" -eq 1 ]; then
export pkglist="$pkglist"" exfat-utils"
@ -214,6 +220,48 @@ if [ "$kali" -eq 1 ]; then
arch-chroot /mnt git -C /usr/local/src/ clone https://aur.archlinux.org/autopsy.git
fi
# Optimizations from https://wiki.archlinux.org/index.php/Power_management
if [ "$powersave" -eq 1 ]; then
if [ `lspci | grep -i intel | grep -ic audio` -eq 1 ]; then
echo 'options snd_hda_intel power_save=1' > /mnt/etc/modprobe.d/audio_powersave.conf
else
echo 'options snd_ac97_codec power_save=1' > /mnt/etc/modprobe.d/audio_powersave.conf
fi
arch-chroot /mnt pacman -S rfkill cpupower --noconfirm
arch-chroot /mnt systemctl enable rfkill-block@.service
echo 'kernel.nmi_watchdog = 0' > /mnt/etc/sysctl.d/disable_watchdog.conf
echo 'vm.dirty_writeback_centisecs = 6000' > /mnt/etc/sysctl.d/dirty_writes.conf
echo 'vm.laptop_mode = 5' > /mnt/etc/sysctl.d/laptop.conf
echo 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/usr/bin/iw dev %k set power_save on"' > /mnt/etc/udev/rules.d/70-wifi-powersave.rules
echo 'blacklist uvcvideo' > /mnt/etc/modprobe.d/no-camera.conf
fi
# Thanks to https://wiki.archlinux.org/index.php/Professional_audio
if [ "$audio" -eq 1 ]; then
sed -i 's#GRUB_CMDLINE_LINUX_DEFAULT="#GRUB_CMDLINE_LINUX_DEFAULT="threadirqs #' /mnt/etc/default/grub
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
printf 'vm.swappiness = 10\nfs.inotify.max_user_watches = 524288\n' > /mnt/etc/sysctl.d/99-audio-tuning.conf
setpci -v -d *:* latency_timer=b0
for SOUND_CARD_PCI_ID in `lspci | grep -i audio | cut -f 1 -d ' '`; do
setpci -v -s $SOUND_CARD_PCI_ID latency_timer=ff;
done
printf 'echo 2048 > /sys/class/rtc/rtc0/max_user_freq\necho 2048 > /proc/sys/dev/hpet/max-user-freq\n' >> /mnt/etc/rc.local
fi
# Emulate old rc.local behavior
touch /mnt/etc/rc.local
echo '[Unit]
Description=Execute commands at boot
[Service]
ExecStart=/etc/rc.local
[Install]
WantedBy=multi-user.target' > /mnt/usr/lib/systemd/system/rclocal.service
arch-chroot /mnt systemctl enable rclocal
arch-chroot /mnt chmod 0700 /etc/rc.local
arch-chroot /mnt chown root: /etc/rc.local
# Set password
header Set new root passphrase and depriviledged user '(depriv)' password.
arch-chroot /mnt passwd