Skip to content

feat: add native WSL (Ubuntu) support#9

Closed
dhruvkej9 wants to merge 1 commit intoFinesssee:mainfrom
dhruvkej9:feat/wsl-support
Closed

feat: add native WSL (Ubuntu) support#9
dhruvkej9 wants to merge 1 commit intoFinesssee:mainfrom
dhruvkej9:feat/wsl-support

Conversation

@dhruvkej9
Copy link
Copy Markdown

Summary

Adds native WSL/Linux support so CodexBar runs inside Windows Subsystem for Linux — following the same pattern as the OpenAI Codex CLI's WSL integration.

What's new

WSL Environment Detection (rust/src/wsl.rs)

  • Detects WSL via /proc/version, WSL_DISTRO_NAME env, and /run/WSL
  • Resolves the Windows username from /mnt/c/Users/
  • Converts Windows paths (C:\Users\...) to WSL paths (/mnt/c/Users/...)

WSL-Aware Browser Detection (rust/src/browser/wsl_paths.rs)

  • Reads Windows browser profiles from /mnt/c/Users/<user>/AppData/Local/...
  • Supports Chrome, Edge, Brave, Arc, Chromium, and Firefox
  • Merges with native detection to avoid duplicates

Cookie Extraction for WSL

  • Reads Chromium/Firefox cookie databases from Windows mount paths
  • Provides clear error messages explaining DPAPI limitations in WSL
  • Guides users to manual cookies or CLI-based auth as alternatives

Linux Notifications

  • Uses notify-send for native desktop notifications
  • Falls back to Windows toast via powershell.exe in WSL

Build & Dev Experience

  • dev.sh — Linux/WSL build script with auto-detection and CLI fallback
  • winreg moved to Windows-only dependency (fixes Linux compilation)
  • Graceful degradation when no display server is detected

WSL Auth Quick Reference

Provider Strategy
Codex npm i -g @openai/codexcodex login (inside WSL)
Claude npm i -g @anthropic-ai/claude-codeclaude login (inside WSL)
Cursor/Kimi Manual cookies — paste from browser DevTools
Copilot GitHub Device Flow works natively

Files changed

 rust/src/wsl.rs                  — WSL detection module (NEW)
 rust/src/browser/wsl_paths.rs    — WSL browser path resolution (NEW)
 dev.sh                           — Linux/WSL build script (NEW)
 rust/src/main.rs                 — Conditional compilation, WSL logging
 rust/src/browser/mod.rs          — Added wsl_paths module
 rust/src/browser/detection.rs    — WSL-aware browser detection
 rust/src/browser/cookies.rs      — Better DPAPI error for WSL
 rust/src/notifications.rs        — Linux notify-send support
 rust/Cargo.toml                  — winreg moved to Windows-only deps
 README.md                        — WSL documentation section

Testing

  • Compiles on Linux (gated all Windows APIs with #[cfg(windows)])
  • WSL detection works via /proc/version parsing
  • Browser paths resolve correctly via /mnt/c/ mapping
  • CLI commands work without display server
  • Notifications use notify-send on Linux

How it mirrors Codex's WSL approach

The OpenAI Codex docs recommend:

  1. Install WSL with wsl --install
  2. Install Node.js inside WSL via nvm
  3. Install and run the CLI natively inside the Linux environment
  4. Keep repositories under ~/code/ for best performance

CodexBar follows the same pattern: the CLI works natively in WSL, provider CLIs (codex, claude) authenticate inside the Linux environment, and the GUI works via WSLg when available.

Add full WSL/Linux support so CodexBar runs natively inside Windows
Subsystem for Linux, following the same pattern as the official
OpenAI Codex CLI's WSL integration.

Changes:
- Add WSL environment detection module (wsl.rs) with distro/user resolution
- Add WSL-aware browser path resolution via /mnt/c/ (wsl_paths.rs)
- Update browser detection to find Windows browsers from WSL
- Add informative DPAPI error messages for WSL cookie extraction
- Add Linux notification support via notify-send with PowerShell fallback
- Move winreg to Windows-only dependencies (compilation fix)
- Add dev.sh build script for Linux/WSL with auto CLI fallback
- Update README with WSL setup docs and auth tips

WSL users can:
- Run CLI commands: codexbar usage -p <provider>
- Use GUI with WSLg (Windows 11)
- Extract cookies manually (Settings → Cookies)
- Authenticate providers natively (codex login, claude login)

DPAPI-encrypted Chromium cookies cannot be auto-extracted in WSL;
manual cookies or CLI-based auth are recommended instead.

Co-Authored-By: OpenClaw <openclaw@openclaw.ai>
@Finesssee
Copy link
Copy Markdown
Owner

Hey thanks for the pull request, I will check on this rn

Finesssee added a commit that referenced this pull request Mar 24, 2026
Port WSL detection, browser path resolution, and cross-platform
notifications from PR #9, with the following fixes over the original:

- Move cross-platform deps (rusqlite, aes-gcm, keyring, dirs, etc.)
  from cfg(windows) to shared [dependencies] so native Linux builds work
- Fix dev.sh to use --target from rustc host instead of relying on
  .cargo/config.toml (which defaults to x86_64-pc-windows-msvc)
- Use cfg_attr(windows, windows_subsystem) instead of separate attrs
- Fix Gemini auth hint in README (was incorrectly showing claude-code)
- Remove dead WslBrowserDetector::should_use() method
- Remove WSL PowerShell MessageBox fallback (blocking modal, bad UX)
- Fix clippy collapsible-if in wsl.rs

New modules: wsl.rs, browser/wsl_paths.rs
Modified: main.rs, notifications.rs, browser/{mod,detection,cookies}.rs,
          Cargo.toml, README.md
New script: dev.sh (Linux/WSL build + run)

Made-with: Cursor
@Finesssee
Copy link
Copy Markdown
Owner

Thanks for this PR! We've ported the WSL support changes into main (commit ebb760a) with the following additional fixes:

  • Moved cross-platform deps (rusqlite, aes-gcm, keyring, dirs, etc.) from cfg(windows) to shared [dependencies] — the original PR only moved winreg, but native Linux builds still failed without the rest
  • Fixed dev.sh to detect the native host target via rustc -vV instead of relying on .cargo/config.toml (which defaults to x86_64-pc-windows-msvc)
  • Fixed #![windows_subsystem] to use cfg_attr(windows, ...) — the #[cfg(windows)] before #![...] form doesn't work correctly
  • Fixed Gemini auth in README (was showing claude-code install instead of gcloud)
  • Removed the PowerShell MessageBox::Show fallback — it's a blocking modal dialog, not a toast notification
  • Removed dead should_use() method from WslBrowserDetector
  • Fixed clippy warning (collapsible if)

All 181 tests pass on Linux, Windows cross-compile verified. Closing this PR since the changes are now on main. Thanks again!

@Finesssee Finesssee closed this Mar 24, 2026
@dhruvkej9
Copy link
Copy Markdown
Author

Thanks for this PR! We've ported the WSL support changes into main (commit ebb760a) with the following additional fixes:

  • Moved cross-platform deps (rusqlite, aes-gcm, keyring, dirs, etc.) from cfg(windows) to shared [dependencies] — the original PR only moved winreg, but native Linux builds still failed without the rest
  • Fixed dev.sh to detect the native host target via rustc -vV instead of relying on .cargo/config.toml (which defaults to x86_64-pc-windows-msvc)
  • Fixed #![windows_subsystem] to use cfg_attr(windows, ...) — the #[cfg(windows)] before #![...] form doesn't work correctly
  • Fixed Gemini auth in README (was showing claude-code install instead of gcloud)
  • Removed the PowerShell MessageBox::Show fallback — it's a blocking modal dialog, not a toast notification
  • Removed dead should_use() method from WslBrowserDetector
  • Fixed clippy warning (collapsible if)

All 181 tests pass on Linux, Windows cross-compile verified. Closing this PR since the changes are now on main. Thanks again!

Can it now run inside windows and detect WSL and fetch data from there and show in the windows GUI itself?

Because nobody likes the WSL GUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants