LinuxCommandLibrary

numlockx

Enable or disable the Num Lock key

TLDR

Show the current number lock status

$ numlockx status
copy

Turn the number lock on
$ numlockx on
copy

Turn the number lock off
$ numlockx off
copy

Toggle the current state
$ numlockx toggle
copy

SYNOPSIS

numlockx [on | off | toggle | status] [--display display]

PARAMETERS

on
    Turns the Num Lock key on.

off
    Turns the Num Lock key off.

toggle
    Toggles the current state of the Num Lock key (if it's on, it turns it off; if it's off, it turns it on).

status
    Prints the current state of the Num Lock key to standard output (e.g., "Numlock is on").

--display display
    Specifies the X display to connect to. This is useful when controlling Num Lock on a remote or specific display other than the default.

DESCRIPTION

numlockx is a lightweight command-line utility for the X Window System designed to manage the state of the Num Lock key. It allows users to explicitly enable, disable, or toggle the Num Lock status on their X session's keyboard. This tool is particularly useful for ensuring that Num Lock is in a desired state (e.g., always on) when an X session starts, often by being included in startup scripts like .xinitrc or .xprofile. It interacts directly with the X server's keyboard settings to modify the key's behavior, providing a simple yet effective way to maintain consistent Num Lock functionality across various desktop environments or login managers that might otherwise leave it off by default.

CAVEATS

numlockx operates within the X Window System environment and therefore requires an active X server. It will not function in a text-only console. In some complex keyboard setups or environments where other applications are constantly remapping keys, its effects might be overridden or appear inconsistent.

<B>DEFAULT BEHAVIOR</B>

When invoked without any arguments (e.g., numlockx), the command defaults to the toggle action, changing the Num Lock state from its current setting.

<B>STARTUP INTEGRATION</B>

A common use case is to add numlockx on to user-specific X startup scripts (like ~/.xinitrc, ~/.xprofile, or desktop environment specific autostart locations) to ensure Num Lock is always enabled upon graphical session login.

HISTORY

numlockx is a well-established utility within the Linux and Unix-like operating systems' X Window System ecosystem. Its purpose has remained consistent since its inception: to provide a simple command-line interface for managing the Num Lock key state. It fills a common need for users who prefer Num Lock to be enabled by default, especially on systems where desktop environments or login managers might not consistently set this preference. Its development reflects a focus on stability and straightforward functionality, with minimal changes to its core behavior over the years.

SEE ALSO

setxkbmap(1), xmodmap(1), xset(1)

Copied to clipboard