magichat
Posts: 1
Joined: Mon Jul 02, 2012 10:38 pm

Boot with number lock on

Mon Jul 02, 2012 10:44 pm

Hello, I have just got my pi and started using it, I have noticed that the system boots with num lock off, I use the number pad on the keyboard a LOT so this is a bit of a pain, is there a way to change the boot so that number lock is on by default? Thank-you in advance.

poundbury
Posts: 1
Joined: Fri Jun 29, 2012 5:59 pm

Re: Boot with number lock on

Tue Jul 10, 2012 6:58 pm

Hi magichat,

I'm having the same issue. I use the NUM lock a lot too. Hopefully someone will post a (simple) solution!

LinkCloud
Posts: 1
Joined: Tue Apr 10, 2012 2:54 pm

Re: Boot with number lock on

Fri Jan 04, 2013 5:53 pm

First post on Raspberry Pi.

This topic is number 1 on google so I figured I could contribute.

Code: Select all

sudo apt-get install numlockx
Test to see if installed.

Code: Select all

numlockx on
numlockx off
Make a startup script.

Code: Select all

cd ~/.config
vi numlock.sh
Insert this code in vim.

Code: Select all

#! /bin/bash

numlockx on
You'll need to set the script.

Code: Select all

chmod +x numlock.sh
Press "i" to input and Ctrl+C and type ":wq!" to finish.

Code: Select all

sudo crontab -e
Add this to the bottom

Code: Select all

@reboot cd /home/pi/.config && ./numlock.sh
Save and reboot!

Edit: Forgot chmod

DanR
Posts: 33
Joined: Fri Jan 18, 2013 1:20 pm

Re: Boot with number lock on

Wed Feb 06, 2013 5:51 pm

Thanks LinkCloud,

Much appreciated, I used nano instead of vim as I just can't get used to the annoying semantics of vim, I start gnawing keyboards whenever vim is mentioned :)

Dan

fredca
Posts: 40
Joined: Tue Oct 16, 2012 12:14 pm

Re: Boot with number lock on

Fri Feb 22, 2013 12:36 pm

Thanks that works fine I use leafpad after startx because I too hate vi & it's ilk.

User avatar
RaTTuS
Posts: 10377
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Boot with number lock on

Fri Feb 22, 2013 12:41 pm

not sure if you can do it via edting
/etc/kbd/config
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

urkraft
Posts: 2
Joined: Sat Nov 29, 2014 4:40 pm
Location: Eiksmarka, Norway

Re: Boot with number lock on

Sat Nov 29, 2014 6:32 pm

RaTTuS wrote:not sure if you can do it via edting
/etc/kbd/config
Thanks for the information - you are right (at least with the version of Raspbian that i am running). There is a line in the file that is commented out by default (LEDS=+num). Just remove the '#' character in front of the line, save the file, and reboot and NumLock is set - no other installations or changes are required! But unfortunately if you use the LXDE GUI (startx) it does not inherit this environment setting and it starts with number lock off if this is the only change you make. When you exit back to the console the number lock will be turned back on again.

RichMoly
Posts: 11
Joined: Fri Jan 25, 2013 2:24 pm

Re: Boot with number lock on

Sat Nov 12, 2016 11:44 am

Yes, a quick search shows LXDE GUI has number lock default to off.

On GNOME you can set 'remember-numlock-state' using dconf-editor (org>gnome>settings-daemon>peripherals>keyboard) or 'gsettings set org.gnome.settings-daemon.peripherals.keyboard remember-numlock-state true' in terminal.

Likewise, I've found org>gnome>desktop>a11y>keyboard on Raspbian, but no numlock settings :-(

Why a numlock option isn't included in the 'Mouse and Keyboard Settings' preferences tool is beyond me... I've had enough of Linux, and am going back to using my beloved RISC OS ;-)

User avatar
RaTTuS
Posts: 10377
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Boot with number lock on

Mon Nov 14, 2016 7:57 am

RichMoly wrote:Yes, a quick search shows LXDE GUI has number lock default to off.

On GNOME you can set 'remember-numlock-state' using dconf-editor (org>gnome>settings-daemon>peripherals>keyboard) or 'gsettings set org.gnome.settings-daemon.peripherals.keyboard remember-numlock-state true' in terminal.

Likewise, I've found org>gnome>desktop>a11y>keyboard on Raspbian, but no numlock settings :-(

Why a numlock option isn't included in the 'Mouse and Keyboard Settings' preferences tool is beyond me... I've had enough of Linux, and am going back to using my beloved RISC OS ;-)
this thread is 4 yours old
however I think you can probably do it via the /etc/kbd/config file [LEDS=+num]
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

RichMoly
Posts: 11
Joined: Fri Jan 25, 2013 2:24 pm

Re: Boot with number lock on

Sun Nov 20, 2016 7:03 pm

Thanks, but as urkraft points out, and hence my reply, the GUI (the horrible IMHO Pixel) ignores the config setting. Besides, why should a user have to edit a config setting for something like this?!

User avatar
RaTTuS
Posts: 10377
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Boot with number lock on

Mon Nov 21, 2016 7:44 am

dunno much about pixel however this may work as PIXEL is LXDM
sudo apt-get install numlockx
sudo nano /etc/lightdm/lightdm.conf
find
#greeter-setup-script =
and change to
greeter-setup-script = /usr/bin/numlockx on
sudo nano
/etc/xdg/lxsession/LXDE/autostart
and add
/usr/bin/numlockx on


it is this way because this is the sensible configuration
why should other people have to edit something to make it as it should be ... [ha!] ;)
Last edited by RaTTuS on Tue Jan 03, 2017 7:45 am, edited 1 time in total.
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

RichMoly
Posts: 11
Joined: Fri Jan 25, 2013 2:24 pm

Re: Boot with number lock on

Tue Nov 22, 2016 7:22 pm

Thanks again, I'll give that a try, when I'm with my Pi :-)

Whilst I like having Num Lock on by default, my main reason for it on the Pi is so I can see from the keyboard LED if my kids have left the damn thing on... again!

No fan noise, obscured power LED and supply, and non-functioning DPMS (another setting I have to change in Config I believe) so they turn the monitor off between usage, I guess it's inevitable...

User avatar
RaTTuS
Posts: 10377
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Boot with number lock on

Wed Nov 23, 2016 8:21 am

just leave it running - it uses so little power ....
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

msjames19702
Posts: 1
Joined: Fri Dec 30, 2016 8:40 pm
Location: Newark, DE, USA

Re: Boot with number lock on

Fri Dec 30, 2016 9:02 pm

@RaTTuS - your prescription was right on the money. :D Thanks for helping! The only correction I needed to make on my pi 3 was the directory to find the autostart file as below. You may have intended to type lxsession instead of xsession.

/etc/xdg/lxsession/LXDE/

My kernel/system build is:

$ uname -a
Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux

I'm keeping a diary of all these system tweaks. I've needed to make many (from out of the box) to suit my preferences and get basic components of the hardware working properly.

Cheers!

User avatar
RaTTuS
Posts: 10377
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Boot with number lock on

Tue Jan 03, 2017 7:46 am

msjames19702 wrote:@RaTTuS - your prescription was right on the money. :D Thanks for helping! The only correction I needed to make on my pi 3 was the directory to find the autostart file as below. You may have intended to type lxsession instead of xsession.

/etc/xdg/lxsession/LXDE/
/...
fixed and yes a typo
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
puzzola
Posts: 5
Joined: Sat Mar 14, 2015 2:22 am

Re: Boot with number lock on

Tue Jul 24, 2018 7:27 pm

Not to necro this thread, but...
If you want numlock turned on so that the tenkey works without having to remember to press the num lock key, you can add

Code: Select all

setleds -D +num
to the end of your ~/.bashrc
It won't turn on until you log in, which is okay for me at least, since I can't really do anything with the tenkey until I'm logged in anyway.

If you want it turned on before login (to use the LED as power indicator), I just found a post on the Debian forum
It's a little more complicated, but it works!
Here's the gist in case the link dies:
From a terminal:
  1. Code: Select all

    [email protected]:~$ sudo nano /usr/bin/numlock
    add

    Code: Select all

    #!/bin/bash
    # Turn Numlock on for the TTYs:
    for tty in /dev/tty[1-6]; do
        /usr/bin/setleds -D +num < "$tty";
    done
    and save.
  2. Code: Select all

    [email protected]:~$ sudo nano /etc/systemd/system/numlock.service
    add

    Code: Select all

    [Unit]
    Description=numlock
    
    [Service]
    ExecStart=/usr/bin/numlock
    StandardInput=tty
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    
    and save. (Capitalization is important!)
  3. Code: Select all

    [email protected]:~$ sudo systemctl enable numlock.service
  4. reboot and see if it works for you, too!
This is on raspbian stretch lite, I have not tried it with wheezy or jessie.
All credit goes to user cybermcm on the Debian forum.
Last edited by puzzola on Wed Jan 23, 2019 2:47 am, edited 2 times in total.

Pugg
Posts: 2
Joined: Sat Jan 12, 2019 8:03 pm

Re: Boot with number lock on

Wed Jan 16, 2019 6:49 pm

Tried this but... "bash: $: command not found " ... Using Raspberry 3 B+

User avatar
rpdom
Posts: 14722
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Boot with number lock on

Wed Jan 16, 2019 7:43 pm

Pugg wrote:
Wed Jan 16, 2019 6:49 pm
Tried this but... "bash: $: command not found " ... Using Raspberry 3 B+
Don't type the "$". That is the command prompt.

User avatar
puzzola
Posts: 5
Joined: Sat Mar 14, 2015 2:22 am

Re: Boot with number lock on

Wed Jan 23, 2019 2:43 am

rpdom wrote:
Pugg wrote:
Oops, yeah, I should've made that clearer. Fixed, I hope? Thanks!

seanspotatobusiness
Posts: 186
Joined: Tue May 22, 2012 11:19 pm

Re: Boot with number lock on

Sat May 11, 2019 12:47 pm

Wow, that's a lot of steps just to get the numlock key on at start-up. Why isn't it the other way around? What percentage of people use the numpad for cursor direction when there are dedicated keys to the left of them?
Raspberry Pi 3 B and B+
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"

Return to “Beginners”