From 418315aa36d3574a27d9a77df02a3294660a43ee Mon Sep 17 00:00:00 2001 From: Quad Date: Fri, 18 Mar 2022 20:30:58 +0100 Subject: [PATCH] Add script and config file --- egpu.conf | 10 ++++++++++ egpu.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 egpu.conf create mode 100644 egpu.sh diff --git a/egpu.conf b/egpu.conf new file mode 100644 index 0000000..19ddd22 --- /dev/null +++ b/egpu.conf @@ -0,0 +1,10 @@ +Section "Device" + Identifier "Device0" + Driver "amdgpu" + BusID "PCI:06:00:0" # Edit to match the PCI address of your AMD GPU +EndSection + +Section "Module" + # Loading this allows offloading to the Intel GPU if you for some reason want that + Load "modesetting" +EndSection diff --git a/egpu.sh b/egpu.sh new file mode 100644 index 0000000..50e1517 --- /dev/null +++ b/egpu.sh @@ -0,0 +1,30 @@ +#! /usr/bin/bash + +## +# +# Update EGPU_NAME to a string which can be used to find your eGPU via lspci. +# If EGPU_NAME is found in the output of lspci, CONFIG_FILE will be copied to TARGET_FILE. +# If it is not found, it will delete TARGET_FILE. So keep that in mind to make sure it does not delete any important config file. +# Ensure the paths in both of those variables look correct. +# +## + +EGPU_NAME="Example string" +CONFIG_FILE="/opt/config/egpu.conf" +TARGET_FILE="/etc/X11/xorg.conf.d/egpu.conf" + +SCRIPT_NAME="eGPU script" + +echo "${SCRIPT_NAME}: Checking for GPU..." + +EGPU_DETECTION=`lspci | grep "$EGPU_NAME"` + +if [ -z "${EGPU_DETECTION}" ]; then + echo "${SCRIPT_NAME}: No GPU found, clearing config..." + rm -f $TARGET_FILE +else + echo "${SCRIPT_NAME}: GPU found, setting as main gpu..." + cp $CONFIG_FILE $TARGET_FILE +fi + +echo "${SCRIPT_NAME}: Done, proceeding."