refactored fzf-pass

- username and password are no longer stored and passed as variables
- no longer need to relocated to unused workspace to function.
- fixed (hopefully logic in page)
This commit is contained in:
James Patrick 2020-08-16 00:43:28 -04:00
parent 468c6f9f19
commit 3c3ca9309d
1 changed files with 10 additions and 15 deletions

View File

@ -13,37 +13,32 @@ if [ -z "$PASSFILE" ]; then
exit 0
fi
PASSDATA="$(pass "$PASSFILE")"
USRNAME="$(echo "$PASSDATA" | grep "username:" | cut -d' ' -f2-)"
PASS="$(echo "$PASSDATA" | head -n 1)"
URL="$(echo "$PASSDATA" | grep url: | cut -d' ' -f2-)"
RESP=$(cat <<EOF | fzf
Autotype
Username
Password
URL
Page
EOF
);
swaymsg move container to workspace 9
case "$RESP" in
Autotype)
ydotool type "$USRNAME" && ydotool key Tab && ydotool type "$PASS" && ydotool key Enter
swaymsg exec "source ~/.profile \
&& ydotool type \"\$(pass get_user $PASSFILE)\" \
&& ydotool key TAB \
&& ydotool type \"\$(pass get_pass $PASSFILE)\""
;;
Username)
ydotool type "$USRNAME"
swaymsg exec "source ~/.profile \
&& ydotool type \"\$(pass get_user $PASSFILE)\""
;;
Password)
ydotool type "$PASS"
;;
URL)
ydotool type "$URL"
swaymsg exec "source ~/.profile \
&& ydotool type \"\$(pass get_pass $PASSFILE)\""
;;
Page)
"$(dirname "$0")/tty-popup" info "bash -c 'echo ${PASSDATA} | LESS=R less'"
"$HOME/.config/sway/scripts/tty-popup" info \
bash -c "pass \"${PASSFILE}\" | LESS=R less"
;;
*)
exit 1