In comp.windows.x, Omon Edeki
wrote
on Sat, 22 Mar 2003 06:06:33 -0600
> Dear all,
> I am trying to switch from an Xwindows graphical mode on my screen to a
> terminal screen. If you're running linux and you press cntrl+alt+Fx {where
> 1<=x<=7), then you can switch from the Xwindows session to that terminal
> screen tty[x]. What I am trying to do is to "automate" this in a
> program;Do you know what functio call to make? Is there a way to replicate
> the process of sending in cntrl+alt+fx to the keyboard by passing say some
> xters to the keyboard input stream?Any idea how to tackle this? THANK YOU
> Omon Edeki
> www.cs.utexas.edu/users/omon
> "Never.Never Give Up."
etc. etc., but the salient ioctl() functions can be had by
'man 4 console_ioctl', at least on my system (Debian x86).
The relevant ioctl() flag is VT_ACTIVATE, which lives in
<linux/vt.h> (/usr/include/linux/vt.h). The manpage states
one should use the POSIX functions but doesn't stipulate
which those are. (/dev/vcs and /dev/vcsa are apparently the
ones to use for console text dumping, but that's not what
you want, AFAICT.)
There is also a 'chvt' command, which appears to be a program-level
enfolding of this functionality.
Unfortunately, my attempts at switching came up with
$ chvt < /dev/tty1 1
chvt: VT_ACTIVATE: Operation not permitted
$
in an xterm, even though
$ chvt 1
works perfectly when I'm sitting on a console to which I'm logged in,
and I've logged into /dev/tty1.
This is of course all highly Linux-specific; followups
therefore set to a (AFAICT) more relevant group as far as
this subtopic is concerned. I'll admit to some curiosity
as to how, say, AIX does it (AIX has virtual consoles and
X, looking vaguely similar to Linux in that regard).
--
It's still legal to go .sigless.