# Maintainer: Karim <karim@gabrielevarano.ch>
#
# tanin-eww — the TANINUX desktop shell config: eww bar/dock/panels/spotlight +
# the niri compositor config. Ships into /usr/share/tanin/skel/.config; tanin-setup
# seeds it into ~/.config on first run (packages must not write to /home).
#
# Local build pulls the live config from $HOME/projects/eww (override with
# EWW_SRC=...). For publish, point `source` at the eww config git repo instead.
pkgname=tanin-eww
pkgver=0.1.0
pkgrel=1
pkgdesc="TANINUX desktop shell — eww bar/dock/panels/spotlight + niri config (skel)"
arch=('any')
url="https://taninux.kgva.ch"
license=('GPL-3.0-or-later')
depends=(
  'niri' 'eww'                     # compositor + the widget toolkit
  'jq' 'wl-clipboard'              # used throughout the scripts
  'tiramisu' 'waypaper' 'cliphist' # notifications · wallpaper · clipboard history
  'brightnessctl' 'playerctl' 'libqalculate'   # backlight · media · calc (qalc)
  'grim' 'slurp'                   # screenshots
  'networkmanager' 'bluez-utils' 'wireplumber' # net/bt/audio module backends
  'ttf-iosevka-nerd' 'inter-font' 'papirus-icon-theme'  # glyphs · UI font · dock icons
)
optdepends=(
  'wlsunset: night light (niri autostart)'
  'nm-applet: tray network applet (niri autostart)'
  'waybar: fallback bar if eww is missing'
)
# source=("git+https://git.openbureau.ch/karim/tanin-eww.git#tag=v$pkgver")  # publish
# sha256sums=('SKIP')

package() {
  local eww="${EWW_SRC:-$HOME/projects/eww}"
  local skel="$pkgdir/usr/share/tanin/skel/.config"
  install -d "$skel/eww/scripts" "$skel/eww/data" "$skel/niri"

  # --- eww config (skip HANDOVER.md / README.md) ---
  install -Dm644 "$eww/eww.yuck"  "$skel/eww/eww.yuck"
  install -Dm644 "$eww/eww.scss"  "$skel/eww/eww.scss"
  install -Dm644 "$eww/dock-pins" "$skel/eww/dock-pins"
  install -Dm755 "$eww/launch.sh" "$skel/eww/launch.sh"
  cp -r "$eww/scripts/." "$skel/eww/scripts/"
  chmod 755 "$skel/eww/scripts/"*.sh
  [ -d "$eww/data" ] && cp -r "$eww/data/." "$skel/eww/data/" || true

  # --- de-hardcode dev paths -> the seeded location (~/.config/eww) ---
  sed -i 's|$HOME/projects/eww|$HOME/.config/eww|g' \
    "$skel/eww/scripts/accent.sh" "$skel/eww/scripts/doupdate.sh"

  # --- niri compositor config (vendored, eww paths already fixed) ---
  install -Dm644 "$startdir/niri-config.kdl" "$skel/niri/config.kdl"
}
