How to release keyboard and mouse from grab by a hung unkillable app?
Although the most well-known use mode of xkill
is "click to kill", there's an option -id
, which can be supplied with Window Id of the client you want to disconnect from X server. Then, if you can access your X session from a remote terminal/VT, you can use xprop
or some other means to get the Id, and pass it to xkill
.
Suppose that current active window belongs to the X client who grabbed the keys&mouse. Then the following will kill this client's connection to the X server and thus release keyboard and mouse from the grab:
winid=$(xprop -root _NET_ACTIVE_WINDOW | cut -d# -f2)
xkill -id $winid
This actually worked for me when I tried to get rid of QEMU's grab when QEMU was stuck in Disk sleep.
You could try the standard SysRq+R trick which should release the keyboard from the X server, or the Ctrl+Alt+1-6 combination that changes the current console, maybe allowing you to run a terminal and kill the faulty program.