From d02c11bd9d93a0a7f4b2080dcd05bf1761d62e2f Mon Sep 17 00:00:00 2001 From: Toby Worland <47527939+tobyWorland@users.noreply.github.com> Date: Wed, 19 Oct 2022 00:50:36 +0100 Subject: [PATCH 1/2] Suppress first time startup dialog box and reuse the same data directory --- src/plot/browser.lisp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plot/browser.lisp b/src/plot/browser.lisp index 0161338..890be6c 100644 --- a/src/plot/browser.lisp +++ b/src/plot/browser.lisp @@ -55,10 +55,14 @@ "Encode command line options for Chrome" ;; We want to add a --user-data-directory so that --windows-size is honoured ;; --app, if present, will have been set by the caller + ;; We also want --no-default-browser-check and --no-first-run to suppress + ;; a dialog box shown on startup when an empty data directory is picked. ;; See note at top of file about proper way to set window attributesc - (let ((chrome-options (push (cons "user-data-dir" - (merge-pathnames (format nil "chrome-data-~A" (princ-to-string (gensym))) - (translate-logical-pathname #P"PLOT:TEMP;"))) + (let ((chrome-options (append (list (cons "user-data-dir" + (merge-pathnames "chrome-data" + (translate-logical-pathname #P"PLOT:TEMP;"))) + (cons "no-default-browser-check" 1) + (cons "no-first-run" 1)) options))) (encode-application-options chrome-options "--~A=~A"))) From 752b35a29d6245cf20b954efd8539177b35d1ab8 Mon Sep 17 00:00:00 2001 From: Toby Worland <47527939+tobyWorland@users.noreply.github.com> Date: Wed, 19 Oct 2022 02:02:20 +0100 Subject: [PATCH 2/2] On Linux, try a few potential chrome executables until one is found --- src/plot/browser.lisp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/plot/browser.lisp b/src/plot/browser.lisp index 890be6c..09ea1ca 100644 --- a/src/plot/browser.lisp +++ b/src/plot/browser.lisp @@ -16,13 +16,28 @@ ;;; specific to each browser that is selected in the arguments to ;;; uiop:launch-program. +;;; +;;; Chrome on Linux +;;; + +(defun find-chrome-executable-linux () + "Find Chrome's executable for Linux distributions" + ;; Linux distributions unfortunately do not all use the same name for chrome, + ;; or there may only be chromium installed. + ;; Partial list of executables: https://unix.stackexchange.com/questions/436835/universal-path-for-chrome-on-nix-systems + (find-if (lambda (potential-executable) + (ignore-errors + (zerop (nth-value 2 (uiop:run-program (list potential-executable "--version")))))) + (list "google-chrome" "chrome" "google-chrome-stable" "chromium" "chromium-browser"))) + ;;; ;;; Functions and data for all browsers ;;; + (defparameter *browser-commands* (list (cons :chrome #+win32 "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" #+(or macos darwin) "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" - #+linux "chrome") ;See https://unix.stackexchange.com/questions/436835/universal-path-for-chrome-on-nix-systems + #+linux (find-chrome-executable-linux)) (cons :firefox #+win32 "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" #+(or macos darwin) "/Applications/Firefox.app/Contents/MacOS/firefox" #+linux "firefox")