#!/usr/bin/env bash # Cadmus installer — wires up the spell picker + Right Alt hotkey via keyd. # # Re-runnable. Needs sudo for steps that touch /usr/local and /etc. set -euo pipefail REPO_DIR="$(cd "$(dirname "$0")" && pwd)" USER_NAME="${SUDO_USER:-$USER}" bold() { printf '\033[1m%s\033[0m\n' "$*"; } bold "==> Checking runtime dependencies" missing=() for bin in fuzzel hunspell wl-copy wl-paste notify-send; do if ! command -v "$bin" >/dev/null; then missing+=("$bin") fi done if (( ${#missing[@]} )); then echo "Missing: ${missing[*]}" echo "On Fedora try: sudo dnf install fuzzel hunspell hunspell-en-US wl-clipboard libnotify" exit 1 fi bold "==> Installing scripts to /usr/local/bin" sudo install -D -m 755 "$REPO_DIR/bin/cadmus" /usr/local/bin/cadmus sudo install -D -m 755 "$REPO_DIR/bin/cadmus-launch" /usr/local/bin/cadmus-launch if ! command -v keyd >/dev/null; then bold "==> keyd not found — building from source" BUILD_DIR="${TMPDIR:-/tmp}/cadmus-keyd-build" rm -rf "$BUILD_DIR" git clone --depth 1 https://github.com/rvaiya/keyd.git "$BUILD_DIR" make -C "$BUILD_DIR" -j"$(nproc)" sudo make -C "$BUILD_DIR" install fi bold "==> Installing keyd config" TMP_CONF="$(mktemp)" sed "s/__USER__/${USER_NAME}/g" "$REPO_DIR/keyd/cadmus.conf" > "$TMP_CONF" sudo install -D -m 644 "$TMP_CONF" /etc/keyd/cadmus.conf rm -f "$TMP_CONF" bold "==> Enabling and (re)starting keyd" sudo systemctl enable --now keyd sudo keyd reload 2>/dev/null || sudo systemctl restart keyd bold "==> Done" cat <<'EOF' Tap Right Alt to open the spell picker. Hold Right Alt to keep normal AltGr. Pick a word -> it lands on your clipboard, ready to paste. Tip: highlight a word first; the popup opens with that word prefilled. EOF