summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpass
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-30 08:23:45 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-30 08:23:45 +0200
commit3f8594ee04d2a3d9b40a259daf3b564a53b510fa (patch)
tree66ed50643cdc81af813b5771a99732d0f78bb618 /bin/menuscripts/mpass
parent45d39ae0c67bb086f4df0c366b251e06c888408d (diff)
parent333aaf38c66a1e4ba41d3acea38b21613c0075b2 (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/menuscripts/mpass')
-rwxr-xr-xbin/menuscripts/mpass38
1 files changed, 20 insertions, 18 deletions
diff --git a/bin/menuscripts/mpass b/bin/menuscripts/mpass
index a50f0fb..8d5f4eb 100755
--- a/bin/menuscripts/mpass
+++ b/bin/menuscripts/mpass
@@ -1,25 +1,27 @@
#!/usr/bin/env sh
store="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
-lscmd="ls --group-directories-first"
-if [ "$MENUCMD" = "tofi" ]
-then
- menucmd="tofi --prompt pass:"
-elif [ "$MENUCMD" = "dmenu" ]
-then
- menucmd="dmenu -l 4 -g 2 -i -p pass:"
-else
- menucmd="fzf --prompt pass:"
-fi
+
+# 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="$($lscmd "$store/$file" | sed 's/\.gpg$//'| $menucmd)"
- [ "$choice" ] || break
- file="$file/$choice"
+ choice="$(list_pswds "$store/$file" | commander -c -d)"
+ [ "$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>"
-test -z "$file" && exit 1
-pass show -c "$file" &&
- if [ -n "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null
-then
+[ "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null && # on wayland and cliphist is running
cliphist list | head -n 1 | cliphist delete
-fi