summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig/chroot_local-includes/usr/local/bin/keepassxc32
1 files changed, 31 insertions, 1 deletions
diff --git a/config/chroot_local-includes/usr/local/bin/keepassxc b/config/chroot_local-includes/usr/local/bin/keepassxc
index c431c56..265ad25 100755
--- a/config/chroot_local-includes/usr/local/bin/keepassxc
+++ b/config/chroot_local-includes/usr/local/bin/keepassxc
@@ -10,11 +10,25 @@ export TEXTDOMAIN
PERSISTENT_DATA_DIR="${HOME}/Persistent"
NEW_DB="${PERSISTENT_DATA_DIR}/keepassx.kdbx"
+prompt_for_starting() {
+ local launch_text="`gettext _Launch`"
+ local exit_text="`gettext _Exit`"
+ local dialog_msg="`gettext \"<b><big>You don\'t have a <i>Persistent</i> directory configured</big></b>
+
+You won\'t be able to store a <i>KeePassXC</i> database persistently, so it will be lost when you restart.
+
+It is recommended that you activate the <i>Persistent</i> directory before using <i>KeePassXC</i>.
+
+Do you want to start <i>KeePassXC</i> anyway?\"`"
+ zenity --question --ellipsize --title "" --text "${dialog_msg}" --default-cancel \
+ --ok-label "${launch_text}" --cancel-label "${exit_text}"
+}
+
prompt_for_database_renaming() {
local filename="${1}"
local dialog_msg="`eval_gettext \"<b><big>Do you want to rename your <i>KeePassXC</i> database?</big></b>
-You have a <i>KeePassXC</i> database in your <i>Persistent</i> folder:
+You have a <i>KeePassXC</i> database in your <i>Persistent</i> directory:
<i>\\\${filename}</i>
@@ -26,6 +40,22 @@ Renaming it to <i>keepassx.kdbx</i> would allow <i>KeePassXC</i> to open it auto
--ok-label "${rename}" --cancel-label "${open}"
}
+if mountpoint -q "$PERSISTENT_DATA_DIR"; then
+ # Setting HOME to the persistent data directory makes KeePassXC propose
+ # to the user to store newly created databases in that directory.
+ # Else it would propose to store them in /home/amnesia, which is
+ # not persisted.
+ ORIG_HOME="${HOME}"
+ export HOME="${PERSISTENT_DATA_DIR}"
+ # With the modified HOME variable, we have to set XDG_CONFIG_HOME to
+ # make KeePassXC still use the correct config file.
+ export XDG_CONFIG_HOME="${ORIG_HOME}/.config"
+else
+ if ! prompt_for_starting; then
+ exit 1
+ fi
+fi
+
# Database file is not named keepassx.kdbx, prompt for renaming it.
if [ -z "$@" ] && mountpoint -q "$PERSISTENT_DATA_DIR" && \
! [ -e "${NEW_DB}" ] && \