: Fixed some issues reported by the CI checks. Some change in jq query.

This commit is contained in:
Mirko König 2021-06-17 14:14:57 +02:00
parent d2e2c8a8b3
commit 468401eecc
1 changed files with 12 additions and 12 deletions

View File

@ -59,26 +59,26 @@ EOF
}
URL=$(echo "$QUTE_URL" | awk -F/ '{print $3}' | sed 's/www.//g')
echo "message-info 'Looking for password for $URL...'" >> $QUTE_FIFO
echo "message-info 'Looking for password for $URL...'" >> "$QUTE_FIFO"
TOKEN=$(rofi -dmenu -password -p "1password: "| op signin --output=raw) || TOKEN=""
if [ -n "$TOKEN" ]; then
UUID_URL=$(op list items --cache --session="$TOKEN" | jq -r '.[] | {uuid, url: [.overview.URLs[]?.u, .overview.url][]?}| "\(.uuid):\(.url)"' | grep "$URL") || UUID_URL=""
UUID=$(op list items --cache --session="$TOKEN" | jq --arg url "$URL" -r '[.[] | {uuid, url: [.overview.URLs[]?.u, .overview.url][]?} | select(.uuid != null) | select(.url != null) | select(.url|test(".*\($url).*"))][.0].uuid') || UUID=""
if [ -z "$UUID_URL" ];then
$(echo "message-error 'No entry found for $URL'" >> $QUTE_FIFO)
if [ -z "$UUID" ];then
echo "message-error 'No entry found for $URL'" >> "$QUTE_FIFO"
TITLE=$(op list items --cache --session="$TOKEN" | jq -r '.[].overview.title' | rofi -dmenu -i) || TITLE=""
echo "$TITLE"|xclip -in -selection clipboard
if [ -n "$TITLE" ]; then
UUID_URL=$(op list items --cache --session="$TOKEN" | jq -r '.[] | "\(.uuid):\(.overview.title)"' | grep "$TITLE") || UUID_URL=""
UUID=$(op list items --cache --session="$TOKEN" | jq -r '.[] | "\(.uuid):\(.overview.title)"' | grep "$TITLE") || UUID=""
else
UUID_URL=""
UUID=""
fi
fi
if [ -n "$UUID_URL" ];then
IFS=: read -r UUID var2 <<< "$UUID_URL"
if [ -n "$UUID" ];then
#IFS=: read -r UUID var2 <<< "$UUID"
ITEM=$(op get item --cache --session="$TOKEN" "$UUID")
PASSWORD=$(echo "$ITEM" | jq -r '.details.fields | .[] | select(.designation=="password") | .value')
@ -95,14 +95,14 @@ if [ -n "$TOKEN" ]; then
TOTP=$(echo "$ITEM" | op get totp --cache --session="$TOKEN" "$UUID") || TOTP=""
if [ -n "$TOTP" ]; then
echo "$TOTP" | xclip -in -selection clipboard
notify-send "One time password for $TITLE: $TOTP in clipboard" -a "Qutebrowser 1Password"
echo "message-info 'Pasted one time password for $TITLE to clipboard'" >> "$QUTE_FIFO"
fi
else
notify-send "No password found for $URL" -a "Qutebrowser 1Password"
echo "message-error 'No password found for $URL'" >> "$QUTE_FIFO"
fi
else
$(echo "message-error 'Entry not found for $UUID_URL'" >> $QUTE_FIFO)
echo "message-error 'Entry not found for $UUID'" >> "$QUTE_FIFO"
fi
else
$(echo "message-error 'Wrong master password'" >> $QUTE_FIFO)
echo "message-error 'Wrong master password'" >> "$QUTE_FIFO"
fi