#!/usr/bin/env bash

# omarchy:summary=Print the corner radius SwayFX draws windows with
# omarchy:hidden=true

# Plain sway draws square corners. On SwayFX the theme's swayfx.conf is the
# include sway reads last, so its corner_radius wins over the user's fx.conf.
omarchy-pkg-present swayfx || { echo 0; exit 0; }

for conf in "$HOME/.local/state/omarchy/current/theme/swayfx.conf" "$HOME/.config/sway/fx.conf"; do
  [[ -f $conf ]] || continue
  radius=$(sed -nE 's/^[[:space:]]*corner_radius[[:space:]]+([0-9]+).*$/\1/p' "$conf" | tail -n 1)
  if [[ -n $radius ]]; then
    echo "$radius"
    exit 0
  fi
done

echo 0
