summaryrefslogtreecommitdiff
path: root/util/pinentry/stumpwm-pinentry
blob: e0aff38c5de0fe7e806b1e17817f0fbf5b1cb31e (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
#!/usr/bin/env bash

command -v nc >/dev/null || { echo >&2 "Netcat not installed. Aborting."; exit 1; }

echo OK Your orders please

while IFS="\n" read -r command; do
    if [ "$command" == "GETINFO flavor" ]; then
        echo D stumpwm
    elif [[ "$command" == SETDESC* ]]; then
        description=${command:8}
    elif [[ "$command" == SETPROMPT* ]]; then
        prompt=${command:10}
    elif [ "$command" == GETPIN ]; then
        password=$(stumpish eval "(pinentry:getpin \"$description\" \"$prompt\")" | cut -d '""' -f 2)
        if [ -z "$password" ]; then
            echo S close_button
        fi
        echo D "$password"
    elif [ "$command" == BYE ]; then
        exit 0
    fi
    echo OK
done < /dev/stdin