commit 355ecb93b1cc4f5069a54e810cd8af30dcb2d424 parent 57896938dcd3bfeb6b3cde582ae95c3b1fc56ebc Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Wed, 16 Jan 2019 13:05:55 +0100 Find and insert passwords via dmenu Diffstat:
M | links/.config/i3/config | | | 1 | + |
A | links/bin/passmenu | | | 25 | +++++++++++++++++++++++++ |
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/links/.config/i3/config b/links/.config/i3/config @@ -110,6 +110,7 @@ bindsym $mod+m exec $term -e tmux-mutt.sh bindsym $mod+n exec $term -e ranger bindsym $mod+o exec --no-startup-id ddspawn fuzzylaunch bindsym $mod+p exec --no-startup-id ddspawn dropdowncalc +bindsym $mod+Shift+p exec --no-startup-id ~/bin/passmenu bindsym $mod+q kill bindsym $mod+r exec $term -e tmux-newsboat.sh bindsym $mod+t exec --no-startup-id message -p diff --git a/links/bin/passmenu b/links/bin/passmenu @@ -0,0 +1,25 @@ +#!/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_themed -i "$@") + +[[ -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 type --clearmodifiers --file - +fi