To: vox-tech@lists.lugod.org
Subject: Re: [vox-tech] more newbie questions
From: Ken Bloom kabMAPSloom@ucdavis.edu
Date: Thu, 18 Apr 2002 16:04:03 -0700
Joey Karalius jwkaralius@ucdavis.edu wrote:
> How do I get NUM-LOCK to stay on when re-booting (Linux,
of course)?
> I thought it was only a BIOS thing, but apparently not,
since it stays
> on when Windows boots up, but not Linux.
It boils down to a "setleds +num" call, which you can put in
your
.profile or .login if you want. Mandrake has a service in
/etc/init.d
called numlock that turns numlock on for all of the virtual
consoles, at
startup. The code for the "numlock start" part of the service is
as
follows:
#snippet from /etc/rc.d/init.d/numlock in mandrake 8.2
start)
gprintf "Starting numlock: "
echo_success
echo
touch $SYSCONF_FILE
for tty in /dev/tty[1-8]; do
setleds -D +num < $tty
done
;;
#end snippet
For the X Window System, it's a little more difficult.
Somewhere, I
found a script that simulates pressing the numlock key once. (If
numlock
is off and you use it, then numlock turns on. If numlock is on
and you
press it, then numlock turns off.) Because I use XDM, I just
compiled
the program, and then modified /etc/X11/xdm/Xsetup_0 to run the
program,
so numlock is on by default for everyone.
You could also execute it from your .xinitrc or your .xsession
//numlock.c
//compile using:
//gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o setnumlock
Numlock.c -lX11 -lXtst
#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, CurrentTime );
XTestFakeKeyEvent( disp, XKeysymToKeycode( disp, XK_Num_Lock),
False, CurrentTime );
XCloseDisplay( disp );
return 0;
}
//end numlock.c