mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-02-04 03:07:13 +08:00
4cc578e736
catalystpxp-utils: rename the new way (experimental) chakra-hwd: adopt to catalyst-utils
167 lines
5.2 KiB
Bash
Executable File
167 lines
5.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Vi0L0: it's my switching script:
|
|
# * switching xorg.conf - it will rename xorg.conf into xorg.conf.cat
|
|
# (if there's fglrx inside) or xorg.conf.oth (if there's intel or radeon inside).
|
|
# And then it will create link to xorg.conf depending on what did you choose
|
|
# * running aticonfig --px-Xgpu
|
|
# * running switchlibGL
|
|
# * adding/removing fglrx into/from MODULES in rc.conf
|
|
#
|
|
# You can do with it whatever you want :P
|
|
# NO WARRANTY OF ANY KIND
|
|
|
|
# Set local language always to C
|
|
export LC_ALL=C
|
|
export LANG=C
|
|
|
|
if [ "$(whoami)" != "root" ]; then
|
|
echo "Must be root to run this script." 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ $# -ge 2 ]; then
|
|
echo "Usage: $(basename $0) <amd|intel|query>" 1>&2
|
|
echo "Please choose one parameter" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
CARCH=`uname -m`
|
|
if [ "${CARCH}" = "i686" ]; then
|
|
_lib=lib
|
|
elif [ "${CARCH}" = "x86_64" ]; then
|
|
_lib=lib64
|
|
fi
|
|
|
|
|
|
|
|
function check_xorg_conf() {
|
|
|
|
if [ ! -e /etc/X11/xorg.conf.cat ];then
|
|
if [ -e /etc/X11/xorg.conf ] && [[ `cat /etc/X11/xorg.conf | grep -c fglrx` != 0 ]]; then
|
|
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.cat
|
|
echo "/etc/X11/xorg.conf renamed to /etc/X11/xorg.conf.cat"
|
|
fi
|
|
fi
|
|
if [ ! -e /etc/X11/xorg.conf.oth ]; then
|
|
if [ -e /etc/X11/xorg.conf ];then
|
|
if [[ `cat /etc/X11/xorg.conf | grep -c radeon` != 0 ]] || [[ `cat /etc/X11/xorg.conf | grep -c intel` != 0 ]]; then
|
|
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.oth
|
|
echo "/etc/X11/xorg.conf renamed to /etc/X11/xorg.conf.oth (radeon or intel inside)"
|
|
fi
|
|
fi
|
|
fi
|
|
if [ -e /etc/X11/xorg.conf ] && [[ `cat /etc/X11/xorg.conf | grep -c fglrx` = 0 ]] && [[ `cat /etc/X11/xorg.conf | grep -c radeon` = 0 ]] && [[ `cat /etc/X11/xorg.conf | grep -c intel` = 0 ]]; then
|
|
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.wth
|
|
echo "/etc/X11/xorg.conf have no fglrx or radeon or intel inside!"
|
|
echo "/etc/X11/xorg.conf renamed to /etc/X11/xorg.conf.wth"
|
|
fi
|
|
}
|
|
|
|
function switch_to_amd() {
|
|
|
|
#switching xorg.conf
|
|
echo -e '\E[37;44m'"\033[1mSwitching xorg.conf ...\033[0m"
|
|
check_xorg_conf
|
|
if [ -e /etc/X11/xorg.conf.cat ]; then
|
|
ln -snf /etc/X11/xorg.conf.cat /etc/X11/xorg.conf
|
|
echo "/etc/X11/xorg.conf.cat linked to /etc/X11/xorg.conf"
|
|
fi
|
|
|
|
#linking!
|
|
echo -e '\E[37;44m'"\033[1mRunning aticonfig --px-dgpu ...\033[0m"
|
|
aticonfig --px-dgpu
|
|
echo -e '\E[37;44m'"\033[1mRunning /usr/${_lib}/fglrx/switchlibGL amd ...\033[0m"
|
|
/usr/${_lib}/fglrx/switchlibGL amd
|
|
echo -e '\E[37;44m'"\033[1mRunning /usr/${_lib}/fglrx/switchlibglx amd ...\033[0m"
|
|
/usr/${_lib}/fglrx/switchlibglx amd
|
|
|
|
#checking MODULES for fglrx
|
|
echo -e '\E[37;44m'"\033[1mChecking MODULES for fglrx ...\033[0m"
|
|
check1=$(grep ^MODULES /etc/rc.conf | grep '!fglrx')
|
|
if [ "$check1" != "" ]; then
|
|
sed 's/!fglrx/fglrx/' -i /etc/rc.conf
|
|
echo "Removed ! from !fglrx in /etc/rc.conf (MODULES)"
|
|
fi
|
|
check2=$(grep ^MODULES /etc/rc.conf | grep fglrx)
|
|
if [ "$check2" = "" ]; then
|
|
sed 's/MODULES=(/MODULES=(fglrx /' -i /etc/rc.conf
|
|
echo "fglrx was added into /etc/rc.conf (MODULES)"
|
|
fi
|
|
|
|
}
|
|
|
|
function switch_to_intel() {
|
|
|
|
#switching xorg.conf part 1
|
|
echo -e '\E[37;44m'"\033[1mSwitching xorg.conf (part 1) ...\033[0m"
|
|
check_xorg_conf
|
|
if [ -e /etc/X11/xorg.conf.cat ]; then
|
|
ln -snf /etc/X11/xorg.conf.cat /etc/X11/xorg.conf
|
|
echo "/etc/X11/xorg.conf.cat linked to /etc/X11/xorg.conf"
|
|
fi
|
|
|
|
#linking!
|
|
echo -e '\E[37;44m'"\033[1mRunning aticonfig --px-igpu ...\033[0m"
|
|
aticonfig --px-igpu
|
|
echo -e '\E[37;44m'"\033[1mRunning /usr/${_lib}/fglrx/switchlibGL intel ...\033[0m"
|
|
/usr/${_lib}/fglrx/switchlibGL intel
|
|
echo -e '\E[37;44m'"\033[1mRunning /usr/${_lib}/fglrx/switchlibglx intel ...\033[0m"
|
|
/usr/${_lib}/fglrx/switchlibglx intel
|
|
|
|
#switching xorg.conf part 2
|
|
echo -e '\E[37;44m'"\033[1mSwitching xorg.conf (part 2) ...\033[0m"
|
|
if [ -e /etc/X11/xorg.conf.oth ]; then
|
|
ln -snf /etc/X11/xorg.conf.oth /etc/X11/xorg.conf
|
|
echo "/etc/X11/xorg.conf.oth linked to /etc/X11/xorg.conf"
|
|
else
|
|
rm /etc/X11/xorg.conf
|
|
echo "/etc/X11/xorg.conf was removed"
|
|
fi
|
|
|
|
#checking MODULES for fglrx
|
|
echo -e '\E[37;44m'"\033[1mChecking MODULES for fglrx ...\033[0m"
|
|
check=$(grep ^MODULES /etc/rc.conf | grep 'fglrx')
|
|
if [ "$check" != "" ]; then
|
|
sed '/^MODULES/s/ *fglrx *//' -i /etc/rc.conf
|
|
echo "fglrx was removed from /etc/rc.conf (MODULES)"
|
|
fi
|
|
|
|
}
|
|
|
|
function get_current_driver() {
|
|
|
|
LIB_LINK="`readlink /usr/lib/catalystpxp/libGL.so.1.2 2>/dev/null`"
|
|
if [ "${LIB_LINK}" = "/usr/lib/catalystpxp/fglrx/fglrx-libGL.so.1.2" ]; then
|
|
echo "amd (catalyst)"
|
|
elif [ "${LIB_LINK}" = "fglrx/fglrx-libGL.so.1.2" ]; then
|
|
echo "catalyst"
|
|
elif [ "${LIB_LINK}" = "/usr/lib/libGL.so.1.2" ]; then
|
|
echo "intel (or radeon)"
|
|
else
|
|
echo "unknown"
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
amd)
|
|
switch_to_amd
|
|
echo -e '\E[37;44m'"\033[1mSwitched to Catalyst\033[0m" 1>&2
|
|
;;
|
|
intel)
|
|
switch_to_intel
|
|
echo -e '\E[37;44m'"\033[1mSwitched to Intel (or Radeon)\033[0m" 1>&2
|
|
;;
|
|
query)
|
|
get_current_driver
|
|
;;
|
|
*)
|
|
echo "Usage: $(basename $0) <amd|intel|query>" 1>&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|