shell-host/apps/keepassxc/keepassxc-unlock.sh

19 lines
736 B
Bash
Executable File

#!/bin/bash
# Get password using secret-tool and unlock keepassxc
# this currently only works for no password but key only unlock
database=${1:-$KEEPASS_DB_PATH}
keyfile=${2:-$KEEPASS_DB_KEY_PATH}
unlock="dbus-send --print-reply --dest=org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.openDatabase string:$database string:"" string:$keyfile"
if ! qdbus | grep keepassxc; then
echo starting keepassxc first
keepassxc&
sleep 1
if ! qdbus | grep keepassxc; then echo unable to start keepassxc; exit; fi
fi
env | grep SSH
if export SSH_AUTH_SOCK=$SSH_AUTH_SOCK; $unlock &> /dev/null; then
echo keepass database $database succesfully unlocked
else
echo unable to unlock $database
fi