This is a shell script I made to switch between the iGPU and the dGPU on optimus-enabled laptops. It resembles optimus-manager, but it has some key diffirences.
I made it because I needed maximum battery life on my laptop while having maximum performance while gaming, maybe you are one of those people, if you have the time to install it and get it working properly on your hardware it might be worth your time.
Well, at first I though optimus-manager was THE way for Arch laptops, but I didn't want to reboot everytime I wanted to use the other GPU and I didn't want the whole X server to run on only one GPU.
-
Better power savings when using the dGPU (
NVreg_DynamicPowerManagement
) -
You get an unnoticeably small boost in performance when using the dGPU (X still uses the iGPU)
-
You don't have to reboot after switching (only restarting X is required)
-
Starting an app, while having switched to the dGPU, will default to the iGPU (run with:
run-gpu app_name
to use the dGPU) -
Modification to some configs may be required before it can work properly
-
It's not as tested, it has more bugs (these will get fixed)
-
Install the required dependencies:
sudo pacman -S bbswitch nvidia nvidia-prime
-
Nvidia drivers (
nvidia
package) -
Nvidia PRIME (
nvidia-prime
package) -
bbswitch (
bbswitch
package)
-
-
Clone this repository somewhere on your system, doesn't really matter where... just make sure you remember the location (not in /tmp)
git clone https://github.com/threadexio/custom-optimus custom-optimus && cd custom-optimus
-
Run the
install.sh
script and it will guide you -
After completing all that, do a quick reboot to ensure everything is loaded and ready to go.
-
If you have done all, without errors, it should all work just run
optimus
from your terminal and choose which GPU you want to use -
To run any app with or without the dGPU use the included wrapper (
/usr/bin/run-gpu
) it will automatically detect if the GPU is active and use it.You can test it by running
run-gpu glxinfo | grep "OpenGL vendor"
with the dGPU active and then without it, when running it with the GPU active it should report:OpenGL vendor string: NVIDIA Corporation
For example, this is how launch options in steam would look:
run-gpu %command%
Or if you don't like VSYNC:
NO_VSYNC=1 run-gpu %command%
NOTE: Before switching the GPU, save all of your work because although you don't have to reboot, restarting X also kills the current session along with the open apps
Tested on:
- Linux archlunix 5.15.6-zen2-1-zen #1 ZEN SMP PREEMPT Thu, 02 Dec 2021 15:47:07 +0000 x86_64 GNU/Linux
- Nvidia Driver version:
495.44
- WM:
i3
- Display Manager:
LightDM
To end this super long README, I want to clarify that I have not tested this on other hardware, your experiences and configs may and probably will vary from mine.