Attempt to keep the screen driver creation from failing.

This commit is contained in:
Storm Dragon
2025-12-20 06:48:18 -05:00
parent 742e8d1ed3
commit addeec3360

View File

@@ -2,17 +2,42 @@
# Change between dummy and fbdev driver for X session.
sudoFlags=()
if [[ -n "${SUDO_ASKPASS:-}" ]]; then
sudoFlags=("-A")
fi
xorgConfDir="/etc/X11/xorg.conf.d"
xorgConfFile="${xorgConfDir}/10-screendriver.conf"
ensure_xorg_conf_dir() {
if ! sudo "${sudoFlags[@]}" mkdir -p "${xorgConfDir}"; then
msgbox "Failed to create ${xorgConfDir}."
return 1
fi
}
active_screen() {
cat << EOF | sudo "${sudoFlags[@]}" tee /etc/X11/xorg.conf.d/10-screendriver.conf &> /dev/null
if ! ensure_xorg_conf_dir; then
return 1
fi
if ! sudo "${sudoFlags[@]}" tee "${xorgConfFile}" > /dev/null << 'EOF'
Section "Device"
Identifier "FBdev"
Driver "fbdev"
EndSection
EOF
then
msgbox "Failed to write ${xorgConfFile}."
return 1
fi
}
headless() {
cat << EOF | sudo "${sudoFlags[@]}" tee /etc/X11/xorg.conf.d/10-screendriver.conf &> /dev/null
if ! ensure_xorg_conf_dir; then
return 1
fi
if ! sudo "${sudoFlags[@]}" tee "${xorgConfFile}" > /dev/null << 'EOF'
Section "Monitor"
Identifier "dummy_monitor"
HorizSync 28.0-80.0
@@ -42,6 +67,10 @@ Section "ServerLayout"
Screen 0 "dummy_screen"
EndSection
EOF
then
msgbox "Failed to write ${xorgConfFile}."
return 1
fi
}
@@ -49,11 +78,17 @@ source ./.includes/functions.sh
source ./.includes/ui.sh
answer=$(yesno "Do you have a physical screen attached?")
if [[ "${answer}" == "Yes" ]]; then
active_screen
msgbox "Settings for physical screen applied."
if active_screen; then
msgbox "Settings for physical screen applied."
else
exit 1
fi
else
headless
msgbox "Settings for no screen applied."
if headless; then
msgbox "Settings for no screen applied."
else
exit 1
fi
fi
if [[ "$1" != "-n" ]]; then