diff --git a/bwui b/bwui new file mode 100755 index 0000000..9f82fd9 --- /dev/null +++ b/bwui @@ -0,0 +1,45 @@ +#!/bin/bash + +# Prompt for master password +PASS=$(yad --title "Master Password" --width=400 --entry --hide-text) +RC=$? +if [[ $RC -eq 1 ]]; then + exit 0 +fi + +# Unlock the session +export BW_SESSION=$(bw unlock $PASS --raw) +if [[ ${#BW_SESSION} -eq 0 ]]; then + yad --title "Error" --text="Invalid master password." --button="Close" + exit 1 +fi + +# Prompt for a search +SEARCH=$(yad --form --title "Search Bitwarden" --width=400 --entry) +RC=$? +if [[ $RC -eq 1 ]]; then + exit 0 +fi + +# Display the results +SID=$(bw list items --search "$SEARCH" | \ + jq '.[] | {id, name, username: .login.username, url: .login.url}' | \ + jq '.id,.name,.username,.url' | \ + yad --title "Bitwarden Entries" --list --width=600 --height=600 \ + --column="ID" --column="Name" --column="Username" --column="URL" \ + --hide-column=1 | cut -d '|' -f 1 | tr -d '"') +if [[ ${#SID} -eq 0 ]]; then + exit 0 +fi + +# Fetch the password for a selected entry +PW=$(bw get password "$SID") + +yad --title "BW" --text="Password ready." --button="Copy:2" --button="Close:1" +RC=$? +if [[ $RC -eq 2 ]]; then + echo $PW | wl-copy + yad --title "BW" --button="Close:1" +fi + +wl-copy --clear diff --git a/bwui.desktop b/bwui.desktop new file mode 100644 index 0000000..373ba26 --- /dev/null +++ b/bwui.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=BW UI +Type=Application +Icon=applications-utilities +Exec=bwui +Categories=Utility;