#!/bin/bash

# omarchy:summary=Launch the Omarchy bar customizer
# omarchy:group=launch
# omarchy:name=bar-settings
# omarchy:examples=omarchy launch bar-settings

OMARCHY_PATH="${OMARCHY_PATH:-$HOME/.local/share/omarchy}"
CONFIG_DIR="$OMARCHY_PATH/default/quickshell/bar-settings"

if quickshell list -p "$CONFIG_DIR" 2>/dev/null | grep -q '^Instance '; then
  if ! hyprctl dispatch focuswindow 'title:Omarchy bar settings' 2>/dev/null | grep -q ok; then
    hyprctl dispatch focuswindow 'initialTitle:Omarchy bar settings' >/dev/null 2>&1
  fi
  exit 0
fi

setsid uwsm-app -- env OMARCHY_PATH="$OMARCHY_PATH" quickshell -p "$CONFIG_DIR" >/dev/null 2>&1 &
