Activating Numlock on Bootup

From ArchWiki
Revision as of 19:30, 12 March 2013 by Raynman (Talk | contribs) (Console: alternative method for VTs under systemd)

Jump to: navigation, search

Console

Using a separate service

Install the package systemd-numlockonttyAUR from the AUR.

Now you should enable the numLockOnTty.service daemon. Read Daemons for more details.

Customizing getty@.service

Unlike the separate service, this approach does not hardcode the number of VTs in a script. Create the following file.

/etc/systemd/system/getty@.service
.include /usr/lib/systemd/system/getty@.service

[Service]
ExecStartPost=/bin/sh -c 'setleds +num < /dev/%I'

Now disable and reenable getty@tty1.service to use the new template. Repeat this if you enabled additional instances. The default configuration spawns additional instances on demand using /usr/lib/systemd/system/autovt@.service, which is a symlink to the default getty@.service. We can add a symlink in /etc/systemd/system to tell systemd to use our custom service file:

# cd /etc/systemd/system
# ln -s getty@.service autovt@.service

Bash alternative

Add setleds -D +num to ~/.bash_profile. Note that, unlike the other methods, this will not take effect until after you login.

X.org

Various methods are available.

startx

Install the numlockx package and add it to the ~/.xinitrc file before exec:

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
#

numlockx &

exec window_manager

KDM

If you use KDM as a login manager, add:

numlockx on

to the /usr/share/config/kdm/Xsetup, or the /opt/kde/share/config/kdm/Xsetup for KDM3.

Note that this file will be overwritten on update without creating a .pacnew file. To prevent this, add the following line to /etc/pacman.conf file (omit the leading slash in the path):

NoUpgrade = usr/share/config/kdm/Xsetup

KDE4 Users

Go to System Settings, under the Hardware/Input Devices/Keyboard item you will find an option to select the behavior of NumLock.

Alternate Method

Alternatively, add the script the ~/.kde4/Autostart/numlockx containing:

#!/bin/sh
numlockx on

And make it executable:

$ chmod +x ~/.kde4/Autostart/numlockx

GDM

First make sure that you have numlockx (from extra) installed then add the following code to /etc/gdm/Init/Default:

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

GNOME

When not using the GDM login manager, numlockx can be added to GNOME's start-up applications.

Install numlockx from the official repositories. Then, add a start-up command to launch numlockx.

$ gnome-session-properties

The above command opens the Startup Applications Preferences applet. Click Add and enter the following:

Name: Numlockx
Command: /usr/bin/numlockx on
Comment: Turns on numlock.
Note: This is not a system-wide change, repeat these steps for each user wishing to activate NumLock after logging in.

SLiM

In the file /etc/slim.conf find the line and uncomment it (remove the #):

#numlock             on

OpenBox

In the file ~/.config/openbox/autostart add the line:

numlockx &

And then save the file.