How to switch between NVIDIA and Intel Graphics Completely || Battery Saving in Manjaro | by Jashaswimalya Acharjee | Medium
2022-2-12 01:28:47 Author: medium.com(查看原文) 阅读量:1116 收藏

One of the main problems people face while switching to Linux based distros is that Notebook users experience tremendous decrease in their battery life, as compared to what they used to get on windows.

On Ubuntu, there is their own flavour of Nvidia drivers present which come with prime-select utility which enables switching between graphics. There’s also a “Hybrid” mode which keeps the GPU active and enables real-time GPU offloading.

Similarly on Manjaro, a flavour of nvidia-intel-hybrid driverf is present,

namely, video-hybtid-intel-nvidia-440xx-prime.

This driver by default enables both GPUs (iGPU and dGPU) with the ability to offload graphical intensive programs on the dedicated GPU and others on the integrated graphics.

But, here’s the thing. There’s a difference between turning off the dedicated GPU and keeping it dormant (and actively powered).

So, tldr: Even when you dedicated GPU isn’t working, it still is sucking up a lot of juice(battery power). Thus your laptop’s battery life decreases significantly no matter what power tuning service you use. Moreover fans also become active more frequently to cool the beast down as well as temps also increase.

PS:- If anything goes wrong I won’t be responsible for any thing that has occurred. Keep a full timeshift backup of your system.

Now let’s proceed towards how this problem can be solved.

There are many different solutions found online on Arch Wiki as well as Manjaro Wiki, but they are pretty much outdated for a rolling release distro, asd didn’t work for me. So, here’s what I did:

Supported display managers are : SDDM (Manjaro KDE), LightDM (Manjaro XFCE), GDM (Manjaro Gnome).

  • Use the latest available Nvidia driver from Manjaro Settings or mhwd.(The default installed driver is the latest one obviously unless you had changed it manually.) (At the time of writing this blog latest is the driver mentioned above)
  1. Installation of packages: optimus-manager from repo and optimus-manager-qt from AUR (it’s possible to install git versions from AUR):

sudo pacman -S optimus-manager

2. Use choosen AUR helper or GUI program like Pamac or Octopi to find and install optimus-manager-qt:

Launch Pamac or Octopi and search for “optimus-manager-qt”.

or

yay optimus-manager-qt

3. Disable Xorg graphic configurations in /etc/X11/xorg.conf.d/

Go to /etc/X11/xorg.conf.d/ and disable any graphic related configs. Instead deleting them, just rename them by adding .bak for the case if you want to restore them manually.

So for example, I had in this location:

00-keyboard.conf 20-intel.conf 30-touchpad.conf 90-mhwd.conf

Your files may be different so don’t worry if you don’t have those or have a bit different ones.

Keyboard and touchpad configs are self explanatory and have nothing to do with GPUs. Intel is clearly graphic related config while mhwd is a Manjaro specific configuration file of mhwd script (won’t be present on non-Manjaro systems) that configures graphic.

I renamed intel and mhwd confs by adding .bak so in the end my files in this locations are:

00-keyboard.conf 20-intel.conf.bak 30-touchpad.conf10-optimus-manager.conf 20-intel.conf.bak-old 90-mhwd.conf.bak

If some files shown in these code snippets are not present don’t worry. Just edit those which are present. Only graphical or mhwd or nvidia or intel setting. Don’t tinker with other files.

4. Disable Xorg graphic configurations in /etc/X11/

The same situation as above. I had in this location a file:

xorg.conf

You can rename it to nvidia-xorg.conf.bak, however, I noticed that some updates may restore the file and optimus-manager still works as intended… so it’s not crucial, however advised to disable this conf anyway.

You may see in this location again different files, like:

xorg.conf or nvidia-xonfig

The same deal, disable it by renaming it (i.e. adding .bak at the end).

It’s Better to do a search on /etc directory for any file relating to nvidia or xorg.conf and disabling it. (Don’t delete anything as if something goes wrong you can revert back).

5. For Manjaro Gnome users (others ignore this point):

  • install gdm-prime from AUR

On Manjaro Gnome you may have manjaro-gdm-tweak installed which requires gdm, so when you install gdm-prime, you get error because of the dependency with gdm.

You need to remove it first:

sudo pacman -Rns manjaro-gdm-tweak

Then dependently which AUR helper you use, install a package gdm-prime and remove gdm from Manjaro repo:

pamac build gdm-prime

or

yay gdm-prime

or

just use Pamac or Octopi GUI programs.

After that enable gdm:

sudo systemctl enable gdm

and reboot.

The reason for that is that optimus-manager cannot switch GPUs with default gdm config, while gdm-prime has Canonical’s patches that add two script entry points for GPU Prime switching. The package is otherwise identical to the official one.

  • You need to edit the file /etc/gdm/custom.conf and remove the # before the line

#WaylandEnable=false

So it would look:

WaylandEnable=false

Gnome launches Wayland sessions by default, which are incompatible with optimus-manager, so the above change forces X session.

Another quirk of GDM is that the X server may not automatically restart after a GPU switch. If you see an empty black screen or a black screen with a blinking cursor, try switching back to an empty TTY (with Ctrl+Alt+F5 for instance), then back to TTY1 with Ctrl+Alt+F1

6. For Manjaro KDE users (others ignore at this point):

Edit the file /etc/sddm.conf and simply put a # before the line starting with DisplayCommand and the one starting with DisplayStopCommand.

To edit the sddm.conf in terminal:

sudo nano /etc/sddm.conf

The reason for that is that Manjaro ships with a default configuration for SDDM (the default login manager for KDE) which overrides some keys needed by optimus-manager.

Weirdly enough, it’s possible that you may not have lines:

DisplayCommand
DisplayStopCommand

In such a case you are fine and you have nothing to do. It’s possible some recent Manjaro updates deleted those additional lines (they are not present in non-Manjaro systems anyway).

7. Create autostart for optimus-manager-qt

I am on Gnome DE. So, here’s the steps you can follow:

  • Install gnome-tweak-tool (Which is installed by default in Manjaro).
  • Launch Tweak tool and navigate to “startup applications” section and click on “+” icon.
  • Then search for Optimus Manager and add it.

On other desktop environments, if such autostart method is available then utilize it or create a systemd service to autostart the service on startup.

There’s also another method:

  • Navigate to
~/.config/autostart/
  • Create a file named “io.optimus_manager.OptimusManagerQt.desktop” and open with any text editor and paste the following & Save the file:
[Desktop Entry]
Name=Optimus Manager
Name[zh_CN]=Optimus 管理器
Comment=A program to handle GPU switching on Optimus laptops
Comment[ru]=Программа для управления переключением графических процессоров на ноутбуках c Optimus
Comment[zh_CN]=处理双显卡笔记本电脑 GPU 切换的程序
Keywords=nvidia;optimus;settings;switch;GPU;
Keywords[ru]=nvidia;optimus;settings;switch;GPU;настройки;видеокарта;
Exec=optimus-manager-qt
Icon=optimus-manager-qt
Terminal=false
StartupNotify=false
Type=Application
Categories=System;Settings;Qt

8. Reboot

At this point all should be done and to make it work, you need to reboot your computer.

Check if optimus-manager daemon is running correctly:

systemctl status optimus-manager.service

If it’s OK, you can start using it from the tray icon or through a terminal.

You should see the intel icon in your tray (optimus-manager boots to Intel session by default, it can be changed). You can right-click it to access switch and options.

My Personal Settings

NOTE: Your system may get stuck while switching graphics cards. In that case Switch to another TTY (Ctrl+Alt+F3..F4) then switching back to TTY2(Ctrl+Alt+F2) or TTY1(Ctrl+Alt+F1). Then rebooting you laptop.

Optimus-Manager Indicator

Now your Nvidia card should be disabled unless you click on the Optimus manager icon on the statusbar and click on NVIDIA or Hybrid.

You can also use “Powertop” or “TLP” to save more power by tuning your settings.

Hope You Like my Article. Share this article to those who are in need of it.

Ref:- https://forum.manjaro.org/t/guide-install-and-configure-optimus-manager-for-hybrid-gpu-setups-intel-nvidia/92196


文章来源: https://medium.com/@jashaswimalyaacharjee/how-to-switch-between-nvidia-and-intel-graphics-completely-battery-saving-in-manjaro-b9254c8bf6af
如有侵权请联系:admin#unsafe.sh