Skip to main content

NumLockW

A Wayland Clone of numlockx

Debug

Enable debug mode via environment variable to see detailed logs for troubleshooting:

NUMLOCKW_DEBUG=1 numlockw on

Install

To install numlockw, use the following commands:

sudo usermod -a -G plugdev $USER  # For Arch users: Refer to https://wiki.archlinux.org/title/Udev#Allowing_regular_users_to_use_devices
pipx install numlockw # or pipx install git+https://github.com/xz-dev/numlockw.git

You can then check the available commands with:

numlockw --help

And simply run:

numlockw on

Example output:

usage: numlockw [-h] [--device-name DEVICE_NAME] [--no-fake-uinput]
                [--pre-hook PRE_HOOK] [--force-led]
                {on,off,toggle,status,list-devices} ...

numlockw is a program to control the NumLock key, designed for use with
Wayland and tty environments.

options:
  -h, --help            show this help message and exit
  --device-name, --dev DEVICE_NAME
                        The name of the input device or "*" for each one. If
                        not provided, will fake keyboard to enable NumLock,
                        and enable LDE_NUML on all devices that support it.
  --no-fake-uinput      Do not fake uinput device, use real devices
  --pre-hook PRE_HOOK   A command to run when NumLock is toggled. The command
                        will be run with the status of uinput device name
                        ${{udevice}}.
  --force-led           Force setting LED_NUML on all devices that support it,
                        not dependent system to set it.

actions:
  valid actions

  {on,off,toggle,status,list-devices}
                        action to perform on NumLock
    on                  Turn NumLock on
    off                 Turn NumLock off
    toggle              Toggle NumLock
    status              Display NumLock status
    list-devices        List devices that support NumLock

Use Notes

  1. Sometimes, you might need some operation before "Click" NumLock. You can try --pre-hook
numlockw --pre-hook 'echo ${{udevice}}' on  # Print uinput (Fake keyboard) device name
  1. Choice exist(real) keyboard to "Click" NumLock:
numlockw --device-name 'AT Translated Set 2 keyboard' on
  1. If you want to Force enable/disable LED with switch NumLock by some reason:
numlockw list-devices
numlockw --device-name 'AT Translated Set 2 keyboard' --force-led on  # Only for 'AT Translated Set 2 keyboard'

Background

Why create it?

  • River: Does not enable Num Lock at boot.
  • numlockx is not available for Wayland.

Why not use the wlroots protocol?

  • The functionality of the protocol depends on its implementation by the compositor.

Why should it work?

Refer to the Activating NumLock on Bootup - ArchWiki for background information.

Issues

  1. Sync status on LED and actual state:

    • The method described here seems problematic, but no better solution was found.
  2. Is it working? (welcome add more):

    • I have tested NumLockW on TTY, KDE (Wayland) and Hyprland, and everything is working fine.
    • Qtile: Work. Confirmed by user (issue #3).
    • However, there are some issues that require attention from the compositor developers:
      • River: Work. Recommend select an exist devices. Issue of River: Add all your keyboards to a keyboard group in ~/.config/river/init, like:
        > riverctl list-inputs
        
         keyboard-13364-832-Keychron_Keychron_V4
             configured: false
        
         keyboard-1-1-AT_Translated_Set_2_keyboard
             configured: false
        
         keyboard-0-0-wlr_virtual_keyboard_v1
             configured: false
        > riverctl keyboard-group-create default
        > riverctl keyboard-group-add default 'keyboard-1-1-AT_Translated_Set_2_keyboard'
        > riverctl keyboard-group-add default 'keyboard-13364-832-Keychron_Keychron_V4'
        
        Then:
        numlockw --device-name 'AT Translated Set 2 keyboard' on
        
      • GNOME: Work. But you must choice an exist keyboard, like: numlockw --device-name 'AT Translated Set 2 keyboard' on
  3. Set udev rules for Debian (issues #2):

    • Add file /etc/udev/rules.d/10-uinput.rules
      KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess", GROUP="input", MODE="0660"
      
    • Then reboot

Contributing

We warmly welcome contributions from the community. If you find any bugs or have suggestions for improvements, please feel free to open an issue.

You're also encouraged to submit pull requests to help make this project better. If you find this project useful, please consider giving it a ⭐ to show your support!

Thank you for your interest and contributions! ❤️

Metadata

Release files for numlockw 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for numlockw 0.1.6
File Size Uploaded
numlockw-0.1.6.tar.gz 21.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for numlockw 0.1.6
File Interpreter ABI Platform
numlockw-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 41.1 kB

Release files / numlockw-0.1.6.tar.gz

Download URL numlockw-0.1.6.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0e4708e2a96be72eb7a87e4f248af26b440fcb2a1519ac19d5009e35e39d7f7d
BLAKE2b-256 checksum
How to use checksums
ff9a11710c6258b1df316bc8c3dbe630254671421dff46c21b5dba96925503c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"'Gentoo'","version":"'2.18'","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / numlockw-0.1.6-py3-none-any.whl

Download URL numlockw-0.1.6-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
105d7d10d36603f2971cd3005a7319336de642e5d87fee1bbfc858c5c082ca42
BLAKE2b-256 checksum
How to use checksums
674163299cf08316072324d57aef993809a7b87880e901068591036804a30668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"'Gentoo'","version":"'2.18'","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

1 release file

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page