mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-18 04:04:29 -05:00
e3c7b570ae
* Remove mention of no longer used IRC network Channels exist on matrix, and on libera.chat now. * Correctly match only files with .png extension The current search would match files such as 'createpng'. * Fix comparison in script The result was always false, due to comparing a literal string instead of a variable. * Use correct license files from upstream Correct license files obtained from: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt https://www.gnu.org/licenses/gpl-3.0.txt https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt https://www.gnu.org/licenses/lgpl-3.0.txt * Refresh several shell scripts This fixes several shellcheck warnings, as well as makes the code more robust and have consistent codestyle between all the files. * Trim excess whitespace
39 lines
1.1 KiB
Bash
Executable File
39 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# fetch KeePass database passwords from kdewallet
|
|
|
|
### change the path to suit your installation or set KDBX_SEARCH before calling ###
|
|
: ${KDBX_SEARCH:=~/.KeePass/*.kdbx}
|
|
|
|
PROG=${0##*/}
|
|
KEEPASSXC=$(which -a keepassxc | sed -e "\\,$0,d" -e 'q')
|
|
|
|
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
|
|
|
|
declare -A DBs
|
|
for DBPATH in $(ls -r $KDBX_SEARCH); do
|
|
DBs[$(realpath $DBPATH)]=$(qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.readPassword "$handle" "Passwords" "${DBPATH##*/}" "$PROG")
|
|
done
|
|
|
|
# launch real keepassxc
|
|
IFS=$'\n\n\n'
|
|
"$KEEPASSXC" --pw-stdin "${!DBs[@]}" <<<"${DBs[*]}" &
|
|
|
|
# done with kdewallet
|
|
qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.close "$handle" "false" "$PROG"
|
|
}
|
|
|
|
if [[ $1 == '-d' ]]; then
|
|
exec >&~/tmp/$PROG.log
|
|
set -vx
|
|
daemon_main
|
|
else
|
|
cd /
|
|
daemon_main </dev/null >&/dev/null &
|
|
disown
|
|
fi
|