Activate Numlock key at the start of X

Support knowledgebase (cg_x11numlock)
Applies to

SuSE Linux: All versions

Request:

You would like to have the Numlock key activated at the start of the graphical user interface instead of pressing the Numlock-key manually.

Procedure:

Use the following program to activate the NumLock-key
//numlock.c
#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;
}
Create a file Numlock.c with the program code mentioned above and enter the command
gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o setnumlock Numlock.c -lX11 -lXtst
To successfully invoke this command you need the C compiler(series d, package gcc) and the include files of the X libraries(package xdevel, series x). You will find a program called setnumlock in the current directory. You have to copy this file into the directory /usr/local/bin and make an entry in the file ~/.xinitrc.
Keywords: NUMLOCK, SETLEDS, X11, X-SERVER

SDB-cg_x11numlock, Copyright SuSE Linux AG, Nürnberg, Germany - Version: 02. Jan 2001
SuSE Linux AG - Last generated: 24. Apr 2002 by snbarth (sdb_gen 1.40.0)