Migrate to Python daemon

This commit is contained in:
Thales Maciel 2026-02-07 15:12:17 -03:00
parent 49ef349d48
commit d81f3dbffe
42 changed files with 660 additions and 1816 deletions

View file

@ -1,6 +1,6 @@
# lel
X11 transcription daemon that records audio, runs Whisper, logs the transcript, and can optionally run AI post-processing before injecting text.
Python X11 transcription daemon that records audio, runs Whisper, logs the transcript, and can optionally run AI post-processing before injecting text.
## Requirements
@ -8,12 +8,22 @@ X11 transcription daemon that records audio, runs Whisper, logs the transcript,
- `ffmpeg`
- `whisper` (OpenAI Whisper CLI)
- `xclip`
- `xdotool`
- Tray icon deps: `libappindicator3` and `gtk3` (required by `systray`)
- Python deps: `pystray`, `pillow`, `python-xlib`, `ollama`, `openai-whisper`
## Build
## Python Daemon
Install Python deps:
```bash
make build
pip install -r src/requirements.txt
```
Run:
```bash
python3 src/leld.py --config ~/.config/lel/config.json
```
## Config
@ -56,23 +66,11 @@ Env overrides:
- `LEL_AI_ENABLED`, `LEL_AI_PROVIDER`, `LEL_AI_MODEL`, `LEL_AI_TEMPERATURE`, `LEL_AI_SYSTEM_PROMPT_FILE`
- `LEL_AI_BASE_URL`, `LEL_AI_API_KEY`, `LEL_AI_TIMEOUT_SEC`
## Run manually
```bash
./leld --config ~/.config/lel/config.json
```
Disable the tray icon:
```bash
./leld --no-tray
```
## systemd user service
```bash
mkdir -p ~/.local/bin
cp leld lelctl ~/.local/bin/
cp src/leld.py ~/.local/bin/leld.py
cp systemd/lel.service ~/.config/systemd/user/lel.service
systemctl --user daemon-reload
systemctl --user enable --now lel
@ -84,10 +82,6 @@ systemctl --user enable --now lel
- Press it again to stop and transcribe.
- The transcript is logged to stderr.
Execution flow (single in-flight state machine):
- `recording` -> `transcribing` -> `processing` (optional) -> `outputting` -> `idle`
Injection backends:
- `clipboard`: copy to clipboard and inject via Ctrl+V (requires `xclip` + `xdotool`)
@ -95,19 +89,10 @@ Injection backends:
AI providers:
- `ollama`: calls the local Ollama HTTP API (`/api/generate`)
- `openai_compat`: calls a chat-completions compatible API (`/v1/chat/completions`)
Dependency checks:
- Recording requires `ffmpeg` (or set `ffmpeg_path`)
- Transcribing uses the `whisper` CLI
- Outputting requires `xclip` (and `xdotool` for injection backends)
- `ollama`: calls the local Ollama API
Control:
```bash
lelctl status
lelctl reload
lelctl stop
make run
```