source /usr/lib/ublue/setup-services/libsetup.sh
version-script framework system 2 || exit 0
set -x
CPU_VENDOR=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ print $2 }')
VEN_ID="$(cat /sys/devices/virtual/dmi/id/chassis_vendor)"
BIOS_VERSION="$(cat /sys/devices/virtual/dmi/id/bios_version 2>/dev/null)"
KARGS=$(rpm-ostree kargs)
NEEDED_KARGS=()
echo "Current kargs: $KARGS"
if [[ $KARGS =~ "nomodeset" ]]; then
echo "Removing nomodeset"
NEEDED_KARGS+=("--delete-if-present=nomodeset")
fi
if [[ ":Framework:" =~ :$VEN_ID: ]]; then
if [[ "GenuineIntel" == "$CPU_VENDOR" ]]; then
if [[ ! $KARGS =~ "hid_sensor_hub" ]]; then
echo "Intel Framework Laptop detected, applying needed keyboard fix"
NEEDED_KARGS+=("--append-if-missing=module_blacklist=hid_sensor_hub")
fi
fi
fi
if [[ -n "$NEEDED_KARGS" ]]; then
echo "Found needed karg changes, applying the following: ${NEEDED_KARGS[*]}"
plymouth display-message --text="Updating kargs - Please wait, this may take a while" || true
rpm-ostree kargs "${NEEDED_KARGS[*]}" --reboot || exit 1
else
echo "No karg changes needed"
fi
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
if [[ "$VEN_ID" == "Framework" && "$SYS_ID" == "Laptop 13 ("* ]]; then
echo "Framework Laptop 13 detected"
if [[ ! -f /etc/modprobe.d/alsa.conf ]]; then
echo "Applying 3.5mm audio jack fix"
tee /etc/modprobe.d/alsa.conf <<<"options snd-hda-intel index=1,0 model=auto,dell-headset-multi"
echo 0 | tee /sys/module/snd_hda_intel/parameters/power_save
fi
if [[ "$SYS_ID" == "Laptop 13 (AMD Ryzen 7040Series)" && "$(printf '%s\n' 03.08 "$BIOS_VERSION" | sort -V | tail -n1)" == "03.08" ]]; then
if [[ ! -f /etc/udev/rules.d/20-suspend-fixes.rules ]]; then
echo "Framework 13 Ryzen 7040 with BIOS $BIOS_VERSION < 3.09 — applying suspend workaround"
echo 'ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled"' \
> /etc/udev/rules.d/20-suspend-fixes.rules
fi
else
if [[ -f /etc/udev/rules.d/20-suspend-fixes.rules ]]; then
echo "Removing old suspend workaround"
rm -f /etc/udev/rules.d/20-suspend-fixes.rules
fi
fi
fi