Switching virtual consoles from within X

Dan Nelson dnelson at allantgroup.com
Thu May 11 16:01:23 PDT 2006

In the last episode (May 11), Nik Clayton said:
> Is it possible to (from the command line) switch virtual consoles while 
> within X?
> Since I upgraded X on my laptop resume from suspend has been a little 
> flaky. But if I make sure I run 'zzz' from within a text virtual terminal 
>  the laptop has (so far) always resumed correctly.
> I could create ~/bin/zzz which checks to see if I'm in X and refuses to 
> run, but it would be even nicer if I could have it automatically switch to 
> a virtual console for me, and then run /usr/sbin/zzz.
> I'm aware of 'vidcontrol -s <n>', and if I run that from a virtual terminal 
> it works.  However, if I run it within X it refuses to work, printing:
>     vidcontrol: must be on a virtual console: Inappropriate ioctl for device
> Is there a way around this restriction?

Redirect stdin from a vty:

vidcontrol -s 1 < /dev/ttyv0

If you're not root you'll either need to specify a vty you are logged
in on, or wrap it in a sudo call.

	Dan Nelson
	dnelson at allantgroup.com

More information about the freebsd-stable mailing list