Skip to content

Instantly share code, notes, and snippets.

@guiodic
Last active November 5, 2025 09:43
Show Gist options
  • Save guiodic/2bcc8f2f126d14b1f8a439f644fdc2c9 to your computer and use it in GitHub Desktop.
Save guiodic/2bcc8f2f126d14b1f8a439f644fdc2c9 to your computer and use it in GitHub Desktop.
Improved Plasma X11 experience

This guide is to improve the KDE Plasma experience on X11. It particularly applies to those using the modesetting driver (mainly Intel graphics cards)

Install Xorg-git or Xlibre

This is a crucial step. XLibre and xorg-git contain the "TearFree" feature for modesetting, which is not available in the standard releases. If you use a driver other than modesetting, check that the TearFree option exists for your driver.

Installation depends on the distribution you use. On Arch Linux and derivatives:

Xorg-git:

sudo yay -S xorg-server-git xorg-server-devel-git xorg-server-common-git xorgproto-git
sudo yay -S xf86-input-libinput-git 

Xlibre:

see here for PKGBUILDS or here for an Arch repo with binary packages.

Configuring Xorg

1. Modesetting options

TearFree should be on by default, but you can configure things better

Creates a file called /etc/X11/xorg.conf.d/20-modesetting.conf with this content

Section "Device"
    Identifier    "My GPU Name"
    Driver        "modesetting"
    Option        "ShadowFB" "false" # you don't need on recent hardware
    #Option        "Atomic" "true" #only effective on Xlibre, or Xorg-git with a special patch
    Option        "TearFree" "true"
EndSection

2. DMABUF

Creates a file called /etc/X11/xorg.conf.d/15-dmabuf.conf with this content

Section "ServerFlags"
	Option "Debug" "dmabuf_capable"
EndSection

Konfiguring KDE/KWIN

Now that we have activated TearFree, the X11 server will take care of the tearing, so we can deactivate Kwin's functions in this regard.

Let's create a file /home/$USER/.config/plasma-workspace/env/kwin_env.sh

with this content:

export KWIN_PERSISTENT_VBO=1 #default?
export KWIN_USE_BUFFER_AGE=1 #default
export KWIN_EXPLICIT_SYNC=0 #Xorg takes care of it
export KWIN_X11_NO_SYNC_TO_VBLANK=1 #Xorg takes care of it
export KWIN_USE_INTEL_SWAP_EVENT=1 #not default, should be relevant only on glx, but we are going to use EGL

Let's make the file executable with

chmod +x /home/$USER/.config/plasma-workspace/env/kwin_env.sh

Now let's disable the synchronisation of Quick Scene Graph (a function of the QT libraries) but only for Kwin, not for the rest of the system, since for plasmashell and other parts of the system it is useful.

sudo mkdir /etc/systemd/user/plasma-kwin_x11.service.d/

Create a file /etc/systemd/user/plasma-kwin_x11.service.d/10-kwin_smoother.conf

With this content

[Service]
Environment="QSG_NO_VSYNC=1"

Using EGL instead of glx

QT and Kwin work better using the EGL interface instead of the traditional GLX.

Create a file /etc/profile.d/egl.sh

with this content:

export QT_XCB_GL_INTEGRATION=xcb_egl
export KWIN_OPENGL_INTERFACE=egl
export GST_GL_PLATFORM=egl #this is not related to kwin, but it's useful

make it executable

sudo chmod +x /etc/profile.d/egl.sh

However, you may encounter some bugs with Libreoffice's OpenGL alimations. In this case you can modify the Impress launcher in menu, to use glx instead of EGL.

In the Enviroment variable: QT_XCB_GL_INTEGRATION=xcb_glx

With QTWebEngine based apps, you don't need to fall back to EGL if suoi set

export QTWEBENGINE_CHROMIUM_FLAGS="--use-gl=angle --use-angle=vulkan"

in a /etc/profile.d/ file like /etc/profile.d/egl.sh created above.

Using GPU for QT Widgets

By default, Qt only uses the GPU for QtQuick objects (for example, in KDE it is used for Plasmashell, Discover, System Settings, etc.) but not for traditional Qt Widgets. However, starting with Qt 6.8, it is also possible to force the rendering of these with the GPU. It is not recommended to do this at the system level, but you can try it for individual apps by entering the environment variable in the launcher.

QT_WIDGETS_RHI=1

The default is OpenGL, which works well, but you can also choose Vulkan, which, however, currently (Qt 6.10) causes numerous problems.

QT_WIDGETS_RHI_BACKEND=vulkan

Please note that some applications will force the rendering of every single frame and effectively slow down the interface update.

Using Vulkan for GTK4

GTK uses OpenGL acceleration by default, but it is possible to use Vulkan, which is faster.

export GSK_RENDERER=vulkan

(GSK is not a typo, GSK is the GTK rendering abstraction; it provides a low level rendering API to GTK in terms of draw operations, and converts them into commands for the graphics pipeline.)

Unlike Qt, using Vulkan with Vulkan does not cause any problems (it is the default on Wayland).

Mixed refresh rates

Kwin has some problems handling mixed refresh rates (e.g. a 144 Hz monitor and a 60 Hz monitor), but it can this way.

kate $HOME/.config/plasma-workspace/env/kwin_env.sh

add this lines

export KWIN_X11_REFRESH_RATE=144000 # the refresh rate of the fastest monitor * 1000, in this case 144 Hz. In most cases, this line is sufficient. Test it before adding the third one.
export KWIN_X11_NO_SYNC_TO_VBLANK=1
export KWIN_X11_FORCE_SOFTWARE_VSYNC=1

Make the file executable, then close the session and login again.

Inertial scrolling (aka kinetic scrolling)

They say Wayland is better and more modern, but it lacks this essential function, without which it is a drama to use many apps.

X11, on the contrary, has had it for years! Kinetic scrolling implemented server-side in the touchpad driver.

Unfortunately, in the changeover to Plasma 6 they removed the driver configuration (heaven forbid someone stays on X11 because of this great feature!), but you can do it with a configuration file.

First, install the driver:

sudo pacman -S xf86-input-synaptics

Then create the configuration file:

kate /etc/X11/xorg.conf.d/70-synaptics.conf

copy&paste this then logout and login. Enjoy all apps with Inertial Scrolling! More information here (ignore the warning about the driver is "no longer actively updated", it works perfectly with practically all touchpads)

Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
        Option "Protocol" "event"
        Option "SHMConfig" "on"
# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
        MatchDevicePath "/dev/input/event*"
        Option "LeftEdge" "140"
        Option "RightEdge" "3372"
        Option "TopEdge" "131"
        Option "BottomEdge" "2311"
        Option "FingerLow" "25"
        Option "FingerHigh" "30"
        Option "MaxTapTime" "180"
        Option "MaxTapMove" "110"
        Option "MaxDoubleTapTime" "180"
        Option "SingleTapTimeout" "180"
        Option "ClickTime" "100"
        Option "EmulateMidButtonTime" "0"
        Option "EmulateTwoFingerMinZ" "282"
        Option "EmulateTwoFingerMinW" "7"
        Option "VertScrollDelta" "78"
        Option "HorizScrollDelta" "155"
        Option "VertEdgeScroll" "0"
        Option "HorizEdgeScroll" "0"
        Option "CornerCoasting" "0"
        Option "VertTwoFingerScroll" "1"
        Option "HorizTwoFingerScroll" "1"
        Option "MinSpeed" "1"
        Option "MaxSpeed" "25"
        Option "AccelFactor" "0.04"
        Option "TouchpadOff" "0"
        Option "LockedDrags" "0"
        Option "LockedDragTimeout" "5000"
        Option "RTCornerButton" "0"
        Option "RBCornerButton" "0"
        Option "LTCornerButton" "0"
        Option "LBCornerButton" "0"
        Option "TapButton1" "1"
        Option "TapButton2" "3"
        Option "TapButton3" "2"
        Option "ClickFinger1" "1"
        Option "ClickFinger2" "3"
        Option "ClickFinger3" "2"
        Option "CircularScrolling" "0"
        Option "CircScrollDelta" "0.10472"
        Option "CircScrollTrigger" "0"
        Option "CircularPad" "0"
        Option "PalmDetect" "1"
        Option "PalmMinWidth" "8"
        Option "PalmMinZ" "100"
        Option "CoastingSpeed" "20"
        Option "CoastingFriction" "50"
        Option "PressureMotionMinZ" "30"
        Option "PressureMotionMaxZ" "160"
        Option "PressureMotionMinFactor" "1"
        Option "PressureMotionMaxFactor" "1"
        Option "GrabEventDevice" "0"
        Option "TapAndDragGesture" "1"
        Option "AreaLeftEdge" "0"
        Option "AreaRightEdge" "0"
        Option "AreaTopEdge" "0"
        Option "AreaBottomEdge" "0"
        Option "HorizHysteresis" "21"
        Option "VertHysteresis" "21"
        Option "ClickPad" "1"
        Option "RightButtonAreaLeft" "1756"
        Option "RightButtonAreaRight" "0"
        Option "RightButtonAreaTop" "2002"
        Option "RightButtonAreaBottom" "0"
        Option "MiddleButtonAreaLeft" "0"
        Option "MiddleButtonAreaRight" "0"
        Option "MiddleButtonAreaTop" "0"
        Option "MiddleButtonAreaBottom" "0"
EndSection

Section "InputClass"
        Identifier "touchpad ignore duplicates"
        MatchIsTouchpad "on"
        MatchOS "Linux"
        MatchDevicePath "/dev/input/mouse*"
        Option "Ignore" "on"
EndSection

# This option enables the bottom right corner to be a right button on clickpads
# and the right and middle top areas to be right / middle buttons on clickpads
# with a top button area.
# This option is only interpreted by clickpads.
Section "InputClass"
        Identifier "Default clickpad buttons"
        MatchDriver "synaptics"
        Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
        Option "SecondarySoftButtonAreas" "58% 0 0 15% 42% 58% 0 15%"
EndSection

# This option disables software buttons on Apple touchpads.
# This option is only interpreted by clickpads.
Section "InputClass"
        Identifier "Disable clickpad buttons on Apple touchpads"
        MatchProduct "Apple|bcm5974"
        MatchDriver "synaptics"
        Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
EndSection

Suggested installations

sudo yay -S material-kwin-decoration-git # for Locally integrated menu

kwin-x11 with backports: kwin-x11-lite

libinput-gestures-qt for gestures (yes, it works even if you use the Synaptics driver for your touchpad!)

Other stuff

My /etc/modprobe.d/i915.conf

options i915 enable_guc=3 enable_fbc=1 nuclear_pageflip=1 enable_dmc_wl=1

My $HOME/.drirc

<driconf>
  <device>
    <application name="Default">
      <option name="mesa_glthread" value="true" />
      <option name="force_glsl_extensions_warn" value="false" />
      <option name="mesa_no_error" value="true" />
      <option name="mesa_glthread_app_profile" value="1" />
      <option name="mesa_glthread_driver" value="true" />
    </application>
    <application name="glxgears" executable="glxgears">
     <option name="mesa_glthread" value="true" />
      <option name="force_glsl_extensions_warn" value="false" />
      <option name="mesa_no_error" value="true" />
      <option name="vblank_mode" value="0"      />
      <option name="mesa_glthread_app_profile" value="1" />
      <option name="mesa_glthread_driver" value="true" />
    </application>  
  </device>
</driconf>

Enable vulkan video decoding/encoding on Intel

/etc/profile.d/VULKAN_VIDEO_ON.sh (must be executable)

export ANV_DEBUG=video-decode,video-encode

MESA and OPENCL tricks

/etc/profile.d/mesa.sh (must be executable)

export INTEL_COMPUTE_CLASS=1
export VAAPI_MPEG4_ENABLED=1
export mesa_glthread=true
#export INTEL_SIMD_DEBUG=fs2x8 # (uncomment for Intel Xe2 or newer)

my chromium flags

$HOME/.config/chromium-flags.conf

#--use-gl=angle 
#--use-angle=vulkan
#--use-vulkan
--use-cmd-decoder=passthrough
--enable-features=VaapiIgnoreDriverChecks,VaapiLowPowerEncoderGen9x,Vp9kSVCHWDecoding,VaapiVp9kSVCHWEncoding,DesktopScreenshots,SharingDesktopScreenshotsEdit,WebUIDarkMode,PlatformHEVCDecoderSupport,PlatformHEVCEncoderSupport,PartialRaster,CanvasOopRasterization,AcceleratedVideoDecoder,AcceleratedVideoEncoder,AcceleratedVideoDecodeLinuxGL,AcceleratedVideoDecodeLinuxZeroCopyGL,UseMultiPlaneFormatForHardwareVideo,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE
--ignore-gpu-blocklist 
--disable-gpu-driver-bug-workaround
#
#--enable-skia-graphite
#--skia-graphite-backend="Dawn"
#
--disk-cache-dir=/run/user/1000/chromium-cache
--disk-cache-size=419430400
--enable-chrome-browser-cloud-management
--show-component-extension-options
--enable-gpu-rasterization
--media-router=0
--enable-remote-extensions
--video-capture-use-gpu-memory-buffer 
--enable-video-player-chromecast-support
--enable-pixel-canvas-recording
--enable-native-gpu-memory-buffers
--enable-zero-copy
--enable-partial-raster
--enable-parallel-downloading
--enable-quic
--enable-lazy-image-loading
--enable-lcd-text
--enable-oop-rasterization
--canvas-oop-rasterization
--enable-gpu-compositing
--enable-accelerated-mjpeg-decode
--enable-font-antialiasing
--enable-accelerated-2d-canvas
--enable-gpu-memory-buffer-video-frames
--enable-gpu-memory-buffer-compositor-resources
--enable-hardware-overlays

#FOR DEBUG
#--enable-features=VaapiVideoDecodeLinuxGL
#--vmodule=*/ozone/*=1,*/vaapi/*=4,*/media/*=4,*/shared_image/*=1
#--enable-logging=stderr --v=0 

@Ro-Den
Copy link

Ro-Den commented Jul 19, 2025

most of the tricks work on Plasma 5 too.

Plasma 5 X11 works out of the box and it's almost perfect. I experience some screen tearing on a desktop PC while playing videos in mpv full screen. But it's a minor issue right now, not worth spending much time to resolve it.

Plasma 6 X11 is a different story. It's almost unusable right now: screen tearing, graphics glitches, freezing (even in SDDM). I experience screen tearing with some Plasma 6 apps even in LXQt. The kids, who maintain the distribution, blame the GPUs, firmware, drivers, etc and advise to use Wayland (of course ); I don't know what's happened. How have they managed to ruin it all?

@pulpog
Copy link

pulpog commented Aug 3, 2025

blame the GPUs, firmware, drivers, etc and advise to use Wayland (of course ); I don't know what's happened. How have they managed to ruin it all?

Look at who their sponsors are.

@dev-jam
Copy link

dev-jam commented Aug 17, 2025

Using Debian Trixie (and before that Bookworm) on Intel. Never had tearing in kwin/x11 with compositor on but it was terrible with the compositor off. With xlibre and these tweaks, there is no more tearing with compositor off. Really nice!

I did have an app that gave a segfault. It is OpenSesame, a python program to create and run scientific experiments for psychology and neuroscience. Any idea which tweak is interfering here? Disabling egl will be my first try. Gonna do some extensive debugging next week but maybe you have an idea:

https://pastebin.com/VTL6sE3c

Edit:
using QT_XCB_GL_INTEGRATION=xcb_glx solved the problem

@guiodic
Copy link
Author

guiodic commented Aug 17, 2025

Using Debian Trixie (and before that Bookworm) on Intel. Never had tearing in kwin/x11 with compositor on but it was terrible with the compositor off. With xlibre and these tweaks, there is no more tearing with compositor off. Really nice!

I did have an app that gave a segfault. It is OpenSesame, a python program to create and run scientific experiments for psychology and neuroscience. Any idea which tweak is interfering here? Disabling egl will be my first try. Gonna do some extensive debugging next week but maybe you have an idea:

https://pastebin.com/VTL6sE3c

Edit: using QT_XCB_GL_INTEGRATION=xcb_glx solved the problem

Yes, some software, very rare, can cause problems with EGL.

@dev-jam
Copy link

dev-jam commented Aug 17, 2025

Gonna contact the dev next week to see if we can get it working with egl. The app also works in wayland which uses egl by default.

Can I also use kwin_env.sh and drirc system-wide instead of user specific?

Maybe put the drirc stuff in /etc/drirc and put kwin_env.sh in /etc/profile.d?

@guiodic
Copy link
Author

guiodic commented Aug 17, 2025

/etc/profile.d is ok

@dev-jam
Copy link

dev-jam commented Aug 18, 2025

Thanks, works perfectly. I put all configs in a deb so I only have to install the deb.

@dev-jam
Copy link

dev-jam commented Aug 19, 2025

Do the tricks apply to both with compositor enabled and disabled?

@guiodic
Copy link
Author

guiodic commented Aug 19, 2025

Do the tricks apply to both with compositor enabled and disabled?

yes, of course.

@guiodic
Copy link
Author

guiodic commented Aug 19, 2025

Using Debian Trixie (and before that Bookworm) on Intel. Never had tearing in kwin/x11 with compositor on but it was terrible with the compositor off. With xlibre and these tweaks, there is no more tearing with compositor off. Really nice!

Yes, because with the compositor active, this problem does not usually occur, as synchronisation is managed by OpenGL from the compositor. However, this is not an optimal solution, partly because there are corner cases that Kwin does not handle well.
Essentially, this guide shifts the management of synchronisation from Kwin to X11. It works better, even in very specific conditions, such as with multiple screens, some of which are vertical and others horizontal, which Kwin cannot handle appropriately.

@dev-jam
Copy link

dev-jam commented Aug 20, 2025

Yes, because with the compositor active, this problem does not usually occur, as synchronisation is managed by OpenGL from the compositor. However, this is not an optimal solution, partly because there are corner cases that Kwin does not handle well. Essentially, this guide shifts the management of synchronisation from Kwin to X11. It works better, even in very specific conditions, such as with multiple screens, some of which are vertical and others horizontal, which Kwin cannot handle appropriately.

Yeah, I know kwin added some tweaks to get their own tearfree desktop. Does kwin automatically turn of these own kwin tweaks when using intel or amdgpu with tearfree? Like we are doing now manually with modesetting, or do they keep working unnecessarily in conjunction?

I am trying to chop up your tweaks in separate packages.

Modesetting/dma buf in one package, depends on xlibre/xorg.git
Kwin tweaks in a package, depends on the former package and kwin.
Egl setup in a package, depends on former.
Inertial scrolling seems to me it should also work with default xorg X11 so can be a separate independent package.

I find the "other stuff" somewhat harder to categorize/separate.

@guiodic
Copy link
Author

guiodic commented Aug 20, 2025

Yeah, I know kwin added some tweaks to get their own tearfree desktop. Does kwin automatically turn of these own kwin tweaks when using intel or amdgpu with tearfree?

As far as I know, no.

I am trying to chop up your tweaks in separate packages.

Very good idea!

@dev-jam
Copy link

dev-jam commented Aug 20, 2025

I think I split it up in 6 parts. But I am left with a couple of questions:

  • Is it also advisable to use mesa.sh and drirc when using glx, or only with egl?

  • Is this the same tweak at two different places, one redundant?
    mesa.sh -> export mesa_glthread=true
    drirc ->

  • Are the chromium flags always applicable or only when using egl or are parts of the flags only applicable to egl?

  • Don't we need something like GTK_XCB_GL_INTEGRATION=xcb_egl for the gtk applications?

@guiodic
Copy link
Author

guiodic commented Aug 23, 2025

  • Is it also advisable to use mesa.sh and drirc when using glx, or only with egl?
    ok for both.
  • Is this the same tweak at two different places, one redundant?
    mesa.sh -> export mesa_glthread=true
    drirc ->

Maybe, but you know, in FLOSS never assume that two configs make the same thing 100% of times. I should go and look at the source code, but maybe something will change in the next version...

  • Are the chromium flags always applicable or only when using egl or are parts of the flags only applicable to egl?

They are independent; Chromium uses Angle, which then uses EGL.

  • Don't we need something like GTK_XCB_GL_INTEGRATION=xcb_egl for the gtk applications?

There used to be a configuration for using EGL, GDK_DEBUG="gl-egl", but it has been removed because it is now used by default, or at least that's what I found online.

@dev-jam
Copy link

dev-jam commented Oct 15, 2025

I just noticed the atomic option has been commented out. What was the reason for this and do you recommend to disable atomic for all gpu's?

@guiodic
Copy link
Author

guiodic commented Oct 15, 2025

I just noticed the atomic option has been commented out. What was the reason for this and do you recommend to disable atomic for all gpu's?

No, it is commented out because it only works on Xlibre, as explained in the comment itself.

@dev-jam
Copy link

dev-jam commented Oct 15, 2025

a yes sorry, I was a bit occupied over here and too hasty with my response.
And the fact that the comment also applies to tearfree but is not commented out, got me confused.

Btw, after a mesa update in trixie-backports, I dont need:

export QT_XCB_GL_INTEGRATION=xcb_glx

anymore for OpenSesame. It works out of the box now. On the other hand. recoll crashes now, and needs xcb_glx. So win one, lose one.

@guiodic
Copy link
Author

guiodic commented Oct 15, 2025

Recoll can work also with QTWEBENGINE_CHROMIUM_FLAGS="--use-gl=angle --use-angle=vulkan" under EGL
The same for all QTWEBENGINE-based apps, like Falkon (I added this to the text).

@dev-jam
Copy link

dev-jam commented Oct 15, 2025

Thanks! Missed that.
Recoll is working correctly now under EGL. Didnt know it was a QTWEBENGINE-based app.

@Xenapte
Copy link

Xenapte commented Nov 2, 2025

xorg-git breaks night light for me (alternatives such as redshift also won't work). Seems that setting gamma and brightness no longer have any effects. Do you have any ideas on how to fix this?

@guiodic
Copy link
Author

guiodic commented Nov 2, 2025

xorg-git breaks night light for me (alternatives such as redshift also won't work). Seems that setting gamma and brightness no longer have any effects. Do you have any ideas on how to fix this?

Which GPU and driver are you using? I don't have this problem.

@Xenapte
Copy link

Xenapte commented Nov 2, 2025

Which GPU and driver are you using? I don't have this problem.

Intel Arc Graphics. Both i915 and xe don't work which is really weird. I have also tried looking for relevant issues in the Xorg repo but couldn't find anything. It seems that xrandr does respond and accept my gamma/brightness settings but there's no visual changes.

@Xenapte
Copy link

Xenapte commented Nov 3, 2025

Solved by applying this pull request as suggested by this comment.

@Vistaus
Copy link

Vistaus commented Nov 5, 2025

Which GPU and driver are you using? I don't have this problem.

Intel Arc Graphics. Both i915 and xe don't work which is really weird. I have also tried looking for relevant issues in the Xorg repo but couldn't find anything. It seems that xrandr does respond and accept my gamma/brightness settings but there's no visual changes.

Same issue with my AMD APU Ryzen 9 5900HX, but only for night light (brightness setting still works fine). I didn't enable modesetting, though, so not sure if the mentioned pull request would solve this issue for me.

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