summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpassgen
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/mpassgen
parent067b271a243dafcf652fe7cfe85e723d25ff1a64 (diff)
[menuscripts] use 'commander' in menuscripts
Diffstat (limited to 'bin/menuscripts/mpassgen')
-rwxr-xr-xbin/menuscripts/mpassgen45
1 files changed, 10 insertions, 35 deletions
diff --git a/bin/menuscripts/mpassgen b/bin/menuscripts/mpassgen
index 8384542..51b9bc4 100755
--- a/bin/menuscripts/mpassgen
+++ b/bin/menuscripts/mpassgen
@@ -1,46 +1,21 @@
#!/usr/bin/env sh
-input ()
-{
- # menu prompt for output
- if [ "$MENUCMD" = "tofi" ]
- then
- inp="$(tofi --prompt-text "$1 " </dev/null)"
- elif [ "$MENUCMD" = "dmenu" ]
- then
- inp="$(dmenu -p "$1" < /dev/null)"
- else
- echo -n "$1" >&2
- read inp
- fi
- echo $inp
-}
-# menu select long
-if [ "$MENUCMD" = "tofi" ]
-then
- menucmd="tofi --prompt login:"
-elif [ "$MENUCMD" = "dmenu" ]
-then
- menucmd="dmenu -l 10 -g 1 -x -i -p login:"
-else
- menucmd="fzf"
-fi
+input () { commander -c -i -p "$1"; }
-choice="$(echo "multiline\nsingle" | $MENUCMD)"
-test -z "${choice}" && exit 1
+choice="$(printf "multiline\nsingle\n" | commander -c -d)"
+[ "$choice" ] || exit 1
password="$(input "name:")"
-test -z "${password}" && exit 1
+[ "$password" ] || exit 1
-if [ "${choice}" = "multiline" ]
+if [ "$choice" = "multiline" ]
then
- login="$(ls -1 ${PASSWORD_STORE_DIR:=$HOME/.password-store}/e-mails |
- sed 's/\.gpg$//' |
- $menucmd)"
- test -z "${login}" && exit 1
+ login="$(find "${PASSWORD_STORE_DIR:=$HOME/.password-store}"/e-mails -type f -maxdepth 1 -iname "*.gpg" -printf "%f\n" |
+ sed 's/\.gpg$//' | commander -c -d -p 'login:')"
+ [ "$login" ] || exit 1
url="$(input "url:")"
- test -z "${url}" && exit 1
- echo "${password}\nlogin: ${login}\nurl: ${url}" |
+ [ "$url" ] || exit 1
+ printf "%s\nlogin: %s\nurl: %s\n" "${password}" "${login}" "${url}" |
pass insert -mf "${password}"
pass generate -ci "${password}"
else