Optimus Switch - Another Solution for Optimus Laptops

Introduction

Since their introduction, getting Optimus (Intel/ nVidia) laptops to work properly has been an issue under Linux. The two most common solutions are Bumblebee and Optimus Manager. Both have their limitations and not every user can get them working properly. Optimus Switch, written by user @dglt, is another option for users to switch between graphics cards on Optimus based (Intel/ nVidia) laptops. By following this guide, the user will install and properly configure Optimus Switch and the GUI indicator/ switcher for it.

Optimus Switch vs. Optimus Manager.

  1. By default, Optimus Switch will completely power down your nVidia card when you are using the Intel iGPU. This allows for longer battery life. While this function can be enabled in Optimus Manager, it is not enabled by default and does not always work properly.

  2. Optimus Switch sets up the nVidia card in “Prime Mode” when the user is in “nVidia” mode. This allows the user full access to their nVidia card without using terminal commands or modifying shortcut parameters to run programs.

  3. Optimus Switch does not require a “patched” version of GDM from the AUR. Less chance of instability when Gnome is updated.

  4. Optimus Switch, unlike Optimus Manager, does not allow for the switching of GPU’s on demand. The user needs to reboot their laptop whenever they “switch” between GPU’s.

Optimus Switch vs. Bumblebee

The same comparisons for Optimus Manager apply to Bumblebee as well. The only difference is the use of the proprietary nVidia driver instead of the Open Source Nouveau driver. By using the driver from nVidia, the user is able to use the full capabilities of their nVidia card.

All the above solutions require the use of Xorg instead of Wayland.

Where to find Optimus Switch

Optimus Switch can be found at the links below. Because of differences in Display Managers, make sure that you use the version appropriate for the Display Manager you are using.

Gnome (GDM) - https://github.com/dglt1/optimus-switch-gdm

KDE (SDDM) - https://github.com/dglt1/optimus-switch-sddm

LightDM - https://github.com/dglt1/optimus-switch

While originally written for Manjaro installs, Optimus Switch can easily be used on other Arch-based distros. For EndeavourOS, we need to follow the instructions below.

Installation

  1. Install EndeavourOS. Make sure to install the nVidia Drivers package. This will install the nVidia driver. I know it says that it is not for legacy cards or hybrid solutions. The system will still boot, but it may not initialize the Display Manager.

  2. Upon reboot, you may be presented with a black screen and a blinking cursor. If you are presented with a log in screen, DO NOT LOG IN. In both cases, hit ctrl-alt-F3 to enter a TTY session. Now log in to your system.

  3. Make sure that the nVidia driver is installed.

pacman -Q | grep nvidia

You should get a result that looks similar to this:

$ pacman -Q | grep nvidia
lib32-nvidia-utils 450.66-1
nvidia-dkms 450.66-1
nvidia-installer-db 2.4.6-1
nvidia-installer-dkms 3.3.7-1
nvidia-settings 450.66-1
nvidia-utils 450.66-1

3a. If the nVidia driver did not install, do the following.

sudo nvidia-installer-dkms

  1. Install the needed dependencies.

sudo pacman -S linux-headers acpi_call-dkms mesa-demos xorg-xrandr xf86-video-intel git

4a. Be sure to change the linux-headers package to match the kernel you are using. For example the zen kernel uses the linux-zen-headers package and the lts kernel uses the linux-lts-headers package.

  1. Enable acpi_call by typing sudo modprobe acpi_call

  2. Make sure that there are no video related config files on your system. Look in the following folders:

/etc/X11/
/etc/X11/xorg.conf.d/
/etc/modprobe.d/
/etc/modules-load.d/

6a. Any conf file that deals with the keyboard, touchpad, or networking can stay. Anything else, you can manually delete. For example, if you have a conf file name 20-nvidia.conf, it needs to be removed. You can remove it by typing sudo rm /etc/X11/xorg.conf.d/20-nvidia.conf

Now we can follow the readme on the GitHub page for the project directly. Make sure you follow the proper instructions for the Display Manager you are using.

  1. From your home directory (~/) do the following. If you do not do this from the home directory, the script will not install files properly.

Gnome (GDM)

git clone https://github.com/dglt1/optimus-switch-gdm.git
cd ~/optimus-switch-gdm
chmod +x install.sh
sudo ./install.sh

Now we need to make sure that Gnome is using Xorg by default.

sudo nano /etc/gdm/custom.conf

Remove the # before the line that reads WaylandEnable=false . Hit ctrl-x to exit and Y to save the changes.

KDE (SDDM)

git clone https://github.com/dglt1/optimus-switch-sddm.git
cd ~/optimus-switch-sddm
chmod +x install.sh
sudo ./install.sh

LightDM


git clone https://github.com/dglt1/optimus-switch.git
cd ~/optimus-switch-sddm
chmod +x install.sh
sudo ./install.sh
  1. Optimus Switch is now installed. You can now reboot your laptop. After your laptop finishes starting up, you will be in nVidia Prime “Mode”.

To switch modes, open a terminal and type the following:

For nVidia mode – sudo set-nvidia.sh
For Intel mode – sudo set-intel.sh

Then restart the laptop.

Reminder: When switching modes, you have to restart your laptop for the changes to take effect.

Powering down the nVidia card in Intel Mode

Optimus Switch uses the functions in the acpi_call package to turn off the nVidia card when the laptop is in Intel Mode. This allows for longer use time while on battery. To properly setup up acpi_call, we need to do the following.

  1. The laptop needs to be in Intel Mode . If the user is in nVidia Mode, the laptop will freeze.

  2. Open a terminal and type sudo /etc/switch/gpu_switch_check.sh . This will display a list of options that acpi_call can use to turn off the nVidia card.

  3. Read through the list of options displayed looking for the line that says “works!”

  4. Highlight and copy that line.

  5. Open the file /etc/switch/intel/no-optimus.sh by typing sudo nano /etc/switch/intel/no-optimus.sh

  6. Near the end of the file, two lines are commented out (#). Remove the (#) and replace the first
    line with what you copied above.

Example:

In the default file /etc/switch/intel/no-optimus.sh, the two lines look like this:

#echo '\_SB.PCI0.PEG0.PEGP._OFF' > /proc/acpi/call
#echo -n 1 > '/sys/bus/pci/devices/0000:01:00.0/remove'

Remove the (#) before each of these lines so it looks like this:

echo '\_SB.PCI0.PEG0.PEGP._OFF' > /proc/acpi/call
echo -n 1 > '/sys/bus/pci/devices/0000:01:00.0/remove'

Change the '\_SB.PCI0.PEG0.PEGP._OFF' with what you copied in step 4.

  1. Save and exit the file by hitting ctrl-x and answering Y to save the changes.

  2. Type sudo set-intel.sh and reboot the system.

The nVidia card should now be powered off when you are using the Intel iGPU to render graphics. To test this, open a terminal and type one of the two commands.

a. glxinfo|grep "OpenGL vendor|OpenGL renderer"

b. inxi -G

You should only see the Intel iGPU listed.

Installing the GUI Indicator/ Switcher Optimus-Indicator

If you are like me, you prefer doing things with a GUI. Also, it would be nice to have an indicator of some sort in the system tray. Because of this, I wrote a program for Optimus Switch that provides not only an indicator, but a way to switch “modes” right from the system tray. It is called Optimus-Indicator. It works with all major Desktop Environments and can be found here:`

https://github.com/linesma/Optimus-indicator

Installation

NOTE: This program relies on python. When python updates, a reinstall may be required.

  1. Make sure that all the dependencies are installed.

sudo pacman -S libappindicator-gtk3 libappindicator-gtk2 libnotify

Additional requirement for Gnome – Make sure you have the KStatusNotifierItem/AppIndicator Support
extension link installed and activated. Without this extension, the icon will not display in the top bar’s system tray or in the system tray if you use the Dash to Panel extension.

Additional requirement for LXQT – The GTK3 package needs to be installed.

sudo pacman -S gtk3

  1. Clone the repository the repository to your computer and go to its folder.
git clone https://github.com/linesma/Optimus-indicator.git
cd Optimus-indicator

For Gnome

Gnome requires slightly modified scripts to switch between the GPU’s. While they are the same scripts in dglt’s Optimus-Switch GDM repository, I have included them here for ease of installation.

  1. Make the install script executable.

chmod a+x setupgn.py

  1. Run the install script.

sudo ./setupgn.py install

  1. The install script will install the needed files.

  2. Once the installation is complete, reboot your laptop. Optimus-Indicator will start automatically when the laptop boots.

For all other Desktop Environments

  1. Make the install script executable.

chmod a+x setup.py

  1. Run the install script.

sudo ./setup.py install

  1. The install script will install the needed files.

  2. Once the installation is complete, reboot your laptop. Optimus-Indicator will start automatically when the laptop boots.

All Desktop Environments

There should now be an icon displayed showing which GPU is in use. Click on the icon and it will bring up a menu allowing you to switch GPU’s and automatically reboot your system.

Flow3

Conclusion

While Optimus Switch is not as easy to setup, ie. Click and Go, as other solutions are, it is very stable. It reliably gives the user the flexibility to choose which GPU they want to use.

Personal Thoughts

I have been using it for the last year and a half, and have not had it break due to updates. I first used it on a Manjaro install. When I later switched to Arch itself, I tried the other options first and ended up going back to using it. I have never had it break due to a system update.

Please do not post support requests here. If you are having issues, open a new thread on the forum.

Thanks!

18 Likes

btw it should be fairly easy to make user-friendly installer bash script with simple menus for actions

1 Like

Excellent guide, I just did this with my laptop that I have been meaning to get over to EOS. I only did the Optimus-switch section as I do not need the indicator application.

I found some changes you may want to edit.

Missing a space after nano here:

Missing a space after sudo here:

With a fresh install with only devel, gnome and nvidia selected at install I did not have either of these commands, needed to install inxi and mesa-demos.

And here you might want to add the sudo nano as part of the code block like sudo nano /etc/switch/intel/no-optimus.sh

6 Likes

So you need to reboot every time you want to switch from Intel to NVidia or vice versa. With Optimus Manager I need to do that only when switching back to Intel from NVidia.

I was unable to get my nvidia card to power off using optimus-manager no mater what options I tried. This is the method that worked for me. Great write up, thanks!

1 Like

Not tried it yet but if its the same implementation as linux mint you logging out of your current session and logging back in should do it rather than a full reboot. But like I said I’ve not tried it yet

restarting the computer to switch cards is very annoying.

1 Like

@Urworstnit3m3r Thanks for the corrections. I had originally typed it up using LibreOffice, and there where some strange formatting issues when I posted it here. I also added the mesa-demos package to the list of “requirements” for Optimus-Switch. I did not realize that it was not apart of the default install.

Thank you again for catching the errors in formatting and the missing package.

@sawdoctor No it is not like the Mint thing. It requires a full reboot. When you switch cards, it changes config files. These files are only loaded when the laptop boots.

5 Likes

Optimus switch was developed by a very helpful user for the Linux community for free. If restarting your comp is too much trouble for you then don’t use this freely developed software.

Perhaps you’ve heard this saying before:

“Don’t look a gift horse in the mouth”

The kind user that developed the optimus switch is no longer using a laptop with optimus graphics. Therefore unless someone else takes over devolopement this is likely the last updated version of the software.

What free software have you developed for the Linux community I might wonder @Alexander?

6 Likes

Wise choice, if you ask me :sunglasses:

However don’t be too hard on @Alexander our of nowhere , criticism != hate, even if he doesn’t know all this and not a dev himself - so what? :wink:

4 Likes

Critism does not equal hate. It is debatable that my post is even critism. I have read some of that users prior posts and if you want me to actually be critical I would say there is a pattern of unrealistic expectations of Linux developers from this user.

Unless he actually develops software himself perhaps he is the one who should be less critical.

Sorry, but users that have the expectation that they can post whatever critisms they want on a Linux forum and never get called on it is nothing but a double standard.

If this user can criticize the free software from a good friend of mine who developed it, then I certainly believe I am well within my rights to criticize his ingratitude towards said developer who created the free software.

What’s good for the goose is good for the gander. Or pick one of a dozen other sayings that are applicable in this case.

Don’t bite the hands that feed you.

Etc, etc, etc.

8 Likes

I meant that his post is criticism, not yours :wink:

From 3rd person perspective it looks that you get way too hostile for no particular reason (well maybe i’m wrong coz i haven’t really followed in depth his posts like you did, or anything like that, so sorry if that’s really the problem here).

We’re all free to do whatever we pleased of course, and @dglt is certainly a good friend for a lot of us here, but i don’t think that if someone pointed obvious flaw in usability (which is not anyone’s fault really, it’s the whole stupid insane concept of Optimus in the first place! to blame :rage: ) without being hateful that automatically means there is some double standard or criticism of FOSS software in general, kinda stretched a lot…

Well…That’s Arch forum mentality, i don’t think it’s productive way in here, as it’s not dev oriented forum.
Why antagonize at all?

Especially in that case, it doesn’t look like something that can be changed at all by anyone, even on Windows it works like crap, it’s zero day flaw by design of switchable graphics, so no wars to fight here is necessary.

Be nice, just point out that it’s not Optimus switch’s fault, it’s by stupid flawed design of Hybrid / Optimus graphics and there’s nothing really could be done here to make it work better, except that solution which is perfect in every other way compared to other ones around :slight_smile:

:peace_symbol:

P.S. Nvidia is enough pain on it’s own, damn that genius who made that problem twice bigger for laptops :laughing:


Well anyway, personally i recommend friends to avoid Optimus at any cost, but if they can’t - @dglt’s Optimus switch + @linesma’s Optimus-Indicator is a first thing i do recommend them, great work! :+1:

3 Likes

A round of purple Kool Aid with blotter acid for all the peeps. Peace out man. :peace_symbol:

6 Likes

No, it doesn’t look like that at all. There wasn’t anything hostile about @tbg’s comment. If there is any hostility in this thread at all (and I wouldn’t go that far!) it would be the criticism that @Alexander gave, which is just a single sentence without proper capitalisation “restarting the computer to switch cards is very annoying.”

This is obviously not constructive criticism. It’s basically just: “using your software is annoying”, to which the only reasonable response is: “then don’t use it”, which is pretty much what @tbg said.

7 Likes

I was only expressing my opinion about having to restart. Imagine If you had to do that for all your software.

Well, it’s just how things are, unfortunately. Either live with that, and be happy and grateful people like @dglt write useful software for free, or ask for your money back.

Trust me, if @dglt could find a way to do it without having to restart, he would have. Stating that this is annoying helps nobody. Nvidia is annoying, and Optimus is doubly so.

4 Likes

Imagine if all users posted “helpful” comments such as yours when YOU post a project you thought would be useful… oh wait… never mind. Use or don’t use it, I don’t really care. I don’t even USE EnOS. I am on Arch. I thought it would be a useful tool for users here. Silly me.

8 Likes

It is useful!

6 Likes

Exactly. Everyone here knows it’s annoying. I’m pretty sure the people responsible for the solution also know it’s annoying. This information is surprising no one. If you don’t want to reboot and Optimus-manager works for you, or you have one of the newer cards that work in prime mode while powering off then use that and don’t deal with the reboot.

For me, I couldn’t get optimus-manager to power off the nvidia card while in intel mode, no matter what options I picked and this is what worked. I can live with a reboot, although it’s not ideal. If you can’t go use something different :wink:

More options = good.

4 Likes

I don’t think that’s possible at all, PRIME works in mysterious ways, but doesn’t turn off cards completely, so they still drain a lot of power…

Maybe with nouveau?