"chvt" analog

Hi,

There is a tool called "chvt" found in some (most?) GNU/Linux distros which changes the active terminal. It can be found in the sys-apps/kbd package (at least on Gentoo).

I find "chvt" very useful for switching to console when X becomes irresponsive by replacing the default command for "acpi button event" - when I press the power button the system switches to tty instead of doing "shutdown -h now".

Is there any way to implement the same functionality on FreeBSD?
 
Savagedlight said:
Shouldn't you be able to reach the console by pressing ctrl+alt+Fx when in X?

Not when X is "frozen". Which doesn't mean the system is dead - e.g. pressing the power button initiates a normal shut down. Typically that happens (to me) while there's excessive hdd I/O.
 
dbi said:
Hi,

There is a tool called "chvt" found in some (most?) GNU/Linux distros which changes the active terminal. It can be found in the sys-apps/kbd package (at least on Gentoo).

I find "chvt" very useful for switching to console when X becomes irresponsive by replacing the default command for "acpi button event" - when I press the power button the system switches to tty instead of doing "shutdown -h now".

Is there any way to implement the same functionality on FreeBSD?

(Seems like X should not be going away often enough to need a special button to get out of it, but maybe it depends on what you're doing.)

ACPI events can be recognized by devd(8). There are a couple of examples in the default /etc/devd.conf.
 
Well, I had figured out that pressing the power button executes /etc/rc.shutdown.
Hence my original question: is there an analog of chvt in FreeBSD, so I could use it in the script.
 
If I'm not mistaken the code is written for some 7.2 kernel that Debian used during that time. I've tested on 9.0-CURRENT and it works. So, unless you give me an exact compiler error I don't care.
 
Hmm, 8.1 amd64 gives
Code:
> cc -o chvt chvt.c
> ./chvt
5
> ./chvt 1
which takes me to the equivalent of punching ctl-alt-F1.

I'd say it works.
 
[solved]

Sorry, my mistake. I guess something went wrong while doing copy/paste yesterday. The program compiled w/o errors and works exactly as I need.

Thank you, guys!
 
Back
Top