Enable Num Lock by default

Issues related to hardware problems
Post Reply
cwlee
Posts: 33
Joined: 2004/12/10 15:44:17
Contact:

Enable Num Lock by default

Post by cwlee » 2005/05/02 08:04:48

I've added these lines to my /etc/rc.d/rc.local file but whenever CentOS starts up, the Num Lock is still not enabled. Does anyone know what could be wrong?

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

# Enable Num Lock upon bootup
INITTY=/dev/tty[1-8]; do
for tty in $INITTY; do
setleds -D +num < $tty
done

touch /var/lock/subsys/local

maja
Posts: 16
Joined: 2005/02/23 18:23:46

Re: Enable Num Lock by default

Post by maja » 2005/05/02 20:24:05

cwlee,

There seem to be different ways to archieve this. I've tried the same
method you are describing earlier but I couldn't get to work. I'm using
this one (works for me).

- Compile the following code (I called the file numlock.c):

#include
#include

int main(){
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;
}

- Install (copy) it in e.g. /usr/local/bin

- Add it to your sessions:
-> Application
-> More Preferences
-> Sessions
-> Startup Programs
-> Add ===> add path to your compiled code
e.g. /usr/local/bin/setnumlock


- This should get you in business.

Have fun,
Marc

cwlee
Posts: 33
Joined: 2004/12/10 15:44:17
Contact:

Re: Enable Num Lock by default

Post by cwlee » 2005/05/04 17:28:30

Hi Marc,

I downloaded & installed NumLockX & now my Num Lock is always enabled whenever I logged in. I guess that script I added into the rc.local file is only applicable to level 3, rather than in the X Windows, haven't really verified my guess though. Anyway, I guess the easiest way would be to use NumLockX under X Windows.

Cheers!

Post Reply

Return to “CentOS 4 - Hardware Support”