pinentry-wrapper 947 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. # Deterministic, context-aware pinentry selector
  3. # 1. Emacs — only when actually inside Emacs
  4. if [ -n "$INSIDE_EMACS" ] && command -v pinentry-emacs >/dev/null 2>&1; then
  5. exec pinentry-emacs "$@"
  6. fi
  7. # 2. macOS GUI
  8. if [ "$(uname -s)" = "Darwin" ]; then
  9. if [ -x /opt/homebrew/bin/pinentry-mac ]; then exec /opt/homebrew/bin/pinentry-mac "$@"; fi
  10. if [ -x /usr/local/bin/pinentry-mac ]; then exec /usr/local/bin/pinentry-mac "$@"; fi
  11. fi
  12. # 3. Linux GUI — only if a GUI session exists
  13. if [ -n "$WAYLAND_DISPLAY" ] || [ -n "$DISPLAY" ]; then
  14. if command -v pinentry-gnome3 >/dev/null 2>&1; then exec pinentry-gnome3 "$@"; fi
  15. if command -v pinentry-gtk-2 >/dev/null 2>&1; then exec pinentry-gtk-2 "$@"; fi
  16. if command -v pinentry-qt >/dev/null 2>&1; then exec pinentry-qt "$@"; fi
  17. fi
  18. # 4. TTY fallback
  19. if command -v pinentry-curses >/dev/null 2>&1; then
  20. exec pinentry-curses "$@"
  21. fi
  22. # 5. Last resort
  23. exec pinentry "$@"