summaryrefslogtreecommitdiff
path: root/private_dot_local/bin/executable_passmenu
blob: 1aa1158ad1838e0eff5b60f786faab02cf06f624 (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
34
35
36
37
38
39
40
41
42
#!/bin/sh

typeit=0
nameit=0
while true; do
    case $1 in
	"--type")
	    typeit=1
	    shift
	    ;;
	"--name")
	    nameit=1
	    shift
	    ;;
	*)
	    break
	    ;;
    esac
done

prefix=${PASSWORD_STORE_DIR-~/.password-store}
password=$(find $prefix -name '*.gpg' | sed "s@$prefix/\(.*\)\.gpg@\1@" | $MENU "$@")

[ -n "$password" ] || exit

if [ $nameit = 0 ]; then
    what=$(pass show "$password" | head -n 1)
    [ -n "$what" ] || exit
else
    what=$(basename $password)
fi

if [ $typeit = 0 ]; then
    printf "$what" | wl-copy
    if [ $nameit = 0 ]; then
	notify-send "Coppied password for:" "$password"
    else
	notify-send "Coppied password name:" "$password"
    fi
else
    printf "$what" | wtype - -k Tab
fi