aboutsummaryrefslogtreecommitdiff
path: root/sh/kp
diff options
context:
space:
mode:
Diffstat (limited to 'sh/kp')
-rw-r--r--sh/kp21
1 files changed, 21 insertions, 0 deletions
diff --git a/sh/kp b/sh/kp
new file mode 100644
index 0000000..8094380
--- /dev/null
+++ b/sh/kp
@@ -0,0 +1,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