Skip to content

Commit

Permalink
fix readme for the new format
Browse files Browse the repository at this point in the history
  • Loading branch information
acro5piano committed Dec 12, 2021
1 parent f548c31 commit 06d27c9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
69 changes: 39 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ I was looking for something similar to `xremap` for Wayland, but not found, so I

```bash
sudo pip install wayremap

# For beta version
sudo pip3 install git+https://github.com/acro5piano/wayremap

```

# Run
Expand All @@ -34,6 +38,7 @@ Simply write your own service and run it as python script:

from wayremap.config import WayremapConfig, Binding
from wayremap.main import run
from wayremap import ecodes as e
import uinput as k

wayremap_config = WayremapConfig(
Expand All @@ -46,32 +51,36 @@ wayremap_config = WayremapConfig(
],
bindings=[
# Emacs-like key binding
Binding('ctrl.alt.a', [[k.KEY_LEFTCTRL, k.KEY_HOME]]),
Binding('ctrl.alt.e', [[k.KEY_LEFTCTRL, k.KEY_END]]),
Binding('ctrl.alt.h', [[k.KEY_LEFTCTRL, k.KEY_BACKSPACE]]),
Binding('ctrl.f', [[k.KEY_RIGHT]]),
Binding('ctrl.b', [[k.KEY_LEFT]]),
Binding('ctrl.p', [[k.KEY_UP]]),
Binding('ctrl.n', [[k.KEY_DOWN]]),
Binding('ctrl.k',
Binding([e.KEY_LEFTCTRL, e.KEY_LEFTALT, e.KEY_A],
[[k.KEY_LEFTCTRL, k.KEY_HOME]]),
Binding([e.KEY_LEFTCTRL, e.KEY_LEFTALT, e.KEY_E],
[[k.KEY_LEFTCTRL, k.KEY_END]]),
Binding([e.KEY_LEFTCTRL, e.KEY_LEFTALT, e.KEY_H],
[[k.KEY_LEFTCTRL, k.KEY_BACKSPACE]]),
Binding([e.KEY_LEFTCTRL, e.KEY_F], [[k.KEY_RIGHT]]),
Binding([e.KEY_LEFTCTRL, e.KEY_B], [[k.KEY_LEFT]]),
Binding([e.KEY_LEFTCTRL, e.KEY_P], [[k.KEY_UP]]),
Binding([e.KEY_LEFTCTRL, e.KEY_N], [[k.KEY_DOWN]]),
Binding([e.KEY_LEFTCTRL, e.KEY_K],
[[k.KEY_LEFTSHIFT, k.KEY_END], [k.KEY_LEFTCTRL, k.KEY_X]]),
Binding('ctrl.a', [[k.KEY_HOME]]),
Binding('ctrl.e', [[k.KEY_END]]),
Binding('ctrl.y', [[k.KEY_LEFTCTRL, k.KEY_V]]),
Binding('alt.f', [[k.KEY_LEFTCTRL, k.KEY_RIGHT]]),
Binding('alt.b', [[k.KEY_LEFTCTRL, k.KEY_LEFT]]),
Binding('alt.d', [[k.KEY_LEFTCTRL, k.KEY_DELETE]]),
Binding('ctrl.h', [[k.KEY_BACKSPACE]]),
Binding('ctrl.s', [[k.KEY_LEFTCTRL, k.KEY_F]]),
Binding([e.KEY_LEFTCTRL, e.KEY_A], [[k.KEY_HOME]]),
Binding([e.KEY_LEFTCTRL, e.KEY_E], [[k.KEY_END]]),
Binding([e.KEY_LEFTCTRL, e.KEY_Y], [[k.KEY_LEFTCTRL, k.KEY_V]]),
Binding([e.KEY_LEFTALT, e.KEY_F], [[k.KEY_LEFTCTRL, k.KEY_RIGHT]]),
Binding([e.KEY_LEFTALT, e.KEY_B], [[k.KEY_LEFTCTRL, k.KEY_LEFT]]),
Binding([e.KEY_LEFTALT, e.KEY_D], [[k.KEY_LEFTCTRL, k.KEY_DELETE]]),
Binding([e.KEY_LEFTCTRL, e.KEY_H], [[k.KEY_BACKSPACE]]),
Binding([e.KEY_LEFTCTRL, e.KEY_D], [[k.KEY_DELETE]]),
Binding([e.KEY_LEFTCTRL, e.KEY_S], [[k.KEY_LEFTCTRL, k.KEY_F]]),


# OSX-like key binding
Binding('alt.a', [[k.KEY_LEFTCTRL, k.KEY_A]]),
Binding('alt.c', [[k.KEY_LEFTCTRL, k.KEY_C]]),
Binding('alt.v', [[k.KEY_LEFTCTRL, k.KEY_V]]),
Binding('alt.x', [[k.KEY_LEFTCTRL, k.KEY_X]]),
Binding([e.KEY_LEFTALT, e.KEY_A], [[k.KEY_LEFTCTRL, k.KEY_A]]),
Binding([e.KEY_LEFTALT, e.KEY_C], [[k.KEY_LEFTCTRL, k.KEY_C]]),
Binding([e.KEY_LEFTALT, e.KEY_V], [[k.KEY_LEFTCTRL, k.KEY_V]]),

# Slack helm!
Binding('alt.x', [[k.KEY_LEFTCTRL, k.KEY_K]]),
Binding([e.KEY_LEFTALT, e.KEY_X], [[k.KEY_LEFTCTRL, k.KEY_K]]),
])

run(wayremap_config, '/dev/input/event4')
Expand All @@ -87,15 +96,15 @@ sudo python /opt/wayremap.py

Please note that

- modifier keys are `ctrl` or `alt` or both
- modifier keys are `KEY_LEFTCTRL` or `KEY_LEFTALT`, or both. Neither `shift` nor `super` is not implemented yet.
- `'/dev/input/event4'` varies among system.

# Enable wayremap as systemd service
# Enable wayremap as a systemd service

```bash
echo uinput | sudo tee /etc/modules-load.d/wayremap.conf # Add uinput to dependent linux modules
echo uinput | sudo tee /etc/modules-load.d/wayremap.conf # Add uinput to auto-loaded linux modules
sudo vim /etc/wayremap.config.py # Edit your config
sudo cp systemd/wayremap.service /etc/systemd/system/wayremap.service
sudo cp ./systemd/wayremap.service /etc/systemd/system/wayremap.service
sudo systemctl enable wayremap
sudo reboot
```
Expand All @@ -107,8 +116,8 @@ sudo reboot

# Roadmap

- Support `shift` key too.
- Enable to run wihtout Sway.
- Packaging for Arch Linux, Debian, Fedora, etc.
- Enable to load per-application config.
- Re-write in Rust for better performance.
- [x] Enable to run wihtout Sway.
- [ ] Support `shift` and `super` keys too.
- [ ] Packaging for Arch Linux, Debian, Fedora, etc.
- [ ] Enable to load per-application config.
- [ ] Re-write in Rust for better performance.
2 changes: 1 addition & 1 deletion wayremap/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
import uinput as k
import wayremap.ecodes as e
from wayremap import ecodes as e
from wayremap import constants


Expand Down

0 comments on commit 06d27c9

Please sign in to comment.