blob: 7f0a3068e2c9cad464a28e09756cd254749b765b (
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 bash
# LICENSE: GPLv2+
# https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu
set -eo pipefail
shopt -s nullglob globstar
printf "\n" | $copy
copy='xsel --input --primary'
menu='dmenu -f -i -b -nhf #ffeb3b -sf #ffeb3b -p ⠀:::⠀passwords⠀:::'
_paste () { xdotool type "$(xsel --output --primary)"; }
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[@]}" | $menu)
[ -n "$password" ] || exit
{ pass show "$password" 2>/dev/null | $copy && _paste; } ||
{ notify-send --urgency=critical --expire-time=5000 "Failed to copy $password to primary clipboard." && exit 1; }
printf "\n" | $copy
notify-send "Copied $password to primary clipboard."
|