From f173ca0ad591f7ad11e6e3755b1d860b2412c8b9 Mon Sep 17 00:00:00 2001 From: krisdoodle45 <86745210+krisdoodle45@users.noreply.github.com> Date: Sat, 25 Sep 2021 10:23:39 +0200 Subject: [PATCH] Some variables --- .local/bin/passwords | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.local/bin/passwords b/.local/bin/passwords index 064ec7f7..de6effab 100644 --- a/.local/bin/passwords +++ b/.local/bin/passwords @@ -2,6 +2,9 @@ shopt -s nullglob globstar +clipb_clear=10 +totp_tmp="${XDG_CACHE_HOME:-$HOME/.cache}/totp-tmp.png" + passwordList() { \ prefix=${PASSWORD_STORE_DIR-~/.password-store} password_files=( "$prefix"/**/*.gpg ) @@ -10,14 +13,14 @@ passwordList() { \ } getPasswords() { \ - choice="$(printf '%s\n' "${password_files[@]}" | grep -v "totp" | dmenu -i -p "Passwords")" + choice="$(printf '%s\n' "${password_files[@]}" | dmenu -i -p "Passwords")" if [ ! -z "$choice" ] then pass "$choice" | xclip -selection clipboard notify-send "📋 Password for $choice copied!" - sleep 10 + sleep $clipb_clear printf "" | xclip -selection clipboard fi @@ -31,7 +34,7 @@ getTOTP() { pass otp "$choice" | xclip -selection clipboard notify-send "📋 OTP for $choice copied!" - sleep 10 + sleep $clipb_clear printf "" | xclip -selection clipboard fi @@ -44,11 +47,11 @@ addTOTP() { \ if [ ! -z "$name" ] then notify-send "📷 Please screenshot the QR code" - maim -m 10 -d 0.1 -s ~/.cache/totp-tmp.png - zbarimg -q --raw ~/.cache/totp-tmp.png | pass otp insert totp-$name && + 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 find QR code!" - rm ~/.cache/totp-tmp.png + notify-send "❌ Failed to add QR code!" + rm "$totp_tmp" fi } @@ -85,7 +88,6 @@ removePassword() { \ } case "$(printf "View password\\nView TOTP\\nAdd password\\nAdd TOTP\\nRemove password" | dmenu -i -p "Passwords")" in - "View password") passwordList && getPasswords ;; "View TOTP") passwordList && getTOTP ;; "Add password") addPassword ;;