Difference between revisions of "Activating Numlock on Bootup"
(→GDM) |
Lahwaacz.bot (talk | contribs) (update interlanguage links) (Tag: wiki-scripts) |
||
(54 intermediate revisions by 34 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Boot process]] | [[Category:Boot process]] | ||
− | |||
[[Category:Keyboards]] | [[Category:Keyboards]] | ||
[[de:Numlock]] | [[de:Numlock]] | ||
[[es:Activating Numlock on Bootup]] | [[es:Activating Numlock on Bootup]] | ||
[[it:Activating Numlock on Bootup]] | [[it:Activating Numlock on Bootup]] | ||
+ | [[ja:起動時に Numlock を有効化]] | ||
[[ru:Activating Numlock on Bootup]] | [[ru:Activating Numlock on Bootup]] | ||
− | + | [[zh-hans:Activating Numlock on Bootup]] | |
− | [[zh- | ||
== Console == | == Console == | ||
− | + | === Using a separate service === | |
− | + | {{Tip|These steps can be automated by [[install]]ing the {{AUR|systemd-numlockontty}} package and [[enabling]] the {{ic|numLockOnTty}} service.}} | |
− | + | First create a script to set the numlock on relevant TTYs: | |
− | + | ||
− | + | {{hc|/usr/bin/numlock|<nowiki> | |
+ | #!/bin/bash | ||
+ | |||
+ | for tty in /dev/tty{1..6} | ||
+ | do | ||
+ | /usr/bin/setleds -D +num < "$tty"; | ||
+ | done | ||
+ | </nowiki>}} | ||
+ | |||
+ | Then create and [[enable]] a systemd service: | ||
+ | |||
+ | {{hc|/etc/systemd/system/numlock.service|<nowiki> | ||
+ | [Unit] | ||
+ | Description=numlock | ||
+ | |||
+ | [Service] | ||
+ | ExecStart=/usr/bin/numlock | ||
+ | StandardInput=tty | ||
+ | RemainAfterExit=yes | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target</nowiki>}} | ||
+ | |||
+ | === Extending getty@.service === | ||
+ | |||
+ | This is simpler than using a separate service (especially since systemd-198) 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: | ||
+ | |||
+ | {{hc|# systemctl edit getty\@.service|<nowiki> | ||
+ | [Service] | ||
+ | ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I' | ||
+ | </nowiki>}} | ||
+ | |||
+ | To disable the num-lock activation hint displaying on the login screen, edit getty@tty1.service and add {{ic|--nohints}} to agetty options: | ||
+ | |||
+ | {{hc|# systemctl edit getty@tty1.service|<nowiki> | ||
+ | [Service] | ||
+ | ExecStart= | ||
+ | ExecStart=-/sbin/agetty --nohints --noclear %I $TERM | ||
+ | </nowiki>}} | ||
+ | |||
+ | === Bash alternative === | ||
+ | |||
+ | 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. | ||
== X.org == | == X.org == | ||
Line 37: | Line 78: | ||
exec window_manager | exec window_manager | ||
− | === | + | === KDE Plasma Users === |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Go to System Settings, under the Hardware/Input Devices/Keyboard item you will find an option to select the behavior of NumLock. | Go to System Settings, under the Hardware/Input Devices/Keyboard item you will find an option to select the behavior of NumLock. | ||
− | ==== | + | === GDM === |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | {{Note|GDM does not execute scripts in {{ic|/etc/gdm/Init}} anymore.}} | |
− | + | Make sure that you have {{Pkg|numlockx}} installed then add the following code to [[xprofile|~/.xprofile]]: | |
if [ -x /usr/bin/numlockx ]; then | if [ -x /usr/bin/numlockx ]; then | ||
Line 76: | Line 96: | ||
When not using the GDM login manager, numlockx can be added to GNOME's start-up applications. | When not using the GDM login manager, numlockx can be added to GNOME's start-up applications. | ||
− | [[ | + | [[Install]] the {{Pkg|numlockx}} package. Then, add a start-up command to launch {{ic|numlockx}}. |
$ gnome-session-properties | $ gnome-session-properties | ||
The above command opens the '''Startup Applications Preferences''' applet. Click '''''Add''''' and enter the following: | The above command opens the '''Startup Applications Preferences''' applet. Click '''''Add''''' and enter the following: | ||
− | {| | + | {| class="wikitable" |
| Name: || ''Numlockx'' | | Name: || ''Numlockx'' | ||
|- | |- | ||
Line 90: | Line 110: | ||
{{note|This is not a system-wide change, repeat these steps for each user wishing to activate NumLock after logging in.}} | {{note|This is not a system-wide change, repeat these steps for each user wishing to activate NumLock after logging in.}} | ||
+ | |||
+ | === Xfce === | ||
+ | |||
+ | In the file {{ic|~/.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"/> | ||
+ | |||
+ | === SDDM === | ||
+ | |||
+ | In the file {{ic|/etc/sddm.conf}}, under the {{ic|[General]}} section, set ''Numlock'' value to ''on'' : | ||
+ | |||
+ | [General] | ||
+ | ... | ||
+ | Numlock=on | ||
=== SLiM === | === SLiM === | ||
Line 104: | Line 139: | ||
And then save the file. | And then save the file. | ||
+ | |||
+ | === LightDM === | ||
+ | See [[LightDM#NumLock on by default]]. | ||
+ | |||
+ | === LXDM === | ||
+ | |||
+ | Set the option in {{ic|/etc/lxdm/lxdm.conf}}: | ||
+ | |||
+ | numlock=1 | ||
+ | |||
+ | === LXQt === | ||
+ | |||
+ | Set the option in {{ic|~/.config/lxqt/session.conf}}: | ||
+ | |||
+ | numlock=true |
Latest revision as of 08:07, 13 December 2017
Contents
Console
Using a separate service
numLockOnTty
service.First create a script to set the numlock on relevant TTYs:
/usr/bin/numlock
#!/bin/bash for tty in /dev/tty{1..6} do /usr/bin/setleds -D +num < "$tty"; done
Then create and enable a systemd service:
/etc/systemd/system/numlock.service
[Unit] Description=numlock [Service] ExecStart=/usr/bin/numlock StandardInput=tty RemainAfterExit=yes [Install] WantedBy=multi-user.target
Extending getty@.service
This is simpler than using a separate service (especially since systemd-198) 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:
# systemctl edit getty\@.service
[Service] ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I'
To disable the num-lock activation hint displaying on the login screen, edit getty@tty1.service and add --nohints
to agetty options:
# systemctl edit getty@tty1.service
[Service] ExecStart= ExecStart=-/sbin/agetty --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 exec
:
#!/bin/sh # # ~/.xinitrc # # Executed by startx (run your window manager from here) # numlockx & exec window_manager
KDE Plasma Users
Go to System Settings, under the Hardware/Input Devices/Keyboard item you will find an option to select the behavior of NumLock.
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
When not using the GDM login manager, numlockx can be added to GNOME's start-up applications.
Install the numlockx package. 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. |
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"/>
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
:
numlock=true