Created
May 18, 2020 18:22
-
-
Save bradfordcp/925817863ee731459a656ef1f5bc9f6c to your computer and use it in GitHub Desktop.
gswitch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/env fish | |
set NVIDIA_GPU_COUNT (/usr/sbin/lspci | grep -i nvidia | wc -l) | |
if test "$NVIDIA_GPU_COUNT" -gt 1 | |
echo "Setting graphics to eGPU" | |
/usr/local/bin/gswitch egpu | |
else | |
echo "Setting graphics to Intel" | |
/usr/local/bin/gswitch internal-intel | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Automatic detection of hardware and XOrg config | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/local/bin/gautodetect | |
[Install] | |
WantedBy=local-fs.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env fish | |
if test (whoami) != "root" | |
echo "You need to be root." | |
exit | |
end | |
set LINK_TARGET /etc/X11/xorg.conf | |
set INTERNAL_INTEL_XORG_CONF /etc/X11/xorg.internal.intel.conf | |
set INTERNAL_NVIDIA_XORG_CONF /etc/X11/xorg.internal.nvidia.conf | |
set EGPU_NVIDIA_XORG_CONF /etc/X11/xorg.egpu.nvidia.conf | |
switch (echo $argv[1]) | |
case "egpu" | |
rm -f $LINK_TARGET | |
ln -s $EGPU_NVIDIA_XORG_CONF $LINK_TARGET | |
case "internal-intel" | |
rm -f $LINK_TARGET | |
ln -s $INTERNAL_INTEL_XORG_CONF $LINK_TARGET | |
case "internal-nvidia" | |
rm -f $LINK_TARGET | |
ln -s $INTERNAL_NVIDIA_XORG_CONF $LINK_TARGET | |
case "*" | |
echo "Unknown configuration $argv[1]. Valid options are 'egpu', 'internal-intel', 'internal-nvidia'" | |
exit 1 | |
end | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Section "Module" | |
Load "modesetting" | |
EndSection | |
Section "Device" | |
Identifier "Device0" | |
Driver "nvidia" | |
BusID "PCI:7:0:0" | |
Option "AllowEmptyInitialConfiguration" | |
Option "AllowExternalGpus" "True" | |
EndSection | |
Section "Monitor" | |
Identifier "HDMI-0" | |
Option "Primary" "true" | |
EndSection | |
Section "Monitor" | |
Identifier "eDP-1-1" | |
Option "LeftOf" "HDMI-0" | |
EndSection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Intentionally empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Section "Module" | |
Load "modesetting" | |
EndSection | |
Section "Device" | |
Identifier "Device0" | |
Driver "nvidia" | |
BusID "PCI:1:0:0" | |
Option "AllowEmptyInitialConfiguration" | |
EndSection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment