ambevar-dotfiles/.scripts/switchdriver

46 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
if [ -z "$(lspci|grep "VGA.*Radeon")" ]; then
echo "You must have a Radeon graphic adapter. Exit."
exit
fi
if [ $(id -u) -ne 0 ]; then
echo "You must be root to run this script. Exit."
exit
fi
if [ $(pacman -Qi catalyst-utils 2>/dev/null |wc -l) -ge 2 ]; then
pacman -Rdd --noconfirm catalyst catalyst-utils lib32-catalyst-utils
rm -f "/etc/X11/xorg.conf"
pacman -S --noconfirm ati-dri lib32-ati-dri xf86-video-ati
pacman -S --noconfirm mesa-libgl lib32-mesa-libgl
pacman -S --noconfirm libcl lib32-libcl
if [ -f "/boot/syslinux/syslinux.cfg" ]; then
ex -sc '/^LABEL arch$/+3 s/ nomodeset//|xit' '/boot/syslinux/syslinux.cfg'
echo
echo "#### Syslinux entry:"
grep -A4 '^LABEL arch$' '/boot/syslinux/syslinux.cfg'
else
echo "You do not seem to use Syslinux. No configuration done."
echo "You have to remove 'nomodeset' kernel parameter manually."
fi
else
pacman -Rs --noconfirm ati-dri lib32-ati-dri xf86-video-ati
pacman -Rdd --noconfirm mesa-libgl lib32-mesa-libgl
pacman -Rdd --noconfirm libcl lib32-libcl
pacman -S --noconfirm catalyst catalyst-utils lib32-catalyst-utils
aticonfig --initial
if [ $? -eq 0 ] && [ -f '/boot/syslinux/syslinux.cfg' ]; then
ex -sc '/^LABEL arch$/+3 s/$/ nomodeset/|xit' '/boot/syslinux/syslinux.cfg'
echo
echo "#### Syslinux entry:"
grep -A4 "^LABEL arch$" "/boot/syslinux/syslinux.cfg"
else
echo "You do not seem to use Syslinux. No configuration done."
echo "You have to add 'nomodeset' kernel parameter manually."
fi
fi