Last active
September 5, 2022 14:21
-
-
Save heikomat/3fe272431b44b580c933bfb901a92257 to your computer and use it in GitHub Desktop.
This file contains 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 "" |
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?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! Good job! It works for my asus transformer mini t103haf !
`$ inxi -F
System:
Host: mint19 Kernel: 5.3.0-24-generic x86_64 bits: 64
Desktop: Cinnamon 4.4.5 Distro: Linux Mint 19.3 Tricia
Machine:
Type: Detachable System: ASUSTeK product: T103HAF v: 1.0
serial:
Mobo: ASUSTeK model: T103HAF v: 1.0 serial:
UEFI: American Megatrends v: T103HAF.307 date: 01/17/2018
Battery:
ID-1: BATC charge: 5.3 Wh condition: 29.2/31.6 Wh (92%)
CPU:
Topology: Quad Core model: Intel Atom x5-Z8350 bits: 64 type: MCP
L2 cache: 1024 KiB
Speed: 480 MHz min/max: 480/1920 MHz Core speeds (MHz): 1: 480 2: 480
3: 480 4: 480
Graphics:
Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series
PCI Configuration Registers
driver: i915 v: kernel
Display: x11 server: X.Org 1.20.4 driver: modesetting unloaded: fbdev,vesa
resolution: 800x1280~60Hz
OpenGL: renderer: Mesa DRI Intel HD Graphics (Cherrytrail)
v: 4.5 Mesa 19.0.8
Audio:
Device-1: Intel HDMI/DP LPE Audio driver: HdmiLpeAudio
Device-2: bytcht-cx2072x driver: bytcht-cx2072x
Sound Server: ALSA v: k5.3.0-24-generic
Network:
Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter
driver: ath10k_pci
IF: wlp1s0 state: up mac: 80:c5:f2:b8:0c:cd
Drives:
Local Storage: total: 177.49 GiB used: 26.35 GiB (14.8%)
ID-1: /dev/mmcblk0 model: DF4064 size: 58.24 GiB
ID-2: /dev/mmcblk1 model: ED4QT size: 119.25 GiB
Partition:
ID-1: / size: 55.64 GiB used: 8.59 GiB (15.4%) fs: ext4 dev: /dev/dm-0
ID-2: swap-1 size: 980.0 MiB used: 0 KiB (0.0%) fs: swap dev: /dev/dm-1
Sensors:
System Temperatures: cpu: 6280.0 C mobo: N/A
Fan Speeds (RPM): cpu: 0
Info:
Processes: 214 Uptime: 5m Memory: 3.68 GiB used: 1007.3 MiB (26.7%)
Shell: bash inxi: 3.0.32 `