config/scripts/bw-unlock

29 lines
530 B
Bash
Executable File

#!/bin/bash
##
# Depends: zenity, bw (bitwarden-cli), notify-send
#
# Generates bw session key and saves it in tmp file where only current user has permissions
#
# By Solomon Laing (solomonlaing@pm.me)
# Date 2020-03-26
##
password=$(zenity --password)
if [ -z $password ]
then
exit 0;
fi
session=$(bw unlock "$password" | awk 'NF{last=$NF} END{print last}')
loc="/tmp/bw-session"
touch $loc -f
chmod 600 $loc
echo "$session" > /tmp/bw-session
notify-send "Your bitwarden vault has been unlocked until next reboot."