I always got anoyed when X crashed, or hanged and I couldn’t do anything anymore, while I knew the rest of the system was still functional and I should be able to get my screen session back.
The ‘easy’ way for this would be to SSH into your workstation, but I like to keep sshd turned off on those machines. preferably no external services on workstations at all actually.
Now I have a Thinkpad, and Thinkpads have this ugly Thinkpad/Thinkvantage button, especially ugly in it’s inner workings, and because of that it’s useful here.
The Thinkvantage button is not a keyboard event (which at this point is controlled by a broken Xorg) but it’s polled by the ACPI daemon, which runs as root. So when you press the button, an ACPI event is generated, which can have scripts linked to them.
A quick fix would be to put ‘chvt 2′ in the /etc/acpi/thinkpad-thinkpad.sh script on debian. But I wanted a little more and changed it to the following:
/etc/acpi/thinkpad-thinkpad.sh
#!/bin/sh
CURVT=`/bin/fgconsole`
NEXTVT=`expr $CURVT + 1`
if [ $NEXTVT -gt 8 ]; then
NEXTVT=1
echo "looped back to: $NEXTVT" >> /tmp/nextvt.log;
fi
echo "Current VT: $CURVT, Next VT: $NEXTVT" >> /tmp/nextvt.log
if [ "X$NEXTVT" eq "X" ]; then
/bin/chvt 2;
else
/bin/chvt $NEXTVT;
fi
So this actually loops through terminal 1 t/m 8, without needing the keyboard-driver.
(don’t forget to reload acpid after chaning any of the scripts).

