[Toybox] Would you consider adding showkey...but

Rob Landley rob at landley.net
Thu May 16 22:06:38 PDT 2013


On 05/15/2013 04:29:25 PM, Isaac Dunham wrote:
> On Wed, 15 May 2013 11:32:28 -0500
> Rob Landley <rob at landley.net> wrote:
> 
> > On 05/14/2013 08:04:33 PM, scsijon wrote:
> > > Would you consider adding the busybox showkey, but with a user set
> > > time
> > > including 0 for immediate, rather than the default 10 seconds?
> >
> > Um, details?
> >
> > I don't think I've ever used busybox showkey, but I'm happy to look
> > at patch submissions. (I may be a little overwhelmed with _dealing_
> > with them, but I'm working as fast as I can. Still chewing on
> > ifconfig when I have time, and then mount's queued up right after
> > that...)
> >
> > Let's see, fire it up in an xterm and see what it does:
> >
> > landley at driftwood:~$ ./busybox-x86_64 showkey
> > showkey: KDGKBMODE: Invalid argument
> >                                      landley at driftwood:~$
> >
> > And it left my terminal in raw mode. Very nice. My static busybox
> > lying around is 1.19.0, maybe they've fixed this since then? Git log
> > on showkey.c says last touched in 2011, so I'm guessing no. Maybe it
> > doesn't like xfce's terminal program? Dunno...
> 
> showkey is intended to be used from a VT, not X.
> It reads a keypress (apparently from /dev/console), then prints its
> keycode/scancode.
> One implementation is esr's showkey, http://catb.org/~esr/showkey/
> (which is MIT license, weighing in at 127 lines including whitespace
> and comments).
> There is also a (1993?!) GPL2+ Debian variant that corresponds to what
> busybox has.

So it's the catv logic with newlines?

> Also, timeout=0 may be tricky if you need to wait some time for a
> keypress...

I dunno what that means. (I honestly haven't used this command.)

I would, however, like to golf clap at the FSF for  
/usr/include/*/sys/kd.h:

/* Copyright (C) 1996, 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.

    Ash nazg durbatulûk, ash nazg bananaphone,
    bananaphone thrakatulûk agh burzum-ishi bananaphone.

    In the land of Mordor, 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */

#ifndef _SYS_KD_H
#define _SYS_KD_H       1

/* Make sure the <linux/types.h> header is not loaded.  */
#ifndef _LINUX_TYPES_H
# define _LINUX_TYPES_H         1
# define __undef_LINUX_TYPES_H
#endif

#include <linux/kd.h>

#ifdef __undef_LINUX_TYPES_H
# undef _LINUX_TYPES_H
# undef __undef_LINUX_TYPES_H
#endif

#endif  /* sys/kd.h */

Yes, they didn't even bother to block copy out the linux/kd.h contents  
but instead #include the file for you and #undefine its header guards  
after the fact.

What on EARTH this file exists for, I couldn't tell you.

Anyway, this file makes exactly as much sense as toys/other/chvt.c and  
as long as we've got that, I might as well put in a small one of these.  
It's linux-specific and attached to semi-obsolete hardware, but  
keyboards aren't going away so I guess we'll find a device to run it  
against. (I wonder what x.org is doing to get this info?)

Rob


More information about the Toybox mailing list