lundi 10 janvier 2022

Unlock Keepass database with Gnome session unlock

In order to unlock your KeepassXC database when you unlock your session, do the following :

prerequisites :
install the packet libsecret-tools

1. put the password in the Gnome keyring
secret-tool store --label="KeePass" database <database_name>

2. create the script like this :
#!/bin/bash
secret-tool lookup database <database_name> | /usr/bin/keepassxc --pw-stdin <database_location> --keyfile <database_key_location>


3. Add a launcher at ~/.config/autostart/Keepass.desktop:
[Desktop Entry]
Name=Keepass Unlock
GenericName=KeepassUnlock
Comment=Unlocks the keepass DB at session unlock
Exec=<absolute_path_of_script>
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

EDIT : added the use of a keyfile