Most users have experienced the problem of screen tearing in different Linux distros. Tiering is usually caused by the X server or GPU driver (most often with NVidia drivers). In this article, we will look at how to get rid of screen tearing in Linux.
Tearing on NVidia graphics cards:
To fix the tearing issue on NVidia video cards, create a configuration file in the modprobe directory:
$ sudo nano /etc/modprobe.d/nvidia-nomodset.conf
Add a line to the file:
options nvidia-drm modset=1
Save the file and run:
$ sudo update-initramfs -u
Restart your computer and check if the screen tearing issue is gone. If not, edit the 20-nvidia.conf file:
$ sudo nano /etc/X11/xorg.conf.d/20-nvidia.conf
Add the following in the Device section:
Section "Device"
Identifier "Nvidia Card"
Driver "nvidia"
VendorName "NVIDIA Corporation"
Option "NoLogo" "true"
Option "metamodes" "nvidia-auto-select +0+0 { ForceCompositionPipeline = On }"
EndSection
Intel Graphics Tearing:
If you have a tearing problem on an Intel Graphics card, edit the file (the path may differ depending on the Linux distro):
$ sudo nano /etc/X11/xorg.conf.d/20-intel.conf
Edit the Device section:
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TearFree" "true"
EndSection
Save the file and restart your computer.
Screen tearing issues on AMD Graphics cards:
For AMD video cards, you can also fix the tearing problem using the config file (this method is not suitable for KDE):
$ sudo /etc/X11/xorg.conf.d/20-radeon.conf
Change the configuration in the Devices section:
Section "Device"
Identifier "Radeon"
Driver "radeon"
Option "TearFree" "on"
EndSection
If you are using XFCE and are having tearing issues, you need to change the default compositor to Compton. Disable the default manager:
# xfconf-query -c xfwm4 -p /general/use_compositing -s false
Or disable the Enable display compositing option in the XFCE settings.
Then install Compton compositor:
$ sudo apt install compton
Now open the XFCE settings, go to Session and Startup and add Compton to autostart with the argument:
/usr/bin/compton --backend glx
Restart your computer and check if Compton is running:
# pgrep -l compton
If tearing is in XFCE, edit the file:
$ sudo nano ~/.config/compton.conf
backend = "glx";
paint-on-overlay = true;
glx-no-stencil = true;
vsync = "opengl-swc";
# Shadow
shadow = true; # Enabled client-side shadows on windows.
no-dock-shadow = true; # Avoid drawing shadows on dock/panel windows.
no-dnd-shadow = true; # Don't draw shadows on DND windows.
clear-shadow = true; # Zero the part of the shadow's mask behind the window (experimental).
shadow-radius = 7; # The blur radius for shadows. (default 12)
shadow-offset-x = -7; # The left offset for shadows. (default -15)
shadow-offset-y = -7; # The top offset for shadows. (default -15)
shadow-exclude = [
"n:e:Notification",
"n:e:Docky",
"g:e:Synapse",
"g:e:Conky",
"n:w:*Firefox*",
"n:w:*Chromium*",
"n:w:*dockbarx*",
"class_g ?= 'Cairo-dock'",
"class_g ?= 'Xfce4-notifyd'",
"class_g ?= 'Xfce4-power-manager'",
"class_g ?= 'Notify-osd'",
"_GTK_FRAME_EXTENTS@:c"
];
# Opacity
detect-client-opacity = true;
# Window type settings
wintypes:
{
tooltip = { shadow = false; };
};
If you are using a KDE environment and have a screen tearing issue, you need to open the settings window (Display and Monitor -> Compositor) and set the option Tearing prevention vsync: Full screen repaints.
If KDE uses the kwin window manager, you need to create a file:
$ sudo nano /etc/profile.d/kwin.sh
and add a line to it:
export KWIN_TRIPLE_BUFFER=1
Also, edit the KWin window manager file:
$ sudo nano /home/sysops/.config/kwinrc
In the [Compositing] section, add the following lines:
MaxFPS = 200
RefreshRate = 200
If tearing appears only in the Mozilla Firefox browser:
- Open about:config in Firefox;
- Change the value of layers.acceleration.force-enabled to true
- Restart Firefox.
I hope this article helped you get rid of the annoying screen tearing problem in Linux.