Improved vtmonitor. /sys/class/tty/tty0/active makes it very easy.