#!/bin/sh

if [ -n "$PINENTRY_PROGRAM" ]; then
	exec $PINENTRY_PROGRAM "$@"
elif [ -z "$DISPLAY" ]; then
	exec /usr/bin/pinentry-curses "$@"
elif [ -x /usr/bin/pinentry-gnome3 ]; then
	exec /usr/bin/pinentry-gnome3 "$@"
elif [ -x /usr/bin/pinentry-gtk-2 ]; then
	exec /usr/bin/pinentry-gtk-2 "$@"
elif [ -x /usr/bin/pinentry-gtk ]; then
	exec /usr/bin/pinentry-gtk "$@"
elif [ -x /usr/bin/pinentry-qt6 ]; then
	exec /usr/bin/pinentry-qt6 "$@"
elif [ -x /usr/bin/pinentry-qt5 ]; then
	exec /usr/bin/pinentry-qt5 "$@"
elif [ -x /usr/bin/pinentry-qt4 ]; then
	exec /usr/bin/pinentry-qt4 "$@"
elif [ -x /usr/bin/pinentry-qt ]; then
	exec /usr/bin/pinentry-qt "$@"
elif [ -x /usr/bin/pinentry-fltk ]; then
	exec /usr/bin/pinentry-fltk "$@"
elif [ -x /usr/bin/pinentry-efl ]; then
	exec /usr/bin/pinentry-efl "$@"
else
	exec /usr/bin/pinentry-curses "$@"
fi
