I recently bought a new laptop, a Clevo PA70ES with a i7-8750H processor and a nvidia 1070 graphics card. Since this is a game laptop it's fairly power-hungry and does not last long when running on battery. To be able to use this thing as a somewhat portable Workstation I had to tweak a few settings. The first of which is enabling gpu switching between the integrated GPU and the nvidia GPU. Since the NVIDIA GPU can be quite power hungry ( > 100w ) it makes sense to disable it when on battery.
Luckily for me, packages that do the switching between the NVIDIA and Intel GPU already exist. Unfortunately none of them were easy to set up or use. With some trial and error, and configuring Xorg by hand I figured out you can switch the Xorg configuration over to intel - stop Xorg and unload the nvidia drivers, then disable the GPU Like so:
modprobe -r -f nvidia-drm
modprobe -r -f nvidia-modeset
modprobe -r -f nvidia
echo 1> /sys/devices/pci0000:00/0000:00:01.0/remove
Ubuntu however has until recently had a package that enables quick switching between these GPUs. Even better, It's GPL-licenced and can be found here: https://github.com/andrebrait/prime-indicator . It's a fairly simple python script that allows the user to quickly switch between existing Xorg configurations.
I modified this ubuntu package to directly replace the Xorg.conf with the ones I wrote by hand - also eliminating a few dependencies in the process. This script was then packagaged with the configuration files neccesary to run it. I've included it below - it should install without trouble on any Gentoo SDDM desktop.
Once it's all configured you will have a quick switch applet in your application bar:
File | prime-indicator.7z |
Size | 21.35kB |
crc32 | 126420125 |
md5 | 5d180923165bc554fa5763d65f7253a3 |
sha512 | 7f1f919e11e176029eb1f55aba292097396c707ce3ff6723fbb085985555b5c4c0603c847c92b8be0877bc31614255631ac897e3e04e984f6ae288e9facd06b9 |