cvs commit: hints numlock.txt

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Tue Jan 7 20:11:10 PST 2003


timothy     03/01/07 23:11:10

  Modified:    .        numlock.txt
  Log:
  Added some improvements from others and (hopefully) clarified a few things.
  
  Revision  Changes    Path
  1.5       +68 -47    hints/numlock.txt
  
  Index: numlock.txt
  ===================================================================
  RCS file: /home/cvsroot/hints/numlock.txt,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- numlock.txt	30 Aug 2002 17:41:30 -0000	1.4
  +++ numlock.txt	8 Jan 2003 04:11:10 -0000	1.5
  @@ -1,26 +1,27 @@
  -TITLE:          Automatically enabling NumLock when booting and starting X
  +TITLE:          Automatically Enabling NumLock When Booting And Starting X
   LFS VERSION:    All
  -AUTHOR:         Tim van der Molen <tbm_AT_home_DOT_nl>
  +AUTHOR:         Tim van der Molen <tbm at home dot nl>
   
   SYNOPSIS:
           See TITLE.
   
   HINT:
   
  -Version 1.5 (August 30, 2002)
  +Version 1.7 (January 8, 2003)
   
  -This hint consists of two parts: enabling NumLock automatically using a
  -boot script when you boot your system and enabling it again with a little C
  -program when you start X (since X disables NumLock when it is started).
  +This hint describes how you can have NumLock automatically enabled when you
  +boot LFS and, as X disables it again, enabled once again when you start X.
   
  -1. ENABLING NUMLOCK ON BOOT
  +1. ENABLING NUMLOCK WHEN BOOTING LFS
   
  -The NumLock boot script uses the setleds program to do the actual work of
  -enabling NumLock. setleds is part of the kbd package and is installed in the
  -LFS book. For more information on setleds, type "man setleds".
  +To enable NumLock when we boot LFS we will create a boot script. This boot
  +script will use setleds to do the actual enabling. setleds is part of the kbd
  +package which is part of a standard LFS system. It can also set CapsLock and
  +ScrollLock. For more information about setleds, see its man page.
   
  -The boot script takes no start/restart/reload/stop arguments because setleds
  -isn't a daemon; it just enables (or disables) NumLock and then exits again.
  +The boot script will enable NumLock on the tty's 1 to 12. It does not take
  +start/restart/reload/stop arguments because setleds isn't a daemon; it just
  +enables or disables a LED and then exits again.
   
   Type the following to create the boot script:
   
  @@ -31,74 +32,94 @@
   source $rc_functions
   
   echo "Enabling NumLock..."
  -for tty in /dev/tty[1-12]; do
  -        setleds -D +num < $tty
  +for tty in /dev/tty{1,2,3,4,5,6,7,8,9,10,11,12}; do
  +    setleds -D +num < $tty
   done
   
   evaluate_retval
   EOF
   
  -Next thing to do, is to create a symlink from the /etc/rc.d/rcsysinit.d
  -directory to the boot script so it's actually invoked when the system is
  -booted. Type the following:
  +And make it executable:
  +
  +chmod a+x /etc/rc.d/init.d/numlock
  +
  +Next to do, is creating a symlink from the /etc/rc.d/rcsysinit.d directory to
  +the boot script so it is actually invoked when LFS is booted. Type the
  +following:
   
   ln -s /etc/rc.d/init.d/numlock /etc/rc.d/rcsysinit.d/S90numlock
   
  -2. ENABLING NUMLOCK ON X START
  +2. ENABLING NUMLOCK WHEN STARTING X
  +
  +For some reason, X thinks it is appropriate to disable NumLock when it is
  +started which can be found very annoying. Luckily, there are different ways to
  +have it enabled again automatically.
   
  -This part is based on an article from the SuSE Support Database
  -(http://sdb.suse.de/en/sdb/html/cg_x11numlock.html), for what I thank Manfred
  -Winter (mahowi_AT_gmx_DOT_net) who made me aware of its existence.
  +If you use KDE, you can have it enabled in Control Center > Peripherals >
  +Keyboard > Advanced.
   
  -Because X disables NumLock when it is being started, we will create a little C
  -program to enable NumLock once again.
  +Also you can use NumlockX which can be found at
  +http://freshmeat.net/projects/numlockx/.
   
  -Type the following:
  +Or you can compile a simple C program yourself as described in the SuSE Support
  +Database (http://sdb.suse.de/en/sdb/html/cg_x11numlock.html), which is to be
  +discussed here.
   
  -cat > numlock.c << "EOF"
  +Type the following to create the C source file:
  +
  +cat > xsetnumlock.c << "EOF"
   #include <X11/extensions/XTest.h>
   #include <X11/keysym.h>
   
   int main(void)
   {
  -        Display* disp = XOpenDisplay(NULL);
  -        if (disp == NULL) return 1;
  -        XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock), True,
  +    Display* disp = XOpenDisplay(NULL);
  +
  +    if (disp == NULL) return 1;
  +
  +    XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock), True,
           CurrentTime);
  -        XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock), False,
  +    XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock), False,
           CurrentTime );
  -        XCloseDisplay(disp);
  -        return 0;
  +    XCloseDisplay(disp);
  +
  +    return 0;
   }
   EOF
   
  -Now compile it by typing:
  +Now, compile it by typing:
   
  -gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o setnumlock numlock.c -lX11 -lXtst
  +gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o xsetnumlock xsetnumlock.c \
  +-lX11 -lXtst
   
  -This will create the program setnumlock which you should copy to /usr/bin or
  -/usr/X11R6/bin, whatever you prefer.
  +This will create a binary xsetnumlock which should be moved to /usr/bin or
  +/usr/X11R6/bin, whatever you want.
   
  -<note>
  -If gcc complains that it can't find the XTest.h and/or keysym.h header files,
  -do the following:
  -1. Unpack the X420src-1.tgz file (if you don't have it already, get it from
  +If gcc complains that it can't find XTest.h and/or keysym.h, do the following:
  +1. Unpack the X420src-1.tgz file (if you don't have it already, download it at
      ftp://ftp.xfree86.org/pub/XFree86/4.2.0/source/). After unpacking, you'll
      have a directory called xc.
   2. Copy the file xc/include/extensions/XTest.h to
      /usr/X11R6/include/X11/extensions and/or the file xc/include/keysym.h to
      /usr/X11R6/include/X11.
  -</note>
   
  -And now add an entry to setnumlock in your .xinitrc (which can be found in
  -your home directory).
  +And finally, add xsetnumlock to your .xinitrc (which can be found in your home
  +directory).
   
   For example, my .xinitrc file looks something like this:
  -/usr/bin/setnumlock
  +
  +/usr/X11R6/bin/xsetnumlock
   exec wmaker
   
  -You're done! From now on, every time you start your system and X, NumLock
  -should be enabled by default. Enjoy your NumPad.
  +Congratulations, you're done! From now on, you will always be accompanied by
  +your loyal NumLock friend. Enjoy your NumPad.
  +
  +3. ACKNOWLEDGEMENTS
  +
  +I am thankful to Manfred Winter and Tushar Teredesai for their comments on this
  +hint.
  +
  +4. CONTACT
   
  -Comments or improvements whatsoever on this hint will be received with a warm
  -welcome at the e-mail address mentioned in the AUTHOR field.
  +Comments, improvements whatsoever on this hint will be received with
  +a warm welcome at the e-mail address mentioned in the AUTHOR field above.
  
  
  
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe hints' in the subject header of the message



More information about the hints mailing list