pfr Upon removing read x, on the first instance obviously, the pinentry window opens, but once you enter the passphrase the window closes, also clearing the clipboard.
Update: patched patch!
Turns out pass
is written in bash
(I had assumed C
) and it wasn't too hard to go through it and find the problem. There is a bug in pass
with non-interactive shells.
Patch:
--- pass.orig 2020-07-17 13:45:22.000000000 +0000
+++ pass 2020-10-06 23:08:41.159955217 +0000
@@ -157,6 +157,12 @@
local sleep_argv0="password store sleep on display $DISPLAY"
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
local before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | $BASE64)"
+ # Explicitly ignore SIGHUP because "disown" only works in interactive shells.
+ # Otherwise, in non-interactive cases like "xterm -e passmenu" or "xterm -e pass",
+ # which is needed to supply a terminal for pinentry when the script is called from
+ # a GUI, bash will kill xclip when the script finishes ie. before $CLIP_TIME has
+ # elapsed.
+ trap '' HUP
echo -n "$1" | xclip -selection "$X_SELECTION" || die "Error: Could not copy data to the clipboard"
(
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '$CLIP_TIME' & wait" )
@@ -173,7 +179,7 @@
qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory &>/dev/null
echo "$before" | $BASE64 -d | xclip -selection "$X_SELECTION"
- ) >/dev/null 2>&1 & disown
+ ) >/dev/null 2>&1 &
echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
}
You can either use the original passmenu.sh
or the 2-piece version (both called via xterm -e ...
as before to supply a terminal). They both do the same thing, just their aesthetics differ (with the first you get a blank screen before pinentry when selecting items; with the other you don't). You won't need the read x
pauses now.
OK...back to sleep. (Woke up for a whizz and this started nagging, so I had to sit down and do something about it.)