The point of GPG_TTY is to tell gpg-agent what terminal to steal with
the pinentry program. Because I like to keep my pinentry bound to the
terminal from which I ran gpg-agent-spawn.sh, it's easier to lock
gpg-agent into that terminal when I spawn it, and avoid reliance on
other terminals setting GPG_TTY appropriately. This should also avoid
problems with GPGME, which seems to ignore GPG_TTY.
# source me!
FILE="${HOME}/.gnupg/agent-info"
-GPG_TTY=$(tty)
-#gpg-agent --daemon --enable-ssh-support --write-env-file "${FILE}" --pinentry-program "/usr/bin/pinentry.py"
-gpg-agent --daemon --write-env-file "${FILE}" --pinentry-program "/usr/bin/pinentry.py"
-echo "export GPG_AGENT_INFO; GPG_TTY='${GPG_TTY}'; export GPG_TTY" >> "${FILE}"
+#todo: --enable-ssh-support
+gpg-agent --daemon \
+ --display "${DISPLAY}" \
+ --ttyname "$(tty)" \
+ --keep-tty \
+ --keep-display \
+ --write-env-file "${FILE}" \
+ --pinentry-program "/usr/bin/pinentry.py"
+echo "export GPG_AGENT_INFO" >> "${FILE}"
source "${FILE}"