Activating numlock on bootup: Difference between revisions
Lahwaacz.bot (talk | contribs) (update interlanguage links) |
(→Early bootup (mkinitcpio): include microcode and kms hooks to match the default /etc/mkinitcpio.conf) |
||
(23 intermediate revisions by 14 users not shown) | |||
Line 3: | Line 3: | ||
[[de:Numlock]] | [[de:Numlock]] | ||
[[es:Activating numlock on bootup]] | [[es:Activating numlock on bootup]] | ||
[[ja:起動時に Numlock を有効化]] | [[ja:起動時に Numlock を有効化]] | ||
[[pt:Activating numlock on bootup]] | [[pt:Activating numlock on bootup]] | ||
Line 10: | Line 9: | ||
== Console == | == Console == | ||
=== | === Early bootup (mkinitcpio) === | ||
You can enable numlock right after the kernel boots in the [[initramfs]]. This is the only way to ensure numlock is on even during [[dm-crypt/Encrypting an entire system|full-disk encryption]] password entry. Install {{AUR|mkinitcpio-numlock}} and add the {{ic|numlock}} [[mkinitcpio]] hook before {{ic|encrypt}} in the {{ic|/etc/mkinitcpio.conf}} HOOKS array: | |||
{{hc|/etc/mkinitcpio.conf|2= | |||
... | |||
HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont '''numlock''' block encrypt lvm2 filesystems fsck) | |||
... | |||
}} | |||
Then [[regenerate the initramfs]] for the change to take effect. | |||
An advantage of using this method is that the numlock setting will be replicated in the later boot process, and new virtual consoles will default to having numlock on. | |||
=== With systemd service === | |||
{{Tip|These steps can be automated by [[install]]ing the {{AUR|systemd-numlockontty}} package and [[enabling]] the {{ic|numLockOnTty}} service.}} | {{Tip|These steps can be automated by [[install]]ing the {{AUR|systemd-numlockontty}} package and [[enabling]] the {{ic|numLockOnTty}} service.}} | ||
Line 69: | Line 82: | ||
=== startx === | === startx === | ||
Install the {{Pkg|numlockx}} package and add it to the | Install the {{Pkg|numlockx}} package and add it to the [[xinitrc]] file before any {{ic|exec}} statement: | ||
{{hc|~/.xinitrc|2= | |||
numlockx & | |||
exec ''window manager'' | |||
}} | |||
=== MATE === | === MATE === | ||
dconf write org.mate.peripherals-keyboard remember-numlock-state false | By default, MATE saves the last state on logout and restores it during the next login. To enable numlock on every login, you must change the following [[dconf]] properties: | ||
dconf write org.mate.peripherals-keyboard numlock-state 'on' | |||
$ dconf write org.mate.peripherals-keyboard remember-numlock-state false | |||
$ dconf write org.mate.peripherals-keyboard numlock-state 'on' | |||
=== KDE Plasma === | === KDE Plasma === | ||
Line 106: | Line 114: | ||
Run the following command: | Run the following command: | ||
$ gsettings set org.gnome.desktop.peripherals.keyboard numlock-state true | |||
In order to remember last state of numlock key (whether you disabled or enabled), use: | In order to remember last state of numlock key (whether you disabled or enabled), use: | ||
$ gsettings set org.gnome.desktop.peripherals.keyboard remember-numlock-state true | |||
Alternatively, you can use add {{ic|numlockx on}} (from {{pkg|numlockx}}) to a startup script or {{ic|~/.profile}}. | |||
Alternatively, you can use add {{ic|numlockx on}} (from {{pkg|numlockx}} to a startup script | |||
=== Xfce === | === Xfce === | ||
Line 135: | Line 141: | ||
=== SLiM === | === SLiM === | ||
In the file {{ic|/etc/slim.conf}} find the line and uncomment it (remove the {{Ic|#}}): | In the file {{ic|/etc/slim.conf}}, find the line and uncomment it (remove the {{Ic|#}}): | ||
#numlock on | #numlock on | ||
Line 141: | Line 147: | ||
=== OpenBox === | === OpenBox === | ||
In the file {{ic|~/.config/openbox/autostart}} add the line: | In the file {{ic|~/.config/openbox/autostart}}, add the line: | ||
numlockx & | numlockx & | ||
Line 148: | Line 154: | ||
=== LightDM === | === LightDM === | ||
See [[LightDM#NumLock on by default]]. | See [[LightDM#NumLock on by default]]. | ||
Line 162: | Line 169: | ||
[Keyboard] | [Keyboard] | ||
numlock=true | numlock=true | ||
== Wayland == | |||
=== Sway === | |||
See [[Sway#Initially enable CapsLock/NumLock]]. | |||
=== Hyprland === | |||
Set the option in {{ic|~/.config/hypr/hyprland.conf}}: | |||
input { | |||
numlock_by_default = true | |||
... | |||
} |
Latest revision as of 07:56, 18 March 2024
Console
Early bootup (mkinitcpio)
You can enable numlock right after the kernel boots in the initramfs. This is the only way to ensure numlock is on even during full-disk encryption password entry. Install mkinitcpio-numlockAUR and add the numlock
mkinitcpio hook before encrypt
in the /etc/mkinitcpio.conf
HOOKS array:
/etc/mkinitcpio.conf
... HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont numlock block encrypt lvm2 filesystems fsck) ...
Then regenerate the initramfs for the change to take effect.
An advantage of using this method is that the numlock setting will be replicated in the later boot process, and new virtual consoles will default to having numlock on.
With systemd service
numLockOnTty
service.First create a script to set the numlock on relevant TTYs:
/usr/local/bin/numlock
#!/bin/bash for tty in /dev/tty{1..6} do /usr/bin/setleds -D +num < "$tty"; done
Once the script is created, you will need to make it executable. Otherwise the script cannot run.
Then create and enable a systemd service:
/etc/systemd/system/numlock.service
[Unit] Description=numlock [Service] ExecStart=/usr/local/bin/numlock StandardInput=tty RemainAfterExit=yes [Install] WantedBy=multi-user.target
Extending getty@.service
This is simpler than using a separate service and does not hardcode the number of VTs in a script. Create a drop-in snippet for getty@.service
which are applied on top of the original unit:
/etc/systemd/system/getty@.service.d/activate-numlock.conf
[Service] ExecStartPre=/bin/sh -c 'setleds -D +num < /dev/%I'
ExecStartPre
with ExecStartPost
, and/or disabling the hint as described below.To disable the numlock activation hint displaying on the login screen, edit getty@tty1.service
and add --nohints
to agetty options:
[Service] ExecStart= ExecStart=-/sbin/agetty '-p -- \\u' --nohints --noclear %I $TERM
Bash alternative
Add setleds -D +num
to ~/.bash_profile
. Note that, unlike the other methods, this will not take effect until after you log in.
X.org
Various methods are available.
startx
Install the numlockx package and add it to the xinitrc file before any exec
statement:
~/.xinitrc
numlockx & exec window manager
MATE
By default, MATE saves the last state on logout and restores it during the next login. To enable numlock on every login, you must change the following dconf properties:
$ dconf write org.mate.peripherals-keyboard remember-numlock-state false $ dconf write org.mate.peripherals-keyboard numlock-state 'on'
KDE Plasma
Go to System Settings > Input Devices > Keyboard, in the Hardware tab, in the NumLock on Plasma Startup section, choose the desired NumLock behavior.
GDM
/etc/gdm/Init
anymore.Make sure that you have numlockx installed then add the following code to ~/.xprofile:
if [ -x /usr/bin/numlockx ]; then /usr/bin/numlockx on fi
GNOME
Run the following command:
$ gsettings set org.gnome.desktop.peripherals.keyboard numlock-state true
In order to remember last state of numlock key (whether you disabled or enabled), use:
$ gsettings set org.gnome.desktop.peripherals.keyboard remember-numlock-state true
Alternatively, you can use add numlockx on
(from numlockx) to a startup script or ~/.profile
.
Xfce
In the file ~/.config/xfce4/xfconf/xfce-perchannel-xml/keyboards.xml
, make sure the following values are set to true:
<property name="Numlock" type="bool" value="true"/> <property name="RestoreNumlock" type="bool" value="true"/>
keyboards.xml
file.SDDM
In the file /etc/sddm.conf
, under the [General]
section, set Numlock value to on :
[General] ... Numlock=on
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.
LightDM
See LightDM#NumLock on by default.
LXDM
Set the option in /etc/lxdm/lxdm.conf
:
numlock=1
LXQt
Set the option in ~/.config/lxqt/session.conf
:
[Keyboard] numlock=true
Wayland
Sway
See Sway#Initially enable CapsLock/NumLock.
Hyprland
Set the option in ~/.config/hypr/hyprland.conf
:
input { numlock_by_default = true ... }