diff options
author | Simon Rettberg | 2023-12-07 14:37:33 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-12-07 14:37:33 +0100 |
commit | 1f95ca0611e649962ca02d0b28710d3d6945bf08 (patch) | |
tree | ea2e4a0dcc1babd0842f1e7bc621e1976712fef0 /core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium | |
parent | [qemu-src] Need ensurepip (python3-venv) now (diff) | |
download | mltk-1f95ca0611e649962ca02d0b28710d3d6945bf08.tar.gz mltk-1f95ca0611e649962ca02d0b28710d3d6945bf08.tar.xz mltk-1f95ca0611e649962ca02d0b28710d3d6945bf08.zip |
[kiosk-chromium] Properly fix auto reload/restart
Diffstat (limited to 'core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium')
-rw-r--r-- | core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium | 38 |
1 files 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 |