How to enable numlock at boot time for login screen?

I am trying to force numlock to be on upon initial boot at the login screen on Ubuntu 12.04. The only solutions I have found so far switch numlock on only after initial login.

I'm looking to force numlock to be on when the login screen is displayed, and before the user has logged in. Can anyone assist?


On many machines, you can set whether or not Number Lock is turned on on boot, in the BIOS settings (accessible when you first power on the machine).

Otherwise, there are a number of ways to enable (or disable) Number Lock in software, depending on your specific needs. The most useful ways are listed here.

If you want Number Lock turned on when Ubuntu starts (not before that on the GRUB menu, and not afterwards when logging in, and not just for specific virtual consoles), then install numlockx and make the initialization script /etc/init.d/rc.local use it to enable Number Lock:

sudo apt-get update
sudo apt-get -y install numlockx
sudo sed -i 's|^exit 0.*$|# Numlock enable\n[ -x /usr/bin/numlockx ] \&\& numlockx on\n\nexit 0|' /etc/init.d/rc.local

Source: NumLock, by Contributors to the Ubuntu documentation wiki, last line taken verbatim (as this source permits).


Here's what worked for me:

  1. Ensure that numlockx is installed:

    sudo apt-get install numlockx
    
  2. Edit the file /etc/lightdm/lightdm.conf

    gksudo gedit /etc/lightdm/lightdm.conf
    
  3. Add the following line to the file:

    greeter-setup-script=/usr/bin/numlockx on
    

14.04

Yes, use locate command as follow:

locate 50-unity-greeter.conf

The output is:

/usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf

So, the file you need to edit is the above file.

sudo apt-get install numlockx
gksu gedit /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf

Add this line at the end of file:

greeter-setup-script=/usr/bin/numlockx on

For Enabling it on Login Screen

First, ensure that numlockx is installed, by typing these in terminal:

sudo apt-get install numlockx

Then, edit the file /etc/lightdm/lightdm.conf

gksudo gedit /etc/lightdm/lightdm.conf

Add the following line to the file:

greeter-setup-script=/usr/bin/numlockx on

For Enabling Numlock by Default after Logging In..

  1. In Dash Search for Keyboard Layout and open it
  2. In the window that opens on the ottom right there is Options, click on it.
  3. Under Miscellaneous compatibility options, Enable Default Numeric Keys.

enter image description here


I have done this, and it worked for me. First, make sure you have universe repository added.

Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.

sudo apt-get update
sudo apt-get install numlockx

Now that numlockx is installed, create a file named Default in /etc/X11/ with these contents:

if [ -x /usr/bin/X11/numlockx ]; then
    /usr/bin/X11/numlockx on
fi

exit 0

Turn off your Num Lock and reboot. Voilà!