2023-12-20 17:24:54 -08:00
|
|
|
#!/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"
|
2024-02-12 14:16:57 -08:00
|
|
|
if ! qdbus | grep keepassxc; then
|
|
|
|
echo starting keepassxc first
|
2023-12-20 17:24:54 -08:00
|
|
|
keepassxc&
|
|
|
|
sleep 1
|
|
|
|
if ! qdbus | grep keepassxc; then echo unable to start keepassxc; exit; fi
|
|
|
|
fi
|
2024-02-12 14:16:57 -08:00
|
|
|
env | grep SSH
|
|
|
|
if export SSH_AUTH_SOCK=$SSH_AUTH_SOCK; $unlock &> /dev/null; then
|
2023-12-20 17:24:54 -08:00
|
|
|
echo keepass database $database succesfully unlocked
|
|
|
|
else
|
|
|
|
echo unable to unlock $database
|
|
|
|
fi
|