[bin] Try fixing pinentry wrapper
This commit is contained in:
@ -1,23 +1,29 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Pick a working pinentry for this machine/session.
|
# Deterministic, context-aware pinentry selector
|
||||||
# Preference order: Emacs pinentry (if in Emacs), mac GUI pinentry, GTK/QT, curses.
|
|
||||||
|
|
||||||
# If you use pinentry-emacs and want it when Emacs is running:
|
# 1. Emacs — only when actually inside Emacs
|
||||||
if command -v pinentry-emacs >/dev/null 2>&1; then
|
if [ -n "$INSIDE_EMACS" ] && command -v pinentry-emacs >/dev/null 2>&1; then
|
||||||
exec pinentry-emacs "$@"
|
exec pinentry-emacs "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# macOS GUI pinentry (Homebrew paths)
|
# 2. macOS GUI
|
||||||
if [ "$(uname -s)" = "Darwin" ]; then
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
if [ -x /opt/homebrew/bin/pinentry-mac ]; then exec /opt/homebrew/bin/pinentry-mac "$@"; fi
|
if [ -x /opt/homebrew/bin/pinentry-mac ]; then exec /opt/homebrew/bin/pinentry-mac "$@"; fi
|
||||||
if [ -x /usr/local/bin/pinentry-mac ]; then exec /usr/local/bin/pinentry-mac "$@"; fi
|
if [ -x /usr/local/bin/pinentry-mac ]; then exec /usr/local/bin/pinentry-mac "$@"; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Common Linux GUI pinentries
|
# 3. Linux GUI — only if a GUI session exists
|
||||||
if command -v pinentry-gnome3 >/dev/null 2>&1; then exec pinentry-gnome3 "$@"; fi
|
if [ -n "$WAYLAND_DISPLAY" ] || [ -n "$DISPLAY" ]; then
|
||||||
if command -v pinentry-gtk-2 >/dev/null 2>&1; then exec pinentry-gtk-2 "$@"; fi
|
if command -v pinentry-gnome3 >/dev/null 2>&1; then exec pinentry-gnome3 "$@"; fi
|
||||||
if command -v pinentry-qt >/dev/null 2>&1; then exec pinentry-qt "$@"; fi
|
if command -v pinentry-gtk-2 >/dev/null 2>&1; then exec pinentry-gtk-2 "$@"; fi
|
||||||
|
if command -v pinentry-qt >/dev/null 2>&1; then exec pinentry-qt "$@"; fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Fallback (may fail in dumb/no-tty contexts)
|
# 4. TTY fallback
|
||||||
if command -v pinentry-curses >/dev/null 2>&1; then exec pinentry-curses "$@"; fi
|
if command -v pinentry-curses >/dev/null 2>&1; then
|
||||||
|
exec pinentry-curses "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 5. Last resort
|
||||||
exec pinentry "$@"
|
exec pinentry "$@"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user