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