If I'm running a FreeBSD system without X, but with several virtual terminals doing various things, under certain circumstances I will use vidcontrol() to switch to a particular virtual terminal in case of an alarm event. But I don't want to do that if I'm actively typing in one or another virtual terminal.
So before doing the virtual terminal switch, I wish to see whether a keypress has happened within, say, three seconds. If so, I won't switch; if not, I'll switch.
How do I determine, in a background process (possibly as root), how long ago the most recent keypress has occurred? If it's necessary to run a different process just to keep track of each keypress event (non-X) and put that in a file somewhere, I'm willing to do that.
So before doing the virtual terminal switch, I wish to see whether a keypress has happened within, say, three seconds. If so, I won't switch; if not, I'll switch.
How do I determine, in a background process (possibly as root), how long ago the most recent keypress has occurred? If it's necessary to run a different process just to keep track of each keypress event (non-X) and put that in a file somewhere, I'm willing to do that.