#!/usr/bin/env sh set -eu export XDG_CURRENT_DESKTOP=sway # xdg-desktop-portal export XDG_SESSION_DESKTOP=sway # systemd export XDG_SESSION_TYPE=wayland # xdg/systemd if [ -d "$HOME/.config/environment.d" ]; then for f in "$HOME"/.config/environment.d/*.conf; do [ -f "$f" ] || continue while IFS= read -r line || [ -n "$line" ]; do # Skip empty lines and comments case "$line" in '' | '#'*) continue ;; esac # Export the variable export "$line" done <"$f" done fi max_attempts=50 attempt=0 while [ ! -d "/run/user/$(id -u)" ]; do if [ "$attempt" -ge "$max_attempts" ]; then echo "Error: XDG_RUNTIME_DIR not available after $max_attempts attempts" >&2 exit 1 fi sleep 0.2 attempt=$((attempt + 1)) done export XDG_RUNTIME_DIR="/run/user/$(id -u)" dbus-run-session sway "$@" # this teardown makes it easier to switch between compositors unset DISPLAY SWAYSOCK WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE