diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-14 00:58:22 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-14 02:16:16 +0100 |
commit | dffd09001ccdf3d4d23ca3f37ac9878e41450a3b (patch) | |
tree | 8798932a604507d9d7b7761c5666acb52994bcae /files/passmenu | |
parent | Gandalf web certbot. (diff) | |
download | profiles-dffd09001ccdf3d4d23ca3f37ac9878e41450a3b.tar.gz profiles-dffd09001ccdf3d4d23ca3f37ac9878e41450a3b.tar.xz |
Migrate stuff from ansible.
Diffstat (limited to '')
-rwxr-xr-x | files/passmenu | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/files/passmenu b/files/passmenu new file mode 100755 index 0000000..653ebda --- /dev/null +++ b/files/passmenu @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +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 "$@") + +[[ -n $password ]] || exit + +if [[ "$password" == *-otp ]]; then + otp='otp' +fi + +if [[ $typeit -eq 0 ]]; then + pass $otp show -c "$password" 2>/dev/null +else + pass $otp show "$password" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - +fi |