summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpass
blob: 8153dc664ab22f8bd5139cc1faef4bb0e8af3056 (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
#!/usr/bin/env sh
store="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
lscmd="ls --group-directories-first"
if [ "$MENUCMD" = "tofi" ]
then
	menucmd="tofi --prompt pass:"
elif [ "$MENUCMD" = "dmenu" ]
then
	menucmd="dmenu -l 4 -g 2 -i -p pass:" 
else
	menucmd="fzf --prompt pass:"
fi
while [ -d "$store/$file" ]
do
	choice="$($lscmd "$store/$file" | sed 's/\.gpg$//'| $menucmd)"
	[ "$choice" ] || break
	file="$file/$choice"
done

test -z "$file" && exit 1
pass show -c "$file" &&
	if [ -n "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null
	then
		cliphist list | head -n 1 | cliphist delete
	fi ||
		exit 1
notify-send "mpass" "copied <b>$choice</b>"