initial bitwarden script

This commit is contained in:
Morgan McMillian 2023-04-09 17:54:01 -07:00
parent 3e92eacd8d
commit 6bbceda0b9
3 changed files with 52 additions and 1 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) <year> <copyright holders>
Copyright (c) 2023 Morgan McMillian
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

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;