egpu-switch-script/egpu.sh

31 lines
867 B
Bash
Raw Permalink Normal View History

2022-03-18 19:30:58 +00:00
#! /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."