summaryrefslogtreecommitdiff
path: root/.local/bin/vlt
blob: 5ef64ce122c20d8eb03c42a1061d0379fb65b0be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

set -e

[ $# -ne 0 ] && {
	echo "Usage: ${0##*/}" >&2
	exit 1
}

: ${vault:="${XDG_DATA_HOME:-$HOME/.local/share}/vault"}
[ -d "$vault" ] || mkdir -p "$vault"
cd "$vault"

# We use ‘*’ instead of ‘.’ to avoid the leading ‘./’
choice="`find * -type f | osel`"
password="`enchive extract "$choice" /dev/stdout`"
[ -n "$password" ] \
	&& { printf '%s' "$password" | wl-copy -no; } \
	&& notify-send -a "${0##*/}" -u normal \
		'Password copied to the clipboard' \
		"The password for ‘$choice’ was copied to the clipboard."