Solved Turn numlock on after boot

Thanks, just curious, it seems it is for X windows, would it still work if I am not using any X windows / kde / etc.?
 
Not sure exactly regarding the X window system, inclusion with other DE's here is a link:
https://en.wikipedia.org/wiki/Comparison_of_X_Window_System_desktop_environments

But, I would add a little warning if you are going to use x11/numlockx and that is you should close it
before ending your user session, shutdown, or poweroff. It has a tendency to hang, since it alters keyboard function.
So, either turn it back off or use the command-line:
Code:
$ pkill numlockx
 
Hi bookwormep, just a couple of things to point out

You could build /usr/ports/x11/numlockx.

Edit: For x11/numlockx to launch at boot, you could include this on a start script. In my case, I type a command-line:

Code:
$ numlockx >/dev/null 2>1&

actually > /dev/null 2>1& redirects the $stderr that /dev/null discards to a file named '1' inside $HOME. Putting a '&' before 1 instead, identifies '1' as a file descriptor, $stdout.

According to numlockx(1), a simple numlockx & would only fork a numlockx process into background, leaving the numeric keypad behavior unchanged; if you instead pass a on option afterwards, program locks arrow keypad to numeric function effectively. I've never tried to check the difference out though. Anyway, something like:

Code:
#!/bin/sh

if [ -x /usr/local/bin/numlockx ]; then
     /usr/local/bin/numlockx on > /dev/null 2>&1 &
fi

Placed in .xinitrc or any Xorg startup script, should do the job; I think however redirecting $stderr /dev/null could be avoided, as I've never seen numlockx returning a single error so far.

marcus123 yes, x11/numlockx works only with Xorg, so were you even to add it to a custom service inside /usr/local/etc/rc.d to be started at boot, it wouldn't take effect until you start Xorg.

On GNU/Linux one can use stleds(1), to create a startup service managing numeric keypad behavior, like that:

Code:
#!/bin/bash

for tty in /dev/tty{1..9}
do
   /usr/bin/setleds -D +num < "$tty";
done

However setleds is not available among freshports, and I've searched for an analogue function in kbdcontrol(1), without luck. Anyway, $nlock is usually mapped at function key 69 for and I've never seen it fail. So long story short, just press numlock.

The standard functions associated to Numeric keypad keys are numbered as follows (in US keyboard):
Code:
          Up_arrow           key 50
          Page_Up            key 51
          (keypad) -         key 52
          Left _arrow        key 53
          (keypad) 5         key 54
          Right_arrow        key 55
          (keypad) +         key 56
          End                key 57
          Down_arrow         key 58
          Page_down          key 59


The way those keys are mapped is summarized in the keymap located inside /usr/share/vt/keymaps. Under column "base" (standard behavior) number from 50 to 59 correspond to fkey[0-9], which are the ones listed above. If numlock is pressed keys behave like numeric keys, regardless of the modifier they're pressed in conjunction with, an this can be seen on the columns following on the right. The lockvaluefor keys from 50 to 59 is set to 'N' meaning that numlock manages the state of those keys (standard and alternative behavior). Probably tweaking with one's own country keymap (after backing it up) should do the job; to test a keymap you can use: kbdcontrol -l <keymap_file>

However, being those special function keys, task may be more complicate, potentially requiring reprogramming keyboard(4) kernel driver, and personally speaking, it way out of the range of my capabilities
 
Sensucht94 well, that was very detailed. No complaints, I would add, however, that I have been effectively launching from the command-line for quite some time now. The utility of the /dev/null is a little more beneficial than you make it out to be. Nonetheless, I appreciate your kind and helpful technical expertise!
Personally, using the /x11/numlockx is especially handy when there is a large volume of
number crunching, keyboard data-entry, etc. that has served me well in bookkeeping, accounting, and most of all vast quantities of litigation documentation.
 
Nonetheless, I appreciate your kind and helpful technical expertise!

Thanks, for the kind words but I'm just a very limited amateur :p, and may be proven wrong, so feel free to answer and correct me for any mistake you noticed
 
Giving the above some further thoughts. Basically, using the code:
Code:
$ numlockx >/dev/null 2>1&

Is a redirected way of launching 'numlockx' while at the same time capturing a small snippet of potential
errors streamed as input to a file named "1". This can be very helpful if you want a quick and concise
view of potential clues in troubleshooting a problem (without trying to search through crash dumps).
Most of the time everything is just fine, so that you can send file "1" to the Trash. If not, you can rename
the file to a more appropriate filename of your choice - and begin tweaking, and troubleshooting.
 
Back
Top