From 0047220084e0769e13984088a63e3945d8b3dc8f Mon Sep 17 00:00:00 2001 From: Matthew Forrester Date: Sat, 18 Apr 2020 19:57:41 +0100 Subject: [PATCH 1/6] Support xdotool as well as ydotool --- README.md | 2 +- fzf-pass | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ee1ba8a..7470a78 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is a script heavily inspired by [rofi-pass](https://github.com/carnager/rofi-pass), but with FZF instead of Rofi. There's still a lot to do and this is just the first version. As it is now, it is only compatible with [Sway](https://github.com/swaywm/sway) (see TODO section) ### TODO -- Figure out a way to keep ydotool running after the popup terminal closes. Right now we can only support Sway because swaymsg is used to move the terminal out of the way +- Figure out a way to keep ydotool / xdotool running after the popup terminal closes. Right now we can only support Sway because swaymsg is used to move the terminal out of the way - Add detection for different fields, and show them only if they are there. Right now every field is hardcoded - Add copy to clipboard option - Make the most used pass entries show up first (don't know if it can be done with fzf) diff --git a/fzf-pass b/fzf-pass index 6973f82..e0e7df2 100755 --- a/fzf-pass +++ b/fzf-pass @@ -1,5 +1,17 @@ #!/usr/bin/env bash + +function ldotool { + ydotool type "" + if [ $? eq 0 ]; then + ydotool "$@" + else + xdotool "$@" + fi + return $? +} + + cd $HOME/.password-store PASSFILE=$(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g' | sed 's/^..//' | fzf) @@ -21,23 +33,28 @@ URL EOF ); -swaymsg move container to workspace 9 +CURRENT_WORKSPACE=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused == true)' | jq -r .name) +if [ "$CURRENT_WORKSPACE" -eq 9 ]; then + swaymsg move container to workspace 8 +else + swaymsg move container to workspace 9 +fi case "$RESP" in Autotype) - ydotool type "$USRNAME" && ydotool key Tab && ydotool type "$PASS" && ydotool key Enter + ldotool type "$USRNAME" && ldotool key Tab && ldotool type "$PASS" && ldotool key Enter ;; Username) - ydotool type "$USRNAME" + ldotool type "$USRNAME" ;; Password) - ydotool type "$PASS" + ldotool type "$PASS" ;; OTP) - ydotool type "$(pass otp $PASSFILE)" + ldotool type "$(pass otp $PASSFILE)" ;; URL) - ydotool type "$URL" + ldotool type "$URL" ;; *) exit 1 From 7586614b33c2c1537fa1c657834997dcfb523e80 Mon Sep 17 00:00:00 2001 From: Matthew Forrester Date: Sun, 20 Mar 2022 07:03:56 +0000 Subject: [PATCH 2/6] feat: OSD for identifying when typing is complete --- fzf-pass | 77 +++++++++++++++-------------------------- fzf-pass-window-control | 4 +++ 2 files changed, 31 insertions(+), 50 deletions(-) create mode 100755 fzf-pass-window-control diff --git a/fzf-pass b/fzf-pass index e0e7df2..ce82423 100755 --- a/fzf-pass +++ b/fzf-pass @@ -1,61 +1,38 @@ #!/usr/bin/env bash +TO_WINDOW="$1" +PASS_WINDOW="$(xdotool getactivewindow)" -function ldotool { - ydotool type "" - if [ $? eq 0 ]; then - ydotool "$@" - else - xdotool "$@" - fi - return $? -} +set -euo pipefail +IFS=$'\n\t' - -cd $HOME/.password-store -PASSFILE=$(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g' | sed 's/^..//' | fzf) +cd "$HOME/.password-store" || exit 1 +PASSFILE="$(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g' | sed 's/^..//' | fzf)" if [ -z "$PASSFILE" ]; then exit 0 fi -PASSDATA="$(pass $PASSFILE)" -USRNAME="$(echo "$PASSDATA" | egrep -i "username:|user:" | head -1 | cut -d' ' -f2-)" -PASS="$(echo "$PASSDATA" | head -n 1)" -URL="$(echo $PASSDATA | grep url: | cut -d' ' -f2-)" - -RESP=$(cat < Date: Sun, 20 Mar 2022 07:08:46 +0000 Subject: [PATCH 3/6] feat: minimize pass window after use --- fzf-pass | 1 + 1 file changed, 1 insertion(+) diff --git a/fzf-pass b/fzf-pass index ce82423..b45a979 100755 --- a/fzf-pass +++ b/fzf-pass @@ -32,6 +32,7 @@ if [ "$RESP" != "PASSWORD" ]; then O="$(echo "$PASSDATA" | awk -F ':' -v VAR="$RESP" '$1==VAR { Z=substr($0, length($1) + 2); gsub(/^[ \t]+|[ \t]+$/, "", Z); print Z }')" fi +xdotool windowminimize "$PASS_WINDOW" xdotool windowactivate "$TO_WINDOW" sleep 0.5 xdotool type "$O" From fcd5004d8ede0654548470e73d2a4bef54a093dd Mon Sep 17 00:00:00 2001 From: Matthew Forrester Date: Sun, 1 May 2022 16:25:28 +0100 Subject: [PATCH 4/6] fix: windowminimize made windows float in paperwm --- fzf-pass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fzf-pass b/fzf-pass index b45a979..da2dc5a 100755 --- a/fzf-pass +++ b/fzf-pass @@ -32,7 +32,7 @@ if [ "$RESP" != "PASSWORD" ]; then O="$(echo "$PASSDATA" | awk -F ':' -v VAR="$RESP" '$1==VAR { Z=substr($0, length($1) + 2); gsub(/^[ \t]+|[ \t]+$/, "", Z); print Z }')" fi -xdotool windowminimize "$PASS_WINDOW" +# xdotool windowminimize "$PASS_WINDOW" xdotool windowactivate "$TO_WINDOW" sleep 0.5 xdotool type "$O" From 7d20b6c6a240a3db9942e0fd4632036254b72d29 Mon Sep 17 00:00:00 2001 From: Matthew Forrester Date: Thu, 16 Feb 2023 08:53:42 +0000 Subject: [PATCH 5/6] feat: otp support --- fzf-pass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fzf-pass b/fzf-pass index da2dc5a..1788cba 100755 --- a/fzf-pass +++ b/fzf-pass @@ -17,6 +17,13 @@ PASSDATA=$(pass "$PASSFILE") MENU=($(echo "$PASSDATA" | tail -n +2 | sed 's/\:.*//' )) MENU+=("DISPLAY") +if echo "$PASSDATA" | grep '^otpauth' > /dev/null; then + MENU+=("OTP") +fi +if echo "$PASSDATA" | grep -i '^username: ' > /dev/null; then + MENU+=("USERNAME") + MENU="$(echo $MENU | grep -v '^username: ')" +fi MENU+=("PASSWORD") RESP=$(printf "%s\n" "${MENU[@]}" | fzf --tac) @@ -31,6 +38,17 @@ O="$(echo "$PASSDATA" | head -n 1)" if [ "$RESP" != "PASSWORD" ]; then O="$(echo "$PASSDATA" | awk -F ':' -v VAR="$RESP" '$1==VAR { Z=substr($0, length($1) + 2); gsub(/^[ \t]+|[ \t]+$/, "", Z); print Z }')" fi +if [ "$RESP" == "OTP" ]; then + O="$(pass otp "$PASSFILE")" +fi +if [ "$RESP" == "USERNAME" ]; then + O="$(pass show "$PASSFILE" | grep -i '^username: ' | sed 's/^[^:]\+\: *//')" +fi + +if [ -z "$TO_WINDOW" ]; then + echo $O + exit +fi # xdotool windowminimize "$PASS_WINDOW" xdotool windowactivate "$TO_WINDOW" From a210621fc94374754ddd11084416377091422cac Mon Sep 17 00:00:00 2001 From: Matthew Forrester Date: Mon, 14 Aug 2023 20:12:58 +0100 Subject: [PATCH 6/6] feat: delay closing --- fzf-pass | 1 + 1 file changed, 1 insertion(+) diff --git a/fzf-pass b/fzf-pass index 1788cba..325a553 100755 --- a/fzf-pass +++ b/fzf-pass @@ -55,3 +55,4 @@ xdotool windowactivate "$TO_WINDOW" sleep 0.5 xdotool type "$O" echo Done | aosd_cat -p 4 -n "Anonymous Pro 99" -R lime +sleep 15