vt turns off Numlock: so stupid

That's actually a good question. It seems it's not possible. I tried to set it myself without success. I checked if maybe getty can do this but no. I checked the vt if maybe there are some hints one can set but failed to find one.
I checked the atkbd code and I found this in sys/dev/atkbdc/atkbd.c:
Code:
 450                 atkbd_clear_state(kbd);
 451                 state->ks_mode = K_XLATE;
 452                 /*
 453                  * FIXME: set the initial value for lock keys in ks_state
 454                  * according to the BIOS data?
 455                  */
 456                 KBD_PROBE_DONE(kbd);
Which would seem that default values are used when keyboard is initialized.

It's strange that kbdcontrol(1) can't do that. I was not able to find any program in base that does it. Port has only X11 version.
As proof of concept I've created this small demo program setnumlock.c:
Code:
/* martin
        cc -g -o setnumlock setnumlock.c
        cp setnumlock /usr/sbin
        chmod 755 /usr/sbin/setnumlock && chown root:wheel /usr/sbin/setnumlock
        echo /usr/sbin/setnumlock >> /etc/rc.conf.local
*/
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/kbio.h>

#define TRY_IOCTL(func, var) \
        if ((ioctl(0, func, var)) == -1) {      \
                perror("ioctl");                \
                return 1;                       \
        }

int main() {
        int leds,state;
        leds = state = 0;
        TRY_IOCTL(KDGKBSTATE, &state);
        TRY_IOCTL(KDGETLED, &leds);

        /* set the numlock */
        state |= NLKED;
        TRY_IOCTL(KDSKBSTATE, state);

        /* toggle led */
        leds |= LED_NUM;
        TRY_IOCTL(KDSETLED, leds);

        return 0;
}
I've put the instructions how to compile and copy to /usr/sbin in comment. This binary is executed during boot and sets the state of the keyboard and led. This is set only on first console which could be still annoying.
 
Back
Top