in Uncategorized

How to set the numlock on as the default in X startup.

Method 1:

apt-get install numlockx

gedit /etc/X11/gdm/Init/Default
搜寻这一行文字

exit 0

在这之前新增下面几行文字
if [ -x /usr/bin/numlockx ];
  then /usr/bin/numlockx on
fi
保存编辑过的文件

Method 2:

 How to Set Num Lock ON as the default in X startup

This applies to people who want to override the Linux kernel default of turning
the Num Lock key off at boot time ->(so their Desktops start up with the Num
Lock key ON when they log in).

If you rarely or never use the number keypad, it really is an insignificant
problem since all you have to do is press the Num Lock key after logging in to
turn it on.

However, if you are an accountant or bookkeeper (or you provide support on a
network for these kinds of users) you would probably like to have the Num Lock
key turned on automatically. It is annoying for data entry people to start
typing and look up to see that they are not even in the field they thought they
were (keypad is in "arrows and paging/home and end" mode).

For those of you who would like to fix this problem, here are two reliable
solutions; chose the one appropriate to your desktop. The fix for the Gnome
desktop should work equally well for others, but I haven’t tried it.

++++++++++++++++++++++++ KDE DESKTOP ++++++++++++++++++++++++

If you use the KDE desktop:
1. Go to the Start button:
–> Control Center –> Preferences –> Peripherals –> Keyboard
2. Check the radio button for "Num Lock On" at KDE startup.
*note: for some versions of KDE you have to click an Advanced tab.
3. Log out and Log back in (to restart the X environment)
…you’re done. If you use the Gnome desktop, it’s slightly more difficult. If
the Num Lock key being on at startup is important to you, two options are to
follow the below instructions OR switch desktops.

++++++++++++++++++++++++ GNOME DESKTOP ++++++++++++++++++++++++

To switch desktops from Gnome to KDE click on the start button and then:

System Tools –> More System Tools –> Desktop Switching Tool
Choose the KDE button
Log Out and Log back in (to restart X server)
Follow the instructions above for the KDE desktop.

============ Below this line is the fix for Gnome desktop ===========

NOTE 1: To successfully do this you need the C compiler (series d, package gcc)
and the include files of the X libraries(package xdevel, series x).

If you don’t have the gcc (Gnu Compiler Collection) which includes the C
compiler,
you should install it. You can fix LOTS of problems with these very valuable
tools
(without a lot of programming knowledge).

If you DO NOT have the C compiler, and you DO NOT WANT the gcc package on your
machine,
I am told you can use the "setleds +num &> /dev/null" command in one of the X
start-up
scripts. I don’t know if this method works or not, but it probably will take
more
tinkering on your part (unless you really know your scripting).

NOTE: For those of you *who boot to run level 3*, you can add "setleds +num &>
/dev/null"
(which null routes any error output) to the end of .bashrc but you must specify
the
"&> /dev/null", NOT just "setleds +num". Otherwise, you will get an error
message every
time you start a terminal from your desktop. Note that "setleds +num" doesn’t
work from
a virtual console (terminal) anyway; it’s NOT quite the same as the console.

>>–>This will turn Num Locks on when you log in to the console, but NOT when
you run startx.

END NOTE 1

>>–>best to perform this procedure as root.

When you have gcc as explained above:

1. Download this very small program: setnumlock.tar.gz
a) here is the link –> ftp://ftp.silug.org/pub/ltsp/setnumlock.tar.gz
NOTE: I tested on Redhat 8/9 (probably works on other distributions too)

b) I suggest you create a directory named num-on to download the file to.
type command: mkdir num-on

c) When you have finished the download:
cd (change directory) to num-on (or wherever you downloaded the file)
gzip -d setnumlock.tar.gz
tar xvf setnumlock.tar
cd setnumlock
type "make"
then type "make install"

Make install has now created /usr/bin/setnumlock
(a very small program that turns numlock on)

2. Now you need to run this program whenever you log in:
Click the start button and go to:
–> Preferences –> More Preferences –> Session
Click the Start Up Programs tab.
Click the Add button.
Browse to /usr/bin/setnumlock (or type in /usr/bin/setnumlock)
Click OK.
Logout and Log back in (to restart the X server)

If you are wondering why such a simple option is missing, there is apparently a
problem with the keyboard options on the Gnome desktop which was not resolved
at the time of this writing, ie. after pressing the Num Lock key sometimes the
keyboard loses some or all functionality. Hasn’t happened to me, but it has to
quite a few other people.

**For this reason, Gnome developers have omitted the "Num Locks On at Startup"
option for peripheral setup under keyboard. I’m guessing this will probably be
fixed by the next release.

There was a patch on the Gnome site, but it seems to have disappeared; I fixed
mine as above and don’t know if the patch is appropriate. Some of the
developers at Gnome feel this problem is too insignificant to warrant their
attention and prefer that it not be mentioned again; for SURE they are very
busy with more important issues so it’s understandable.

Nuff said. Hope this helps someone,

J.May

Write a Comment

Comment