安装 optimus-manager

yay -S optimus-manager

按照官方教程修改配置文件文件

Askannz/optimus-manager

IMPORTANT : Gnome and GDM users

If you use Gnome or the Gnome Display Manager (GDM), there are a couple extra requirements to be able to use optimus-manager : The default gdm package from the Archlinux and Manjaro repositories is not compatible with optimus-manager, so you must replace it with this patched version : gdm-prime (also replaces libgdm). The patch was written by Canonical for Ubuntu and simply adds two script entry points specifically for Prime switching. The package is otherwise identical to the official one. Gnome launches Wayland sessions by default, which are incompatible with optimus-manager. To force Xorg sessions, You need to edit the file /etc/gdm/custom.conf and remove the # before the line #WaylandEnable=false. 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. See this FAQ question.

IMPORTANT : Manjaro KDE users

Manjaro ships with a default configuration for SDDM (the default login manager for KDE) which overrides some keys needed by optimus-manager. To use optimus-manager, you need to edit the file /etc/sddm.conf and simply put a # before the line starting with DisplayCommandand the one starting with DisplayStopCommand.

增加自定义配置文件

nano /etc/optimus-manager/optimus-manager.conf

添加以下内容

[amd]
DRI=3
driver=modesetting
tearfree=

[intel]
DRI=3
accel=
driver=modesetting
modeset=yes
tearfree=

[nvidia]
DPI=96
PAT=yes
allow_external_gpus=no
dynamic_power_management=no
ignore_abi=no
modeset=yes
options=overclocking

[optimus]
auto_logout=yes
pci_power_control=no
pci_remove=no
pci_reset=no
startup_auto_battery_mode=integrated
startup_auto_extpower_mode=nvidia
startup_mode=nvidia
switching=none

然后编辑

nano /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT增加以下内容(…表示其他配置)

GRUB_CMDLINE_LINUX_DEFAULT="... nvidia-drm.modeset=1"

然后运行命令

grub-mkconfig
update-grub

注意,启用外接显示器后若KDE无法使用桌面动画。建议安装

yay -S optimus-manager-qt

快速修改主要使用的显卡