From 35fcc5af1801155b0446ed921476a2c3671cf101 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 6 Feb 2020 14:09:01 +0100 Subject: [kiosk-chromium] fix auto-reload --- .../opt/openslx/scripts/kiosk-launch.d/00-chromium | 26 +++++++++++++++++----- .../scripts/systemd-setup_kiosk.d/00-preload | 10 ++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium b/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium index bdbd275e..91127373 100644 --- a/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium +++ b/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium @@ -99,13 +99,27 @@ fi if [ -n "$SLX_BROWSER_RELOAD_SECS" ]; then ( + wid= + wpid= while true; do - wid="$(xdotool search --onlyvisible --class browser)" - [ -z "$wid" ] && sleep 1 && continue - readonly wid - wpid="$(xprop -id "$wid" | awk -F= '$1 ~ /_NET_WM_PID\(CARDINAL\)/ {print $2}' | tr -d ' ')" - readonly wpid - [ ! -d "/proc/$wpid" ] && exit 0 + if [ -z "$wid" ]; then + wid="$(xdotool search --onlyvisible --class browser)" + [ -z "$wid" ] && sleep 1 && continue + readonly wid + fi + if [ -z "$wpid" ]; then + wpid="$(xprop -id "$wid" | awk -F= '$1 ~ /_NET_WM_PID\(CARDINAL\)/ {print $2}' | tr -d ' ')" + if [ -z "$wpid" ]; then + # logs to ~/.xsession-errors + echo "Failed to get the pid of chromium-browser via xprop..." + exit 1 + fi + readonly wpid + fi + if [ ! -d "/proc/$wpid" ]; then + echo "Process with PID $wpid stopped, exiting auto-reload loop." + exit 0 + fi current_idle="$(idle-daemon --send 'get :0' | grep -oP '(?<=idleSeconds=)[0-9]+')" if [ "$current_idle " -ge "$SLX_BROWSER_RELOAD_SECS" ]; then xdotool windowactivate "$wid" diff --git a/core/modules/kiosk-chromium/data/opt/openslx/scripts/systemd-setup_kiosk.d/00-preload b/core/modules/kiosk-chromium/data/opt/openslx/scripts/systemd-setup_kiosk.d/00-preload index 285acc86..29542d22 100644 --- a/core/modules/kiosk-chromium/data/opt/openslx/scripts/systemd-setup_kiosk.d/00-preload +++ b/core/modules/kiosk-chromium/data/opt/openslx/scripts/systemd-setup_kiosk.d/00-preload @@ -1,13 +1,13 @@ #!/bin/ash # # Simple "preload" by just reading the directory /usr/lib/chromium-browser - -preload() { - find /usr/lib/chromium-browser -type f -exec dd if={} of=/dev/null \; & -} +# Tested the variation loading just the linked libraries, but it does +# not bring the same startup acceleration than this trivial method... . /opt/openslx/config if [ "${SLX_BROWSER//chromium/}" != "$SLX_BROWSER" ]; then - preload & + ( + find /usr/lib/chromium-browser -type f -exec dd if={} of=/dev/null \; &> /dev/null & + ) & fi -- cgit v1.2.3-55-g7522