[Main]
Type = classic
Version = 0.1.2
Description = "lightdm daemon (no Depends on boot stub)"
User = ( root )
Depends = ( dbus devmanager logind x11-common mount-rw )
Options = ( log )

[Start]
Execute = (
	# Do not use "exec -c" or "fdmove -c": that yields a restart loop
	# and the host shows "Display output is not active". LightDM's own
	# log (paths in lightdm.conf / /var/log/lightdm/) is enough; the s6
	# pipeline still captures stdout without merging stderr via fdmove -c.
	# Pause when another display manager is selected (OpenRC/runit pattern).

	ifelse {
		ifelse { test ! -s /etc/X11/default-display-manager } { true }
		redirfd -r 0 /etc/X11/default-display-manager
		grep -qx /usr/sbin/lightdm
	} {
		foreground { mkdir -p /var/lib/lightdm/data }
		foreground { chown lightdm:lightdm /var/lib/lightdm /var/lib/lightdm/data }
		exec /usr/sbin/lightdm
	}
	s6-pause
)

[Logger]
RunAs = s6log
Backup = 3
MaxSize = 2000000
Timestamp = tai
Destination = /var/log/lightdm
