#!/bin/bash
set -e
APP_NAME="dhf-agent"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

echo "Installing ${APP_NAME}..."

chmod +x "${SCRIPT_DIR}/${APP_NAME}"
sudo cp "${SCRIPT_DIR}/${APP_NAME}" /usr/local/bin/${APP_NAME}
sudo chmod +x /usr/local/bin/${APP_NAME}

sudo mkdir -p /usr/share/icons/hicolor/128x128/apps
sudo cp "${SCRIPT_DIR}/${APP_NAME}.png" /usr/share/icons/hicolor/128x128/apps/${APP_NAME}.png

sudo cp "${SCRIPT_DIR}/${APP_NAME}.desktop" /usr/share/applications/${APP_NAME}.desktop

sudo update-desktop-database /usr/share/applications 2>/dev/null || true
sudo gtk-update-icon-cache /usr/share/icons/hicolor 2>/dev/null || true

echo "${APP_NAME} installed successfully!"
echo "You can now find DHF Agent in your application menu."
