Last active
September 5, 2022 14:21
-
-
Save heikomat/3fe272431b44b580c933bfb901a92257 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
system=$(lsb_release --description) | |
system_name=$(lsb_release --id --short) | |
system_version=$(lsb_release --release --short) | |
system_main_version=${system_version%%.*} | |
is_debian=false | |
is_ubuntu=false | |
is_mint=false | |
is_elementary=false | |
is_popos=false | |
if [ ! "${system/Pop!_OS}" = "$system" ] ; then | |
is_popos=true | |
is_ubuntu=true | |
elif [ ! "${system/Ubuntu}" = "$system" ] ; then | |
is_ubuntu=true | |
elif [ ! "${system/Linux Mint}" = "$system" ] ; then | |
is_mint=true | |
elif [ ! "${system/Debian}" = "$system" ] ; then | |
is_debian=true | |
elif [ ! "${system/elementary}" = "$system" ] ; then | |
is_elementary=true | |
else | |
echo "this script is only for debian, ubuntu, mint and elementary. You're using ${system_name}." | |
exit 1 | |
fi | |
# make sure the firmware for intel sst audio device 808622A8 is installed | |
echo " -> Checking if the firmware for intels 808622A8 exists..." | |
if [ ! -f /lib/firmware/intel/fw_sst_22a8.bin ]; then | |
# the firmware is not found where it is supposed to be, so install it | |
package="firmware-intel-sound" | |
package_source="deb http://ftp.de.debian.org/debian/ buster main non-free contrib" | |
if [ "$is_ubuntu" = true ] || [ "$is_mint" = true ]; then | |
package="linux-firmware" | |
package_source="deb http://de.archive.ubuntu.com/ubuntu/ artful main" | |
fi | |
echo " -> firmware not found, downloading ${package} to install it" | |
install_from_newer_version=false | |
if [ "$is_ubuntu" = true ] && [ "$system_main_version" -lt "16" ]; then | |
install_from_newer_version=true | |
fi | |
if [ "$is_mint" = true ] && [ "$system_main_version" -lt "18" ]; then | |
install_from_newer_version=true | |
fi | |
if [ "$is_debian" = true ] && [ "${system/stretch}" = "$system" ] && [ "${system/buster}" = "$system" ] && [ "${system/sid}" = "$system" ]; then | |
install_from_newer_version=true | |
fi | |
if [ "$install_from_newer_version" = true ]; then | |
echo " -> Your version of ${system_name} is too old. Temporarily installing newer package source." | |
sudo su -c "echo '${package_source}' >> /etc/apt/sources.list" | |
fi | |
sudo apt-get -qq update | |
sudo apt-get -qq install $package | |
if [ "$install_from_newer_version" = true ]; then | |
echo " -> Removing temporarily added package source." | |
sudo sed -i '$d' /etc/apt/sources.list | |
sudo apt-get -qq update | |
fi | |
else | |
echo " -> firmware found." | |
fi | |
# Make sure alsa and pulseaudio are installed | |
echo "" | |
echo " -> Making sure pulseaudio is installed" | |
sudo apt-get -qq install pulseaudio | |
# configure pulseaudio to disable realtime-scheduling | |
echo " -> Disabling realtime scheduling in /etc/pulse.daemon.conf" | |
sudo sed --in-place --regexp-extended --expression='s/;?\s*realtime-scheduling\s*=\s*(yes|no)/realtime-scheduling = no/g' /etc/pulse/daemon.conf | |
# install alsa configuration files | |
echo " -> Downloading and installing alsa-ucm-configuration files" | |
sudo rm -rf /usr/share/alsa/ucm/chtcx2072x | |
sudo mkdir --parents /usr/share/alsa/ucm/bytcht-cx2072x/ | |
sudo rm --force /usr/share/alsa/ucm/bytcht-cx2072x/HiFi.conf | |
sudo rm --force /usr/share/alsa/ucm/bytcht-cx2072x/bytcht-cx2072x.conf | |
sudo wget --quiet --show-progress --output-document="/usr/share/alsa/ucm/bytcht-cx2072x/HiFi.conf" "https://raw.githubusercontent.com/heikomat/linux/cx2072x/cx2072x_fixes_and_manual/bytcht-cx2072x/HiFi.conf" | |
sudo wget --quiet --show-progress --output-document="/usr/share/alsa/ucm/bytcht-cx2072x/bytcht-cx2072x.conf" "https://raw.githubusercontent.com/heikomat/linux/cx2072x/cx2072x_fixes_and_manual/bytcht-cx2072x/bytcht-cx2072x.conf" | |
# install the kernel | |
version=5.2 | |
full_linux_version="${version}.0+" | |
headerfile="linux-headers-${version}_cx2072x_amd64.deb" | |
imagefile="linux-image-${version}_cx2072x_amd64.deb" | |
# download the kernel with cx2072x codec | |
echo "" | |
echo " -> Downloading Kernel with cx2072x support" | |
rm --force ${imagefile} ${headerfile} | |
wget --quiet --show-progress "https://github.com/heikomat/linux/releases/download/v${version}_cx2072x/${headerfile}" | |
wget --quiet --show-progress "https://github.com/heikomat/linux/releases/download/v${version}_cx2072x/${imagefile}" | |
# install the kernel | |
echo "" | |
echo " -> Installing the kernel" | |
sudo dpkg --install ${headerfile} | |
sudo dpkg --install ${imagefile} | |
# Pop!_OS uses systemd-boot instead of grub, and a tool called kernelstub to manage it | |
# Here we configure the efi-partition to boot with the new kernel | |
if [ "$is_popos" = true ]; then | |
echo " -> Pop!_OS detected. configuring efi-partition to use the new kernel" | |
# make sure kernelstub is actually installed | |
sudo apt-get -qq install kernelstub | |
sudo kernelstub --kernel-path "/boot/vmlinuz-${full_linux_version}" --initrd-path "/boot/initrd.img-${full_linux_version}" | |
fi | |
# remove older kernels | |
echo " -> Removing old kernels" | |
sudo apt-get -qq autoremove | |
# cleanup | |
echo " -> Cleaning up downloads" | |
rm --force ${imagefile} ${headerfile} | |
echo "" | |
echo "" | |
echo " -> All done. Please reboot! <-" | |
echo " If you still have no sound after rebooting, try the following: " | |
echo "" | |
echo " - Change the audio-output in your audio-control" | |
echo " - Set the default sink with:" | |
echo " pacmd set-default-sink \$(pactl list short sinks | grep cx2072x | cut -c1)" | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to use it on Linux Lite 6.0 but the terminal says
this script is only for debian, ubuntu, mint and elementary. You're using Ubuntu.
Any suggestions?