diff --git a/runs/atreboot.sh b/runs/atreboot.sh index f457e5e9f6..110868f216 100755 --- a/runs/atreboot.sh +++ b/runs/atreboot.sh @@ -256,7 +256,22 @@ chmod 666 "$LOGFILE" echo "'tvservice' not found, assuming a display is present" fi echo "displayDetected: $displayDetected" - mosquitto_pub -p 1886 -t "openWB/optional/int_display/detected" -r -m "$displayDetected" + forceDisplaySetup=0 + if displayDetected_old=$(mosquitto_sub -p 1886 -t "openWB/optional/int_display/detected" -C 1 -W 1); then + echo "previous displayDetected value: $displayDetected_old" + if [[ $displayDetected_old != "$displayDetected" ]]; then + echo "displayDetected value changed, publishing new value" + mosquitto_pub -p 1886 -t "openWB/optional/int_display/detected" -r -m "$displayDetected" + else + echo "no change in displayDetected value, skipping publish" + fi + else + echo "no previous displayDetected value found, assuming initial boot" + echo "update of display settings forced" + forceDisplaySetup=1 + mosquitto_pub -p 1886 -t "openWB/optional/int_display/detected" -r -m "$displayDetected" + mosquitto_pub -p 1886 -t "openWB/optional/int_display/active" -r -m "true" + fi # display setup echo "display setup..." @@ -285,8 +300,8 @@ chmod 666 "$LOGFILE" cp "${OPENWBBASEDIR}/data/config/display/lxdeautostart" "/home/openwb/.config/lxsession/LXDE/autostart" displaySetupModified=1 fi - if ((displaySetupModified == 1)); then - "${OPENWBBASEDIR}/runs/update_local_display.sh" + if ((displaySetupModified == 1)) || ((forceDisplaySetup == 1)); then + "${OPENWBBASEDIR}/runs/update_local_display.sh" $forceDisplaySetup fi # check apache configuration diff --git a/runs/update_local_display.sh b/runs/update_local_display.sh index fb3dd1bd46..8c7500ac84 100755 --- a/runs/update_local_display.sh +++ b/runs/update_local_display.sh @@ -1,5 +1,7 @@ #!/bin/bash OPENWBBASEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +# set "forceUpdate" to parameter $1, set to 0 if not set +forceUpdate=${1:-0} # update display standby timeout if timeout=$(mosquitto_sub -p 1886 -t "openWB/optional/int_display/standby" -C 1 -W 1); then @@ -20,8 +22,8 @@ if display_active=$(mosquitto_sub -p 1886 -t "openWB/optional/int_display/active echo "setting graphical target as default" sudo systemctl set-default graphical.target fi - # only restart display manager if boot done - if [[ -f "${OPENWBBASEDIR}/ramdisk/bootdone" ]]; then + # only restart display manager if boot done or forceUpdate is set + if [[ -f "${OPENWBBASEDIR}/ramdisk/bootdone" ]] || ((forceUpdate == 1)); then echo "restarting lightdm service" sudo systemctl restart lightdm.service fi