|
|
发表于 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] |
|