Askannz / optimus-manager

A Linux program to handle GPU switching on Optimus laptops.
MIT License
2.25k stars 165 forks source link

βš™οΈ Function

Enhances the performance and power management on NVIDIA Optimus Laptops, by properly selecting when to use each GPU.

The NVIDIA GPU runs the whole desktop, while the Intel/AMD GPU acts as relay between the NVIDIA GPU and the screen.

More info at the wiki.

πŸ”§ Contributing

  1. Thorougly test code.
  2. Open a pull request.
  3. Mention the user: @es20490446e.
  4. Accepted in two days.

πŸ”₯ Reporting issues

  1. Isolate which specific config is causing your issue.
  2. Open an issue report.

When requesting further info your issue may be closed. Just reopen it when done so.

πŸ–₯️ Supported platforms

πŸ’½ Installation

Remove similar tools:

If using gdm:

In any case:

πŸ“œ Usage

Run

WARNING : Switching mode automatically logs you out, so make sure you save your work and close all your applications before doing so.

Auto-logout is supported for the following desktop environments/window managers: KDE Plasma, Gnome, XFCE, Deepin, i3, Openbox, AwesomeWM, bspwm, dwm, LXDE, QTile, Xmonad, herbstluftwm. You can disable this feature in the configuration file. In that case, the GPU switch will not be effective until the next login.

You can also specify which GPU you want to be used by default when the system boots, by setting startup_mode in the configuration file at /etc/optimus-manager/optimus-manager.conf.

Note that switching to and from "integrated" mode can be a little unstable, due to having to load/unload the nvidia kernel modules and change the power state of the card. If you're experiencing stability issues, the safest way to use this mode is to boot straight into it using the startup_mode config options or the kernel parameter (see below).

System Tray App

optimus-manager systray screenshot

The program optimus-manager-qt provides a system tray icon for easy switching. It also includes a GUI for setting options without editing the configuration file manually.
AUR package : optimus-manager-qt

Unofficial Gnome Shell extensions are also available :

Kernel parameter

As an alternative to startup_mode, optimus-manager also allows you to set the startup GPU mode using a kernel parameter. This is useful if you want to create multiple entries in your bootloader with different GPU startup modes (for instance a "battery-saving" mode that starts with the integrated GPU, and a "gaming" mode that starts with Nvidia).

Simply add optimus-manager.startup=MODE to your kernel parameters list, where MODE can be any startup mode. Note that this parameter overrides whatever startup mode was set in the config file.

Also note that this parameter only affects which GPU your desktop session starts with ; it has absolutely no effect on the boot process before that, because optimus-manager has no control over it.

See this project to automatically create corresponding boot entries in GRUB: https://github.com/hakasapl/optimus-manager-grub

πŸ”‹ Power management

Since version v1.2, power management is disabled by default, so the Nvidia GPU will stay powered on (consuming energy) until manual configuration is done. This choice was made because there is no catch-all configuration that works for all laptop models, and incorrect configurations often break the boot process.

Please refer to the guide on power management in the Wiki.

πŸ“ Configuration

Main configuration file

The default configuration file can be found at /usr/share/optimus-manager.conf. Please do not edit this file ; instead, edit the config file at /etc/optimus-manager/optimus-manager.conf (or create it if it does not exist).

Any parameter not specified in your config file will take value from the default file. Remember to include the section headers of the options you override.

Please refer to the comments in the default config file for descriptions of the available parameters. In particular, it is possible to set common Xorg options like DRI version or triple buffering, as well as some kernel module loading options.

No config changes will be effective until you computer is rebooted or the optimus-manager service is restarted.

Extra Xorg configuration

You can also add your own options to the auto-generated Xorg config by editing the files at /etc/optimus-manager/xorg/. Anything you write in those files will be copied to one of the "Device" sections of the auto-generated Xorg configuration at /etc/X11/xorg.conf.d/10-optimus-manager.conf. There are specific files for specific modes and GPUs; for instance, /etc/optimus-manager/xorg/hybrid-mode/integrated-gpu.conf only applies to the Xorg config of the integrated GPU in "hybrid" mode.

Display setup scripts

If you need the display manager to run some specific commands to set up the display (to force a particular resolution, for instance), you can write them to /etc/optimus-manager/xsetup-integrated.sh, /etc/optimus-manager/xsetup-nvidia.sh and /etc/optimus-manager/xsetup-hybrid.sh.

Custom enable/disable scripts for Nvidia

Finally, if you need to run some specific commands prior to enabling or after disabling the nvidia graphics card (for example, to manually enable the card if the available power management methods are not supported), you can write them to /etc/optimus-manager/nvidia-enable.sh and /etc/optimus-manager/nvidia-disable.sh.

πŸ€” FAQ / Troubleshooting