On Wed, Jan 30, 2002 at 12:20:02PM +0200, Matan wrote:
> On Wed, 30 Jan 2002, Johannes Zellner wrote:
> > 
> > if I'm running svgalib in screen (a terminal mutliplexer, see
> > http://www.gnu.org/software/screen/screen.html) and try to
> > use svgalib I get the following message:
> > 
> >   You must be the owner of the current console to use svgalib.
> >   Not running in a graphics capable console,
> >   and unable to find one.
> > 
> > I'm using svgalib 1.9.12.
> > What's the problem?
> 
> I think using screen is the same (as far as svgalib is concerned) as
> running telnet localhost, so svgalib does not know the program is
> actually running on the local console.
> I am not sure it's a good idea to run an svgalib program from a screen
> session - when you try to move to another window, svgalib won't catch
> that (as it catches vc switches), so you will now run a program that
> thinks it's in text mode, but the video card is actually in graphics
> mode.
> 
> I guess that the only real solution is to add support for screen, the
> same as there is support for linux virtual consoles.

ok. attached is a small patch which works on screen.

-- 
   Johannes
*** ./vga_console.c.orig        Wed Jan 30 11:47:28 2002
--- ./vga_console.c     Wed Jan 30 12:17:03 2002
***************
*** 95,105 ****
--- 95,115 ----
  {
      struct stat sbuf;
      char fname[30];
+     char* sty;
  
  #ifdef ROOT_VC_SHORTCUT
      if (!getuid())
          return 1;               /* root can do it always */
  #endif
+     /* support for running svgalib from 'screen' */
+     if ((sty = getenv("STY"))) {
+       /* screen exports something like "STY=568.tty1.orbital"
+        * so check if sty contains the ttyX string */
+       sprintf(fname, "tty%d", vc);
+       if (strstr(sty, fname)) {
+           return 1;
+       }
+     }
      sprintf(fname, "/dev/tty%d", vc);
      if ((stat(fname, &sbuf) >= 0) && (getuid() == sbuf.st_uid)) {
          return 1;

Reply via email to