Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed to install only for current user via systemctl --user servic + refactored install/uninstall scripts + finished renaming to asus-numberpad-driver #145

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__pycache__
*~
asus_touchpad_numpad_dev
numberpad_dev
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"sudo": true,
"args": ["up5401ea-unicode-31B9", ""]
}
]
Expand Down
160 changes: 106 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ If you find this project useful, do not forget to give it a [![GitHub stars](htt

## Features

- Driver is installed for current user and does not run under `$ sudo`
- Multiple pre-created [NumberPad layouts](https://github.com/asus-linux-drivers/asus-numberpad-driver#layouts) with possibility [create custom one or improve existing](https://github.com/asus-linux-drivers/asus-numberpad-driver#keyboard-layout) (keys, sizes, paddings..)
- Customization through 2-way sync [configuration file](https://github.com/asus-linux-drivers/asus-numberpad-driver#configuration-file) (when is run `sudo bash ./install.sh` changes done in config file may not be overwritten, the same when is run `sudo bash ./uninstall.sh` and when config file or part of does not exist is automatically created/completed with default values)
- Customization through 2-way sync [configuration file](https://github.com/asus-linux-drivers/asus-numberpad-driver#configuration-file) (when is run `$ sudo bash ./install.sh` changes done in config file may not be overwritten, the same when is run `$ sudo bash ./uninstall.sh` and when config file or part of does not exist is automatically created/completed with default values)
- Automatic NumberPad model detection via [list of used NumberPad layouts for laptops](https://github.com/asus-linux-drivers/asus-numberpad-driver/blob/master/laptop_numpad_layouts) and when is available a connection via finding all other laptops on [linux-hardware.org](https://linux-hardware.org) which use the same version of NumberPad to which might be already in mentioned list associated proper layout
- Activation/deactivation of NumberPad via holding top right icon or every spot with key `KEY_NUMLOCK` (activation time by default 1s)
- Fast activation/deactivation of NumberPad via slide gesture beginning on top right icon (by default is required end slide after at least 30% of touchpad width and height)
Expand All @@ -43,6 +44,91 @@ If you find this project useful, do not forget to give it a [![GitHub stars](htt
- Disabling Touchpad (e.g. Fn+special key) disables by default NumberPad as well (*this functionality supports atm only `xinput` from `xorg` and `gnome` via `gsettings`*, can be disabled)
- Is recognized when is connected external keyboard and automatically is changed [configuration](https://github.com/asus-linux-drivers/asus-numberpad-driver#external-keyboard-configuration)

## Installation

Get latest dev version using `git`

```bash
$ git clone https://github.com/asus-linux-drivers/asus-numberpad-driver
$ cd asus-numberpad-driver
```

or download latest release (stable version) from [release page](https://github.com/asus-linux-drivers/asus-numberpad-driver/releases), extract and install like this for current user only or for all users

```bash
# try found touchpad with numberpad
$ bash install_device_check.sh
```

```bash
# install for current user
$ bash install.sh
```

or run separately parts of install script

- add user to newly created `numberpad` group which owns `/var/log/asus-numberpad-driver`

```bash
$ install_logs.sh
```

- add user to groups `i2c,input,uinput`

```bash
$ bash install_user_groups.sh
```

- install predefined rule for change configuration when is external keyboard connected/disconnected

```bash
$ export INSTALL_DIR_PATH="/usr/share/asus-numberpad-driver"
$ export CONFIG_FILE_DIR_PATH="$INSTALL_DIR_PATH"
$ export CONFIG_FILE_NAME="numberpad_dev"
$ export CONFIG_FILE_PATH="$CONFIG_FILE_DIR_PATH/$CONFIG_FILE_NAME"

$ bash install_external_keyboard_toggle.sh
```

- run driver now and every time when user log in (do NOT run as `$ sudo`, works via `systemctl`)

```bash
$ export CONFIG_FILE_DIR_PATH="/usr/share/asus-numberpad-driver"
$ export LAYOUT_NAME="up5401ea"

$ bash install_service.sh
```

- make work top left corner slide gesture as function for show/disable calculator app (script below supports `io.elementary.calculator` and `gnome-calculator` via `gsettings`)

```bash
#
$ bash install_calc_toggle.sh
```

or is available package for arch on AUR [here](https://aur.archlinux.org/packages?O=0&SeB=nd&K=asus-numberpad-driver&outdated=&SB=p&SO=d&PP=50&submit=Go) (replace model with available models, e.g. `asus-numberpad-driver-ux433fa-git`)

```bash
$ paru -S asus-numberpad-driver-${model}-git
```

## Uninstallation

And to uninstall run

```bash
bash uninstall.sh
```

or run separately parts of uninstall script

```bash
bash uninstall_calc_toggle.sh
bash uninstall_external_keyboard_toggle.sh
bash uninstall_external_service.sh
bash uninstall_user_groups.sh
```

## Layouts

| Model/Layout | Description | Image |
Expand Down Expand Up @@ -112,72 +198,31 @@ B: MSC=20

[Link](touchpad_product_id_info.md)

## Installation

Install latest dev version using `git`

```bash
git clone https://github.com/asus-linux-drivers/asus-numberpad-driver
cd asus-numberpad-driver
# install under current user (highly recommended)
sudo bash ./install.sh --user
# install as root
sudo bash ./install.sh
```

or download latest release (stable version) from [release page](https://github.com/asus-linux-drivers/asus-numberpad-driver/releases), extract and run:

```bash
# install as root
sudo bash ./install.sh
# install under current user (highly recommended)
sudo bash ./install.sh --user
```

or is available package for arch on AUR [here](https://aur.archlinux.org/packages?O=0&SeB=nd&K=asus-numberpad-driver&outdated=&SB=p&SO=d&PP=50&submit=Go) (replace model with available models, e.g. `asus-numberpad-driver-ux433fa-git`)

```bash
paru -S asus-numberpad-driver-${model}-git
```

## Uninstallation

And to uninstall, just run:

```bash
sudo bash ./uninstall.sh
# stop driver and uninstall for current user
sudo bash ./uninstall.sh --user
```

### Dependencies

**Everything is included in install script `sudo bash ./install.sh`**
**Everything is included in install scripts**

To see the exact commands for your package manager look [here](./install.sh) (for python dependencies take a look at [requirements.txt](./requirements.txt))

## Troubleshooting

- **Start point [x:0,y:0] of touchpad is on the left top!**
- **Before debugging make sure you have disabled the [email protected] service**
- **Before debugging make sure you have disabled the asus_numberpad_driver@.service**

```bash
# when installed for running under root (`sudo bash ./install.sh`)
sudo systemctl stop [email protected]
# when installed for running under current user (`sudo bash ./install.sh --user`)
sudo systemctl stop asus_touchpad_numpad@<user>.service
$ sudo systemctl stop asus_numberpad_driver@<$USER>.service
```

- To show debug logs run this command in terminal (**Do not forget specify numpad layout and which config do you want to use**):

```bash
# LOG=DEBUG sudo -E ./asus_touchpad.py <REQUIRED:numpad layout file name without extension .py> <OPTIONAL:directory where is located config file with name: asus_touchpad_numpad_dev, by default is taken CWD - current working directory, not existing config file is created and filled with default values>
# LOG=DEBUG ./numberpad.py <REQUIRED:numpad layout file name without extension .py> <OPTIONAL:directory where is located config file with name: numberpad_dev, by default is taken CWD - current working directory, not existing config file is created and filled with default values>

cd asus-numberpad-driver
LOG=DEBUG sudo -E ./asus_touchpad.py "up5401ea" "" # now driver use root of repository as directory for config file named asus_touchpad_numpad_dev
LOG=DEBUG ./numberpad.py "up5401ea" "" # now driver use root of repository as directory for config file named numberpad_dev which if does not exist will be autocreated with default values

cd asus-numberpad-driver
LOG=DEBUG sudo -E ./asus_touchpad.py "up5401ea" "/usr/share/asus_touchpad_numpad-driver/" # now driver use installed config
LOG=DEBUG ./numberpad.py "up5401ea" "/usr/share/asus-numberpad-driver/" # now driver use installed config
```

- To show pressed keys:
Expand Down Expand Up @@ -206,11 +251,11 @@ xdotool key XF86Calculator
# when is installed under current user (--user) sudo is not required

# enabling NumberPad via command line
sudo sed -i "s/enabled = 0/enabled = 1/g" asus_touchpad_numpad_dev
sudo sed -i "s/enabled = 0/enabled = 1/g" /usr/share/asus_touchpad_numpad-driver/asus_touchpad_numpad_dev
sudo sed -i "s/enabled = 0/enabled = 1/g" numberpad_dev
sudo sed -i "s/enabled = 0/enabled = 1/g" /usr/share/asus-numberpad-driver/numberpad_dev
# disabling
sudo sed -i "s/enabled = 1/enabled = 0/g" asus_touchpad_numpad_dev
sudo sed -i "s/enabled = 1/enabled = 0/g" /usr/share/asus_touchpad_numpad-driver/asus_touchpad_numpad_dev
sudo sed -i "s/enabled = 1/enabled = 0/g" numberpad_dev
sudo sed -i "s/enabled = 1/enabled = 0/g" /usr/share/asus-numberpad-driver/numberpad_dev
```

**Is any key from NumberPad not send properly?**
Expand Down Expand Up @@ -284,7 +329,7 @@ $ sudo install dconf-editor
$ gsettings set org.gnome.settings-daemon.plugins.media-keys calculator [\'\']
$ gsettings set org.gnome.settings-daemon.plugins.media-keys calculator-static [\'\']
```
- Whether script works can be tested via `bash /usr/share/asus_touchpad_numpad-driver/scripts/calculator_toggle.sh`
- Whether script works can be tested via `bash /usr/share/asus-numberpad-driver/scripts/calculator_toggle.sh`

- Whether keybinding works can be tested via slide gesture from NumberPad or via simulating `XF86Calculator` key `xdotool key XF86Calculator`

Expand Down Expand Up @@ -338,6 +383,13 @@ $ rm /home/ldrahnik/.Xauthority
$ reboot
```

**Read environment variables for systemctl service**

```
$ systemctl status <name>.service # read PID
$ sudo strings /proc/<PID>/environ
```

## Configuration

### Keyboard layout
Expand Down Expand Up @@ -386,7 +438,7 @@ Example: If you want to set the size of top right icon to bigger and you have ch

### Configuration file

What is not depending on specific keyboard of Numpad is mentioned in table below and can be changed in config file `asus_touchpad_numpad_dev` (dev as device interface because is here saved even status enabled of NumberPad, latest used brightness) in installed driver location `/usr/share/asus_touchpad_numpad-driver/asus_touchpad_numpad_dev`. Example default one:
What is not depending on specific keyboard of Numpad is mentioned in table below and can be changed in config file `numberpad_dev` (dev as device interface because is here saved even status enabled of NumberPad, latest used brightness) in installed driver location `/usr/share/asus-numberpad-driver/numberpad_dev`. Example default one:

```
[main]
Expand Down
15 changes: 15 additions & 0 deletions asus_numberpad_driver.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Asus NumberPad Driver

[Service]
Type=simple
ExecStart=/usr/bin/env python3 /usr/share/asus-numberpad-driver/numberpad.py $LAYOUT_NAME $CONFIG_FILE_DIR_PATH
StandardOutput=append:$ERROR_LOG_FILE_PATH
StandardError=append:$ERROR_LOG_FILE_PATH
TimeoutSec=5
Restart=on-failure
Environment="DISPLAY=$DISPLAY"
Environment="DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"

[Install]
WantedBy=default.target
17 changes: 17 additions & 0 deletions asus_numberpad_driver.x11.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Asus NumberPad Driver

[Service]
Type=simple
ExecStart=/usr/bin/env python3 /usr/share/asus-numberpad-driver/numberpad.py $LAYOUT_NAME $CONFIG_FILE_DIR_PATH
StandardOutput=append:$ERROR_LOG_FILE_PATH
StandardError=append:$ERROR_LOG_FILE_PATH
TimeoutSec=5
Restart=on-failure
Environment="DISPLAY=$DISPLAY"
Environment="XAUTHORITY=$XAUTHORITY"
Environment="DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"
Environment="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"

[Install]
WantedBy=default.target
18 changes: 0 additions & 18 deletions asus_touchpad.X11.service

This file was deleted.

15 changes: 0 additions & 15 deletions asus_touchpad.service

This file was deleted.

Loading