#!/bin/sh
#250407 sfs
grep " nox" /proc/cmdline && return
[ -e /etc/systemd/system/display-manager.service ] && return
#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx >/dev/null
U(){
[ "`cat /etc/ld.so.conf.d/*.conf 2>/dev/null |egrep '^[^#]*/nvidia/'`" ] || return
echo -n "Wait /etc/rc.d/010-update-cache"
while true ;do
#    pgrep -f /etc/rc.d/010-update-cach >/dev/null || break
#    pidof ldconfig || break
#    pgrep -f update-cache >/dev/null || { echo -n ".OK ";echo ; break ; }
    pidof depmod ldconfig >/dev/null || { echo -n ".OK ";echo ; break ; }
     echo -n "." && sleep 1
done
}
#ps ax |grep udev
#echo "========sleep======="
#which systemctl > /dev/null 2>&1 || sleep 1
#ps ax |grep udev
#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx >/dev/null
if which wayfire > /dev/null 2>&1 ;then
	    [[ $(fgconsole 2>/dev/null) == 1 ]] &&  exec wayfire 2>/dev/null
elif which labwc > /dev/null 2>&1 ;then
	    [[ $(fgconsole 2>/dev/null) == 1 ]] &&  exec labwc 2>/dev/null
else
	    [[ $(fgconsole 2>/dev/null) == 1 ]] &&  { [ -e /usr/bin/systemctl ] ||  U ; exec startx  2>/dev/null ; }
fi
###	    [[ $(fgconsole 2>/dev/null) == 1 ]] &&  { [ -e /usr/bin/systemctl ] ||  U ; exec startx -- vt7  2>/dev/null ; }

##	    [[ $(fgconsole 2>/dev/null) == 1 ]] &&  exec startx -- vt7 2>/dev/null
#	    [[ $(fgconsole 2>/dev/null) == 1 ]] &&  { [ -e /usr/bin/systemctl ] ||  U ; exec startx  2>/dev/null ; }
