Skip to content

Linux driver for Asus laptops to activate numpad on touchpad

License

Notifications You must be signed in to change notification settings

vazw/asus-numpad

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asus Touchpad Numpad Driver

Linux tool to allow using the numpad that is overlayed on various Asus Laptop touchpads.

Features

This builds upon the work done in asus-touchpad-numpad-driver, and adds more goodies that bring it closer to parity with the official Windows driver-

  • Hold to toggle numlock/cycle brightness
  • Drag to trigger calculator (on supported models)
  • Allows using the touchpad when numlock is active
  • Ignores touches in margins (outside the numpad)
  • Integration with system's NumLock state - toggle with external keyboards

Installation

Prerequisites

  • Install libevdev
    • Debian / Ubuntu / Linux Mint / Pop!_OS / Zorin OS: sudo apt install libevdev2
    • Arch Linux / Manjaro: sudo pacman -S libevdev
    • Fedora: sudo dnf install libevdev

Use prebuilt binary

  • Download from Releases page
  • Copy to some directory in PATH. (Further instructions assume it is in /usr/bin/)

OR

Compile from source

  • Install the Rust 2021 toolchain using Rustup
  • sudo -E cargo install --root /usr --git="https://github.com/iamkroot/asus-numpad"

Run

  • sudo modprobe i2c-dev and sudo modprobe uinput

    • You can have them be loaded automatically at boot. Consult ArchWiki for details
  • Create the config file at /etc/xdg/asus_numpad.toml and add layout = "LAYOUT", where LAYOUT is one of UX433FA, M433IA, UX581, GX701 or GX531. See Configuration for more options.

  • sudo asus-numpad

Running without sudo

It is best to run this program through a separate Unix user that is allowed to access input devices.

# create a group `uinput` and add a `udev` rule for it
# needed to be able to create a dummy virtual keyboard
sudo groupadd uinput
echo 'KERNEL=="uinput", GROUP="uinput", MODE:="0660"' | sudo tee /etc/udev/rules.d/99-input.rules

# create a system user called "asus_numpad" which is a part of the required groups,
# so that the program can access the touchpad events and control its brightness
sudo useradd -Gi2c,input,uinput --no-create-home --system asus_numpad

After a reboot, check that the permissions are correct:

  • ls -l /dev/uinput should show crw-rw---- 1 root uinput ... /dev/uinput (The uinput after root is important)
  • Similarly, ls -l /dev/i2c-* should be owned by i2c group
  • Finally, groups asus_numpad should include input, i2c and uinput.

Systemd Service

To enable autoloading at boot, a systemd service has been provided.

  • If you have added the new user from previous section, add User=asus_numpad the end of [Service] section in tools/asus-numpad.service.
  • Run the following
    # copy the systemd service to a known location
    sudo cp tools/asus-numpad.service /etc/systemd/system/
    
    # enable and start the service
    sudo systemctl enable --now asus-numpad.service

Configuration

The config file is stored in TOML format at /etc/xdg/asus_numpad.toml. It supports the following params:

name type default desc
layout string Required One of UX433FA, M433IA, UX581, GX701 or GX531.
calc_start_command
  1. Array of EV_KEY, or
  2. {cmd = "some_binary", args = ["arg1", "arg2]}
["KEY_CALC"] Defines what is to be done when calc key is dragged.
If variant a is used, the specified keys will be pressed. Variant b allows running an arbitrary command.
calc_stop_command Same as calc_start_command Not specified Defines what is to be done when calc key is dragged the second time. Useful for closing/killing a launched process. If not specified, the calc_start_command will be triggered.
disable_numlock_on_start bool true Specifies whether we should deactivate the numlock when starting up.

Running commands as main user

If you are running the daemon under a different user as discussed in Running without sudo, and you have specified custom commands in the configuration, then you'll find that the commands are actually running under the asus_numpad user. This may or may not be irksome based on what the command does (it won't have access to your user's files).

You can use sudo for in order to run the commands as your main user account:

  1. sudo visudo to edit the sudoers file
  2. At the very end, add asus_numpad ALL=(__YOUR_USERNAME__) NOPASSWD: ALL (replace __YOUR_USERNAME__ with your actual username!)
  3. In asus_numpad.toml, specify the commands as {cmd = "sudo", args = ["-u", "__YOUR_USERNAME__", "some_binary", "arg1", "arg2"]

Todo

The following features are planned and implemented for the app:

  • Support UX433FA and M433IA
  • Hold the numpad button to toggle it
  • Use i2cdev crate for setting brightness
  • Handle Calc Key
  • Cycle through multiple brightness options
  • Ignore touches in margins
  • Support more numpad layouts (UX581 and GX701)
  • Logging for debugging purposes
  • Set model via program argument
  • Systemd service to enable autostart
  • Run without sudo
  • Start Calc only on drag instead of tap
  • Don't panic on errors - exit gracefully
  • Integration with system's NumLock state (toggle with external keyboards)
  • strip release binaries
  • Re-triggering Calc Key should close the previously opened calc
  • Run custom command on triggering Calc Key
  • Autodetect laptop model
  • Disable numpad if idle for more than a minute

Acknowledgements

About

Linux driver for Asus laptops to activate numpad on touchpad

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%