97 lines
1.9 KiB
Bash
Executable File
97 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# 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() {
|
|
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() {
|
|
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
|
|
VertRefresh 48.0-75.0
|
|
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
|
|
EndSection
|
|
|
|
Section "Device"
|
|
Identifier "dummy_card"
|
|
Driver "dummy"
|
|
VideoRam 256000
|
|
Option "UseFBDev" "false"
|
|
EndSection
|
|
|
|
Section "Screen"
|
|
Identifier "dummy_screen"
|
|
Device "dummy_card"
|
|
Monitor "dummy_monitor"
|
|
SubSection "Display"
|
|
Depth 24
|
|
Modes "1920x1080"
|
|
EndSubSection
|
|
EndSection
|
|
|
|
Section "ServerLayout"
|
|
Identifier "dummy_layout"
|
|
Screen 0 "dummy_screen"
|
|
EndSection
|
|
EOF
|
|
then
|
|
msgbox "Failed to write ${xorgConfFile}."
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
|
|
source ./.includes/functions.sh
|
|
source ./.includes/ui.sh
|
|
answer=$(yesno "Do you have a physical screen attached?")
|
|
if [[ "${answer}" == "Yes" ]]; then
|
|
if active_screen; then
|
|
msgbox "Settings for physical screen applied."
|
|
else
|
|
exit 1
|
|
fi
|
|
else
|
|
if headless; then
|
|
msgbox "Settings for no screen applied."
|
|
else
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [[ "$1" != "-n" ]]; then
|
|
restart
|
|
fi
|