Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bugra455/b40d7f505beec6bea514af7cf618fcf5 to your computer and use it in GitHub Desktop.
Save bugra455/b40d7f505beec6bea514af7cf618fcf5 to your computer and use it in GitHub Desktop.
Solve KDE6 Animation Lagging with defaulting KWIN GPU to Nvidia

Fix KDE Plasma Lagging on NVIDIA Hybrid Graphics

This guide provides a workaround to launch a KDE Plasma Wayland session on laptops with hybrid GPU setups, particularly those with NVIDIA DGPU's. This method forces KWin, the Plasma compositor, to recognize and use specific DRM (Direct Rendering Manager) devices, resolving the common bug of lagging animations on hybrid setups.


1. Create the Launcher Script

First, you'll create a shell script that sets a necessary environment variable before starting the Plasma session. This explicitly tells KWin which DRM devices (your GPUs) to use.

Identify Your GPU Devices

You need to find the correct device numbers for your GPUs. Run the following command in your terminal:

for card in /sys/class/drm/card*; do \
  pci_bus_id=$(cat "$card/device/uevent" | grep "PCI_SLOT_NAME" | cut -d'=' -f2); \
  card_name=$(basename "$card"); \
  echo "/dev/dri/$card_name is: $(lspci -s "$pci_bus_id")"; \
done

You'll get a very long output containing your outputs and GPUs, find the gpu related ones, not the output related ones:

/dev/dri/card0 is: 01:00.0 VGA compatible controller: NVIDIA Corporation AD107M [GeForce RTX 4060 Max-Q / Mobile] (rev a1)

/dev/dri/card0-DP-3 is: 00:00.0 Host bridge: Intel Corporation Device 462b (rev 02)

00:01.0 PCI bridge: Intel Corporation 12th Gen Core Processor PCI Express x16 Controller #1 (rev 02)

00:02.0 VGA compatible controller: Intel Corporation Alder Lake-S [UHD Graphics] (rev 0c)

00:04.0 Signal processing controller: Intel Corporation Alder Lake Innovation Platform Framework Processor Participant (rev 02)

00:06.0 PCI bridge: Intel Corporation 12th Gen Core Processor PCI Express x4 Controller #0 (rev 02)

00:0a.0 Signal processing controller: Intel Corporation Platform Monitoring Technology (rev 01)

Note the /dev/dri/cardX path for each GPU. In this example, the NVIDIA card is card0 and the integrated Intel GPU is card1.

Create the Script File

sudo nano /usr/share/wayland-sessions/NvidiaKDELauncher.sh

Paste the following content into the file. Remember to replace /dev/dri/card0:/dev/dri/card1 with the paths you identified in the previous step.

#prepares environment variables before launching plasma to make NVIDIA default
export KWIN_DRM_DEVICES=/dev/dri/card0:/dev/dri/card1

/usr/bin/startplasma-wayland

make the new script executable with

sudo chmod +x /usr/share/wayland-sessions/NvidiaKDELauncher.sh

Create the Desktop Entry

sudo nano /usr/share/wayland-sessions/plasma-NVIDIA.desktop
[Desktop Entry]
Name=Plasma (NVIDIA Wayland)
Exec=sh -c /usr/share/wayland-sessions/NvidiaKDELauncher.sh
DesktopNames=KDE

After creating both files, log out of your current session. On the login screen, click the session switcher (it often looks like a gear or desktop icon ⚙️) and you should see a new option named Plasma (NVIDIA Wayland).

Select this new session and log in. Your KDE Plasma Wayland session should now start using the correct GPU configuration, resulting in smoother performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment