initial bitwarden script

This commit is contained in:
Morgan McMillian 2023-04-09 17:54:01 -07:00
parent 3e92eacd8d
commit 8293d648da
2 changed files with 51 additions and 0 deletions

45
bwui Executable file
View File

@ -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

6
bwui.desktop Normal file
View File

@ -0,0 +1,6 @@
[Desktop Entry]
Name=BW UI
Type=Application
Icon=applications-utilities
Exec=bwui
Categories=Utility;