summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpass
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-24 21:11:27 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-24 21:11:27 +0200
commit8b9e93321bfd229b8a29fdd1fc60de670e16636d (patch)
tree60963be78e9bca76d996be3de468fc4e03deb137 /bin/menuscripts/mpass
parent067b271a243dafcf652fe7cfe85e723d25ff1a64 (diff)
[menuscripts] use 'commander' in menuscripts
Diffstat (limited to 'bin/menuscripts/mpass')
-rwxr-xr-xbin/menuscripts/mpass32
1 files changed, 17 insertions, 15 deletions
diff --git a/bin/menuscripts/mpass b/bin/menuscripts/mpass
index 4ecd4bc..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
-test -z "$file" && exit 1
+[ "$file" ] || exit 1
pass show -c "$file" || exit 1
-notify-send -t 1000 "mpass" "copied <b>$choice</b>"
+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