Enable numeric keypad on startup

I’m using a keyboard with a numeric keypad on my osmc running on a raspberry pi 3.

I would like to have the numeric keypad automatically enabled after startup. How can this be configured?

This should work. I’m not sure which startup script you should put this in though, might need a bit of trial and error there

That’s also the only one I found googleing, but I didn’t recommended to @stp as I assume that it will drag in all the X packages unnecessarily

Thank you for your answers! I had found the solution with numlockx before I made my post, but unfortunately it doesn’t work.

osmc@osmc:~$ numlockx on
Error opening display!

Hi stp,

You may have more success with setleds, more details in this stack exchange post:

numlockx needs x11, which isn’t installed by default with osmc.

Thanks Tom.

Hi Tom,

I tried also setled like explained in Num Lock in Stretch [SOLVED] - Debian User Forums

Unfortunately it also doesn’t work.

After rebooting and loggin on via ssh I receive the following error:
setleds: Error reading current flags setting. Maybe you are not on the console?: ioctl KDGKBLED: Inappropriate ioctl for device

this would work
sudo setleds -D +num < /dev/tty1

While I am not sure which tty would impact Kodi (if any)

Hi fzinken,

how should I integrate the command correctly on startup?

If I enter the command
sudo setleds -D +num < /dev/tty1
via ssh, the LED on the keypd turns on. But if I push a button on the keypad, it turns off again.

I have manual keymaps, so that a press on the numbers on the keypad starts playing different radio streams. That’s why I would like that the keypad is automatically turned on on startup.

Normally you could do that via /etc/rc.local but if it switches off after first keypress than that doesn’t help you too much

Yes correct. The LED turns on startup, but it switches off after first keypress (the first keypress has also no other effect).

Has anyone an idea how to solve this problem?
sudo setleds -D +num < /dev/tty1
seems to only turn on the LED, but doesn’t actually activate the keypad.

Hi,

Does the bash script work if called manually?

Thanks Tom.

Are you sure that it’s tty1 that’s being used for the keypad?

FIrst, to rule out a permissions problem, try this:

sudo -i
setleds -D +num < /dev/tty1

and see if that helps. Make sure to exit from the sudo bash after testing

exit

if that does not work, try this:

sudo -i
INITTY=/dev/tty[0-8]
for tty in $INITTY; do
     setleds -D +num < $tty
done

and again test. If that works you will need to try each tty until you find the correct one.

Don’t forget to exit the elevated bash when done testing.

1 Like

Hi bmillham,

no I’m not sure that tty1 is the correct one.

I tried your suggested commands:

sudo -i
setleds -D +num < /dev/tty1
exit

It turns on the LED, but has no other effect. If I press one of the numbers, the LED turns off again.

Also your 2nd suggestion

sudo -i
INITTY=/dev/tty[0-8]
for tty in $INITTY; do
     setleds -D +num < $tty
done

had the same effect. It turned on the LED, but the keypad is not enabled. I also rebooted the raspberry between my tests. Unfortunately it didn’t help.

Hi,

I’ve found some time to test this, setleds works as expected on the console and I can reproduce the led switching off within kodi. I’ve done some digging and unfortunately kodi doesn’t have any access to tty(s), this would explain why setleds is not working.

Unfortunately I don’t think there is going to easy solution to this, from googling I can only find the 2 solutions listed above:

numlockx - Requires X11, although x11 can be installed; you have to exit kodi before you can use it.

setleds - Kodi can’t access tty(s), so again kodi needs to be not running for this to work.

I know its a pain, but the best solution may just be to press numlock after startup. Raspberry pi’s are designed to always be on, so you shouldn’t be required to press numlock to often.

Regards Tom.

Thank you all for your help!
It’s a bit sad that we couldn’t find a technical solution.
If someone finds a solution in the future, I would be really happy to know about it.