From ba6a8c2da55df8da408ba7b26e8d9203d99eee92 Mon Sep 17 00:00:00 2001 From: Philip Crockett Date: Tue, 18 Feb 2025 21:38:52 +0100 Subject: [PATCH] support XDG standard, search for chrome and chromium DBs --- bin/export_browser_history.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/export_browser_history.sh b/bin/export_browser_history.sh index e650d928..6aa8f4d5 100755 --- a/bin/export_browser_history.sh +++ b/bin/export_browser_history.sh @@ -43,9 +43,21 @@ find_firefox_places_db() { fi } -get_chrome_history_db() { +find_chrome_history_db() { if is_linux; then - echo ~/.config/chromium/Default/History + local config_home="${XDG_CONFIG_HOME:-${HOME}/.config}" + for path in \ + "${config_home}/chromium/Default/History" \ + "${config_home}/google-chrome/Default/History"; + do + if [ -f "${path}" ]; then + echo "${path}" + return + fi + done + + echo "Unable to find Chrome history database. You can supply it manually as a second parameter." >&2 + exit 1 else echo ~/Library/Application\ Support/Google/Chrome/Default/History fi @@ -55,7 +67,7 @@ export_chrome() { if [[ -e "$2" ]]; then cp "$2" "$OUTPUT_DIR/chrome_history.db.tmp" else - default="$(get_chrome_history_db)" + default="$(find_chrome_history_db)" echo "Defaulting to history db: $default" echo "Optionally specify the path to a different sqlite history database as the 2nd argument." cp "$default" "$OUTPUT_DIR/chrome_history.db.tmp"