Blame SOURCES/pinentry-wrapper

d1ad85
#!/bin/sh
d1ad85
d1ad85
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
d1ad85
# Copyright (c) 2009 Fedora Project
d1ad85
# This file and all modifications and additions to the pristine
d1ad85
# package are under the same license as the package itself.
d1ad85
#
d1ad85
# Please submit bugfixes or comments via http://bugs.opensuse.org/
d1ad85
#
d1ad85
# Anna Bernathova <anicka@novell.com> 2006
d1ad85
# Pavel Nemec <pnemec@novell.com> 2006
d1ad85
# Rex Dieter <rdieter@fedoraproject.org> 2009
d1ad85
#
d1ad85
# use proper binary (pinentry-qt, pinentry-gtk-2 or pinentry-curses) 
d1ad85
d1ad85
if [ -z "$PINENTRY_BINARY" ]; then
d1ad85
d1ad85
kde_running=
d1ad85
if [ -n "$KDE_FULL_SESSION" ]; then
d1ad85
    kde_running=1
d1ad85
elif [ -n "$DISPLAY" ]; then
d1ad85
    xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
d1ad85
    if test $? -eq 0; then
d1ad85
        kde_running=1
d1ad85
    fi
d1ad85
else
d1ad85
    arg=
d1ad85
    display=
d1ad85
    for opt in "$@"; do
d1ad85
        if [ "$opt" = "--display" ]; then
d1ad85
            arg=1
d1ad85
        elif [ -n "$arg" ]; then
d1ad85
            display="$opt"
d1ad85
        else
d1ad85
            arg=
d1ad85
        fi
d1ad85
    done
d1ad85
    if [ -n "$display" ]; then
d1ad85
        DISPLAY="$display" xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
d1ad85
        if test $? -eq 0; then
d1ad85
            kde_running=1
d1ad85
        fi
d1ad85
    fi
d1ad85
fi
d1ad85
d1ad85
# if KDE is detected and pinentry-qt exists, use pinentry-qt
d1ad85
if [ -n "$kde_running" -a -x /usr/bin/pinentry-qt ]
d1ad85
then
d1ad85
	export PINENTRY_BINARY="/usr/bin/pinentry-qt"
d1ad85
# otherwise test if pinentry-gtk-2 is installed
d1ad85
elif [ -x /usr/bin/pinentry-gtk-2 ] 
d1ad85
then
d1ad85
	export PINENTRY_BINARY="/usr/bin/pinentry-gtk-2"
d1ad85
# otherwise test if pinentry-qt4 is installed
d1ad85
elif [ -x /usr/bin/pinentry-qt4 ]
d1ad85
then
d1ad85
        export PINENTRY_BINARY="/usr/bin/pinentry-qt4"
d1ad85
# otherwise test if pinentry-qt exists although KDE is not detected
d1ad85
elif [ -x /usr/bin/pinentry-qt ]
d1ad85
then
d1ad85
	export PINENTRY_BINARY="/usr/bin/pinentry-qt"
d1ad85
# pinentry-curses is installed by default, test if we're in a terminal
d1ad85
elif [ -t 2 ]
d1ad85
then
d1ad85
	export PINENTRY_BINARY="/usr/bin/pinentry-curses"
d1ad85
else
d1ad85
	#test if gui binary is required
d1ad85
	for opt in "$@"; do
d1ad85
		if [ "x$opt" = "x--display" ]; then
d1ad85
		        # should not happen because of package dependencies
d1ad85
			echo "Please install pinentry-gui" >&2
d1ad85
			exit 1
d1ad85
		fi
d1ad85
	done
8461b8
        export PINENTRY_BINARY="/usr/bin/pinentry-curses"
d1ad85
fi
d1ad85
fi
d1ad85
d1ad85
exec $PINENTRY_BINARY "$@"