#!/usr/bin/env bash set -euo pipefail echo "==> Configuring WSL for systemd (required for Avahi)" if [ ! -f /etc/wsl.conf ]; then printf "[boot]\nsystemd=true\n" | sudo tee /etc/wsl.conf >/dev/null else if ! grep -q '^\[boot\]' /etc/wsl.conf; then printf "\n[boot]\nsystemd=true\n" | sudo tee -a /etc/wsl.conf >/dev/null elif ! grep -q '^systemd=' /etc/wsl.conf; then sudo sed -i '/^\[boot\]$/a systemd=true' /etc/wsl.conf fi fi echo "==> Installing dependencies" sudo apt-get update sudo apt-get install -y \ build-essential \ cmake \ pkg-config \ git \ libssl-dev \ libplist-dev \ libavahi-compat-libdnssd-dev \ avahi-daemon \ avahi-utils \ gstreamer1.0-tools \ gstreamer1.0-plugins-base \ gstreamer1.0-plugins-good \ gstreamer1.0-plugins-bad \ gstreamer1.0-plugins-ugly \ gstreamer1.0-libav \ gstreamer1.0-gtk3 echo "==> Installing UxPlay" if apt-cache show uxplay >/dev/null 2>&1; then sudo apt-get install -y uxplay else workdir="$HOME/uxplay-src" if [ ! -d "$workdir/.git" ]; then rm -rf "$workdir" git clone https://github.com/FDH2/UxPlay "$workdir" else git -C "$workdir" pull --ff-only fi cmake -S "$workdir" -B "$workdir/build" cmake --build "$workdir/build" -j sudo cmake --install "$workdir/build" fi if command -v systemctl >/dev/null 2>&1 && ps -p 1 -o comm= | grep -q systemd; then echo "==> Enabling Avahi" sudo systemctl enable --now avahi-daemon else echo "NOTE: systemd is not active yet. After WSL restart, run:" echo " sudo systemctl enable --now avahi-daemon" fi echo "==> Done"