@@ -144,39 +144,75 @@ WantedBy=timers.target
144144UNIT
145145
146146systemctl daemon-reload
147- systemctl enable display-kiosk.service
148147systemctl enable display-update.timer
149148
150- # ── 5. Auto-login + start X ──
149+ # ── 5. Auto-login + start kiosk ──
151150echo " [5/5] Configuring auto-login..."
152151
153152USER_HOME=$( getent passwd " $REAL_USER " | cut -d: -f6)
154153
155- mkdir -p /etc/systemd/system/getty@tty1.service.d
156- cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << CONF
154+ # ── Detect display manager and configure autologin accordingly ──
155+ if command -v gdm3 > /dev/null 2>&1 || [[ -f /etc/gdm3/custom.conf ]]; then
156+ # Ubuntu/GDM path
157+ echo " -> Detected GDM, configuring autologin..."
158+ GDM_CONF=/etc/gdm3/custom.conf
159+ if grep -q " ^\[daemon\]" " $GDM_CONF " 2> /dev/null; then
160+ # Update existing [daemon] section
161+ sed -i " /^\[daemon\]/a AutomaticLoginEnable=true\nAutomaticLogin=$REAL_USER " " $GDM_CONF "
162+ else
163+ cat >> " $GDM_CONF " << GDMCONF
164+
165+ [daemon]
166+ AutomaticLoginEnable=true
167+ AutomaticLogin=$REAL_USER
168+ GDMCONF
169+ fi
170+
171+ # Use GNOME autostart .desktop entry (no X auth issues)
172+ echo " -> Installing GNOME autostart entry..."
173+ mkdir -p " $USER_HOME /.config/autostart"
174+ cat > " $USER_HOME /.config/autostart/display-kiosk.desktop" << DESKTOP
175+ [Desktop Entry]
176+ Type=Application
177+ Name=Display Kiosk
178+ Exec=bash -c 'SERVER_URL=\$ (grep SERVER_URL /opt/display-node/config.env | cut -d= -f2); FLOOR_ID=\$ (grep FLOOR_ID /opt/display-node/config.env | cut -d= -f2); sleep 5; chromium-browser --noerrdialogs --disable-infobars --kiosk --incognito --disable-translate --disable-features=TranslateUI --disable-session-crashed-bubble --disable-component-update --check-for-update-interval=31536000 --no-first-run --start-fullscreen "\$ {SERVER_URL}/display/\$ {FLOOR_ID}"'
179+ Hidden=false
180+ NoDisplay=false
181+ X-GNOME-Autostart-enabled=true
182+ DESKTOP
183+ chown -R " $REAL_USER :$( id -gn " $REAL_USER " ) " " $USER_HOME /.config"
184+
185+ # Disable the systemd kiosk service (not needed with GDM+GNOME autostart)
186+ systemctl disable display-kiosk.service 2> /dev/null || true
187+
188+ echo " -> GDM autologin configured. Will use GNOME autostart for kiosk."
189+
190+ else
191+ # Raspberry Pi OS / lightdm / getty path
192+ echo " -> No GDM detected, using getty autologin + openbox..."
193+ systemctl enable display-kiosk.service
194+
195+ mkdir -p /etc/systemd/system/getty@tty1.service.d
196+ cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << CONF
157197[Service]
158198ExecStart=
159199ExecStart=-/sbin/agetty --autologin $REAL_USER --noclear %I \$ TERM
160200CONF
161201
162- # only add auto‑start line if the user home exists
163- if [[ -d " $USER_HOME " ]]; then
164- if ! grep -q " startx" " $USER_HOME /.bash_profile" 2> /dev/null; then
165- echo ' [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor' >> " $USER_HOME /.bash_profile"
166- fi
167- fi
168-
169- # only configure openbox/autostart if the user home directory exists
170- if [[ -d " $USER_HOME " ]]; then
171- mkdir -p " $USER_HOME /.config/openbox"
172- cat > " $USER_HOME /.config/openbox/autostart" << 'AUTOSTART '
202+ if [[ -d " $USER_HOME " ]]; then
203+ if ! grep -q " startx" " $USER_HOME /.bash_profile" 2> /dev/null; then
204+ echo ' [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor' >> " $USER_HOME /.bash_profile"
205+ fi
206+ mkdir -p " $USER_HOME /.config/openbox"
207+ cat > " $USER_HOME /.config/openbox/autostart" << 'AUTOSTART '
173208 xset s off
174209 xset s noblank
175210 xset -dpms
176211 unclutter -idle 0.5 -root &
177212 systemctl start display-kiosk &
178213AUTOSTART
179- chown -R " $REAL_USER :$( id -gn " $REAL_USER " ) " " $USER_HOME /.config"
214+ chown -R " $REAL_USER :$( id -gn " $REAL_USER " ) " " $USER_HOME /.config"
215+ fi
180216fi
181217
182218echo " "
0 commit comments