From 2025acce7369c2fa71fe3b1719b5584aab5ccf70 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Tue, 15 Jun 2021 15:10:49 +0200 Subject: [PATCH] conditional xvfb --- pack-chrome.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pack-chrome.sh b/pack-chrome.sh index ae75e2c..899fa39 100755 --- a/pack-chrome.sh +++ b/pack-chrome.sh @@ -1,7 +1,21 @@ #!/usr/bin/env sh dir=$(dirname $(realpath $0)) -export DISPLAY=:8819 -screen -dmS xvfb Xvfb :8819 +temp_name=$(head -c 20 /dev/random | xxd -p | tr -dc a-f0-9) +temp_dir="/tmp/${temp_name}" +chrome_dir="${temp_dir}/chrome" +mkdir -p "${chrome_dir}" + +if [[ "${DBUS_SESSION_BUS_ADDRESS}test" == "test" ]] +then + export DBUS_SESSION_BUS_ADDRESS="unix:path=${temp_dir}/dbus.sock" + dbus-daemon --session --address="${DBUS_SESSION_BUS_ADDRESS}" & +fi + +if [[ "${DISPLAY}test" == "test" ]] +then + export DISPLAY=:8819 + Xvfb "${DISPLAY}" & +fi ${dir}/icons.sh @@ -11,9 +25,6 @@ then browser=$(which chromium 2> /dev/null) fi -temp_name=$(head -c 20 /dev/random | xxd -p | tr -dc a-f0-9) -temp_dir="/tmp/${temp_name}" - -${browser} --disable-gpu --no-sandbox --user-data-dir=${temp_dir} --pack-extension="${dir}/chrome" --pack-extension-key=${HOME}/keys/privkey.pem +${browser} --disable-gpu --no-sandbox --user-data-dir=${chrome_dir} --pack-extension="${dir}/chrome" --pack-extension-key=${HOME}/keys/privkey.pem rm -rf ${temp_dir}