Giter Club home page Giter Club logo

asus-numpad's Introduction

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

asus-numpad's People

Contributors

abuseware avatar iamkroot avatar lordmzte avatar sporif avatar undeadkernel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

asus-numpad's Issues

Need to restart daemon after system reboot

After every boot, it requires to give the below command to work
sudo systemctl status asus-numpad.service

moved asus-numpad to /usr/bin
in /etc/xdg/asus_numpad.toml

layout = "M433IA"
calc_start_command = ["KEY_CALC"]
calc_stop_command = {cmd = "killall", args = ["gnome-calculator"]}
disable_numlock_on_start = false

Daemon status after reboot:

asus-numpad.service - Asus Numpad Driver
Loaded: loaded (/etc/systemd/system/asus-numpad.service; enabled; preset: disabled)
Active: active (running) since Tue 2022-08-02 00:17:13 IST; 52s ago
Main PID: 3644 (asus-numpad)
Tasks: 1 (limit: 18811)
Memory: 348.0K
CPU: 343ms
CGroup: /system.slice/asus-numpad.service
โ””โ”€3644 /usr/bin/asus-numpad

Aug 02 00:17:13 zenbook systemd[1]: Started Asus Numpad Driver.

Note: Not created separate user and user group

System Conf:
OS: Arch Linux x86_64
Host: ZenBook UX325EA_UX325EA 1.0
Kernel: 5.18.15-arch1-1

ASUS Dial (Dialpad)

Any plans on implementing dialpad? I have Vivobook Pro 14X OLED and asus-numpad works perfectly except it lights as dial, not numpad (for obvious reasons)

The GX701 layout doesn't seem to be the correct one.

I have a Zephyrus S GX701 and noticed that after installing the asus-numpad service, the layout was not the right one.

The original (python) repository defines the layout in this file. Your definition of the GX701 layout, found in here, does not match the original (and correct) one.

Was the change to the GX701 layout intentional?

(BUG) Missing brightness on changed.

None of the brightness level are not working except for Brightness::Full

video_2024-05-09_14-39-31.mp4

I think this due to i2c devices need turn on with signal 0x01 and then chenge the brightness later.
I'm able to sloved this problem with this commit If you think this is useful I can make the Pull Request now or is there other solution we can discuss here.

GLIBC not Found

sudo ./asus-numpad
./asus-numpad: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.33' not found (required by ./asus-numpad) ./asus-numpad: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.32' not found (required by ./asus-numpad)
libc6 already installed..

Linux Mint 20.3 Kernel 5.15.0-46

Number buttons are triggering secondary functions (e.g. pg_up)

Expected behavior: Touching numbers 1-9 on touch pad will trigger a keypress of t heir respective number.
Actual behavior: Touching numbers 1-9 on touch pad trigger secondary functions (9 will page up, 3 will page down, etc.)
Hardware: Asus Zenbook UM425Q

Steps:

  1. Long press the upper-right icon to enable numberpad
  2. Press any number button 0-9

Comments:
Other buttons, such as backspace, '=', and the dimmer button, work as expected. I'm assuming that it's behaving as if numlock is off. Unless I'm blind, there doesn't appear to be a numlock key on the keyboard, so I can't turn it on.

strange backlight behavior

the functionality is working. But when the numpad is turned off, pressing any key on the keyboard turns on the backlight. At the same time, the touchpad does not start working as a numpad, only the backlight. If you touch the touchpad, the backlight turns off. And so in a circle you can turn on and off the backlight with the keyboard :/. UM3402YAR Zenbook, M433IA

Drag to trigger calculator does not works

Hi,

Thanks for sharing your work!

I tried all the possible drag movement and the calculator does not show
I'm using a Zenbook UX425EA running Pop!_OS 21.10 (same calculator app as Ubunutu)
It does works on windows 10 (by dragging from-top left to top-right of the mousepad)

Upstream as kernel driver

Hi! This is the sort of functionality that would be best added to the kernel upstream in https://github.com/torvalds/linux/blob/master/drivers/platform/x86/asus-nb-wmi.c (and asus-wmi.c). The ideal thing would be to have the entire thing in kernel, including the touchpoints config, but right now I'm not 100% sure of the best way to manage that part. Maybe sparking up a conversation on the mailing list or emailing Corentin or Hans de Goede. Hans is a great guy and did all the code review for me.

Even if it was just detect and init the device, plus expose a sysfs point for toggling on/off I think it would dramatically help you with this project, maybe even enough that you could reduce this to a crate we can add to asusctl.

I unfortunately don't have one of these types of laptops so I won't be able to help much (I wrote https://gitlab.com/asus-linux/asusctl and upstreamed most of the ROG stuff like keyboard support, platform-profile support, fan-curves, and other stuff), but I'll try if I can.

If you would like to write a blog post about your project, you can add it to our website at https://asus-linux.org/ through https://gitlab.com/asus-linux/website

P.S: You might be interested in the virt keyboard I did before pulling out functionality in to kernel patches - https://github.com/flukejones/rog-core/blob/master/rog-core/src/virt_device.rs

Different Keyboard Layout Problem

Problem is my keyboard is Turkish and buttons are not correctly working. If change my layout to English UK, it works without any problem. So this problem can be caused in any other keyboard layouts which are different then English.

2023-06-26_20-05
This layout should work properly but as i said because of keyboard layout, "equal" behave like minus and "dot" behave like "comma".

My idea about solution is. Keeping code in fixed layout even OS has different layout. Maybe we can use ASCII.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.