#!/usr/bin/env bash
set -euo pipefail

config_dir="${XDG_CONFIG_HOME:-$HOME/.config}"
config_file="$config_dir/sway/config"
include_line="include $config_dir/sway/noctalia"

mkdir -p "$(dirname "$config_file")"

if [ ! -f "$config_file" ]; then
    printf '%s\n' "$include_line" >"$config_file"
    exit 0
fi

if ! grep -q '^include .*noctalia' "$config_file"; then
    printf '\n%s\n' "$include_line" >>"$config_file"
fi
