summaryrefslogtreecommitdiff
path: root/common/bin/rofipass-wayland
blob: 2dbbd1049e7b47a3d1d02018961009186f153064 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
set -x
shopt -s nullglob globstar

typeit=0
if [[ $1 == "--type" ]]; then
	typeit=1
	shift
fi

prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )

password=$(printf '%s\n' "${password_files[@]}" | rofi -dmenu "$@")

[[ -n $password ]] || exit

if [[ $typeit -eq 0 ]]; then
    wl-copy "$(pass show "$password" | head -1)" & sleep 45s && wl-copy -c
fi