#!/usr/bin/env bash
# biglinux-webapps-systemd — runs at graphical session start via systemd user service.
# Ensures the user's applications directory exists so newly installed webapp
# .desktop files are discoverable without a logout/login cycle.
set -euo pipefail

readonly apps_dir="$HOME/.local/share/applications"

# Ensure the applications directory exists (XDG baseline requirement)
mkdir -p "$apps_dir"

# Refresh desktop database so any newly installed webapps are visible
# immediately without the user needing to log out and back in.
if command -v update-desktop-database &>/dev/null; then
	update-desktop-database "$apps_dir" 2>/dev/null || true
fi
