Skip to content

Commit

Permalink
Add Python3 release.
Browse files Browse the repository at this point in the history
Add Python3 poetry env.
Add aarch64 build.
Add build.sh.
  • Loading branch information
meganerd committed Apr 5, 2024
1 parent 2d7377b commit d36483e
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# night-vision
Virtual cursor for LXC Containers running X11 display

### Usage

```bash
$ ./night-vision {ms}
```

`{ms}` Milliseconds delay between cursor iteration, default: 100

```bash
# 50-ms delay is fine, 10-100 is probably the expected range
$ ./night-vision 50
# 1-ms delay, uses more CPU resource naturally
$ ./night-vision 1
```

### Building
You can use a pre-made build or run:
```bash
$ g++ night-vision.cpp -o ./build/night-vision -lX11
```

### Python
There is also a python release of night-vision in `./python`
It uses more CPU resource, but is still viable at 100-ms delay

The `./python` directory also includes a poetry virtual environment
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
g++ night-vision.cpp -o ./build/night-vision -lX11
sha256sum ./build/night-vision > ./build/night-vision.sha256
md5sum ./build/night-vision > ./build/night-vision.md5
Binary file added build/aarch64/night-vision
Binary file not shown.
1 change: 1 addition & 0 deletions build/aarch64/night-vision.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ba3b4c3f23c5fb99201568d4f48b8ce9 ./build/night-vision
1 change: 1 addition & 0 deletions build/aarch64/night-vision.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
89d70e3e56c6afb811ae6fe35e545db70508487c6df22240b4b7ce5749a7d397 ./build/night-vision
31 changes: 31 additions & 0 deletions python/night-vision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from Xlib import X, display
import time

d = display.Display()
root = d.screen().root

window = root.create_window(-10, -10, 20, 20, 1, X.CopyFromParent,
X.InputOutput, X.CopyFromParent,
background_pixel=d.screen().white_pixel,
override_redirect=True)

gc = window.create_gc()

window.map()

def draw_crosshair():
window.clear_area(0, 0, 20, 20)
window.line(gc, 10, 0, 10, 20)
window.line(gc, 0, 10, 20, 10)

while True:
pointer = root.query_pointer()
x, y = pointer.root_x, pointer.root_y

window.configure(x=x - 10, y=y - 10)

draw_crosshair()

d.flush()

time.sleep(0.1)
16 changes: 16 additions & 0 deletions python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "night-vision"
version = "0.1.0"
description = "Virtual cursor for LXC Containers running X11 display, Python release build"
authors = ["meganerd <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
python3-xlib = "^0.15"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit d36483e

Please sign in to comment.