#!/usr/bin/env bash # Install the lintunes .desktop entry and icon for the current user, so GNOME # shows a proper icon and the app can be pinned to the dash. # Re-run after swapping packaging/lintunes.png to update the icon. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" APPS_DIR="$HOME/.local/share/applications" ICON_DIR="$HOME/.local/share/icons/hicolor/256x256/apps" mkdir -p "$APPS_DIR" "$ICON_DIR" cp "$HERE/lintunes.png" "$ICON_DIR/lintunes.png" # If lintunes isn't on PATH, point Exec at this checkout's module instead. # We must NOT rely on the working directory: GNOME's dash launches apps via a # systemd scope that does not reliably honor the Path= key, so `python3 -m` # would fail with "No module named 'lintunes'". Put the checkout on PYTHONPATH # and use absolute python so the launch is independent of CWD and PATH. PROJECT_DIR="$(dirname "$HERE")" PY="$(command -v python3 || echo /usr/bin/python3)" if command -v lintunes >/dev/null 2>&1; then cp "$HERE/lintunes.desktop" "$APPS_DIR/lintunes.desktop" else sed -e "s|^Exec=lintunes|Exec=/usr/bin/env PYTHONPATH=$PROJECT_DIR $PY -m lintunes.main|" \ -e "s|^Terminal=|Path=$PROJECT_DIR\nTerminal=|" \ "$HERE/lintunes.desktop" > "$APPS_DIR/lintunes.desktop" fi command -v update-desktop-database >/dev/null 2>&1 && \ update-desktop-database "$APPS_DIR" || true command -v gtk-update-icon-cache >/dev/null 2>&1 && \ gtk-update-icon-cache -t "$HOME/.local/share/icons/hicolor" 2>/dev/null || true echo "Installed. Find 'LinTunes' in the app grid; right-click to pin to dash."