- if [[ $2 == 'chroot' ]]; then
- chrun "mkdir -pv '$dir'"
- for i in dwm dmenu st; do
- if chrun "git clone 'https://git.suckless.org/$i' '$dir/$i'"; then
- chrun "cd '$dir/$i' && make PREFIX=/usr install"
+ 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"