#!/bin/sh
# aero-session — launches the AeroOS glassmorphism desktop.
# Sets up the runtime/audio environment, then execs the aerowm compositor.

# XDG runtime dir (systemd usually provides this; ensure it exists)
if [ -z "$XDG_RUNTIME_DIR" ]; then
    export XDG_RUNTIME_DIR="/run/user/$(id -u)"
    mkdir -p "$XDG_RUNTIME_DIR"
    chmod 700 "$XDG_RUNTIME_DIR"
fi

export XDG_SESSION_TYPE=wayland
export XDG_CURRENT_DESKTOP=AeroOS
export GTK_THEME=AeroGlass
export GDK_BACKEND=wayland
export QT_QPA_PLATFORM=wayland
export MOZ_ENABLE_WAYLAND=1
export AEROWM_WALLPAPER="/usr/share/backgrounds/aeros/frutiger-aero.png"

# Start the user audio graph (PipeWire) for lofi playback.
if command -v pipewire >/dev/null 2>&1; then
    systemctl --user start pipewire pipewire-pulse wireplumber 2>/dev/null || {
        pipewire & 
        sleep 0.3
        pipewire-pulse 2>/dev/null &
        wireplumber 2>/dev/null &
    }
fi

# Hand off to the compositor (it autostarts aero-lofi itself).
exec aerowm
