#!/bin/sh shopt -s nullglob globstar totp_tmp="${XDG_CACHE_HOME:-$HOME/.cache}/totp-tmp.png" passwordList() { prefix=${PASSWORD_STORE_DIR-~/.password-store} password_files=("$prefix"/**/*.gpg) password_files=("${password_files[@]#"$prefix"/}") password_files=("${password_files[@]%.gpg}") password_files=$(printf '%s\n' "${password_files[@]}") } getPasswords() { choice="$(echo "$password_files" | grep -v "totp" | dmenu -i -p "Passwords")" [ -z "$choice" ] && exit pass -c "$choice" && notify-send "📋 Password for $choice copied!" } getTOTP() { choice="$(echo "$password_files" | grep "totp" | dmenu -i -p "OTP")" [ -z "$choice" ] && exit pass otp -c "$choice" && notify-send "📋 OTP for $choice copied!" } addTOTP() { ifinstalled zbarimg || exit name=$(printf "" | dmenu -i -p "What is the account name?") [ -z "$name" ] && exit notify-send "📷 Please screenshot the QR code" maim -m 10 -d 0.1 -s "$totp_tmp" zbarimg -q --raw "$totp_tmp" | pass otp insert totp-$name && notify-send "🔒 OTP for totp-$name added!" || notify-send "❌ Failed to add QR code!" rm "$totp_tmp" } addPassword() { name=$(printf "" | dmenu -i -p "What is the account name?") [ -z "$name" ] && exit case "$(printf "Random password\\nManual password" | dmenu -i -p "Passwords")" in "Random password") addPass=$(tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~'