Advertisement
Guest User

thinkpad-e15-gen2-firmware-1.09-power-supply-fix.sh

a guest
Jan 22nd, 2021
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.45 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. GRUB_CUSTOM_ACPI='/boot/thinkpad-e15-gen2-firmware-1.09-power-supply-fix.aml'
  4. GRUB_ACPI_CFG='/etc/grub.d/01_acpi'
  5. OUTPUT_DIR='thinkpad-e15-gen2-firmware-1.09-power-supply-fix'
  6.  
  7. if [ "$1" == '--help' ]; then
  8.     echo "Fixes power supply events on Lenovo ThinkPad E15 Gen2 with firmware 1.09 R1AET33W"
  9.     echo "Output will be located in $OUTPUT_DIR"
  10.     echo ""
  11.     echo "Options:"
  12.     echo "--grub-setup-dsdt  - setup new DSDT table to grub"
  13.     exit 0
  14. fi
  15.  
  16. mkdir -p "$OUTPUT_DIR"
  17. pushd $_
  18.  
  19. acpidump -b -n DSDT && \
  20. iasl dsdt.dat && \
  21. sed -i 's/Name (H8DR, 0x00)/Name (H8DR, One)/g' dsdt.dsl && \
  22. iasl dsdt.dsl || \
  23. exit 1
  24.  
  25. if [ "$1" == "--grub-setup-dsdt" ]; then
  26.     if test -f "$GRUB_ACPI_CFG"; then
  27.         echo "Failed to include custom DSDT: file $GRUB_ACPI_CFG already exists"
  28.         exit 1
  29.     fi
  30.  
  31.     cat <<EOF2 >$GRUB_ACPI_CFG
  32. #!/bin/sh
  33.  
  34. GRUB_CUSTOM_ACPI="${GRUB_CUSTOM_ACPI}"
  35.  
  36. libdir=/usr/share
  37.  
  38. . \${libdir}/grub/grub-mkconfig_lib
  39.  
  40. # Load custom ACPI table
  41. if [ x\${GRUB_CUSTOM_ACPI} != x ] && [ -f \${GRUB_CUSTOM_ACPI} ] \\
  42.         && is_path_readable_by_grub \${GRUB_CUSTOM_ACPI}; then
  43.     echo "Found custom ACPI table: \${GRUB_CUSTOM_ACPI}" >&2
  44.     prepare_grub_to_access_device \`\${grub_probe} --target=device \${GRUB_CUSTOM_ACPI}\` | sed -e "s/^/  /"
  45.     cat << EOF
  46. acpi (\\\$root)\`make_system_path_relative_to_its_root \${GRUB_CUSTOM_ACPI}\`
  47. EOF
  48. fi
  49. EOF2
  50.     chmod a+x "$GRUB_ACPI_CFG"
  51.     cp -f dsdt.aml "$GRUB_CUSTOM_ACPI"
  52.     update-grub
  53. fi
  54. popd
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement