#!/usr/bin/env bash

# omarchy:summary=True when this process can talk to a live sway instance.
# omarchy:hidden=true

# Pair of omarchy-on-hyprland. Every process in a sway session inherits
# SWAYSOCK; a caller from outside (ssh, a TTY) has none, so look for the
# socket the way omarchy-restart-sway does.
if [[ -z ${SWAYSOCK:-} ]]; then
  SWAYSOCK=$(ls -t "${XDG_RUNTIME_DIR:-/run/user/$UID}"/sway-ipc.*.sock 2>/dev/null | head -n1)
  [[ -n $SWAYSOCK ]] || exit 1
  export SWAYSOCK
fi

"${BASH_SOURCE[0]%/*}/omarchy-cmd-present" swaymsg
