4.0 KiB
4.0 KiB
Linux Port Plan (Botty)
Goal
Make Botty runnable on Linux in phased steps, with clear checkpoints and minimal regressions for current Windows users.
Current status
Botty is currently Windows-first. Full gameplay flow does not run on Linux due to:
- Windows input stack (
win_input, Win32 hotkey polling). - Windows process/window management (
taskkill, Win32 window APIs,os.startfile). - Windows dependency assumptions (
pywin32, Windows tesserocr wheel guidance). - Windows path/env assumptions (
APPDATA,C:\...,D2R.exe,.batscripts).
Principles
- Keep Windows behavior unchanged while adding Linux support.
- Introduce platform abstractions before replacing implementations.
- Land small, testable phases.
- Prefer graceful
NotImplementedbehavior over hard crashes on unsupported paths.
Phase 1: Platform abstraction layer
- Add a
platform_adaptermodule with interfaces for:- Input (keyboard/mouse send + hotkeys)
- Window management (find game window, set top-most, geometry)
- Process control (start/stop/check D2R/Battle.net)
- Route existing Windows calls through adapters.
- Add Linux stub implementations that fail gracefully with actionable logs.
- Add unit tests for adapter selection and fallback behavior.
Phase 2: Linux-safe startup and tooling
- Add Linux entry script (
run_botty.sh) and dependency checker shell script. - Update startup to avoid Windows-only calls unless platform is Windows.
- Normalize path handling to
pathlibwhere feasible. - Ensure
main.pycan start on Linux without immediate import/runtime crashes.
Phase 3: Linux input backend
- Implement Linux input backend (X11/Wayland-compatible strategy):
- Candidate libs:
pynput,python-xlib, or tool-backed approach (xdotoolfor X11).
- Candidate libs:
- Match required Botty features:
- Key press/hold/release
- Mouse move/click with jitter and timing controls
- Hotkey registration/polling
- Add integration tests/mocks for input primitives.
Phase 4: Linux screen/window backend
- Validate capture compatibility for
mssunder target Linux desktop/session. - Implement Linux window discovery/focus/geometry handling.
- Rework DPI/coordinate normalization independent of Win32 APIs.
- Add diagnostics tool to verify coordinates, capture ROI, and template matching on Linux.
Phase 5: Process and launcher integration
- Linux-compatible process management (replace
taskkillpaths). - Replace
os.startfilelauncher logic with cross-platform process spawning. - Add platform-specific config defaults for game executable path conventions.
Phase 6: Dependency and OCR strategy
- Split dependencies by platform (base + windows extras + linux extras).
- Document Linux OCR setup (tesseract/leptonica packages + python bindings).
- Add CI matrix entries:
- Windows: full current pipeline
- Linux: import/startup + unit/integration subset first, expand later
Phase 7: Feature parity validation
- Verify end-to-end flows:
- Start game, run cycle, maintenance, save/exit, restart handling
- Validate pickit, stash/sell, discord messaging, stats logging.
- Benchmark timing-sensitive routines and tune Linux defaults.
Risk register
- Wayland restrictions can block synthetic input/screen capture depending on compositor.
- Template matching thresholds may differ due to capture pipeline differences.
- Hotkey handling behavior can differ across desktop environments.
- OCR reliability can vary based on font rendering stack.
Suggested delivery milestones
- M1: Linux no-crash startup + stubs + docs.
- M2: Linux input backend functional in sandbox diagnostics.
- M3: Linux screen/window backend and maintenance loop stable.
- M4: End-to-end run support in supported Linux environments.
Acceptance criteria
- Botty starts on Linux and logs clear capability status.
- No Windows-only hard failures on Linux code paths.
- Core run loop can execute in a supported Linux environment.
- Windows behavior remains stable and covered by existing tests/CI.