From 28e417ea74ca4d7169031e5a31ddc462dbd3c7b3 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Thu, 14 Mar 2024 17:22:41 +0100 Subject: [PATCH] Test different locations for "real" rofi-pass --- rofi-pass | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/rofi-pass b/rofi-pass index 2dcb0b6..2cf6061 100755 --- a/rofi-pass +++ b/rofi-pass @@ -2,7 +2,7 @@ # # Purpose {{{ # This script will : -# 1. If non gpg-key is in cache. +# 1. If no gpg-key is in cache. # a. Run a terminal with a tmux splits (at least a split to enter gpg passphrase). # b. Wait until timeout. # c. Check every second if a key is now cached. @@ -23,6 +23,19 @@ TERM_TITLE="Authentication with tmux" TIMEOUT=60 TIME=1 +# Get "real" rofi-pass binary path {{{ +if [ -f /bin/rofi-pass ]; then + ROFI_PASS_BIN="/bin/rofi-pass" +elif [ -f /usr/bin/rofi-pass ]; then + ROFI_PASS_BIN="/usr/bin/rofi-pass" +elif [ -f "${HOME}"/repos/rofi-pass/rofi-pass ]; then + ROFI_PASS_BIN="${HOME}/repos/rofi-pass/rofi-pass" +else + printf '%s' "No rofi-pass binary available" + exit 1 +fi +# }}} + # If gpg-agent doesn't have any key in cache if [ "${gpg_agent_info}" -eq 0 ]; then ## Start a terminal emulator @@ -57,16 +70,16 @@ if [ "${gpg_agent_info}" -eq 0 ]; then ## If a gpg key is finally in cache if [ "${gpg_agent_info}" -eq 1 ]; then # Then, call real rofi-pass - "${HOME}"/repos/rofi-pass/rofi-pass + "${ROFI_PASS_BIN}" else - exit 1 + exit 2 fi # If gpg-agent already have a key in cache {{{ elif [ "${gpg_agent_info}" -gt 0 ]; then # Then, call real rofi-pass - "${HOME}"/repos/rofi-pass/rofi-pass + "${ROFI_PASS_BIN}" else # Not supposed to happen - exit 2 + exit 3 fi # }}}