This is mostly a note for my future self, but others might find it useful, since my path to this solution was not straightforward.

TL;DR: if you use the i3 window manager, Xorg, and the closed-source NVIDIA driver on Linux and experience screen tearing, try using a compositor such as picom.

I use Manjaro with i3 on my laptop, which has both a Geforce GTX 950M video card and an integrated Intel GPU. This dual-GPU setup is called NVIDIA Optimus. I somehow set it up using Bumblebee and haven’t touched it for years until one day my external monitor stopped working after a system update. The monitor started working again after a full power cycle, but since I blamed the system update, I reinstalled the graphics driver before trying powering off everything. After reinstalling the driver Xorg did not start.

The first step I took to get it working was removing all NVIDIA-related packages and installing the driver with Manjaro’s mhwd tool. Installing the auto-detected non-free driver is done with sudo mhwd -a pci nonfree 0300, after which mhwd reports two installed drivers:

$ mhwd -li
> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2023.03.23               false            PCI
     video-modesetting            2020.01.13                true            PCI

For Xorg to start, I also had to remove a leftover config file from /etc/X11/xorg.conf.d/. I probably created that when doing the initial setup with Bumblebee. The lesson there is to document any manual system-wide configuration that’s hardware-specific, since I’ll have no idea in five years why I did that.

After this I had a working graphical environment, but I noticed horrible screen tearing. A lot of relevant posts on the Manjaro forums led to checking nvidia-settings, which didn’t start for me. After checking the boot logs with journalctl -b, it turned out the nvidia kernel module was blacklisted. Grepping for blacklist in /usr/lib/modprobe.d showed that a leftover config file from Bumblebee blacklists it.

After deleting yet another leftover config file, nvidia-settings started, and I verified with prime-run glxinfo | grep renderer that rendering can be offloaded to the NVIDIA GPU. However, the screen tearing persisted.

The screen tearing was finally fixed by installing picom after a Manjaro forum dive led to a post mentioning that one should install a compositor for i3 to avoid screen tearing. I have no idea why I had no screen tearing with my Bumblebee setup, though.

I made picom automatically start with an X session by adding picom -b to my .xprofile file. The default settings of picom add various fade in/out and opacity effects that I disabled after creating ~/.config/picom.conf from the default config at /etc/xdg/picom.conf:

shadow = false;
fading = false;
inactive-opacity = 1;