#!/bin/sh
# greetd's default_session command. Installed to /usr/local/bin/kiosk-session.
#
# Same purpose as the thin client's own kiosk-session: gets MQTT_BROKER_HOST / HA_URL /
# SPOTIFY_APP_ID / etc into Sway's environment, since sway's config file has no way to
# read an env file itself but every `exec` line it runs inherits this process's
# environment.
set -eu

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

export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=sway
export MOZ_ENABLE_WAYLAND=1
# Chromium's Wayland/Ozone backend, needed for native touch events in the HA kiosk
# window (see configs/sway/ha-kiosk) — without it Chromium falls back to Xwayland,
# where touch input is translated through XTest and loses multi-touch gestures.
export OZONE_PLATFORM=wayland

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

exec sway
