sudo install -D -m 0755 /dev/stdin \
/usr/lib/systemd/system-sleep/99-redrix-touchpad-resume <<'EOF'
#!/bin/sh
# Reinitialize only the ELAN2703 touchpad after system resume.
# The ELAN2513 touchscreen is intentionally left untouched.
driver=/sys/bus/i2c/drivers/i2c_hid_acpi
device=i2c-ELAN2703:00
wakeup=/sys/bus/i2c/devices/$device/power/wakeup
if [ ! -e "/sys/bus/i2c/devices/$device" ]; then
logger -t redrix-touchpad "ELAN2703 device is absent; skipping"
exit 0
fi
case "$1" in
pre)
# LID0 remains enabled, so opening the lid can still wake the system.
[ ! -w "$wakeup" ] || printf '%s' disabled > "$wakeup"
exit 0
;;
post)
;;
*)
exit 0
;;
esac
# Let the I2C controller finish resuming before reinitializing the touchpad.
sleep 1
if [ -e "$driver/$device" ]; then
printf '%s' "$device" > "$driver/unbind" || {
logger -t redrix-touchpad "failed to unbind $device"
exit 1
}
sleep 1
fi
printf '%s' "$device" > "$driver/bind" || {
logger -t redrix-touchpad "failed to bind $device"
exit 1
}
# Rebinding may restore wakeup=enabled, so disable it again.
[ ! -w "$wakeup" ] || printf '%s' disabled > "$wakeup"
logger -t redrix-touchpad "reinitialized $device after resume"
EOF
3.2 安装 udev 唤醒规则
1
2
3
4
5
6
7
8
9
10
sudo install -D -m 0644 /dev/stdin \
/etc/udev/rules.d/99-redrix-touchpad-wakeup.rules <<'EOF'
# ELAN2703 can leave a wake event pending and abort deep suspend on Redrix.
# Lid-open (LID0) remains enabled as the normal wake source.
ACTION=="add", SUBSYSTEM=="i2c", KERNEL=="i2c-ELAN2703:00", ATTR{power/wakeup}="disabled"
EOFsudo udevadm control --reload-rules
echo disabled | sudo tee \
/sys/bus/i2c/devices/i2c-ELAN2703:00/power/wakeup
3.3 立即恢复当前已经失灵的触摸板
只有在确认设备名是 i2c-ELAN2703:00 后才运行:
1
2
3
4
5
6
7
echo i2c-ELAN2703:00 | sudo tee \
/sys/bus/i2c/drivers/i2c_hid_acpi/unbind
sleep 1echo i2c-ELAN2703:00 | sudo tee \
/sys/bus/i2c/drivers/i2c_hid_acpi/bind
echo disabled | sudo tee \
/sys/bus/i2c/devices/i2c-ELAN2703:00/power/wakeup