12345678910111213141516171819202122232425262728293031323334353637 |
- #!/usr/bin/env bash
- function log {
- if [ -t 1 ]; then
- echo "$@" >&2
- fi
- }
- function prompt_password {
- if command -v kdialog >/dev/null; then
- kdialog --password Password
- else
- zenity --password --timeout=60
- fi
- }
- function get_from_keepassxc {
- keepassxc-cli show -q "$KEEPASS_FILE" "$1" -a "$2" <<< "$3"
- }
- function get_credentials {
- local opPassword
- local password
- if ! password=$(prompt_password 2> /dev/null); then
- log "Failed to get password"
- return 1
- fi
- if ! opPassword=$(get_from_keepassxc "$KEEPASS_OP_ENTRY" Password "$password"); then
- log "Failed to open vault"
- exit 1
- fi
- op signin -f <<<"$opPassword"
- }
- get_credentials
|