LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2555|回复: 4

请问怎么样才能让NumLock键,在进系统时,就自动打开?

[复制链接]
太平洋里的水 该用户已被删除
发表于 2004-10-13 18:35:04 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2004-10-13 18:39:20 | 显示全部楼层
gentoo里有numlock这个服务,就是干这个的。
RH类下,曾经有过一个rpm包,也是numlock的。
发表于 2004-10-13 21:18:11 | 显示全部楼层
[PHP]When started, X disables NumLock for some reason. So we should enable it.
The easiest way is to compile a little C program yourself which does
nothing more than changing the current state of NumLock. Thus, X disables
NumLock and this program enables it again. The source code of this program was
taken from an article in the SuSE Support Database at
http://sdb.suse.de/en/sdb/html/cg_x11numlock.html.

Create the C source file:

        cat > xsetnumlock.c << "EOF"
        #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;
        }
        EOF

        And compile it:

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

Now you have a binary named xsetnumlock. If required, change its ownership and
permissions:

        chown root:root xsetnumlock
        chmod 0755 xsetnumlock

Move it to either /usr/bin or /usr/X11R6/bin, whatever you consider more
suitable. Then add the following line to the beginning of either the
~/.xinitrc, ~/.Xsession or ~/.Xclients file (assuming you have moved
xsetnumlock to /usr/bin; if not, use the appropriate path):

        /usr/bin/xsetnumlock[/PHP]
太平洋里的水 该用户已被删除
 楼主| 发表于 2004-10-14 16:34:52 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2004-10-14 17:24:37 | 显示全部楼层
在 /etc/rc.d/rc.sysinit 中添加:

for tty in /dev/tty[1-9]*; do
setleds -D +num < $tty
done
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表