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:
@@ -18,7 +18,7 @@ from fastapi.responses import Response
|
||||
from ..auth import verify_token, verify_token_or_query
|
||||
from ..config import settings
|
||||
from ..models import MediaStatus, SeekRequest, VolumeRequest
|
||||
from ..services import get_current_album_art, get_media_controller
|
||||
from ..services import get_current_album_art_async, get_media_controller
|
||||
from ..services.websocket_manager import ws_manager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -287,7 +287,7 @@ async def get_artwork(
|
||||
Returns the bytes with a content-derived ETag so the browser can serve a
|
||||
304 when the same track is re-requested.
|
||||
"""
|
||||
art_bytes = get_current_album_art()
|
||||
art_bytes = await get_current_album_art_async()
|
||||
if art_bytes is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
@@ -326,14 +326,43 @@ async def get_artwork(
|
||||
|
||||
@router.get("/visualizer/status")
|
||||
async def visualizer_status(_: str = Depends(verify_token)) -> dict:
|
||||
"""Check if audio visualizer is available and running."""
|
||||
"""Check if audio visualizer is available and running.
|
||||
|
||||
``available`` is True only when both numpy + soundcard import.
|
||||
``unavailable_reason`` carries a short human-readable hint when False
|
||||
or when a usable loopback device was not found — useful on Linux where
|
||||
PulseAudio/PipeWire may not expose monitor sources to a headless
|
||||
systemd-as-user service.
|
||||
"""
|
||||
import platform as _platform
|
||||
|
||||
from ..services.audio_analyzer import get_audio_analyzer
|
||||
|
||||
analyzer = get_audio_analyzer()
|
||||
reason: str | None = None
|
||||
if not analyzer.available:
|
||||
reason = "soundcard or numpy is not installed"
|
||||
elif getattr(analyzer, "_unavailable", False):
|
||||
if _platform.system() == "Linux":
|
||||
reason = (
|
||||
"No loopback audio device found. On Linux this requires a "
|
||||
"running PulseAudio/PipeWire session with monitor sources "
|
||||
"(systemd user service: ensure DBUS_SESSION_BUS_ADDRESS + "
|
||||
"XDG_RUNTIME_DIR are set)."
|
||||
)
|
||||
elif _platform.system() == "Darwin":
|
||||
reason = (
|
||||
"No loopback audio device found. macOS does not expose system "
|
||||
"loopback by default — install BlackHole or Soundflower."
|
||||
)
|
||||
else:
|
||||
reason = "No loopback audio device found"
|
||||
|
||||
return {
|
||||
"available": analyzer.available,
|
||||
"running": analyzer.running,
|
||||
"current_device": analyzer.current_device,
|
||||
"unavailable_reason": reason,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user