#!/usr/bin/env bash # Add Stemify and Stemify Player to the app grid (and "Open with" for audio files). # Re-run after moving the project; `--uninstall` removes all of it. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" APPS="${XDG_DATA_HOME:-$HOME/.local/share}/applications" ICONS="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/scalable/apps" DESKTOP="$APPS/stemify.desktop" ICON="$ICONS/stemify.svg" PLAYER_DESKTOP="$APPS/stemify-player.desktop" PLAYER_ICON="$ICONS/stemify-player.svg" # stem-on / stem-off from older installs; library separation now runs on the server (server/stemd.py). OLD_BIN="$HOME/.local/bin" if [[ "${1:-}" == "--uninstall" ]]; then rm -f "$DESKTOP" "$ICON" "$PLAYER_DESKTOP" "$PLAYER_ICON" "$OLD_BIN/stem-on" "$OLD_BIN/stem-off" echo "removed $DESKTOP, $PLAYER_DESKTOP and their icons" exit 0 fi for bin in stemify stemify-player; do if [[ ! -x "$ROOT/.venv/bin/$bin" ]]; then echo "missing $ROOT/.venv/bin/$bin; run 'uv sync' in $ROOT first" >&2 exit 1 fi done mkdir -p "$APPS" "$ICONS" install -m 644 "$ROOT/stemify/assets/stemify.svg" "$ICON" install -m 644 "$ROOT/stemify/player/assets/stemify-player.svg" "$PLAYER_ICON" # StartupWMClass / file name match QGuiApplication.setDesktopFileName("stemify"), # so Wayland groups the window under this entry and shows its icon. cat > "$DESKTOP" < "$PLAYER_DESKTOP" </dev/null && update-desktop-database -q "$APPS" || true command -v gtk-update-icon-cache >/dev/null && gtk-update-icon-cache -q -t "${ICONS%/scalable/apps}" || true command -v desktop-file-validate >/dev/null && desktop-file-validate "$DESKTOP" "$PLAYER_DESKTOP" || true rm -f "$OLD_BIN/stem-on" "$OLD_BIN/stem-off" echo "installed $DESKTOP and $PLAYER_DESKTOP"