Score:0

Screen tearing and multiple monitors problems in Lubuntu

cn flag

So I've been having screentearing issues on my system for a while.

Finally figured out that running

compton --backend glx --vsync opengl

in the terminal allows me to get rid of the screen tearing.

So I dedcied it would be a good idea to add this command to startup so it simply runs everytime I boot up. However, although I now boot up screen tearing free, my second monitor (which is in fact my laptop's screen my main screen being an external monitor connected through VGA) is simply grey (though my mouse pointer is visible on top when moving to that screen but applications aren't). Killing compton gets rid of the problem and running the same command from the command line still works but I just can't figure out how to make it work from start up so any input you guys have would be super appreciated!

bw3u avatar
cn flag
What is your GPU? Your question is not clear, do you want to start compton (it's picom now actually please update it) at startup ?
tlleclerc avatar
cn flag
Yes absolutely! My bad, I'm not really good at this. My GPU is an Nvidia GT 630M (old thing). I want to run the command mentionned above on startup to get rid of the screen tearing but when I make it as startup preference it makes my other montior go grey while if I run it manually from the terminal it do that.
bw3u avatar
cn flag
You are perfectly fine, I've added an answer hopefully it will solve your problem. Also which Desktop Environment are you using LXQt?
guiverc avatar
cn flag
You've provided no release details, but have you looked in the manual? https://manual.lubuntu.me/stable/3/3.2/3.2.13/session_settings.html?highlight=autostart (as I don't know your release, I've provided the *stable* release (ie. 21.04) so adjust URL to match your system if you're not using 21.04)
tlleclerc avatar
cn flag
Sorry guys, I'm currently using Lubuntu 20.04 with LXQt.
Score:0
cn flag

There's plenty way of doing this but I mostly add apps or scripts that I want to start before Window Manager, I add them to .xprofile.

So create a magical file named .xprofile in your home directory. /home/username/.xprofile.

Add the following contents:

compton --backend glx --vsync opengl &

When you login it should start the apps or scripts you've provided. Alternatively if .xprofile does not work. You can create the .xinitrc and use it with the same content.

Extras:

  • I highly suggest you to, update compton to picom if you haven't done it yet.
  • Create a configuration file in .config/picom/picom.conf
  • Fill the config with sample config.
  • After saving your config edit your .xprofile with:
picom &
  • For your screen tearing issue this might solve it as well; after installing proprietary NVIDIA drivers (370 or higher version). Edit: Seems your GPU supports NVIDIA 390, you can install it with this command: sudo apt install nvidia-driver-390

    • You can try adding nvidia-drm.modeset=1 kernel parameter in /etc/grub/default to GRUB_CMDLINE_LINUX_DEFAULT, dont forget to update your grub as well with; sudo update-grub (Source)
  • If you need anything else feel free to reply :)


Edit 2: First try making .xprofile and/or .xinitrc executable with:

$ chmod +x .xprofile
$ chmod +x .xinitrc

If .xprofile and .xinitrc doesn't works let's create a configuration and directly start compton with LXQt Autostart.

  • Create a configuration in /home/username/.config/compton.conf
  • Add the following contents;
backend = "glx";
glx-no-stencil = true;

# Try to detect WM windows and mark them as active.
mark-wmwin-focused = true;

# Mark all non-WM but override-redirect windows active (e.g. menus).
mark-ovredir-focused = true;

# Use EWMH _NET_WM_ACTIVE_WINDOW to determine which window is focused instead of using FocusIn/Out events.
# Usually more reliable but depends on a EWMH-compliant WM.
use-ewmh-active-win = true;

# Painting on X Composite overlay window. Recommended.
paint-on-overlay = true;

# GLX backend: Avoid rebinding pixmap on window damage.
# Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe).
# Recommended if it works.
glx-no-rebind-pixmap = true;

# Set VSync method. VSync methods currently available:
# none: No VSync
# drm: VSync with DRM_IOCTL_WAIT_VBLANK. May only work on some drivers.
# opengl: Try to VSync with SGI_video_sync OpenGL extension. Only work on some drivers.
# opengl-oml: Try to VSync with OML_sync_control OpenGL extension. Only work on some drivers.
# opengl-swc: Try to VSync with SGI_swap_control OpenGL extension. Only work on some drivers. Works only with GLX backend. Known to be most effective on many drivers. Does not actually control paint timing, only buffer swap is affected, so it doesn’t have the effect of --sw-opti unlike other methods. Experimental.
# opengl-mswc: Try to VSync with MESA_swap_control OpenGL extension. Basically the same as opengl-swc above, except the extension we use.
# (Note some VSync methods may not be enabled at compile time.)
vsync = "opengl";

# If not specified or 0, compton will try detecting this with X RandR extension.
refresh-rate = 0;
  • With this you won't have to pass parameters to compton. You can Google it for detailed compton configurations.

  • I assume you are familiar with LXQt you can just add compton to Autostart. Preferences -> Default applications for LXSession -> Autostart -> Manual autostarted applications -> Add

  • If it doesn't work either you can do something like this;

    • Add this to line ~/.config/lxsession/Lubuntu/autostart (if it doesn't exist create it and make it executable with chmod +x)
@compton

or

@compton -b
  • -b parameter deamonizes the compton.
  • Hopefully compton will start with session.
tlleclerc avatar
cn flag
Hey thanks again for your help. I added the line above /home/[myusername]/.xprofile but unfortunately it didn't stop the screen tearing like it does when manually running the command from the command line. I really wonder why it doesn't work the same... :( I'm really open to trying anything at this point.
tlleclerc avatar
cn flag
Unfortunately, installing Nvidia 390 just made me boot into directly into black screens (not even the logging page) so I had to nomodeset on boot up and ALT+CTRL+F1 to remove and purge the Nvidia driver and reinstall the Nouveau driver.
bw3u avatar
cn flag
Thats a bummer, I've had those issues when I was using 390 few years ago. [Arch Wiki](https://wiki.archlinux.org/title/NVIDIA_Optimus) was really helpful you can check it out if you have some free time. Also there is actually no difference between running from your terminal or when startup, meantime you can pass `-b` parameter to compton it will run in background so you won't have to keep your terminal running in foreground. Can you confirm `.xprofile` starts up the compton when session starts as well? You can add the same line to your `.xinitrc` as well if compton won't start with `.xprofile`
tlleclerc avatar
cn flag
Bad news! I tried with `.xprofile` and with both `.xprofile` and `.xinitrc` but in either case compton didn't start when the session started.
bw3u avatar
cn flag
@tlleclerc I've added more solutions, Today I learned LXQt is little painful to work with :)
tlleclerc avatar
cn flag
Thanks again so much! I will try this this evening and let you know how it goes!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.