Test different locations for "real" rofi-pass

This commit is contained in:
gardouille 2024-03-14 17:22:41 +01:00
parent 512a6ebe46
commit 28e417ea74
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 18 additions and 5 deletions

View File

@ -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
# }}}