Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #197398

Re: VT2 for Xorg?

From Dan Ritter <dsr@randomstring.org>
Newsgroups linux.debian.user
Subject Re: VT2 for Xorg?
Date 2018-07-09 15:50 +0200
Message-ID <w9EI9-2Be-3@gated-at.bofh.it> (permalink)
References <w929P-4sk-1@gated-at.bofh.it> <w98ff-8lx-1@gated-at.bofh.it> <w9E5r-2oD-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 09, 2018 at 09:08:17AM -0400, Greg Wooledge wrote:
> On Sun, Jul 08, 2018 at 01:08:59PM +1000, Zenaan Harkness wrote:
> > With a bash fn like:
> >   ttyGetNum () { return $(tty | grep -oE '[0-9]+$') ; }
> > 
> > Then something like this will id your current tty:
> >   ttyGetNum;  export Xorg_vt=vt$?
> 
> Ewwwww!
> 
> The return status of a shell function is NOT intended to be used this way.
> It's analogous to the exit status of a shell command.  It's a single
> byte, unsigned, so you can only return 0 to 255.  It's intended to convey
> success or failure, not to carry an actual data payload.
> 
> I recommend that you switch to using a regular variable for this purpose.
> I happen to like "r".  With a regular variable, you're not restricted to
> integers from 0 to 255, and you retain the ability to convey succss/failure
> through the return code.
> 
> As an aside, you can save the call to GNU grep by simply stripping the
> leading "/dev/tty" from the output of tty using a shell parameter
> expansion:
> 
>   ttyGetNum() {
>     local t
>     t=$(tty) || return 1
>     [[ $t = /dev/tty+([0-9]) ]] || return 1
>     r=${t#/dev/tty}
>   }
> 
>   if ttyGetNum; then export Xorg_vt=vt"$r"; fi
> 

fgconsole returns the current virtual terminal number.
chvt switches to a specified virtual terminal.

These are from package kbd.

-dsr-

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

VT2 for Xorg? Carl Fink <carlf@panix.com> - 2018-07-07 22:40 +0200
  Re: VT2 for Xorg? Zenaan Harkness <zenaan@freedbms.net> - 2018-07-08 05:10 +0200
    Re: VT2 for Xorg? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-07-09 15:10 +0200
      Re: VT2 for Xorg? Dan Ritter <dsr@randomstring.org> - 2018-07-09 15:50 +0200
        Re: VT2 for Xorg? Zenaan Harkness <zenaan@freedbms.net> - 2018-07-09 16:00 +0200
          Re: VT2 for Xorg? Zenaan Harkness <zenaan@freedbms.net> - 2018-07-09 16:00 +0200
      Re: VT2 for Xorg? Zenaan Harkness <zenaan@freedbms.net> - 2018-07-09 16:00 +0200

csiph-web