]> git.sev.monster Git - dotfiles.git/commitdiff
simplify some gpg stuff, add pinentry fallback
authorsev <git@sev.monster>
Sun, 31 Dec 2023 07:16:56 +0000 (01:16 -0600)
committersev <git@sev.monster>
Fri, 5 Apr 2024 21:27:41 +0000 (16:27 -0500)
bin/pinentry
etc/zsh/.zprofile

index 39349d58b9f26509a6eaad6dab622cf2f49eb25c..5a31bd427e05d67d1672911c9d3460e00f19420d 100755 (executable)
@@ -2,7 +2,7 @@
 # https://kevinlocke.name/bits/2019/07/31/prefer-terminal-for-gpg-pinentry
 
 set -C
-gfx="gnome qt gtk-4 gtk-3 gtk-2 gtk bemenu dmenu x11"
+gfx="qt gnome gtk-4 gtk-3 gtk-2 gtk bemenu dmenu x11"
 tty="curses-ss curses tty"
 case "${PINENTRY_USER_DATA-}" in
        # prefer tty unless USE_TTY is 0
@@ -17,4 +17,7 @@ for x in $list; do
        fi
 done
 
+# fallback
+exec pinentry "$@"
+
 echo "No pinentry program found" >&2
index 407c3009fe16e637e6c0fc9ec0f5c108f3720d4a..58ebfa1fba81381e8fae2813792eeb14f644244d 100644 (file)
@@ -143,18 +143,15 @@ if [[ -v commands[gpg-connect-agent] &&
                 export GPG_TTY=$(tty)
             if [[ ( -v DISPLAY || -v WAYLAND_DISPLAY ) &&
                   ${PINENTRY_USER_DATA/USE_TTY=0} == $PINENTRY_USER_DATA ]]
-                export PINENTRY_USER_DATA=USE_TTY=$((
-                  ${+DISPLAY} + ${+WAYLAND_DISPLAY} == 0))
-            # XXX: don't know if gpg-agent supports comments after directives
-            # XXX: path could have #
+                export PINENTRY_USER_DATA=USE_TTY=0
             # XXX: we are assuming this is our pinentry from .local/bin
-            sed -Ei 's#^([[:space:]]*pinentry-program[[:space:]]).*$#\1'$HOME'/.local/bin/pinentry#' \
+            sed -Ei 's\1f^([[:space:]]*pinentry-program[[:space:]]).*$\1f\1'$HOME'/.local/bin/pinentry\1f' \
               ${GNUPGHOME:-~/.gnupg}/gpg-agent.conf 2>/dev/null
             # XXX: could check for changes before doing this to save perf
             gpg-connect-agent RELOADAGENT UPDATESTARTUPTTY /bye >/dev/null 2>&1
             if {$p} {
                 gpg-connect-agent /subst /serverpid \
-                  "/echo pid \${get serverpid} on $GPG_TTY" /bye 2>/dev/null
+                  "/echo pid \${get serverpid} on ${WAYLAND_DISPLAY:-${DISPLAY:-$GPG_TTY}}" /bye 2>/dev/null
                 print -nP '%f'
             }
         } elif {$p} {
This page took 0.033899 seconds and 4 git commands to generate.