This commit is contained in:
workD12
2026-07-31 20:16:28 +03:00
commit 8e24f19a07
20 changed files with 10037 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Install rcalc launcher + icon for Wayland/XDG desktops (KDE, GNOME, …).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
BIN="${ROOT}/dist/rcalc"
ICON_SRC="${ROOT}/assets/icon-256.png"
DESKTOP_SRC="${ROOT}/assets/rcalc.desktop"
if [[ ! -x "$BIN" ]]; then
echo "Building release binary…"
(cd "$ROOT" && cargo build --release)
# Prefer project dist/, else cargo target
if [[ -x "$ROOT/dist/rcalc" ]]; then
BIN="$ROOT/dist/rcalc"
else
BIN="$(find "$ROOT" /tmp/cursor-sandbox-cache -path '*/release/rcalc' -type f 2>/dev/null | head -1 || true)"
fi
fi
if [[ ! -x "$BIN" ]]; then
echo "error: binary not found; run: cargo build --release && cp target/release/rcalc dist/" >&2
exit 1
fi
APP_DIR="${HOME}/.local/share/applications"
ICON_DIR="${HOME}/.local/share/icons/hicolor/256x256/apps"
mkdir -p "$APP_DIR" "$ICON_DIR" "${HOME}/.local/bin"
cp -f "$ICON_SRC" "${ICON_DIR}/rcalc.png"
ln -sfn "$BIN" "${HOME}/.local/bin/rcalc"
# Rewrite Exec to absolute binary path
sed "s|^Exec=.*|Exec=${BIN}|" "$DESKTOP_SRC" \
| sed "s|^Path=.*|Path=${ROOT}|" \
> "${APP_DIR}/rcalc.desktop"
chmod 644 "${APP_DIR}/rcalc.desktop"
# Refresh caches (ignore failures on minimal setups)
update-desktop-database "$APP_DIR" 2>/dev/null || true
gtk-update-icon-cache -f -t "${HOME}/.local/share/icons/hicolor" 2>/dev/null || true
echo "Installed:"
echo " launcher: ${APP_DIR}/rcalc.desktop"
echo " icon: ${ICON_DIR}/rcalc.png"
echo " symlink: ${HOME}/.local/bin/rcalc"
echo
echo "On Wayland: quit rcalc if running, then start it from the app menu"
echo "(or: rcalc). The dock should show the custom icon."