#!/bin/sh

BUDGIE_VERSION="10.10.2 (git-4ef101b1cdde814317d3ded1d22361b6faa239ea)"

if [ "$1" = "--version" ]; then
    echo "budgie-desktop $BUDGIE_VERSION"
    echo "Copyright © Budgie Desktop Developers"
    exit 0
fi

if [ -z "${XDG_CURRENT_DESKTOP:-}" ] || ! printf %s "$XDG_CURRENT_DESKTOP" | grep -qi 'budgie'; then
  XDG_CURRENT_DESKTOP=Budgie
  export XDG_CURRENT_DESKTOP
fi

export BUDGIE_SESSION_VERSION=${BUDGIE_VERSION}

# Wait until the server starts before launching the session
compositor="/usr/lib/budgie-session-compositor-ready"
if command -v "$compositor" > /dev/null 2>&1 && "$compositor"; then
  /usr/bin/org.buddiesofbudgie.Services &
  /usr/lib/xdg-desktop-portal &
  exec budgie-session --builtin --session=org.buddiesofbudgie.BudgieDesktop $*
fi
