diff options
| author | ivan-boikov <ik.boikov.public@protonmail.com> | 2021-08-07 19:24:25 +0200 |
|---|---|---|
| committer | ivan-boikov <ik.boikov.public@protonmail.com> | 2021-08-07 19:24:25 +0200 |
| commit | 4d917e227b80c7b15beaa054e8c3c1409b8d273d (patch) | |
| tree | b472c845a5303f16e080aa93b338679c8c7794ac /scripts | |
| parent | 395a14503492fd39495812395904e8685293ba2c (diff) | |
| parent | f2b9860ff378bc0a02137bc1a8955a51705e2935 (diff) | |
Merge branch 'master' of github.com:ivan-boikov/.dotfiles
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/.local/bin/dpass | 36 | ||||
| -rwxr-xr-x | scripts/.local/bin/pass-askpass | 9 |
2 files changed, 45 insertions, 0 deletions
diff --git a/scripts/.local/bin/dpass b/scripts/.local/bin/dpass new file mode 100755 index 0000000..9da7c0d --- /dev/null +++ b/scripts/.local/bin/dpass @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +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 30 "$@") + +[[ -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/scripts/.local/bin/pass-askpass b/scripts/.local/bin/pass-askpass new file mode 100755 index 0000000..6fbb003 --- /dev/null +++ b/scripts/.local/bin/pass-askpass @@ -0,0 +1,9 @@ +#! /bin/sh + +# shellcheck disable=2046 +caller="$(ps -o comm= -p $(ps -o ppid= -p $$))" +prompt="${1:-[$caller]}" +hidden=black + +dmenu -p "$prompt" -nf "$hidden" -nb "$hidden" <&- + |
