dotfiles/scripts/wlrofi-rbw
2021-09-22 09:58:13 -05:00

70 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Very basic interface for rbw using rofi
if [ $(hostname) = "syl" ]; then
style="laptop-rbw"
#echo "this is hidpi"
else
style="desktop-rbw"
#echo "this is not hidpi"
fi
# Get all password files and create an array
root=~/.password-store
CACHE=~/.local/tmp/pass_rofi
seat=seat0
rbw sync
rbw list
list_passwords() {
rbw list
}
passwords=$(rbw list)
prompt='search for passwords...'
SECRET=$(list_passwords | wofi -i -p"${prompt}" -d)
# Ask whether pass, user or both are required
options=("Password" \
"User" \
"User and password" \
"QR-Code" \
"OTP")
option=$(printf '%s\n' "${options[@]%}" | wofi -id -W 400 -H 150 -p"...")
# echo $option
case ${option} in
Password )
# echo "${SECRET}"
ydotool type $(rbw get "${SECRET}")
;;
User )
ydotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
;;
"User and password" )
ydotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
ydotool key TAB
ydotool type $(rbw get "${SECRET}")
;;
"QR-Code" )
if [[ $SECRET =~ wifi$ ]]; then
# Produce a valid wifi QR-code
WIFISSID=$(pass get_user ${SECRET})
WIFIPASS=$(pass get_pass ${SECRET})
WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
else
# Only password
pass show -q1 ${SECRET}
fi
;;
"OTP" )
ydotool type $(rbw code ${SECRET})
;;
esac
# wl-copy -o -s ${seat} ${PASSWD_PASS}