aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorMario Forzanini <mf@marioforzanini.com>2024-08-04 21:06:50 +0200
committerMario Forzanini <mf@marioforzanini.com>2024-08-04 21:06:50 +0200
commitf273588d5ffc4651cd8e94d233372955a607feb9 (patch)
tree06ebb562bdc4119c07441d3a998393de5874b9ee /sh
parent7c1ce8d2c9cd296022c3ef212dc03a2b30c2bebe (diff)
Add sh/kp to prompt for keepass passwordsHEADmaster
Diffstat (limited to 'sh')
-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