Severe Screen Tearing in Intel Mode With Optimus Laptop

I'm experiencing severe screen tearing when running in intel mode. When I switch to nvidia, there is no tearing, but I don't want to be in NVIDIA mode all the time.

I have proprietary NVIDIA driver installed via "Additional Drivers" menu.

I looked over the internet, searching for a solution.
I tried creating the file /etc/X11/xorg.conf.d/20-intel.conf, then adding the following to it:

Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "TearFree"    "true"
EndSection

This works for intel mode, but breaks nvidia mode. Programs that require graphics will output the follwing: Xlib: extension "NV-GLX" missing on display ":0"

I also tried enabling nvidia-drm, which did nothing.

So I'm thinking of enabling the /etc/X11/xorg.conf.d/20-intel.conf only in intel mode, but I have no idea how to do that.
Also, if you have better solutions, then please tell me.

This is just a guess... but what happens if you add another device section for NVidia?

Section "Device"
    Identifier     "Nvidia Graphics"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
EndSection

So I try two different files /etc/X11/xorg.conf.d/20-intel.conf and /etc/X11/xorg.conf.d/20-nvidia.conf?

Or maybe both in one file. I don't have the hardware here to try this myself, currently.

Sorry it took a while. Was trying different combinations.

If I add what you asked me to, the screen tearing returns.

Tried both in same file and in separate files.

did you try this?

Tried it before, but I tried it again just in case.
The problem still persists.

I think the nvidia-drm.modeset=1 only affects nvidia mode, as the /sys/module/nvidia_drm/parameters/modeset directory doesn't exist in intel mode.

For me intel mode is tearing but nvidia isn't, so it's the opposite of what is linked.

How about a script to switch to Intel or Nvidia mode, which also adds that Intel config file when switching to intel and removes it when switching to nvidia?
It's probably not the most elegant solution, but worth a try.

1 Like

Ok, so I wrote my first bash script!

#!/bin/bash
if [ $1 == "nvidia" ]
then
    sudo prime-select nvidia
    sudo rm /etc/X11/xorg.conf.d/20-intel.conf
fi

if [ $1 == "intel" ]
then
    sudo prime-select intel
    sudo cp ~/Desktop/20-intel.conf /etc/X11/xorg.conf.d/20-intel.conf
fi

Please advise me on where user-created scripts usually go in the Linux filesystem, so I can add the script there and add to path if necessary.
Also, should I mark it as solved even though it's kind of a work-around?

You can put it into /usr/local/bin/ .
I'd move the intel config from your desktop to a global location (/usr/local/share/ maybe).

Whether or not you mark this as solved is up to you.
I think until Wayland finally gets off the ground I'm afraid screen tearing issues and ugly workarounds are probably here to stay.

1 Like

Also, can someone tell me what I did wrong here.

Removed the nvidia.drm-modeset=1, and now update-grub2 returns:

/usr/sbin/grub-mkconfig: 308: /usr/sbin/grub-mkconfig: gettext: Exec format error
/usr/sbin/grub-mkconfig: 260: /usr/sbin/grub-mkconfig: gettext: Exec format error

Here is my /etc/default/grub file

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

I don't see anything that would cause that error, here is my file for comparison (it does have some custom tweaks)

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

GRUB_GFXPAYLOAD_LINUX=1920x1200

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

Weird. Yours also gives me same error... I didn't change anything else...

Actually the output looks like the gettext program is somehow broken. What happens when you run just "gettext"?
If that gives the same error, mabye try reinstalling gettext-base.

1 Like

Yeah, it is broken... How did that happen?

Also can't do anything now...

dpkg: unrecoverable fatal error, aborting:
 files list file for package 'libsratom-0-0:amd64' is missing final newline
sh: 1: /usr/bin/gdbus: Exec format error
E: Sub-process /usr/bin/dpkg returned an error code (2)

Is reinstall only option?

Btw here is output of gettext:
bash: /usr/bin/gettext: cannot execute binary file: Exec format error

Also noticed a lot of things broken, like keyring won't unlock for Evolution mail, and random files in my home direcotry like "=", "at!data", etc.

Could be a broken drive maybe... can you check the SMART data somehow (via e.g. gsmartcontrol)?
Boot from a live ISO if necessary.

Ok, I booted into a live USB and installed gsmartcontrol, but I don't know what to do.
Btw, this is an nvme device.

Run it, then double-click on the device and check the error log.
Also you can post the contents of "View Output".

Double click says no additional information is available.

Here is Show Output:

smartctl 6.6 2016-05-31 r4324 [x86_64-linux-5.0.0-23-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number:                       INTEL SSDPEKNW010T8H
Serial Number:                      BTNH93550K0N1P0B
Firmware Version:                   HPS0
PCI Vendor/Subsystem ID:            0x8086
IEEE OUI Identifier:                0x5cd2e4
Controller ID:                      1
Number of Namespaces:               1
Namespace 1 Size/Capacity:          1,024,209,543,168 [1.02 TB]
Namespace 1 Formatted LBA Size:     512
Local Time is:                      Sat Nov  2 18:26:59 2019 UTC
Firmware Updates (0x14):            2 Slots, no Reset required
Optional Admin Commands (0x0017):   Security Format Frmw_DL *Other*
Optional NVM Commands (0x005f):     Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat *Other*
Maximum Data Transfer Size:         32 Pages
Warning  Comp. Temp. Threshold:     77 Celsius
Critical Comp. Temp. Threshold:     80 Celsius

Supported Power States
St Op     Max   Active     Idle   RL RT WL WT  Ent_Lat  Ex_Lat
 0 +     4.00W       -        -    0  0  0  0        0       0
 1 +     3.00W       -        -    1  1  1  1        0       0
 2 +     2.20W       -        -    2  2  2  2        0       0
 3 -   0.0300W       -        -    3  3  3  3     5000    5000
 4 -   0.0040W       -        -    4  4  4  4     5000    9000

Supported LBA Sizes (NSID 0x1)
Id Fmt  Data  Metadt  Rel_Perf
 0 +     512       0         0

=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

At the end it says passed, so I guess there is nothing wrong with the drive.
Is there a way to fix gettext or should I just reinstall the OS and hope I don't mess it up again?

Update: Reinstalled the OS and set it up again.
Using my script no problem.
I think I'll mark it as solved even though it's a workaround. I don't think there will be anything and end-user can do to fix this.

Btw, thanks maximuscore for helping me for 2-3 hours.

1 Like