From 1f95ca0611e649962ca02d0b28710d3d6945bf08 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 7 Dec 2023 14:37:33 +0100 Subject: [kiosk-chromium] Properly fix auto reload/restart --- .../opt/openslx/scripts/kiosk-launch.d/00-chromium | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 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 a11d4cbb..0c949044 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 @@ -90,23 +90,23 @@ fi if [ -n "$SLX_BROWSER_RELOAD_SECS" ] && [ "$SLX_BROWSER_RELOAD_SECS" -gt 0 ]; then ( wid= - wpid= + while [ -z "$wid" ]; do + sleep 1 + [ -z "$wid" ] && wid="$( xdotool search --onlyvisible --class chromium-browser )" + [ -z "$wid" ] && wid="$( xdotool search --onlyvisible --class chromium )" + [ -z "$wid" ] && wid="$( xdotool search --onlyvisible --class browser )" + done + readonly wid + wpid="$( xprop -id "$wid" | awk '$1 == "_NET_WM_PID(CARDINAL)" {print $3}' )" + if [ -z "$wpid" ]; then + # logs to ~/.xsession-errors + echo "Failed to get the pid of chromium-browser via xprop..." + exit 1 + fi + readonly wpid activity=init + last= while true; do - 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 '$1 == "_NET_WM_PID(CARDINAL)" {print $3}' )" - 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 @@ -120,16 +120,20 @@ if [ -n "$SLX_BROWSER_RELOAD_SECS" ] && [ "$SLX_BROWSER_RELOAD_SECS" -gt 0 ]; th else xdotool windowactivate "$wid" xdotool key Alt+Home + last="$current_idle" sleep "$SLX_BROWSER_RELOAD_SECS" activity=init continue fi elif [ "$activity" = "init" ]; then activity=no - else + elif [ -n "$last" ] && (( last > current_idle )); then activity=yes fi - sleep "$(( 1 + SLX_BROWSER_RELOAD_SECS - current_idle ))" + last="$current_idle" + num="$(( SLX_BROWSER_RELOAD_SECS - ( current_idle + 3 ) ))" + (( num < 1 )) && num=1 + sleep "$num" done ) & fi -- cgit v1.2.3-55-g7522