summaryrefslogtreecommitdiff
path: root/.local/bin/dmenu/dm-pass
blob: 542054933f5d2f43d1ddd61bacfc52f1d60826f3 (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
#!/bin/sh

DMENU_CMD="dmenu -p 'Pass:' -b -i -fn 'JetBrainsMono Nerd Font:size=11'"

entry=$(find "$PASSWORD_STORE_DIR" -name '*.gpg' |\
    sed "s|$PASSWORD_STORE_DIR/||" |\
    sed "s|.gpg||" |\
    sort -n |\
    eval "$DMENU_CMD") || exit 1

details=$(pass "$entry") || exit 1
user=$(echo "$details" | sed -n '2p' | sed 's|user: ||')
pass=$(echo "$details" | head -n1)

case "$(printf "autotype\npass\nuser" | eval "$DMENU_CMD")" in         
    autotype) 
        xdotool type "$user"
        xdotool key Tab
        xdotool type "$pass" ;;
    pass) 
        xdotool type "$pass" ;;
    user) 
        xdotool type "$user" ;;
esac