Numpad disables after logging into unity

I just setup Ubuntu 15.04 on my Asus G74Sx laptop. This laptop does not have a physical NumLock key.

My Numpad works fine in Windows 8.1, the SSTYs, as well as lightdm (I can enter numbers via the numpad into the password input).

After logging into Unity it only works for a short time. I succeeded once opening up a terminal and inputting a few numbers, before it got disabled. If I logout it no longer works in lightdm either.
I can enable it using numlockx on.

I already tried adding numlockx on to my autostart programs (which did not work) and also using dconf-editor to change org → gnome → settings-daemon → peripherals → keyboard according to a tutorial on German Ubuntuusers (which gets reset after reboot).

The accessibility feature to move the mouse via the numpad is not enabled.

It looks like something disables the numpad after logging into Unity. Any idea?

Answer

Adding the command numlockx on to Startup Applications

Some commands break if you add them to startup applications, because the command needs a fully loaded desktop to run successfully, and Startup Applications runs the commands too early.

If the command

numlockx on

works once you are logged in, I am pretty sure it is a matter of timing to make it work as a startup application. You can add a little break to make it work.

Since Startup Applications creates a .desktop file in ~/.config/autostart to run the startup command, you need the “regular” syntax to add a complicated command (including the break) to be used in a .desktop file, which is in this case:

/bin/bash -c "sleep 15&&numlockx on"

Possibly, you need to play a little with the sleep 15 to optimize.

Edit

An alternative method to run the command at startup is mentioned here, but the result is the same.

EDIT

If your startup procedure (-time) is unpredictable for some reason and/or the numpad is set to off repeatedly by some process during startup, you can make sure it works correctly by adding the script below to your Startup Applications

It keeps an eye on the Numpad, to be set on during the first minute after startup (log in):

#!/bin/bash

n=1
while [ "$n" -ne 60 ]; do
if [ "$( numlockx status )" != "Numlock is on" ]; then
  numlockx on
fi
sleep 1
n=$((n+1))
done

Add to Startup Applications: Dash > Startup Applications > Add, add the command:

/bin/bash /path/to/script.sh

Attribution
Source : Link , Question Author : TimWolla , Answer Author : Community

Leave a Comment