Enable lightdm and LXDE

Hi,
Is there any method to set the lightdm and LXDE to the default choice?
What I want is that after flash, on the first boot, the display manager is lightdm and login with the LXDE desktop environment.

Thanks

We put this inside the nano guide, but it is applicable to NX too.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/adaptation_and_bringup_nano.html#

Thank you Wayne,
I have read the doc, but I find it is runtime change the gdm3 to lightdm and LXDE.
What I want is to set the lightdm and LXDE as the default in the rootfs, and after flashing, on the first boot, the display manager has already been changed to lightdm, and after login, the LXDE is the desktop environmet.

I find nv_customize_rootfs.sh under Linux_for_Tegra/nv_tools/scripts

#!/bin/bash

# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#  * Neither the name of NVIDIA CORPORATION nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# This script contains function to apply NVIDIA customization to root
# file system
#

function AddSystemGroup {
	# add $1 as a system group and search unused gid decreasingly from
	# SYS_GID_MAX to SYS_GID_MIN
	pushd "${LDK_ROOTFS_DIR}" > /dev/null 2>&1
	if [ -z $(grep "^${1}:" ./etc/group) ]; then
		gids=($(cut -d: -f3 ./etc/group))
		for gid in {999..100}; do
			if [[ ! " ${gids[*]} " =~ " ${gid} " ]]; then
				echo "${1}:x:${gid}:" >> ./etc/group
				echo "${1}:!::" >> ./etc/gshadow
				break
			fi
		done
	fi
	popd > /dev/null 2>&1
}

function nv_customize_rootfs {
	ARM_ABI_DIR=

	if [ -d "${LDK_ROOTFS_DIR}/usr/lib/arm-linux-gnueabihf/tegra" ]; then
		ARM_ABI_DIR_ABS="usr/lib/arm-linux-gnueabihf"
	elif [ -d "${LDK_ROOTFS_DIR}/usr/lib/arm-linux-gnueabi/tegra" ]; then
		ARM_ABI_DIR_ABS="usr/lib/arm-linux-gnueabi"
	elif [ -d "${LDK_ROOTFS_DIR}/usr/lib/aarch64-linux-gnu/tegra" ]; then
		ARM_ABI_DIR_ABS="usr/lib/aarch64-linux-gnu"
	else
		echo "Error: None of Hardfp/Softfp Tegra libs found"
		exit 4
	fi

	ARM_ABI_DIR="${LDK_ROOTFS_DIR}/${ARM_ABI_DIR_ABS}"
	ARM_ABI_TEGRA_DIR="${ARM_ABI_DIR}/tegra"
	install ${INSTALL_ROOT_OPTS} -m 0755 -d \
		"${LDK_ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants"
	pushd "${LDK_ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants" \
		> /dev/null 2>&1
	if [ -h "isc-dhcp-server.service" ]; then
		rm -f "isc-dhcp-server.service"
	fi
	if [ -h "isc-dhcp-server6.service" ]; then
		rm -f "isc-dhcp-server6.service"
	fi
	popd > /dev/null

	# Enable Unity by default for better user experience [2332219]
	echo "Rename ubuntu.desktop --> ux-ubuntu.desktop"
	if [ -d "${LDK_ROOTFS_DIR}/usr/share/xsessions" ]; then
		pushd "${LDK_ROOTFS_DIR}/usr/share/xsessions" > /dev/null 2>&1
		if [ -f "ubuntu.desktop" ]; then
			mv "ubuntu.desktop" "ux-ubuntu.desktop"
		fi
		if [ -f "openbox.desktop" ]; then
			mv "openbox.desktop" "ux-openbox.desktop"
		fi
		if [ -f "LXDE.desktop" ]; then
			mv "LXDE.desktop" "ux-LXDE.desktop"
		fi
		popd > /dev/null
	fi


	if [ -e "${LDK_ROOTFS_DIR}/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf" ] ; then
		grep -q -F 'allow-guest=false' \
			"${LDK_ROOTFS_DIR}/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf" \
			|| echo 'allow-guest=false' \
			>> "${LDK_ROOTFS_DIR}/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf"
	fi

	# Disabling NetworkManager-wait-online.service for Bug 200290321
	echo "Disabling NetworkManager-wait-online.service"
	if [ -h "${LDK_ROOTFS_DIR}/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service" ]; then
		rm "${LDK_ROOTFS_DIR}/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service"
	fi

	echo "Disable the ondemand service by changing the runlevels to 'K'"
	for file in "${LDK_ROOTFS_DIR}"/etc/rc[0-9].d/; do
		if [ -f "${file}"/S*ondemand ]; then
			mv "${file}"/S*ondemand "${file}/K01ondemand"
		fi
	done

	# Remove the spawning of ondemand service
	if [ -h "${LDK_ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants/ondemand.service" ]; then
		rm -f "${LDK_ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants/ondemand.service"
	fi

	# If default target does not exist and if rootfs contains gdm, set default to nv-oem-config target
	if [ ! -e "${LDK_ROOTFS_DIR}/etc/systemd/system/default.target" ] && \
	   [ -d "${LDK_ROOTFS_DIR}/etc/gdm3/" ]; then
		mkdir -p "${LDK_ROOTFS_DIR}/etc/systemd/system/nv-oem-config.target.wants"
		pushd "${LDK_ROOTFS_DIR}/etc/systemd/system/nv-oem-config.target.wants" \
			> /dev/null 2>&1
		ln -sf "/lib/systemd/system/nv-oem-config.service" \
			"nv-oem-config.service"
		ln -sf "/etc/systemd/system/nvfb-early.service" \
			"nvfb-early.service"
		popd > /dev/null 2>&1
		pushd "${LDK_ROOTFS_DIR}/etc/systemd/system" > /dev/null 2>&1
		ln -sf /lib/systemd/system/nv-oem-config.target \
			nv-oem-config.target
		ln -sf nv-oem-config.target default.target
		popd > /dev/null 2>&1

		extra_groups="EXTRA_GROUPS=\"audio gdm gpio i2c lightdm video weston-launch\""
		sed -i "/\<EXTRA_GROUPS\>=/ s/^.*/${extra_groups}/" \
			"${LDK_ROOTFS_DIR}/etc/adduser.conf"
		sed -i "/\<ADD_EXTRA_GROUPS\>=/ s/^.*/ADD_EXTRA_GROUPS=1/" \
			"${LDK_ROOTFS_DIR}/etc/adduser.conf"
	fi

	if [ -d "${LDK_ROOTFS_DIR}/etc/gdm3/" ] || \
		[ -e "${LDK_ROOTFS_DIR}/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf" ]; then
		pushd "${LDK_ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants" > /dev/null 2>&1
		if [ -f "${LDK_ROOTFS_DIR}/etc/systemd/system/nvpmodel.service" ]; then
			ln -sf "../nvpmodel.service" "nvpmodel.service"
		fi
		popd > /dev/null 2>&1
	fi

	if [ -e "${LDK_ROOTFS_DIR}/etc/gdm3/custom.conf" ]; then
		sed -i "/WaylandEnable=false/ s/^#//" \
			"${LDK_ROOTFS_DIR}/etc/gdm3/custom.conf"
	fi

	# Disable release upgrade
	if [ -e "${LDK_ROOTFS_DIR}/etc/update-motd.d/91-release-upgrade" ]; then
		rm -f "${LDK_ROOTFS_DIR}/etc/update-motd.d/91-release-upgrade"
	fi
	if [ -e "${LDK_ROOTFS_DIR}/etc/update-manager/release-upgrades" ]; then
		sed -i "s/Prompt=lts/Prompt=never/" \
			"${LDK_ROOTFS_DIR}/etc/update-manager/release-upgrades"
	fi

	# Set LXDE as default LightDM user session
	if [ -e "${LDK_ROOTFS_DIR}/etc/lightdm/lightdm.conf.d/50-nvidia.conf" ] && \
		[ -e "${LDK_ROOTFS_DIR}/usr/share/xsessions/ux-LXDE.desktop" ]; then
		grep -q -F 'user-session=ux-LXDE' \
			"${LDK_ROOTFS_DIR}/etc/lightdm/lightdm.conf.d/50-nvidia.conf" \
			|| sed -i '1 auser-session=ux-LXDE' \
			"${LDK_ROOTFS_DIR}/etc/lightdm/lightdm.conf.d/50-nvidia.conf"
	fi

	# Set lightdm-gtk-greeter as default login greeter for LightDM
	if [ -e "${LDK_ROOTFS_DIR}/etc/lightdm/lightdm.conf.d/50-nvidia.conf" ] && \
		[ -e "${LDK_ROOTFS_DIR}/usr/sbin/lightdm-gtk-greeter" ]; then
		grep -q -F 'greeter-session=lightdm-gtk-greeter' \
			"${LDK_ROOTFS_DIR}/etc/lightdm/lightdm.conf.d/50-nvidia.conf" \
			|| sed -i '1 agreeter-session=lightdm-gtk-greeter' \
			"${LDK_ROOTFS_DIR}/etc/lightdm/lightdm.conf.d/50-nvidia.conf"
	fi

	# Set XScreensaver default mode as blank
	if [ -e "${LDK_ROOTFS_DIR}/etc/X11/app-defaults/XScreenSaver" ]; then
		sed -i "s/random/blank/" \
			"$(readlink -f "${LDK_ROOTFS_DIR}/etc/X11/app-defaults/XScreenSaver")"
	fi
}

LDK_ROOTFS_DIR="${1}"
if [ ! -d "${LDK_ROOTFS_DIR}" ]; then
	echo "Error: ${LDK_ROOTFS_DIR} does not exist!"
	exit 1
fi

AddSystemGroup gpio
AddSystemGroup crypto
AddSystemGroup trusty

nv_customize_rootfs

For function nv_customize_rootfs above, there is a comment , # Enable Unity by default for better user experience [2332219], it just adds prefix ‘ux-’ to rename these desktop.
If I rename other desktops with prefix ‘ux-’ except LXDE.desktop, could LXDE be the default desktop environment?

Hi @YHuang0915 ,

You can refer to /etc/systemd/nvfb-early.sh. There is a mechanism that we are using for jetson nano 2gb.

Please check that line:

If RAM size is less than 4 GB, set default display manager as LightDM

You can use similar setting for your NX so it will switch to lxde +lightdm.

Hi @WayneWWW
I modify the /etc/X11/default-display-manager with /usr/sbin/lightdm.
Above could enable the lightdm to be the display manager.

And I also rename the .desktops under /usr/share/xsessions, which helps to set the LXDE to be default desktop environment.

Thank you again, Wayne, and hope above could help other in the same case :)

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.