From afb1a4153eedf79f7c2f72b88ccf047ab1e7b6ba Mon Sep 17 00:00:00 2001 From: Christian Hammacher Date: Thu, 14 Dec 2023 12:25:17 +0100 Subject: [PATCH] Prepared bookworm support Updated launch script Removed obsolete patch file --- params.diff | 22 ----------- pkg/common/duetwebcontrol/usr/bin/launch-dwc | 41 ++++++++++++-------- 2 files changed, 25 insertions(+), 38 deletions(-) delete mode 100644 params.diff diff --git a/params.diff b/params.diff deleted file mode 100644 index 70576cf0f..000000000 --- a/params.diff +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/src/DuetAPI/Commands/Code/Parameter.cs b/src/DuetAPI/Commands/Code/Parameter.cs -index 059ad6b1..e66f79b4 100644 ---- a/src/DuetAPI/Commands/Code/Parameter.cs -+++ b/src/DuetAPI/Commands/Code/Parameter.cs -@@ -135,7 +135,7 @@ namespace DuetAPI.Commands - // It is a hex integer - ParsedValue = asHexInt; - } -- else if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out int asInt)) -+ else if (!value.Contains('.') && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out int asInt)) - { - // It is a valid integer - ParsedValue = asInt; -@@ -145,7 +145,7 @@ namespace DuetAPI.Commands - // It is a hex unsigned integer - ParsedValue = asHexUInt; - } -- else if (uint.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out uint asUInt)) -+ else if (!value.Contains('.') && uint.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out uint asUInt)) - { - // It is a valid unsigned integer - ParsedValue = asUInt; diff --git a/pkg/common/duetwebcontrol/usr/bin/launch-dwc b/pkg/common/duetwebcontrol/usr/bin/launch-dwc index dfdee2280..391a95a4f 100755 --- a/pkg/common/duetwebcontrol/usr/bin/launch-dwc +++ b/pkg/common/duetwebcontrol/usr/bin/launch-dwc @@ -5,25 +5,34 @@ while (systemctl -q is-enabled duetwebserver.service) && !(systemctl -q is-activ sleep 1 done -# Start Chromium -sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State' -sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences -chromium-browser --app=http://$(hostname) --app-auto-launched --start-fullscreen --in-process-gpu & +# Start preinstalled browser but prefer Chromium +if [ -x /usr/bin/chromium-browser ]; then + sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State' + sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences + chromium-browser --app=http://localhost --app-auto-launched --start-fullscreen & +elif [ -x /usr/bin/firefox ]; then + firefox --kiosk --new-window http://localhost +else + xdg-open http://localhost +fi pid=$! -# Wait for DWC to be started -while [ -z "$(wmctrl -l | cut -d ' ' -f 5- | grep -e "Duet Web Control" -e "$(hostname)")" ]; do - sleep 1 -done -sleep 2 +# Focus other windows if wmctrl is preinstalled (not the case on Bookworm) +if [ -x /usr/bin/wmctrl ]; then + # Wait for DWC to be started + while [ -z "$(wmctrl -l | cut -d ' ' -f 5- | grep -e "Duet Web Control" -e "$(hostname)")" ]; do + sleep 1 + done + sleep 2 -# Focus other windows -wmctrl -l | cut -d ' ' -f 5- | grep -v -e "Duet Web Control" -e "$(hostname)" | while read window; do - if [ ! -z "$window" ]; then - echo "Focusing $window" - wmctrl -R "$window" - fi -done + # Focus other windows + wmctrl -l | cut -d ' ' -f 5- | grep -v -e "Duet Web Control" -e "$(hostname)" | while read window; do + if [ ! -z "$window" ]; then + echo "Focusing $window" + wmctrl -R "$window" + fi + done +fi # Wait for Chromium to be closed again wait $pid