feat: production-ready Linux & macOS support
- Add `linux` (dbus-python, PyGObject, python-xlib) and `macos`
(pyobjc) extras to pyproject.toml with sys_platform markers; move
cross-platform screen-brightness-control + monitorcontrol to base deps.
- build-dist-linux.sh: install `.[linux]`, pkg-config pre-flight for
dbus-1/glib-2.0, emit a systemd unit with DBUS_SESSION_BUS_ADDRESS +
XDG_RUNTIME_DIR + ReadWritePaths for ~/.config and ~/.cache so MPRIS
works and audit-log / thumbnail writes aren't blocked by ProtectHome.
- New build-dist-macos.sh + per-user LaunchAgent installer producing
MediaServer-vX.Y-macos-{arm64,x86_64}.tar.gz.
- Templated media-server.service updated to match the dist layout with
proper session-bus env vars and a writable state-dir grant.
- install_linux.sh: drop dead requirements.txt path; install via
`pip install ".[linux]"` and pre-create the writable state dirs.
- Cross-platform album artwork: abstract MediaController.get_album_art()
with Linux (mpris:artUrl, file:// + http(s)://) and macOS (Spotify URL)
impls; routes/media artwork endpoint now awaits the controller.
- LinuxMediaController connects to the session bus lazily — failure no
longer crashes lifespan startup; MPRIS calls return idle until the bus
is reachable. Logged once at INFO with a hint about
`loginctl enable-linger`.
- Startup preflight on Linux warns if DBUS_SESSION_BUS_ADDRESS or
XDG_RUNTIME_DIR is unset and informs the user when Wayland disables
the foreground probe.
- /api/media/visualizer/status now reports a per-OS unavailable_reason.
- tray._confirm guarded against ctypes.windll on non-Windows.
- config.example.yaml: per-OS commented script examples; on_turn_off
default is now a no-op echo (used to silently fail off Windows).
- README: replace stale `pip install -r requirements.txt` instructions
with the new extras; add systemd lingering doc + troubleshooting
section; add macOS LaunchAgent section.
- CI: new linux-smoke job (installs `.[linux]`, boots the server under
dbus-run-session, asserts /api/health). Release workflow gains
apt-deps step for the Linux build and a best-effort macOS build job.
This commit is contained in:
@@ -285,37 +285,44 @@ All connected WebSocket clients receive a `links_changed` notification when link
|
||||
|
||||
## Installation
|
||||
|
||||
Dependencies are declared in `pyproject.toml`. Pick the extra that matches
|
||||
your OS — the Python deps differ enough between Windows / Linux / macOS
|
||||
that there's no single `pip install` line.
|
||||
|
||||
### Installing on Windows
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
pip install ".[windows]"
|
||||
```
|
||||
|
||||
Required packages: `winsdk`, `pywin32`, `pycaw`, `comtypes`
|
||||
Pulls in `winsdk`, `pywin32`, `pycaw`, `comtypes`, `pystray`, etc.
|
||||
|
||||
### Installing on Linux
|
||||
|
||||
```bash
|
||||
# Install system dependencies
|
||||
sudo apt-get install python3-dbus python3-gi libdbus-1-dev libglib2.0-dev
|
||||
# System packages required to build dbus-python + PyGObject from sdist.
|
||||
sudo apt-get install -y python3-pip python3-venv \
|
||||
libdbus-1-dev libglib2.0-dev pkg-config
|
||||
|
||||
pip install -r requirements.txt
|
||||
pip install ".[linux]"
|
||||
```
|
||||
|
||||
### Installing on macOS
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
pip install ".[macos]"
|
||||
```
|
||||
|
||||
No additional dependencies - uses built-in `osascript`.
|
||||
Pulls in `pyobjc-framework-Cocoa` + `pyobjc-framework-Quartz` for the
|
||||
foreground-window probe; AppleScript-based media control uses the
|
||||
built-in `osascript`.
|
||||
|
||||
### Installing on Android (Termux)
|
||||
|
||||
```bash
|
||||
# In Termux
|
||||
pkg install python termux-api
|
||||
pip install -r requirements.txt
|
||||
pip install "."
|
||||
```
|
||||
|
||||
Requires Termux and Termux:API apps from F-Droid.
|
||||
@@ -835,11 +842,19 @@ Install:
|
||||
sudo ./service/install_linux.sh install
|
||||
```
|
||||
|
||||
Enable and start for your user:
|
||||
**Enable user lingering** — required so `/run/user/$UID/bus` (the D-Bus
|
||||
session socket needed for MPRIS) exists even when no graphical session
|
||||
is active. Without this the server boots but every `/api/media/*` call
|
||||
silently returns idle.
|
||||
|
||||
```bash
|
||||
sudo systemctl enable media-server@$USER
|
||||
sudo systemctl start media-server@$USER
|
||||
sudo loginctl enable-linger $USER
|
||||
```
|
||||
|
||||
Enable and start the templated unit for your user:
|
||||
|
||||
```bash
|
||||
sudo systemctl enable --now media-server@$USER
|
||||
```
|
||||
|
||||
View logs:
|
||||
@@ -848,6 +863,39 @@ View logs:
|
||||
journalctl -u media-server@$USER -f
|
||||
```
|
||||
|
||||
**Troubleshooting:**
|
||||
|
||||
- *"`/api/media/status` always returns `idle`"* — check the service log for
|
||||
`D-Bus session bus not available`. Most commonly: lingering isn't
|
||||
enabled, or the unit is using the wrong `XDG_RUNTIME_DIR` (`%U` must
|
||||
expand to the user's numeric UID).
|
||||
- *"Visualizer permanently unavailable"* — PulseAudio/PipeWire must
|
||||
expose monitor sources. `pactl list sources short | grep monitor`
|
||||
should list at least one entry; if not, install `pipewire-pulse` and
|
||||
restart your session.
|
||||
- *"Volume control silently fails"* — `pactl` must be on `PATH` and the
|
||||
user's PulseAudio/PipeWire server must be reachable
|
||||
(`PULSE_RUNTIME_PATH=/run/user/$UID/pulse`).
|
||||
- *"Foreground window is always `null`"* — expected under Wayland; the
|
||||
compositor hides window info from unprivileged clients. X11 sessions
|
||||
work normally.
|
||||
|
||||
### macOS (LaunchAgent)
|
||||
|
||||
The distribution tarball ships an installer:
|
||||
|
||||
```bash
|
||||
./install-launchagent.sh
|
||||
```
|
||||
|
||||
This drops `~/Library/LaunchAgents/com.dolgolyov.media-server.plist`,
|
||||
starts the service immediately, and re-launches it at every login. Logs
|
||||
go to `~/Library/Logs/media-server/{stdout,stderr}.log`. To stop:
|
||||
|
||||
```bash
|
||||
./uninstall-launchagent.sh
|
||||
```
|
||||
|
||||
## Command Line Options
|
||||
|
||||
```text
|
||||
|
||||
Reference in New Issue
Block a user