# [SOLVED] Setting numlock on startup

## arnvidr

Hi all,

Do people have a reliable way to set numlock on at bootup?

I've tried the numlock init script, but that only switched on the light, not the functionality, so worse than nothing.

If I run x11-misc/numlockx after I log in, that does the trick, so I tried to put that into /root/.xinitrc with no result. This file also has a setxkbmap command in it, which seems to do what I want reliably, but nothing happens to my numlock.

Any ideas? Better places to place the command?

How do I technically turn on this function anyway? I can switch the light on in numerous ways, including messing with stuff in /sys/class/leds/ but I'm not sure how this functionality is actually activated.

----------

## NeddySeagoon

arnvidr,

Hopefully you never run Xorg as root, so /root/.xinitrc is never consulted.

It belongs in ~/.xinitrc fot the normal user that will startx.

----------

## fedeliallalinea

But you mean in a tty or in X?

numlock script work for tty numlockx for X, you can see here how enable it on X depending on what wm/de you use

----------

## arnvidr

 *NeddySeagoon wrote:*   

> Hopefully you never run Xorg as root, so /root/.xinitrc is never consulted.

 

I assume I don't, since my numlockx call does nothing.

I remember trying a few solutions for setting my keyboard map (setxkbmap), so I guess a different solution has worked as well then, since presumably this script is never called. Will try to disable it here and see if I still have my desired keyboard layout on next boot.

 *fedeliallalinea wrote:*   

> you can see here how enable it on X depending on what wm/de you use

 

That seems perfect, cheers. I use sddm, so I added a /etc/sddm.conf file with numlock=on, so I'll see if I can check if that works this evening.

----------

## gaurav712

I use xdotool to do that. 

```
xdotool key Num_Lock &
```

----------

## arnvidr

 *gaurav712 wrote:*   

> I use xdotool to do that. 
> 
> ```
> xdotool key Num_Lock &
> ```
> ...

 That's a great tip! I have xdotool installed already, so even if the previous tips work out, I'll check that out and see if I can avoid having numlockx installed as well.

----------

## C5ace

Run:

```
rc-update add numlock default
```

Then reboot and log into a terminal.

This allows me to login from a terminal using a password containg letters and numbers without pushing the Numlock key.

----------

## fedeliallalinea

 *C5ace wrote:*   

> This allows me to login from a terminal using a password containg letters and numbers without pushing the Numlock key.

 

but probably not in X as arnvidr want

----------

## C5ace

I use Xfce.  With Xfce open Applications -> Settings -> Keyboard -> Behavior and tick "Restore numlock state on startup". This will rembar the last numlock state when loging out of Xfce.

----------

## gaurav712

 *arnvidr wrote:*   

>  *gaurav712 wrote:*   I use xdotool to do that. 
> 
> ```
> xdotool key Num_Lock &
> ```
> ...

  I use xdotool for the same reason  :Smile:  .

----------

## samidarko

Maybe it will be useful for someone. I'm using Awesome WM.

I have a the end of my awesome configuration "rc.lua"

```
do

    local icons = {

        'nm-applet', 'parcellite', 'numlockx'

        }

    for _,icon in pairs(icons) do

        awful.spawn(icon)

    end

end
```

----------

## arnvidr

Just a quick update to let people know that the sddm.conf trick worked just fine, so I haven't tried the xdotool solution, but either way, I could remove numlockx from my system, as it wasn't needed.

Thanks all!   :Very Happy: 

----------

