In this post I am sharing how to use optimus-manager to shift between Integrated and NVIDIA GPU on Arch Linux with i3 as the tiling windows manager and no display manager.
(That is you start your Xserver using the startx command).
The official documentation just mentions that prime-offload and prime-switch need to be run at start and end of the Xserver (respectively) but, it fails to mention to how to do this setup.
Without wasting any further time, lets get started.
Steps
Open up your
.xinitrclocated under$HOMEor~. If it doesn't exist then, create one.-
Look at the following code-block:
# MENTION HERE COMMAND THAT IS RUN AT THE START OF XServer # and before starting up `i3` (#a) nitrogen --restore & picom & i3 # MENTION HERE COMMAND THAT IS RUN AT THE END OF XServer # and after exiting `i3` (#b) -
Place the command to run
prime-offloadat #a:
if [[ -f /usr/bin/prime-offload ]]; then /usr/bin/prime-offload fi nitrogen --restore & picom & i3 -
Place the command to run
prime-switchat #b:
nitrogen --restore & picom & i3 if [[ -f /usr/bin/prime-switch ]]; then sudo /usr/bin/prime-switch fi
Verify
Your final .xinitrc should be like this:
if [[ -f /usr/bin/prime-offload ]]; then
/usr/bin/prime-offload
fi
nitrogen --restore &
picom &
i3
if [[ -f /usr/bin/prime-switch ]]; then
sudo /usr/bin/prime-switch
fi
Basically, we are checking if prime-offload exists then, run it at the start of XServer. Technically, not exactly at start but, before we run our compositor and i3 instance.
And then, we are checking if prime-switch exists then, run it after the i3 instance has ended.
You can read more about .xinitrc here

Top comments (0)