#!/bin/bash
MODULE_URL="github.com/marianozunino/sdm-ui"
BINARY_NAME="sdm-ui"
TARGET_DIR="$HOME/.local/bin"
BINARY_PATH="$TARGET_DIR/$BINARY_NAME"

if [ ! -x "$BINARY_PATH" ]; then
	notify-send "📦 Installing $BINARY_NAME" "Installing from $MODULE_URL..."
	GO111MODULE=on GOBIN="$TARGET_DIR" go install "$MODULE_URL@latest" || {
		notify-send -u critical "Installation Failed" "Failed to install $BINARY_NAME from $MODULE_URL"
		exit 1
	}
	notify-send "Installation Complete" "$BINARY_NAME has been installed successfully"
fi

exec "$BINARY_PATH" "$@"
