https://wiki.archlinux.org/api.php?action=feedcontributions&user=Brnelsons&feedformat=atomArchWiki - User contributions [en]2024-03-28T10:30:49ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Activating_numlock_on_bootup&diff=575206Activating numlock on bootup2019-06-11T23:26:37Z<p>Brnelsons: Fixed syntax. Apologies, I'm unfamiliar with this markdown</p>
<hr />
<div>[[Category:Boot process]]<br />
[[Category:Keyboards]]<br />
[[pt:Activating Numlock on Bootup]]<br />
[[de:Numlock]]<br />
[[es:Activating Numlock on Bootup]]<br />
[[it:Activating Numlock on Bootup]]<br />
[[ja:起動時に Numlock を有効化]]<br />
[[ru:Activating Numlock on Bootup]]<br />
[[zh-hans:Activating Numlock on Bootup]]<br />
== Console ==<br />
<br />
=== Using a separate service ===<br />
<br />
{{Tip|These steps can be automated by [[install]]ing the {{AUR|systemd-numlockontty}} package and [[enabling]] the {{ic|numLockOnTty}} service.}}<br />
<br />
First create a script to set the numlock on relevant TTYs:<br />
<br />
{{hc|/usr/local/bin/numlock|<br />
#!/bin/bash<br />
<br />
for tty in /dev/tty{1..6}<br />
do<br />
/usr/bin/setleds -D +num < "$tty";<br />
done<br />
}}<br />
<br />
Then create and [[enable]] a systemd service:<br />
<br />
{{hc|/etc/systemd/system/numlock.service|2=<br />
[Unit]<br />
Description=numlock<br />
<br />
[Service]<br />
ExecStart=/usr/local/bin/numlock<br />
StandardInput=tty<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
=== Extending getty@.service ===<br />
<br />
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 {{ic|getty@.service}} which are applied on top of the original unit:<br />
<br />
{{hc|/etc/systemd/system/getty@.service.d/activate-numlock.conf|2=<br />
[Service]<br />
ExecStartPre=/bin/sh -c 'setleds -D +num < /dev/%I'<br />
}}<br />
<br />
{{Note|If you experience any problems, try replacing {{ic|ExecStartPre}} with {{ic|ExecStartPost}}, and/or disabling the hint as described below.}}<br />
<br />
To disable the num-lock activation hint displaying on the login screen, [[edit]] {{ic|getty@tty1.service}} and add {{ic|--nohints}} to ''agetty'' options:<br />
<br />
[Service]<br />
ExecStart=<br />
ExecStart=-/sbin/agetty '-p -- \\u' --nohints --noclear %I $TERM<br />
<br />
=== Bash alternative ===<br />
<br />
Add {{ic|setleds -D +num}} to {{ic|~/.bash_profile}}. Note that, unlike the other methods, this will not take effect until after you log in.<br />
<br />
== X.org ==<br />
<br />
Various methods are available.<br />
<br />
=== startx ===<br />
<br />
Install the {{Pkg|numlockx}} package and add it to the {{ic|~/.xinitrc}} file before {{Ic|exec}}:<br />
<br />
#!/bin/sh<br />
#<br />
# ~/.xinitrc<br />
#<br />
# Executed by startx (run your window manager from here)<br />
#<br />
<br />
numlockx &<br />
<br />
exec window_manager<br />
<br />
=== MATE ===<br />
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-Values:<br />
<br />
dconf write org.mate.peripherals-keyboard remember-numlock-state false<br />
dconf write org.mate.peripherals-keyboard numlock-state 'on'<br />
<br />
=== KDE Plasma Users ===<br />
<br />
Go to System Settings, under the Hardware/Input Devices/Keyboard item you will find an option to select the behavior of NumLock.<br />
<br />
=== GDM ===<br />
<br />
{{Note|GDM does not execute scripts in {{ic|/etc/gdm/Init}} anymore.}}<br />
<br />
Make sure that you have {{Pkg|numlockx}} installed then add the following code to [[xprofile|~/.xprofile]]:<br />
<br />
if [ -x /usr/bin/numlockx ]; then<br />
/usr/bin/numlockx on<br />
fi<br />
<br />
=== GNOME ===<br />
<br />
When not using the GDM login manager, numlockx can be added to GNOME's start-up applications.<br />
<br />
[[Install]] the {{Pkg|numlockx}} package. Then, add a start-up command to launch {{ic|numlockx}}.<br />
$ gnome-session-properties<br />
<br />
The above command opens the '''Startup Applications Preferences''' applet. Click '''''Add''''' and enter the following:<br />
<br />
{| class="wikitable"<br />
| Name: || ''Numlockx''<br />
|-<br />
| Command: || ''/usr/bin/numlockx on''<br />
|-<br />
| Comment: || ''Turns on numlock.''<br />
|}<br />
<br />
{{note|This is not a system-wide change, repeat these steps for each user wishing to activate NumLock after logging in.}}<br />
<br />
=== Xfce ===<br />
<br />
In the file {{ic|~/.config/xfce4/xfconf/xfce-perchannel-xml/keyboards.xml}}, make sure the following values are set to true:<br />
<br />
<property name="Numlock" type="bool" value="true"/><br />
<property name="RestoreNumlock" type="bool" value="true"/><br />
<br />
Note: If the file does not exist then open Settings > Keyboard, then check and uncheck the {{ic|Restore num lock state on startup}}. This will create the {{ic|keyboards.xml}} file.<br />
<br />
=== SDDM ===<br />
<br />
In the file {{ic|/etc/sddm.conf}}, under the {{ic|[General]}} section, set ''Numlock'' value to ''on'' :<br />
<br />
[General]<br />
...<br />
Numlock=on<br />
<br />
=== SLiM ===<br />
<br />
In the file {{ic|/etc/slim.conf}} find the line and uncomment it (remove the {{Ic|#}}):<br />
<br />
#numlock on<br />
<br />
=== OpenBox ===<br />
<br />
In the file {{ic|~/.config/openbox/autostart}} add the line:<br />
<br />
numlockx &<br />
<br />
And then save the file.<br />
<br />
=== LightDM ===<br />
See [[LightDM#NumLock on by default]].<br />
<br />
=== LXDM ===<br />
<br />
Set the option in {{ic|/etc/lxdm/lxdm.conf}}:<br />
<br />
numlock=1<br />
<br />
=== LXQt ===<br />
<br />
Set the option in {{ic|~/.config/lxqt/session.conf}}:<br />
<br />
[Keyboard]<br />
numlock=true</div>Brnelsonshttps://wiki.archlinux.org/index.php?title=Activating_numlock_on_bootup&diff=575205Activating numlock on bootup2019-06-11T23:25:00Z<p>Brnelsons: Updated the XFCE documentation to include creating the keyboards.xml file when it does not exist.</p>
<hr />
<div>[[Category:Boot process]]<br />
[[Category:Keyboards]]<br />
[[pt:Activating Numlock on Bootup]]<br />
[[de:Numlock]]<br />
[[es:Activating Numlock on Bootup]]<br />
[[it:Activating Numlock on Bootup]]<br />
[[ja:起動時に Numlock を有効化]]<br />
[[ru:Activating Numlock on Bootup]]<br />
[[zh-hans:Activating Numlock on Bootup]]<br />
== Console ==<br />
<br />
=== Using a separate service ===<br />
<br />
{{Tip|These steps can be automated by [[install]]ing the {{AUR|systemd-numlockontty}} package and [[enabling]] the {{ic|numLockOnTty}} service.}}<br />
<br />
First create a script to set the numlock on relevant TTYs:<br />
<br />
{{hc|/usr/local/bin/numlock|<br />
#!/bin/bash<br />
<br />
for tty in /dev/tty{1..6}<br />
do<br />
/usr/bin/setleds -D +num < "$tty";<br />
done<br />
}}<br />
<br />
Then create and [[enable]] a systemd service:<br />
<br />
{{hc|/etc/systemd/system/numlock.service|2=<br />
[Unit]<br />
Description=numlock<br />
<br />
[Service]<br />
ExecStart=/usr/local/bin/numlock<br />
StandardInput=tty<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
=== Extending getty@.service ===<br />
<br />
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 {{ic|getty@.service}} which are applied on top of the original unit:<br />
<br />
{{hc|/etc/systemd/system/getty@.service.d/activate-numlock.conf|2=<br />
[Service]<br />
ExecStartPre=/bin/sh -c 'setleds -D +num < /dev/%I'<br />
}}<br />
<br />
{{Note|If you experience any problems, try replacing {{ic|ExecStartPre}} with {{ic|ExecStartPost}}, and/or disabling the hint as described below.}}<br />
<br />
To disable the num-lock activation hint displaying on the login screen, [[edit]] {{ic|getty@tty1.service}} and add {{ic|--nohints}} to ''agetty'' options:<br />
<br />
[Service]<br />
ExecStart=<br />
ExecStart=-/sbin/agetty '-p -- \\u' --nohints --noclear %I $TERM<br />
<br />
=== Bash alternative ===<br />
<br />
Add {{ic|setleds -D +num}} to {{ic|~/.bash_profile}}. Note that, unlike the other methods, this will not take effect until after you log in.<br />
<br />
== X.org ==<br />
<br />
Various methods are available.<br />
<br />
=== startx ===<br />
<br />
Install the {{Pkg|numlockx}} package and add it to the {{ic|~/.xinitrc}} file before {{Ic|exec}}:<br />
<br />
#!/bin/sh<br />
#<br />
# ~/.xinitrc<br />
#<br />
# Executed by startx (run your window manager from here)<br />
#<br />
<br />
numlockx &<br />
<br />
exec window_manager<br />
<br />
=== MATE ===<br />
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-Values:<br />
<br />
dconf write org.mate.peripherals-keyboard remember-numlock-state false<br />
dconf write org.mate.peripherals-keyboard numlock-state 'on'<br />
<br />
=== KDE Plasma Users ===<br />
<br />
Go to System Settings, under the Hardware/Input Devices/Keyboard item you will find an option to select the behavior of NumLock.<br />
<br />
=== GDM ===<br />
<br />
{{Note|GDM does not execute scripts in {{ic|/etc/gdm/Init}} anymore.}}<br />
<br />
Make sure that you have {{Pkg|numlockx}} installed then add the following code to [[xprofile|~/.xprofile]]:<br />
<br />
if [ -x /usr/bin/numlockx ]; then<br />
/usr/bin/numlockx on<br />
fi<br />
<br />
=== GNOME ===<br />
<br />
When not using the GDM login manager, numlockx can be added to GNOME's start-up applications.<br />
<br />
[[Install]] the {{Pkg|numlockx}} package. Then, add a start-up command to launch {{ic|numlockx}}.<br />
$ gnome-session-properties<br />
<br />
The above command opens the '''Startup Applications Preferences''' applet. Click '''''Add''''' and enter the following:<br />
<br />
{| class="wikitable"<br />
| Name: || ''Numlockx''<br />
|-<br />
| Command: || ''/usr/bin/numlockx on''<br />
|-<br />
| Comment: || ''Turns on numlock.''<br />
|}<br />
<br />
{{note|This is not a system-wide change, repeat these steps for each user wishing to activate NumLock after logging in.}}<br />
<br />
=== Xfce ===<br />
<br />
In the file {{ic|~/.config/xfce4/xfconf/xfce-perchannel-xml/keyboards.xml}}, make sure the following values are set to true:<br />
<br />
<property name="Numlock" type="bool" value="true"/><br />
<property name="RestoreNumlock" type="bool" value="true"/><br />
<br />
Note: If the file does not exist then open Settings > Keyboard, then check and uncheck the {{Restore num lock state on startup}}. This will create the {{keyboards.xml}} file.<br />
<br />
=== SDDM ===<br />
<br />
In the file {{ic|/etc/sddm.conf}}, under the {{ic|[General]}} section, set ''Numlock'' value to ''on'' :<br />
<br />
[General]<br />
...<br />
Numlock=on<br />
<br />
=== SLiM ===<br />
<br />
In the file {{ic|/etc/slim.conf}} find the line and uncomment it (remove the {{Ic|#}}):<br />
<br />
#numlock on<br />
<br />
=== OpenBox ===<br />
<br />
In the file {{ic|~/.config/openbox/autostart}} add the line:<br />
<br />
numlockx &<br />
<br />
And then save the file.<br />
<br />
=== LightDM ===<br />
See [[LightDM#NumLock on by default]].<br />
<br />
=== LXDM ===<br />
<br />
Set the option in {{ic|/etc/lxdm/lxdm.conf}}:<br />
<br />
numlock=1<br />
<br />
=== LXQt ===<br />
<br />
Set the option in {{ic|~/.config/lxqt/session.conf}}:<br />
<br />
[Keyboard]<br />
numlock=true</div>Brnelsons