Linux – Enable numlock when new external keyboard is connected

keyboardlinuxnumlockusb

I'm not sure this is possible, but I thought why not to ask.

I have a laptop without a numeric block, and use it sometimes with external keyboard. Numlock for the internal keyboard = useless, so I never use it.

No numlock for the external keyboard = I press arrows etc instead of numbers by accident.

So, is there any possibility to enable numlock when the laptop starts with the external keyboard, and no numlock with only the internal?

I guess maybe some trickery with lsusb and numlockx?

Best Answer

Ok so I've made a script for that:

It's now also available in AUR as autonumlock-git. Basically loop with lsusb, grep and checking if the device ID is there or not.

Output - numlockx on / off.

Related Question