dotfiles/rofi/.config/rofi/modes/gopass

74 lines
1.7 KiB
Text
Raw Normal View History

2019-12-29 22:12:13 +00:00
#!/usr/bin/env sh
# Custom key bindings do not work in script-mode, use a wrapper instead
# Script at .local/bin/rofi-gopass
OLD_GOPASS_GPG_OPTS="$GOPASS_GPG_OPTS"
break_out() {
if [ "$1" -eq 1 ]; then
exit
fi
}
has_xclip() {
if (type xclip >/dev/null 2>&1); then
printf "Your system does not appear to support pasting to clipboard via xclip."
exit 1
else
return 0
fi
}
to_clipboard() {
has_xclip
value="$(gopass show "$1" "$2")"
printf "%s" "$value" | xclip -selection clipboard
notify-send "Password" "Copied pass for $2 to clipboard.\n"
exit
}
show_secrets() {
printf "%s" "$(gopass ls -fo)"
}
# get_key() {
# return echo "$*" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch --export-secret-keys 2>&1
# }
# check_gpg_key() {
# check_keyphrase=$(echo "$*" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch --export-secret-keys 2>&1)
# if echo "$check_keyphrase" | grep -q -e '.*<.*@.*>'; then
# printf "\x00prompt\x1fLogin> \n"
# show_secrets
# elif echo "$check_keyphrase" | grep -q -e "can't get input" - || echo "$check_keyphrase" | grep -q -e "error receiving key" -; then
# printf "\x00prompt\x1fMaster Passphrase> \n"
# printf "%s" "$check_keyphrase"
# else
# echo "passphrase successfully input, $check_keyphrase"
# fi
# }
# has_selected_login() {
# echo "this is passed to ls: $*"
# echo "grep reveals: $(gopass ls -f | grep -e "$*" -)"
# if grep "$(gopass ls -f | grep -q -e "$*" -)"; then
# echo "ls found something"
# true
# else
# false
# fi
# }
# if [ -z "$*" ]; then
# check_gpg_key "$*"
# elif has_selected_login "$*"; then
# echo "has selected login $*"
# else
# check_gpg_key "$*"
# fi
main() {
show_secrets
}
main