summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpass
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-06 15:29:58 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-06 15:29:58 +0200
commitad05cb18f03f3a97a918e090c38ba760147a0bb6 (patch)
tree233097b3ccbf1a4fef18a291d0d8fda3fba34c03 /bin/menuscripts/mpass
parent1a7e35285abb5db60d2e1544ce0100e82c5d3490 (diff)
parent511b6c1bc9acd9e6029d08a6c448f6e0037755fb (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/menuscripts/mpass')
-rwxr-xr-xbin/menuscripts/mpass27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/menuscripts/mpass b/bin/menuscripts/mpass
new file mode 100755
index 0000000..7029ffe
--- /dev/null
+++ b/bin/menuscripts/mpass
@@ -0,0 +1,27 @@
+#!/usr/bin/env sh
+store="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
+
+# list passwords, group directories first
+list_pswds()
+{
+ find "$1" \
+ -maxdepth 1 -mindepth 1 \
+ -not -name '.*' -type d -printf "%y\t%f\n" -o \
+ -not -name '.*' -not -type d -printf "%y\t%f\n" |
+ sort -k1 -k2 |
+ cut -f 2 | sed 's/\.gpg$//'
+}
+
+while [ -d "$store/$file" ]
+do
+ choice="$(list_pswds "$store/$file" | commander -c)"
+ [ "$choice" ] || exit 1
+ [ -z "$file" ] && file="$choice" || file="$file/$choice"
+done
+[ "$file" ] || exit 1
+
+pass show -c "$file" || exit 1
+notify-send -t 1000 "mpass" "copied <b>$file</b>"
+
+[ "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null && # on wayland and cliphist is running
+ cliphist list | head -n 1 | cliphist delete