LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   NumLock (https://www.linuxquestions.org/questions/linux-newbie-8/numlock-53292/)

infamous41md 04-03-2003 05:34 PM

Turning on NUM LOCK automatically at startup
 
This is super newb question, and not really of the utmost importance, but it is kind of annoying and maybe someone knows this, how do u set it so NUMLOCK is always on when u startup? BIOS takes care of that for windows but it doesnt seem to affect RH8.

aha i have figured it out:

Turn on NumLock automatically

Add the following lines to /etc/rc.d/rc.local:

echo -n "Turning on numlock ... "
for tty in /dev/tty[1-6] /dev/tty1[2]; do
setleds -D +num < $tty &
done
echo "done "

infamous41md 04-03-2003 06:20 PM

bah this shit doesnt work...anyone see what is wrong with dat script?

cuckoopint 04-03-2003 06:30 PM

Assuming you boot into X, you don't actually use /dev/tty[1-6]. Also, I don't think you need that second argument. basically:

echo -n "Turning on numlock ... "
for tty in /dev/tty[1-8]; do
setleds -D +num < $tty
done
echo "done "

I don't think you have to necessarily make it go in the background wither (ie. no '&'). I coud be wrong...

infamous41md 04-03-2003 07:36 PM

heh, now it turns on numlock at startup, but once i log on it goes off. LOL
is there a script that runs after login that i could stick that code into?

cuckoopint 04-03-2003 07:56 PM

you could try using an ~/.xsession

something like:

setleds -D +num&
exec openbox

#assuming you run openbox. i think kde's executable is startkde, but I'm not sure. you can check that.

then when your X is started, either by 'startx' or by logging in, it will parse that file, run setleds (dont forget the &), and then start kde, or whatever.

infamous41md 04-03-2003 07:59 PM

**********FIGURED IT OUT***********************

cuckoopint 04-03-2003 08:27 PM

Quote:

**********FIGURED IT OUT***********************
1. does it work?
2. what was the problem? (maybe someone will come by this thread...)

PTBmilo 04-03-2003 08:34 PM

I was just about to post this when i saw that the problem was solved, but if people are curious, here's the way that I do it:

create a source file with this:
Code:

#include <X11/extensions/XTest.h>
#include <X11//keysym.h>

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;
}

then compile with:

gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o setnumlock setnumlock.c -lX11 -lXtst

Then run 'setnumlock' from the xinitrc file.

macewan 04-04-2003 01:03 AM

http://www.deadmule.com/macewan/scre...ckx-1.0.tar.gz

jonr 04-04-2003 07:34 AM

Mandrake users--Mandrake 8.0 or 8.2 (or both?) offered a way to configure startup with NUMLOCK turned on, in one of the checkbox-type things you could work with. I've been unable to locate it in Mandrake 9.0 so far!

Seems like a fairly common thing for people to want, and I wish the default were NUMLOCK on. I can set NUMLOCK on in my machine's BIOS, but it gets changed again to "off" by Linux....

andrewstr 02-11-2004 12:28 PM

PTBmilo,

Thanks for posting the code for the num lock utility. It works great!


All times are GMT -5. The time now is 04:13 AM.