From 0ad890bae271b17a7eaf76f70b2c462e4ca10333 Mon Sep 17 00:00:00 2001 From: zachir Date: Sun, 9 Oct 2022 01:19:04 -0500 Subject: reorganize .local/bin folder --- passmenu | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 passmenu (limited to 'passmenu') diff --git a/passmenu b/passmenu new file mode 100755 index 0000000..fd91178 --- /dev/null +++ b/passmenu @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +if [[ -n $WAYLAND_DISPLAY ]]; then + barmenu=tofi + xdotool="ydotool type --file -" +elif [[ -n $DISPLAY ]]; then + barmenu=dmenu + xdotool="xdotool type --clearmodifiers --file -" +else + echo "Error: No Wayland or X11 display detected" >&2 + exit 1 +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | "$barmenu" "$@") + +[[ -n $password ]] || exit + +if [[ $typeit -eq 0 ]]; then + pass show -c "$password" 2>/dev/null +else + pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool +fi -- cgit v1.2.3