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 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium') 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" -- cgit v1.2.3-55-g7522