+ trap "kill $BG_PID 2> /dev/null" EXIT
+}
+
+install_tearfree_conf()
+{
+ local xpath="$1"
+
+ if [[ $VM ]]; then
+ echo "Virtual machine detected, removing xorg configs"
+ find "$xpath/" -name '*.conf' -delete -printf "remove %p\n"
+ elif lspci | grep ' VGA ' | grep -q 'Intel'; then
+ echo "Creating Intel Tear Free config /etc/X11/xorg.conf.d/20-intel.conf"
+ cat > "$xpath/20-intel.conf" <<- EOF
+ Section "Device"
+ Identifier "Intel Graphics"
+ Driver "intel"
+ Option "TearFree" "true"
+ EndSection
+ EOF
+ cat "$xpath/20-intel.conf"
+ elif lspci | grep ' VGA ' | grep -q 'AMD/ATI.*RX\|AMD/ATI.*R[579]'; then # newer RX, R5, R7, and R9 cards can use the amdgpu driver
+ echo "Creating AMD Tear Free config /etc/X11/xorg.conf.d/20-amdgpu.conf"
+ cat > "$xpath/20-amdgpu.conf" <<- EOF
+ Section "Device"
+ Identifier "AMD Graphics"
+ Driver "amdgpu"
+ Option "TearFree" "true"
+ EndSection
+ EOF
+ cat "$xpath/20-amdgpu.conf"
+ elif lspci | grep ' VGA ' | grep -q 'AMD/ATI.*HD [2-6][0-9]*'; then # older HD 2xxx-6xxx cards must use the radeon driver
+ echo "Creating Radeon Tear Free config /etc/X11/xorg.conf.d/20-radeon.conf"
+ cat > "$xpath/20-radeon.conf" <<- EOF
+ Section "Device"
+ Identifier "AMD Graphics"
+ Driver "radeon"
+ Option "TearFree" "on"
+ EndSection
+ EOF
+ cat "$xpath/20-radeon.conf"
+ elif lspci | grep ' VGA ' | grep -q 'NVIDIA'; then # nvidia cards require a bit of checking for notebook gpus
+ echo "Trying nvidia driver install"
+ if lspci | grep ' VGA ' | grep -q 'Intel\|AMD' && lspci | grep ' VGA ' | grep -q 'NVIDIA.*[6-9][1-8][05]M[X]\?\|NVIDIA.*Quadro.*[KMP][1-6][0-2][0]*M'; then # optimus
+ if [[ $xpath == *"$MNT"* ]]; then
+ chrun "nvidia-installer --bumblebee"
+ else
+ nvidia-installer --bumblebee
+ fi
+ else
+ if [[ $xpath == *"$MNT"* ]]; then
+ chrun "nvidia-installer" # unsure which card so try auto detection
+ else
+ nvidia-installer
+ fi
+ fi
+ if [[ -e $xpath/20-nvidia.conf ]]; then
+ cat "$xpath/20-radeon.conf"
+ echo
+ echo "NVIDIA driver installed"
+ if [[ $xpath == *"$MNT"* ]]; then
+ echo "Trying to load the driver for live session"
+ nvidia-smi -r
+ fi
+ echo "To enable driver vsync:"
+ echo -e "\trun nvidia-settings (as root) on first boot\n\tenable 'ForceFullCompositionPipeline' under the advanced settings"
+ echo -e "\tlastly save the change to your nvida xorg config /etc/X11/xorg.conf.d/20-nvidia.conf"
+ echo -e "\tand remove everything but the Device and Screen sections from the file"
+ else
+ echo "Unable to install nvidia driver"
+ fi
+ return 0
+ fi
+
+ if lspci | grep ' VGA ' | grep -q 'Intel\|AMD/ATI'; then
+ if [[ $xpath == *"$MNT"* ]]; then
+ sed -i 's/xrender/glx/g' "$MNT/etc/skel/.config/compton.conf"
+ else
+ sed -i 's/xrender/glx/g' /etc/skel/.config/compton.conf
+ fi
+ fi
+
+ # remove nvidia installer from installed system when not running nvidia gpu
+ [[ $xpath == *"$MNT"* ]] && rm -rf "$MNT/usr/bin/nvidia-installer" "$MNT/var/lib/nvidia-installer"
+}
+
+###############################################################################
+# display manager config
+# these are called based on which DM is chosen after it is installed
+# additional config can be handled here, for now only lightdm has one
+
+ly_config()
+{
+ : #TODO
+}
+
+gdm_config()
+{
+ : #TODO
+}
+
+sddm_config()
+{
+ : #TODO
+}
+
+lightdm_config()
+{
+ cat > "$MNT/etc/lightdm/lightdm-gtk-greeter.conf" <<- EOF
+ [greeter]
+ default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png
+ background=/usr/share/backgrounds/archlabs/archlabs.jpg
+ theme-name=Adwaita-dark
+ icon-theme-name=Adwaita
+ font-name=DejaVu Sans Mono 11
+ position=30%,end 50%,end
+ EOF