#!/bin/sh
# greetd's default_session command. Installed to /usr/local/bin/kiosk-session.
#
# Exists so that MQTT_BROKER_HOST / HA_URL / DIGEST_WEB_URL are in Sway's environment:
# sway's config file has no way to read an env file itself, but every `exec` line it
# runs inherits this process's environment, so sourcing here is what lets the Firefox
# kiosk `exec` point at $DIGEST_WEB_URL without templating the sway config.
set -eu

[ -r /etc/thinclient-agent/config.env ] && . /etc/thinclient-agent/config.env
export MQTT_BROKER_HOST HA_URL DIGEST_WEB_URL

export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=sway
export MOZ_ENABLE_WAYLAND=1

: "${XDG_RUNTIME_DIR:=/run/user/$(id -u)}"
export XDG_RUNTIME_DIR

exec sway
