Skip to content
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
30 changes: 30 additions & 0 deletions .github/workflows/deploy-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy Pages
on:
push:
paths:
- 'docs/**'
branches:
- master
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# WayKey

![Image](./docs/assets/WayKey.svg)

![CI](https://github.com/Nmstr/WayKey/actions/workflows/run-ruff.yaml/badge.svg)
![GitHub License](https://img.shields.io/github/license/Nmstr/WayKey)

Expand Down
70 changes: 70 additions & 0 deletions docs/assets/WayKey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Cli

The WayKey CLI consists of 5 main components (`press`, `release`, `click`, `mouse_move` and `device`). Each component will be described in detail below.

# Press

Press takes one key code as an argument and presses the corresponding key. The key will not be released automatically (refer to `release` to release the key again).
Optionally, a device can be specified with the `-d` flag.

Examples:
```bash
waykey press KEY_A
waykey press KEY_A -d ~/path/to/device.json
```

# Release

Release takes one key code as an argument and releases the corresponding key. The key must have been pressed before for this to have an effect (refer to `press` to press the key).
Optionally, a device can be specified with the `-d` flag.

Examples:
```bash
waykey release KEY_A
waykey release KEY_A -d ~/path/to/device.json
```

# Click

Click takes one key code as an argument and clicks the corresponding key by both pressing and automatically releasing it after a short delay.
Optionally, a device can be specified with the `-d` flag.
It also has an optional `--delay` flag to specify the delay between pressing and releasing the key in seconds (default is 0s).

Examples:
```bash
waykey click KEY_A
waykey click KEY_A -d ~/path/to/device.json
waykey click KEY_A --delay 0.5
waykey click KEY_A -d ~/path/to/device.json --delay 0.5
```

# Mouse Move

Mouse Move takes two arguments, `x` and `y`, which specify the position to move the mouse to (absolute movement) or the distance to move the mouse by (relative movement).
By default, the movement is relative. Absolute movement can be enabled with the `--absolute` flag.
The mouse wheel can be scrolled with the `-w` flag, which takes an integer argument. It is not possible to combine wheel movement with absolute mouse movement.
Optionally, a device can be specified with the `-d` flag.

Examples:
```bash
waykey mouse_move 100 100
waykey mouse_move 100 100 -d ~/path/to/device.json
waykey mouse_move 100 100 --absolute
waykey mouse_move 100 100 --absolute -d ~/path/to/device.json
waykey mouse_move 0 0 -w 100
waykey mouse_move 0 0 -w 100 -d ~/path/to/device.json
waykey mouse_move 200 200 -w -100
```

# Device

The device component is used to manage virtual input devices. It has 3 subcomponents (`list`, `load` and `unload`). Each subcomponent will be described in detail below.

## List

List lists all currently loaded virtual input devices. The list shows the device ID and Name.

Examples:
```bash
waykey device list
```

## Load

Load takes the ID of a device as an argument and attempts to load that device.

Examples:
```bash
waykey device load my_device_id
```

## Unload

Unload takes the ID of a device as an argument and attempts to unload that device.

Examples:
```bash
waykey device unload my_device_id
```
44 changes: 44 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# WayKey

![Image](./assets/WayKey.svg)

WayKey is a wayland automation tool.

# Installation

## Manual (Recommended)

1. Clone the repository:
```bash
git clone git@github.com:Nmstr/WayKey.git
cd WayKey
```

2. Install dependencies:
```bash
uv sync
```

3. Create links:
```bash
sudo ln -s $(pwd)/WayKey/cli/run.sh /usr/bin/waykey
sudo ln -s $(pwd)/WayKey/daemon/run.sh /usr/bin/waykeyd
```

# Basic Usage

Start the daemon:
```bash
waykeyd
# or
sudo waykeyd
```

Click a Key:
```bash
waykey click KEY_A
# or
sudo waykey click KEY_A
```

Whether to use `sudo` or not depends on your system configuration.
111 changes: 111 additions & 0 deletions docs/library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Library

The WayKey library provides a python interface to interact with the WayKey daemon. It mirrors the functionality of the CLI, but is much more performant.

# Building

```bash
uv build
```

# Usage

## Importing

```python
import WayKey as wk
```

## Press

Presses a key.

Arguments:
- `code` (str | int): The key code to press (e.g. "KEY_A" or 42).
- `device_id` (str, optional): ID of the device. If not provided, the default device will be used.

```python
wk.press("KEY_A") # The integer key code can also be used directly
wk.press("KEY_A", device_id="my_device_id")
```

## Release

Releases a key.

Arguments:
- `code` (str | int): The key code to release (e.g. "KEY_A" or 42).
- `device_id` (str, optional): ID of the device. If not provided, the default device will be used.

```python
wk.release("KEY_A") # The integer key code can also be used directly
wk.release("KEY_A", device_id="my_device_id")
```

## Click

Clicks a key by pressing and releasing it.

Arguments:
- `code` (str | int): The key code to click (e.g. "KEY_A" or 42).
- `device_id` (str, optional): ID of the device. If not provided, the default device will be used.
- `delay` (float, optional): Delay between pressing and releasing the key in seconds. Default is 0.

```python
wk.click("KEY_A") # The integer key code can also be used directly
wk.click("KEY_A", device_id="my_device_id")
wk.click("KEY_A", delay=0.5)
wk.click("KEY_A", device_id="my_device_id", delay=0.5)
```

## Mouse Move

Moves the mouse either absolutely or relatively, and can also scroll the mouse wheel.

Arguments:
- `x` (int): The x position to move the mouse to (absolute movement) or the distance to move the mouse by (relative movement).
- `y` (int): The y position to move the mouse to (absolute movement) or the distance to move the mouse by (relative movement).
- `w` (int, optional): Amount to scroll the mouse wheel. Default is 0 (no scrolling). This can not be used with absolute movement.
- `absolute` (bool, optional): Whether to use absolute movement. Default is False (relative movement).
- `device_id` (str, optional): ID of the device. If not provided, the default device will be used.

```python
wk.mouse_move(100, 100)
wk.mouse_move(100, 100, device_id="my_device_id")
wk.mouse_move(100, 100, absolute=True)
wk.mouse_move(100, 100, absolute=True, device_id="my_device_id")
wk.mouse_move(0, 0, w=100)
wk.mouse_move(0, 0, w=100, device_id="my_device_id")
wk.mouse_move(200, 200, w=-100)
```

## Get Devices

Returns a dictionary of all available devices.

```python
devices = wk.get_devices()
print(devices)
```

## Load Device

Loads a device by its ID.

Arguments:
- `device_id` (str): ID of the device to load.

```python
wk.load_device("my_device_id")
```

## Unload Device

Unloads a device by its ID.

Arguments:
- `device_id` (str): ID of the device to unload.

```python
wk.unload_device("my_device_id")
```
33 changes: 33 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
site_name: WayKey
site_url: https://nmstr.github.io/WayKey/
theme:
name: "material"
logo: "assets/WayKey.svg"
favicon: "assets/WayKey.svg"
features:
- navigation.tabs
- navigation.expand
palette:
- scheme: slate
toggle:
icon: material/brightness-4
name: Switch to light mode
- scheme: default
toggle:
icon: material/brightness-7
name: Switch to dark mode

markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences

extra:
social:
- icon: fontawesome/brands/github
link: https://github.com/Nmstr/WayKey

nav:
- Home: "index.md"
- Cli: "cli.md"
- Library: "library.md"
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ source-exclude = [
"daemon",
"cli"
]

[dependency-groups]
dev = [
"mkdocs-material>=9.6.18",
]
Loading