#!/bin/bash

# omarchy:summary=Edit, set, or reset screensaver branding
# omarchy:group=branding
# omarchy:name=screensaver
# omarchy:args=<image|text|reset>
# omarchy:examples=omarchy branding screensaver image | omarchy branding screensaver text | omarchy branding screensaver reset

set -euo pipefail

case "${1:-}" in
image)
  image=$(omarchy-file-select --title "Pick PNG or SVG for screensaver" --extensions "png svg")
  if omarchy-transcode-ascii "$image" ~/.config/omarchy/branding/screensaver.txt; then
    omarchy-launch-screensaver force >/dev/null 2>&1
  fi
  ;;
text)
  omarchy-launch-editor ~/.config/omarchy/branding/screensaver.txt >/dev/null 2>&1 && omarchy-launch-screensaver force >/dev/null 2>&1
  ;;
reset)
  cp "$OMARCHY_PATH/logo.txt" ~/.config/omarchy/branding/screensaver.txt && omarchy-launch-screensaver force >/dev/null 2>&1
  ;;
*)
  echo "Usage: omarchy-branding-screensaver <image|text|reset>" >&2
  exit 1
  ;;
esac
