Subject : Switching btw Xwin graphical mode and terminal mode

Subject : Switching btw Xwin graphical mode and terminal mode

Post by The Ghost In The Machin » Mon, 24 Mar 2003 03:15:37



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."

Highly dangerous, caveat emptor, you're on your own,
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.

 
 
 

Subject : Switching btw Xwin graphical mode and terminal mode

Post by Dan Espe » Mon, 24 Mar 2003 03:42:19



> 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."

> Highly dangerous, caveat emptor, you're on your own,
> 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
> $

You need to be root.

 
 
 

Subject : Switching btw Xwin graphical mode and terminal mode

Post by Kasper Dupon » Mon, 24 Mar 2003 04:54:32




> > $ chvt < /dev/tty1 1
> > chvt: VT_ACTIVATE: Operation not permitted
> > $

> You need to be root.

The permission check is more complicated than that. IIRC you need
either to be root or do it on your own controlling terminal. If you
use the escape sequence rather than the ioctl with only slightly
different semantics you only need write access to the device.

--
Kasper Dupont -- der bruger for meget tid p? usenet.

for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_);

 
 
 

Subject : Switching btw Xwin graphical mode and terminal mode

Post by The Ghost In The Machin » Mon, 24 Mar 2003 17:28:24


In comp.windows.x, Dan Espen

 wrote
on Sat, 22 Mar 2003 13:42:19 -0500

[snip for brevity]

Quote:>> Unfortunately, my attempts at switching came up with

>> $ chvt < /dev/tty1 1
>> chvt: VT_ACTIVATE: Operation not permitted
>> $

> You need to be root.

Why does that *not* surprise me? :-)  But yes, that works.
The original poster could use this method, or a suid
program or script (danger! warning! caution!) to accomplish
what he wants.

--

It's still legal to go .sigless.

 
 
 

1. Switching btw Xwin graphical mode and terminal mode

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

2. Soft-Spoken Programming

3. Switching from an Xwin graphics mode to a terminal mode

4. yet another question

5. The sistem crash when i change terminal mode - graphical mode and viceversa

6. No connections with en1207

7. Graphical Mode Hangs; Command Mode Fine

8. rdump from DU4.0 to Solaris2.5

9. User login hangs in graphical mode, not text mode

10. Switching from Graphical to Text mode Boot

11. switch from protected mode to real mode in kernel

12. Problems switching between X Mode and Login Prompt Mode

13. How do I switch from 32-bit mode to 64-bit mode?