install.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. # Cadmus installer — wires up the spell picker + Right Alt hotkey via keyd.
  3. #
  4. # Re-runnable. Needs sudo for steps that touch /usr/local and /etc.
  5. set -euo pipefail
  6. REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
  7. USER_NAME="${SUDO_USER:-$USER}"
  8. bold() { printf '\033[1m%s\033[0m\n' "$*"; }
  9. bold "==> Checking runtime dependencies"
  10. missing=()
  11. for bin in fuzzel hunspell wl-copy wl-paste notify-send; do
  12. if ! command -v "$bin" >/dev/null; then
  13. missing+=("$bin")
  14. fi
  15. done
  16. if (( ${#missing[@]} )); then
  17. echo "Missing: ${missing[*]}"
  18. echo "On Fedora try: sudo dnf install fuzzel hunspell hunspell-en-US wl-clipboard libnotify"
  19. exit 1
  20. fi
  21. bold "==> Installing scripts to /usr/local/bin"
  22. sudo install -D -m 755 "$REPO_DIR/bin/cadmus" /usr/local/bin/cadmus
  23. sudo install -D -m 755 "$REPO_DIR/bin/cadmus-launch" /usr/local/bin/cadmus-launch
  24. if ! command -v keyd >/dev/null; then
  25. bold "==> keyd not found — building from source"
  26. BUILD_DIR="${TMPDIR:-/tmp}/cadmus-keyd-build"
  27. rm -rf "$BUILD_DIR"
  28. git clone --depth 1 https://github.com/rvaiya/keyd.git "$BUILD_DIR"
  29. make -C "$BUILD_DIR" -j"$(nproc)"
  30. sudo make -C "$BUILD_DIR" install
  31. fi
  32. bold "==> Installing keyd config"
  33. TMP_CONF="$(mktemp)"
  34. sed "s/__USER__/${USER_NAME}/g" "$REPO_DIR/keyd/cadmus.conf" > "$TMP_CONF"
  35. sudo install -D -m 644 "$TMP_CONF" /etc/keyd/cadmus.conf
  36. rm -f "$TMP_CONF"
  37. bold "==> Enabling and (re)starting keyd"
  38. sudo systemctl enable --now keyd
  39. sudo keyd reload 2>/dev/null || sudo systemctl restart keyd
  40. bold "==> Done"
  41. cat <<'EOF'
  42. Tap Right Alt to open the spell picker.
  43. Hold Right Alt to keep normal AltGr.
  44. Pick a word -> it lands on your clipboard, ready to paste.
  45. Tip: highlight a word first; the popup opens with that word prefilled.
  46. EOF