updated bw related scripts to deal with user exiting

This commit is contained in:
Solomon Laing 2021-03-30 09:13:12 +10:30
parent fb5725c20e
commit b95f3e1270
3 changed files with 18 additions and 3 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
## ##
# Depends: zenity # Depends: zenity, bw (bitwarden-cli), notify-send
# #
# Generates bw session key and saves it in tmp file where only current user has permissions # Generates bw session key and saves it in tmp file where only current user has permissions
# #
@ -20,3 +20,5 @@ touch $loc -f
chmod 600 $loc chmod 600 $loc
echo "$session" > /tmp/bw-session echo "$session" > /tmp/bw-session
notify-send "Your bitwarden vault has been unlocked until next reboot."

View File

@ -21,6 +21,11 @@ options=$(echo "$items" | jq ".[].name" | sed 's/"//g')
entry=$(echo "$options" | dmenu -i -p "Which entry?" $1) entry=$(echo "$options" | dmenu -i -p "Which entry?" $1)
if [ -z $entry ]
then
exit 0
fi
if ! password=$(bw get password "$entry" --session "$session") if ! password=$(bw get password "$entry" --session "$session")
then then
@ -31,6 +36,11 @@ then
user=$(echo "$user_options" | jq '.[].login.username' | dmenu -i -p "Which account?" $1 | sed 's/"//g') user=$(echo "$user_options" | jq '.[].login.username' | dmenu -i -p "Which account?" $1 | sed 's/"//g')
if [ -z $user ]
then
exit 0;
fi
pass=$(echo "$user_options" | jq '.[] | select(.login.username == "'"$user"'") | .login.password' | sed 's/"//g') pass=$(echo "$user_options" | jq '.[] | select(.login.username == "'"$user"'") | .login.password' | sed 's/"//g')
echo "$pass" | xclip -sel clip echo "$pass" | xclip -sel clip
@ -38,3 +48,5 @@ then
else else
echo "$password" | xclip -sel clip echo "$password" | xclip -sel clip
fi fi
notify-send "password for $entry probably copied to clipbroad"

View File

@ -48,5 +48,6 @@ if [ "$HOST" == "archmetabox" ] ; then
fi fi
# start my trusty window manager # start my trusty window manager
# exec xmonad exec xmonad --recompile
exec xmonad