mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
utility to launch keepassx with database passwords fetched from kdewallet
This commit is contained in:
parent
f7fd78d715
commit
0138209004
35
utils/keepassx-kwallet
Executable file
35
utils/keepassx-kwallet
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROG="$(basename $0)"
|
||||
|
||||
function daemon_main {
|
||||
# open kdewallet
|
||||
handle=$(qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.open kdewallet 0 "$PROG")
|
||||
while [[ true != $(qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.isOpen kdewallet) ]]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# fetch KeePass database passwords from kdewallet
|
||||
declare -A DBs
|
||||
### change the path to suit your installation ###
|
||||
for DBPATH in ~/.keepassx/*.kdbx; do
|
||||
DBs[$DBPATH]=$(qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.readPassword "$handle" "Passwords" "$DBPATH" "$PROG")
|
||||
done
|
||||
|
||||
# launch keepassx
|
||||
IFS=$'\n\n\n'
|
||||
keepassx --pw-stdin "${!DBs[@]}" <<<"${DBs[*]}" &
|
||||
|
||||
# done with kdewallet
|
||||
qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.close "$handle" "false" "$PROG"
|
||||
}
|
||||
|
||||
if [[ '-d' = "$1" ]]; then
|
||||
exec >&~/tmp/$PROG.log
|
||||
set -vx
|
||||
daemon_main
|
||||
else
|
||||
cd /
|
||||
daemon_main </dev/null >&/dev/null &
|
||||
disown
|
||||
fi
|
Loading…
Reference in New Issue
Block a user