pin.sh (796B)
1 #!/bin/sh 2 # 3 # pin 4 5 get_pin() { 6 prompt='Pin' 7 8 # get pin using dmenu and check 9 if pin="$(dmenu -c -p "${prompt}" -P 2>/dev/null)"; then 10 [ -n "${pin}" ] && printf '%s\n' "D ${pin}" 11 printf 'OK\n' 12 # operation cancelled 13 else printf 'ERR 99\n' 14 fi 15 } 16 17 main() { 18 # export display 19 if [ -z "${DISPLAY}" ]; then 20 DISPLAY=':1' 21 export DISPLAY 22 fi 23 24 # start msg 25 printf 'OK Pleased to meet you\n' 26 27 # ipc 28 while read -r line; do 29 # cmds needed to interface with pinentry 30 cmd="$(printf '%s\n' "${line}" | cut -d ' ' -f 1)" 31 32 case "${cmd}" in 33 # GETPIN is command pinentry uses for GNUPG pass 34 GETPIN) get_pin ;; 35 *) printf 'OK\n' ;; 36 esac 37 done 38 } 39 40 main "${@}"