Adds the option to type a passord in password manager

This commit is contained in:
Jonathan Hodgson 2020-03-11 11:45:16 +00:00
parent 715b2b7d3e
commit 85af6ac011
2 changed files with 30 additions and 2 deletions

View file

@ -3,6 +3,15 @@
PASSWORDS="$HOME/.password-store"
function type_password(){
local password="$1"
local pw=$(pass "$password" | head -n 1)
if [ -z "$pw" ]; then
exit 1
fi
sleep 1
echo "$pw" | xdotool type --clearmodifiers --file -
}
function copy_password(){
local password="$1"
local part="${2:-0}"
@ -40,7 +49,7 @@ if [ -d "$PASSWORDS" ]; then
selection="$1"
ret="${2:-0}"
if [ -z "$selection" ]; then
selection=$((find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -kb-custom-1 "Ctrl-o" -i -l 20)
selection=$((find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -kb-custom-1 "Ctrl-o" -kb-custom-2 "Ctrl-i" -i -l 20)
ret="$?"
fi
if [ -n "$selection" ]; then
@ -52,7 +61,11 @@ if [ -d "$PASSWORDS" ]; then
name="$(rofi -dmenu -p Name -lines 0)"
# Todo - create new passwords
else
copy_password "$selection" "$ret"
if [ "$ret" -ne "11" ]; then
copy_password "$selection" "$ret"
else
type_password "$selection" "$ret"
fi
fi
fi
else