This gist will help you circumvent a bug with the current Linux kernels (6.17 at the time of writing) that breaks the keyboard after booting your laptop back up from standby.
Credits go to mistine (Github) for coming up with this fix, u/ymmvxd (Reddit) for adapting this fix for Fedora and me (MyFairJulia) for adapting this fix again for Fedora Atomic.
What this fix does is simply removing the i8042 driver (responsible for communication with PS/2 keyboards and mice) while entering standby and adding the driver back in while resuming. The problem is that you cannot simply apply this fix to a Fedora Atomic based distro, since it doesn't allow the user to mess with the system. These instructions will help you wrap the fix into an rpm package to layer it onto your deployment.
Before you spend an hour (or more than half a day as i did) we'll have to check first whether this fix even works on your laptop.
To do that, enter the following command in your terminal:
sudo dmesg | grep i8042
If your terminal output contains the following lines, this fix will work on your machine. It definitely worked on my Sony Vaio Flip 15:
[ 0.494344] serio: i8042 KBD port at 0x60,0x64 irq 1
[ 0.494363] serio: i8042 AUX port at 0x60,0x64 irq 12
[ 0.507130] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input3
[ 1.394864] input: SynPS/2 Synaptics TouchPad as /devices/platform/i8042/serio1/input/input5
If you happen to have any i8042-related kernel arguments, i suggest to remove them before starting as they could interfere with the fix.
We need distrobox to create an environment to build the rpm package. This could theoretically work with rpm-ostree but temporarily layering a development environment onto Fedora wastes a lot of time.
Anyway, run these commands to install distrobox:
sudo rpm-ostree install distrobox
systemctl reboot
After reboot, run the following command to create and enter the distrobox:
distrobox enter
Then confirm the prompt to create the distrobox.
Run the following commands to install fpm and its dependencies:
yum install ruby rpm-build
gem install fpm
fpm is the tool that will help us build the package and we need ruby to install and run it as well as rpm-build so fpm can create the rpm package.
Create the script file using nano keyboard-reset.sh and paste the following content into the terminal:
#!/bin/sh
case $1/$2 in
pre/*)
echo i8042 > /sys/bus/platform/drivers/i8042/unbind
;;
post/*)
echo i8042 > /sys/bus/platform/drivers/i8042/bind
;;
esac
This is the actual fix! The real deal! The script is described in the intro.
Save the file using Ctrl-X and grant the script the execute permission using sudo chmod +x keyboard-reset.sh
Create the rpm package using the following command:
fpm -s dir -t rpm -p keyboard-reset.rpm --name i8042-keyboard-reset --version 0.1.0 --architecture all --description "Resets the keyboard driver after returning from standby" --maintainer "mistine, u/ymmvxd and MyFairJulia" keyboard-reset.sh=/usr/lib/systemd/system-sleep/keyboard-reset.sh
This command takes the script and creates an rpm package around it that will put the script in the correct location to be run automatically on standby and resume by systemd.
Leave the distrobox behind using the command exit and run the following commands to install the package and reboot your machine:
sudo rpm-ostree install ~/keyboard-reset.rpm
systemctl reboot
Does this fix every issue related with hibernate? The keyboard is the worse of the issues, but there are other problems that come with it: laptop does not turn off on lid close; function keys do not work. I remember seeing this script a while back and it didn't fix those, did anything change?
Anyways, thanks for creating this!