Skip to content

Commit 4ee731b

Browse files
committed
[add] : Session auto detect
1 parent 563825f commit 4ee731b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Seat:*]
2+
autologin-session=%SESSION%

modules/lightdm/airootfs.any/root/customize_airootfs_lightdm.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,21 @@ fi
1717

1818
# Replace auto login user
1919
sed -i "s|%USERNAME%|${username}|g" "/etc/lightdm/lightdm.conf.d/02-autologin.conf"
20+
21+
22+
# Session list
23+
if cat "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf" | grep "%SESSION%" 1> /dev/null 2>&1; then
24+
session_list=()
25+
while read -r session; do
26+
session_list+=("${session}")
27+
done < <(find "/usr/share/xsessions" -type f -print0 -name "*.desktop" | xargs -0 -I{} bash -c 'basename {} | sed "s|.desktop||g"')
28+
29+
if (( "${#session_list[@]}" = 1)); then
30+
session="${session_list[*]}"
31+
sed -i "s|%SESSION%|${session}|g" "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf"
32+
elif (( "${#session_list[@]}" = 0)); then
33+
echo "Warining: Auto login session was not found"
34+
else
35+
remove "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf"
36+
fi
37+
fi

0 commit comments

Comments
 (0)