aboutsummaryrefslogtreecommitdiff
path: root/sh/kp
blob: 80943807512f967b289e4e3a602a07edf21a86da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh -e

if [[ -n $WAYLAND_DISPLAY ]]; then
	dmenu="wofi --dmenu"
elif [[ -n $DISPLAY ]]; then
	dmenu=dmenu
else
	echo "Error: No Wayland or X11 display detected" >&2
	exit 1
fi

db="$HOME/.local/share/Passwords.kdbx"
entry="$(pass keepass | keepassxc-cli ls $db | $dmenu)"

if [ ! -z "$entry" ]; then
   pass keepass | keepassxc-cli clip "$db" "$entry" &
   pid=$!
   sleep 0.5
   notify-send "KeepassXC" "Clipped $entry"
   wait $pid && notify-send "KeepassXC" "Clipboard cleared"
fi