#!/usr/bin/env bash
set -euo pipefail

# -------------------------------------------------
# 1️⃣  CONFIGURATION
# -------------------------------------------------
REPO="nwg-piotr/lightdm-nwg-greeter"
USER="nwg-piotr"
PROJECT="lightdm-nwg-greeter"

# -------------------------------------------------
# 2️⃣  FETCH JSON ONLY ONCE
# -------------------------------------------------
raw_json=$(lastversion --format json "$REPO")

# -------------------------------------------------
# 3️⃣  ONE‑SHOT extraction of everything we need
# -------------------------------------------------
eval $(jq -r '
  {
    author:       .author.login,                      # "nwg-piotr"
    install_name: .install_name,                      # "lightdm-nwg-greeter"
    version:      .tag_name | sub("^v"; ""),          # "0.1.1"
    license:      .license.name,                      # "mit"
    homepage:     .html_url,                          # release page URL
    rss_feed:     (.html_url + ".atom"),
    description:  (.body // ""),
    long_desc:    (.body // "")
  }
    "USER=\(.author)
    PROJECT=\(.install_name)
  | VERSION=\(.version)
    LICENSE=\(.license)
    RELEASE_URL=\(.homepage)
    RSS_FEED=\(.rss_feed)
    DESCRIPTION=\(.description)
    LONG_DESCRIPTION=\(.long_desc)"
' <<<"$raw_json")

# -------------------------------------------------
# 4️⃣  Use the variables downstream (example: print them)
# -------------------------------------------------
echo "Package version      : $VERSION"
echo "License              : $LICENSE"
echo "Homepage (release)   : $RELEASE_URL"
echo "RSS feed             : $RSS_FEED"
echo "Short description    : $DESCRIPTION"
echo "Long description     : $LONG_DESCRIPTION"

# Set github user and project name
USER="nwg-piotr"
PROJECT="lightdm-nwg-greeter"
LICENSE="mit"
SECTION="admin"
HOMEPAGE=
BUILD_HOME="/var/tmp/build_${PROJECT}"
#VERSION="2.1.0"
PACKAGE="${
VERSION=
DEBEMAIL="${DEBMAIL}"
DEBFULLNAME="${DEBFULLNAME}"
DESCRIPTION=
LONG_DESCRIPTION=

RSS_FEED="https://github.com/${USER}/${PROJECT}/releases.atom"
# xdg-open ${RSS_FEED}
echo ${RSS_FEED}

# A simple LightDM greeter, using Python and GTK, that doesn't require an X11 server,

# https://github.com/cage-kiosk/cage/wiki/
sudo apt install -y cage

# pygobject - https://pygobject.gnome.org/getting_started.html#ubuntu-getting-started
sudo apt install -y python3-gi python3-gi-cairo gir1.2-gtk-4.0


