11

I usually edit in Vim,and when pressing +, I'd rather move my hand to the right part of the keyboard where + resides rather than doing shift + =.

But when NumLock is not on, in Vim it just opens a new line above and inserts the letter k. And every time I start my PC NumLock is off.

I would like to know if there is any xmodmap trick to turn on NumLock,so I could add it to my .xinitrc.And it would be even better if I could add it to my .map file which swaps Escape and CapsLock which I load with loadkeys in my /etc/rc.local on startup.

I am using Arch Linux.

John Militer
  • 773
  • 4
  • 14
  • 29
bollovan
  • 513
  • 5
  • 11

5 Answers5

13

There is a package in community numlockx:

# pacman -S numlockx

and then add it to your .xinitrc:

numlockx &

There are also methods on the the Arch Wiki if you are using a login manager, such as GDM or KDM: https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup

jasonwryan
  • 71,734
  • 34
  • 193
  • 226
4

The archlinux wiki has a page about enabling the numlock key on bootup here

ryuslash
  • 256
  • 1
  • 2
  • 4
    Please never just link to an answer on StackExchange QnA sites; always include at least a summary of the solution and links for extra reference. – Caleb Jun 27 '11 at 10:06
2

Numlock status at startup is usually an option in the BIOS (as another option, rather than setting it per OS). Although I guess it's possible that it's already set to on, and something in Arch Linux (or other OS's) is turning it off again.

EightBitTony
  • 20,963
  • 4
  • 61
  • 62
1

This does not pretend to be the most elegant solution, but on many of my systems my users ~/.xmodmaprc file has entries that look like this:

keycode 79 = 7
keycode 80 = 8
keycode 81 = 9
keycode 83 = 4
keycode 84 = 5
keycode 85 = 6
keycode 87 = 1
keycode 88 = 2
keycode 89 = 3
keycode 90 = 0
keycode 86 = plus
keycode 82 = minus
keycode 91 = period

I use several different desktop environments on several different distros and this is a hacky but sure-fire way to make sure that no matter how the system comes down on NumLock policy, my numeric keypad gives me numbers. Basically strips the NumLock function of significance by by stripping all other values from the key-codes. You can turn NumLock on or off as you like but the only thing the keys do is spit out the number values.

Caleb
  • 69,278
  • 18
  • 196
  • 226
0

Package free:

  • Open root crontab sudo crontab -e
  • Add
    @reboot sh -c 'setleds +num < /dev/console'
    
    on a new line.
  • Some users may need to run:
    sudo systemctl enable cron.service
    
  • Then reboot and see it in action.
AdminBee
  • 21,637
  • 21
  • 47
  • 71
zqxyz
  • 21
  • 3