#!/usr/bin/env bash # Installs Kadence's launcher entry and icon for the current user. # # The app itself runs straight from the checkout (`python3 -m kadence_desktop`) # or from a pip install; this just makes it appear in the application menu with # a proper icon and the right-click actions. set -euo pipefail HERE="$(dirname "$(readlink -f "$0")")" APPS="${XDG_DATA_HOME:-$HOME/.local/share}/applications" ICONS="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/scalable/apps" BIN="${HOME}/.local/bin" mkdir -p "$APPS" "$ICONS" "$BIN" # A launcher that works whether or not the package is pip-installed. The # desktop entry points at this absolute path, so nothing depends on PATH. cat > "$BIN/kadence-desktop" < "$SITE_PTH/kadence-desktop.pth" # Exec/TryExec are written as absolute paths on purpose. # # Application launchers (KDE's Kickoff, rofi -show drun, GNOME's overview) run # with the *session* PATH, which on most setups does not include ~/.local/bin — # and an entry whose TryExec cannot be resolved is silently hidden. An absolute # path cannot be hidden by a PATH that differs from your shell's. sed -e "s|^Exec=kadence-desktop|Exec=$BIN/kadence-desktop|" \ -e "s|^TryExec=kadence-desktop|TryExec=$BIN/kadence-desktop|" \ -e "s|^Exec=kadence-desktop |Exec=$BIN/kadence-desktop |" \ "$HERE/kadence.desktop" > "$APPS/kadence.desktop" chmod 0644 "$APPS/kadence.desktop" install -m 0644 "$HERE/kadence.svg" "$ICONS/kadence.svg" # Each launcher keeps its own cache; refresh all of the ones that are present. command -v update-desktop-database >/dev/null && update-desktop-database "$APPS" || true command -v gtk-update-icon-cache >/dev/null && \ gtk-update-icon-cache -f -t "${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor" 2>/dev/null || true command -v kbuildsycoca6 >/dev/null && kbuildsycoca6 --noincremental >/dev/null 2>&1 || true # rofi rebuilds its drun cache when the directory changes; nudge the timestamp. touch "$APPS" 2>/dev/null || true if command -v desktop-file-validate >/dev/null; then desktop-file-validate "$APPS/kadence.desktop" && echo "Desktop entry validates." fi echo echo "Installed:" echo " launcher $BIN/kadence-desktop" echo " menu entry $APPS/kadence.desktop" echo " icon $ICONS/kadence.svg" echo echo "It should now appear in the application menu and in \`rofi -show drun\`" echo "as \"Kadence\" (search: pomodoro, timer, focus)."