Metadata-Version: 2.4
Name: wslenv
Version: 0.1.0
Summary: Script to investigate environment variables useful in WSL if missing
Author: Michael Dubner
Author-email: pywebmail@list.ru
Requires-Python: >=3.12
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Description-Content-Type: text/markdown

# wslenv

`wslenv` is a small helper script intended to populate and print environment variables that are useful when running inside **WSL (Windows Subsystem for Linux)** - especially when those variables are missing.

It detects WSL, prepares distro info, configures interop, and merges the Windows `PATH`. Optionally, it prepares WSLg-related GUI variables.

At the end, it prints shell-ready `export` commands for any variables it had to set.

## Why you need it

There are situations where you end up inside a WSL distribution without the expected interop variables - for example, when you log into it via SSH.

## Install

If you want it only as a program available in your `PATH`, use `pipx`:

```sh
pipx install wslenv
```

If you want to have development version:

```console
$ git clone https://github.com/pyhedgehog/wslenv.git
$ cd wslenv
$ pipx install -e .
```

## Usage

Typical usage is to evaluate wslenv output in your shell or in your script (i.e. in `~/.profile`:

```sh
eval "$(wslenv)"
```

If you want to skip WSLg variables:

```sh
eval "$(wslenv --no-gui)"
```

## What it sets

### Core WSL variables

- `WSL_INTEROP` - detects the nearest parent WSL interop relay
- `WSL_DISTRO_NAME` - uses `wslpath -w /`
- `WSLENV` - gets Windows `WSLENV` or sets it to empty
- `PATH` - merges Windows `PATH` entries into the Linux `PATH` (avoids duplicates)

### Optional WSLg variables (GUI apps)

When GUI support is detected and `--no-gui` / `--no-wslg` is not used:

- `WAYLAND_DISPLAY`
- `PULSE_SERVER`
- `XDG_RUNTIME_DIR`
- `DISPLAY`
- `WSL2_GUI_APPS_ENABLED`

## Notes

The script relies on WSL interop utilities:

- `wslpath`
- `wslinfo`
- `cmd.exe /c set`

## TODO

- Import from Windows variables mentioned in inherited or imported `WSLENV`.
- Make OS packages (at least for Alpine).
- Make minimal version - i.e. without python dependencies (shell or compilable - C/Ninja/Rust/...).

