iamkroot / asus-numpad

Linux driver for Asus laptops to activate numpad on touchpad
MIT License
36 stars 10 forks source link
asus driver linux numpad rust touchpad

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-

Installation

Prerequisites

Use prebuilt binary

OR

Compile from source

Run

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:

Systemd Service

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

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, GX531 or G533.
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:

Acknowledgements