summaryrefslogtreecommitdiff
path: root/private_dot_local/bin/executable_pinentry-menu
blob: 5f42c0c8d842b6b84f48586d05c4f49ea9d70796 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

echo "OK Pleased to meet you"

while read line; do
    echo "GPG sent: $line" >> /tmp/pinentry-trace.log
    # Ignore empty lines
    [ -z "$line" ] && continue

    case "$line" in
	*GETPIN*)
	    # Run menu and capture output
	    # We use /dev/tty for input if needed, but wmenu usually handles its own window
	    PIN=$(echo -n | menu -p "Passphrase: " -P)
	    
	    if [ $? -ne 0 ] || [ -z "$PIN" ]; then
		echo "CAN"
	    else
		echo "D $PIN"
		echo "OK"
	    fi
	    ;;
	*BYE*)
	    echo "OK"
	    exit 0
	    ;;
	*)
	    # For everything else (SETDESC, SETPROMPT, OPTION, etc.)
	    # We MUST say OK or the agent thinks we crashed
	    echo "OK"
	    ;;
    esac
done