the elusive numlock

Eric R. rossiter at discoverynet.com
Fri Jan 17 15:01:24 CST 2003


hey LugNuts,

In case you didn't know...

When you boot Linux, the kernel turns off Num Lock by default. This
isn't a problem if, for you, the numeric keypad is the no-man's-land
between the cursor keys and the mouse. But if you're an accountant, or
setting up a system for an accountant, you probably don't want to turn
it on every single time.

Here's the easy way, if you're using KDE. Go to K --> Preferences -->
Peripherals --> Keyboard and select the Advanced tab. Select the radio
button of your choice under NumLock on KDE startup and click OK.

If you only run KDE and want Num Lock on when you start a KDE session,
you're done. Otherwise, read on.

To set Num Lock on in a virtual console, use:

setleds +num

If you choose to put this in a .bashrc file to set Num Lock when you
log in, make it:

setleds +num &> /dev/null

to suppress the error message you'll get if you try it in an xterm or
over an SSH connection.

Finally, here's the way to hit this problem with a big hammer--make
the numeric keypad always work as a numeric keypad in X, no matter
what Num Lock says. This will make them never work as cursor keys, but
you're fine with that because you have cursor keys, right? Create a
file called .Xmodmap in your home directory, and insert these lines:

keycode 79=7
keycode 80=8
keycode 81=9

keycode 83=4
keycode 84=5
keycode 85=6

keycode 86=plus
keycode 87=1
keycode 88=2
keycode 89=3

keycode 90=0
keycode 91=period

keycode 77=Escape

    (from a Usenet post by Yvan Loranger:
    http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=3BFD087F.20003
00%40iquebec.com&rnum=3+)

The last line takes the now-useless Num Lock key and makes it an extra
Escape key. If your favorite accounting software uses one of the F
keys frequently, you might prefer that.

The number to the left of the equals sign is an X "keycode", the key
on the keyboard you pressed, and the number or name to the right is an
X "keysym", the character or function X thinks it is. You don't have
to look these up in some X manual. To find out the keycode and keysym
for any key, run xev in an xterm, move the mouse to the small white
xev window and watch the keycodes and keysyms scroll by in the xterm.

Thanks for your time folks, and have a quality day everyone,

E




More information about the Kclug mailing list