Commit a415cd4b authored by Roland Singer's avatar Roland Singer

update to new mhwd-xorg

parent 19579a9b
INSTALL(PROGRAMS mhwd
DESTINATION /var/lib/mhwd/scripts)
INSTALL(PROGRAMS mhwd-gpu
INSTALL(PROGRAMS mhwd-xorg
DESTINATION /usr/bin)
INSTALL(PROGRAMS mhwd-kernel
......
#!/bin/bash
PARAM=$#
MHWDXORGCONF="/etc/X11/xorg.conf.d/90-mhwd.conf"
CHECKCONFIG="false"
SETGL=""
SETXORGCONF=""
GRUBDEFAULT="/etc/default/grub"
UPDATEGRUBCMD="/usr/sbin/update-grub"
# param 1: modules to load
# param 2: blacklisted modules
set_modules() {
echo "##" > "/etc/modprobe.d/mhwd-gpu.conf"
echo "## Generated by mhwd - Manjaro Hardware Detection" >> "/etc/modprobe.d/mhwd-gpu.conf"
echo "##" >> "/etc/modprobe.d/mhwd-gpu.conf"
echo " " >> "/etc/modprobe.d/mhwd-gpu.conf"
for module in $2
do
echo "blacklist ${module}" >> "/etc/modprobe.d/mhwd-gpu.conf"
# Unload module if X is not running
if [ ! "$(pgrep X)" ]; then
rmmod -f ${module}
fi
done
echo "##" > "/etc/modules-load.d/mhwd-gpu.conf"
echo "## Generated by mhwd - Manjaro Hardware Detection" >> "/etc/modules-load.d/mhwd-gpu.conf"
echo "##" >> "/etc/modules-load.d/mhwd-gpu.conf"
echo " " >> "/etc/modules-load.d/mhwd-gpu.conf"
for module in $1
do
echo "${module}" >> "/etc/modules-load.d/mhwd-gpu.conf"
# Load module if X is not running
if [ ! "$(pgrep X)" ]; then
modprobe ${module}
fi
done
}
# param 1: Xorg configuration file
set_xorg()
{
if [ -e "${MHWDXORGCONF}" ]; then
rm "${MHWDXORGCONF}"
fi
if [ -e "$1" ]; then
ln -sf "$1" "${MHWDXORGCONF}"
echo "xorg configuration file: '$1'"
else
echo "warning: could not find '$1'!"
fi
}
# param 1: libGl path
# param 2: libglx path
# optional param 3: lib32 libGl path
set_Gl() {
if [ -e "$1" ]; then
ln -sf "$1" /usr/lib/libGL.so
ln -sf "$1" /usr/lib/libGL.so.1
ln -sf "$1" /usr/lib/libGL.so.1.2.0
echo "libGl: '$1'"
else
echo "warning: could not find '$1'!"
fi
if [ -e "$3" ]; then
ln -sf "$3" /usr/lib32/libGL.so
ln -sf "$3" /usr/lib32/libGL.so.1
ln -sf "$3" /usr/lib32/libGL.so.1.2.0
echo "lib32-libGl: '$3'"
fi
if [ -e "$2" ]; then
ln -sf "$2" /usr/lib/xorg/modules/extensions/libglx.so
echo "libglx: '$2'"
else
echo "warning: could not find '$2'!"
fi
}
print_link_destination_if_exists()
{
if [ -e "$1" ]; then
echo "$2 '$(readlink "$1")'"
else
echo "warning: could not find '$1'!"
fi
}
print_status()
{
echo ":: status"
print_link_destination_if_exists "/usr/lib32/libGL.so" " lib32-libGl:"
print_link_destination_if_exists "/usr/lib/libGL.so" " libGl:"
print_link_destination_if_exists "/usr/lib/xorg/modules/extensions/libglx.so" " libglx:"
print_link_destination_if_exists "${MHWDXORGCONF}" " xorg configuration file:"
}
print_help()
{
echo "mhwd-gpu [OPTION] [...]"
echo ""
echo " --help show help"
echo " --status show current status"
echo " --check check for invalid symlinks and repair"
echo " --setgl [mesa/nvidia/catalyst] set libgl and libglx"
echo " --setxorg [PATH] set xorg configuration file"
echo ""
}
if [ "${PARAM}" -lt 1 ]; then
print_status
exit 0
fi
for (( I=1; $I <= $PARAM; I++ ))
do
case "$1" in
--help)
print_help
exit 0
;;
--status)
print_status
exit 0
;;
--check)
CHECKCONFIG="true"
;;
--setgl)
shift
SETGL="$1"
;;
--setxorg)
shift
SETXORGCONF="$1"
;;
"") ;;
*)
echo "error: invalid argument: $1"
echo ""
print_help
exit 1
;;
esac
shift
done
# Check root
if [[ $EUID -ne 0 ]]; then
echo "error: you cannot perform this operation unless you are root." 1>&2
exit 1
fi
# Set libGl and libglx
if [ "${SETGL}" == "mesa" ] || [ "${SETGL}" == "default" ]; then
set_modules
set_Gl "/usr/lib/libGL.so.mesa" "/usr/lib/xorg/modules/extensions/libglx.xorg" "/usr/lib32/libGL.so.mesa"
elif [ "${SETGL}" == "nvidia" ]; then
set_modules "nvidia" "nouveau ttm drm_kms_helper drm"
set_Gl "/usr/lib/libGL.so.nvidia" "/usr/lib/xorg/modules/extensions/libglx.so.nvidia" "/usr/lib32/libGL.so.nvidia"
elif [ "${SETGL}" == "catalyst" ] || [ "${SETGL}" == "ati" ]; then
set_modules "fglrx" "radeon"
set_Gl "/usr/lib/libGL.so.catalyst" "/usr/lib/xorg/modules/extensions/libglx.so.catalyst" "/usr/lib32/libGL.so.catalyst"
elif [ "${SETGL}" != "" ]; then
echo "error: invalid argument '${SETGL}'"
exit 1
fi
# Set xorg configuration file
if [ "${SETXORGCONF}" != "" ]; then
set_xorg "${SETXORGCONF}"
fi
# Check config
if [ "${CHECKCONFIG}" == "true" ]; then
if [ -L "${MHWDXORGCONF}" -a ! -e "${MHWDXORGCONF}" ]; then
echo "'${MHWDXORGCONF}' symlink is invalid! Removing it..."
rm "${MHWDXORGCONF}"
elif [ -e "${MHWDXORGCONF}" ]; then
echo "xorg configuration symlink valid..."
fi
if [ ! -e "/usr/lib/libGL.so" ] || [ ! -e "/usr/lib/xorg/modules/extensions/libglx.so" ] || [ -L "/usr/lib32/libGL.so" -a ! -e "/usr/lib32/libGL.so" ] || [ -e "/usr/lib32/libGL.so.mesa" -a ! -e "/usr/lib32/libGL.so" ]; then
echo "libGl and libglx symlinks are invalid!"
echo "Falling back to default..."
set_modules
set_Gl "/usr/lib/libGL.so.mesa" "/usr/lib/xorg/modules/extensions/libglx.xorg" "/usr/lib32/libGL.so.mesa"
else
echo "libGl and libglx symlinks valid..."
fi
fi
#!/bin/bash
PARAM=$#
MHWDXORGCONF="/etc/X11/xorg.conf.d/90-mhwd.conf"
CHECKCONFIG="false"
SETXORGCONF=""
# param 1: Xorg configuration file
set_xorg()
{
if [ ! -e "$1" ]; then
echo "error: could not find symlink target '$1'!" 1>&2
exit 1
fi
if [ -e "${MHWDXORGCONF}" ]; then
rm "${MHWDXORGCONF}"
fi
ln -sf "$1" "${MHWDXORGCONF}"
echo "xorg configuration file: '$1'"
}
print_link_destination_if_exists()
{
if [ -e "$1" ]; then
echo "$2 '$(readlink "$1")'"
else
echo "warning: invalid symlink '$1'!"
fi
}
print_status()
{
echo ":: status"
print_link_destination_if_exists "${MHWDXORGCONF}" " xorg configuration file:"
}
print_help()
{
echo "mhwd-xorg [OPTION] [...]"
echo ""
echo " -h --help show help"
echo " -s --status show current status"
echo " -x --setxorg [PATH] set xorg configuration file"
echo ""
}
if [ "${PARAM}" -lt 1 ]; then
print_status
exit 0
fi
for (( I=1; $I <= $PARAM; I++ ))
do
case "$1" in
-h|--help)
print_help
exit 0
;;
-s|--status)
print_status
exit 0
;;
-x|--setxorg)
shift
SETXORGCONF="$1"
if [ "$SETXORGCONF" == "" ]; then
echo "error: invalid argument" 1>&2
exit 1
fi
;;
"") ;;
*)
echo "error: invalid argument: $1" 1>&2
echo ""
print_help
exit 1
;;
esac
shift
done
# Set xorg configuration file
if [ "${SETXORGCONF}" != "" ]; then
# Check root
if [[ $EUID -ne 0 ]]; then
echo "error: you cannot perform this operation unless you are root." 1>&2
exit 1
fi
set_xorg "${SETXORGCONF}"
fi
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment