I have a dirty solution that is to plug a USB keyboard in and execute the following command:
setxkbmap -rules evdev -layout us -model evdev
Afterward my keyboard will work.
This solution only works if I have a usb keyboard handy which is seldom the case and I am forced to reboot my laptop. I have tried to have the command auto execute when the system wakes by adding:
set -e
if [ "${1}" = "resume" ] && [ "${2}" != "standby" ]; then
setxkbmap -rules evdev -layout us -model evdev
fi
exit 0
to: /etc/apm/event.d/enable_xkb But this does not work. I am guessing because it is not run by the appropriate user.
So there are two possible answers to this question: 1) How do I get the above script to execute after my system wakes up. If I can get this to work I can simply put my computer to sleep and wake it back up and have the keyboard working again. 2) (preferred) How do I actually fix this probelem.
More details about situation that my be needed to answer 2) Due to the randomness of this problem I do not know when this issue first started. I do know that it exists on Debian Unstable, and Testing but not Stable. It also exists on curret Arch linux but not before November 2012. My system is a Lenovo w520.
Also note: This is a bit of a heisenbug, as such I would not be able to accept a response until it has worked for a few days.
Further clarification: When this happens I am unable to switch to any of the tty#s so no console does not work. I have also tried the "Raising Skinny Elephants is Utterly Boring" combo and this does not work either... After I post I will check if this works when my keyboard is functional. It is very random, sometimes it will be fine for a couple days and bam my keyboard doesn't work.
export DISPLAY=:0
and run your command above. Run it once every second if you'd like, or even once every 15 to 30 seconds. – Naftuli Kay Apr 05 '13 at 00:26