From c5a12d565d4fa5c64cba4720cf7329a4bba89dd3 Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Sat, 25 Nov 2023 18:13:52 -0500 Subject: [PATCH] Add passmenu --- passmenu | 37 +++++++++++++++++++++++++++++++++++++ secrets.json | 3 +++ 2 files changed, 40 insertions(+) create mode 100755 passmenu create mode 100644 secrets.json diff --git a/passmenu b/passmenu new file mode 100755 index 0000000..6c9c3df --- /dev/null +++ b/passmenu @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +LINES=25 + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +if [[ -n $WAYLAND_DISPLAY ]]; then + dmenu=dmenu-wl + xdotool="ydotool type --file -" +elif [[ -n $DISPLAY ]]; then + dmenu=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[@]}" | "$dmenu" "-l" "$LINES" "$@") + +[[ -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 diff --git a/secrets.json b/secrets.json new file mode 100644 index 0000000..e63d37b --- /dev/null +++ b/secrets.json @@ -0,0 +1,3 @@ +{ + "foo": "bar" +}