#!/bin/sh
set -eu

SOURCE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
APP_DIR="$HOME/.local/share/snackshare"
DESKTOP_DIR="$HOME/.local/share/applications"

mkdir -p "$APP_DIR" "$DESKTOP_DIR"
install -m 755 "$SOURCE_DIR/SnackShare" "$APP_DIR/SnackShare"
install -m 644 "$SOURCE_DIR/icon.png" "$APP_DIR/icon.png"
sed "s|__APP_DIR__|$APP_DIR|g" "$SOURCE_DIR/snackshare.desktop" > "$DESKTOP_DIR/snackshare.desktop"
chmod 644 "$DESKTOP_DIR/snackshare.desktop"

echo "SnackShare is installed. Open it from your applications menu."
