pinentry-wrapper 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. # Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
  3. # Copyright (c) 2009 Fedora Project
  4. # This file and all modifications and additions to the pristine
  5. # package are under the same license as the package itself.
  6. #
  7. # Please submit bugfixes or comments via http://bugs.opensuse.org/
  8. #
  9. # Anna Bernathova <anicka@novell.com> 2006
  10. # Pavel Nemec <pnemec@novell.com> 2006
  11. # Rex Dieter <rdieter@fedoraproject.org> 2009
  12. #
  13. # use proper binary (pinentry-qt, pinentry-gtk-2 or pinentry-curses)
  14. if [ -z "$PINENTRY_BINARY" ]; then
  15. kde_running=
  16. if [ -n "$KDE_FULL_SESSION" ]; then
  17. kde_running=1
  18. elif [ -n "$DISPLAY" ]; then
  19. xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
  20. if test $? -eq 0; then
  21. kde_running=1
  22. fi
  23. else
  24. arg=
  25. display=
  26. for opt in "$@"; do
  27. if [ "$opt" = "--display" ]; then
  28. arg=1
  29. elif [ -n "$arg" ]; then
  30. display="$opt"
  31. else
  32. arg=
  33. fi
  34. done
  35. if [ -n "$display" ]; then
  36. DISPLAY="$display" xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
  37. if test $? -eq 0; then
  38. kde_running=1
  39. fi
  40. fi
  41. fi
  42. # if KDE is detected and pinentry-qt exists, use pinentry-qt
  43. if [ -n "$kde_running" -a -x /usr/bin/pinentry-qt ]
  44. then
  45. export PINENTRY_BINARY="/usr/bin/pinentry-qt"
  46. # otherwise test if pinentry-gnome3 is installed
  47. elif [ -x /usr/bin/pinentry-gnome3 ]
  48. then
  49. export PINENTRY_BINARY="/usr/bin/pinentry-gnome3"
  50. # pinentry-curses is installed by default
  51. else
  52. #test if gui binary is required
  53. for opt in "$@"; do
  54. if [ "x$opt" = "x--display" ]; then
  55. # should not happen because of package dependencies
  56. echo "Please install pinentry-gui" >&2
  57. exit 1
  58. fi
  59. done
  60. export PINENTRY_BINARY="/usr/bin/pinentry-curses"
  61. fi
  62. fi
  63. exec $PINENTRY_BINARY "$@"