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