Announcement

Collapse
No announcement yet.

SDDM and multiple monitors X11 session - too many log in screens

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [XORG] SDDM and multiple monitors X11 session - too many log in screens

    A small thing, but a bit annoying: if you have two or more monitors at boot up using Xorg, SDDM displays it's menu on ALL screens but only the final screen (last to initialize) shows the password entry. It seems more "normal" to me that only the primary screen should display anything - and everything. So I went looking for a solution...

    I found several references to using xrandr in /usr/share/sddm/scripts/Xsetup to turn off all but the primary monitor. All of them claimed this was the solution and at log in all the screens would light up. Not true - at least not here. The second monitor stayed off until I issued an xrandr command to turn it on. Not sure if this is a distro variation or what, but it didn't work by itself for me.

    A bit more research and I found a solution that works. YMMV.

    Steps:
    1. Determine correct xrandr setup for each monitor.
    2. Turn off all but primary monitor in sddm.
    3. Turn on all monitors during login.
    This got the results I wanted. When I boot, only the primary monitor comes on and has the sddm login screen. When I log in, my second monitor comes on and all is well. For the Step Details below, I will use my monitor specs. You will need to use your own obviously...

    Step details:
    Step 1:

    In a console run this command: xrandr |grep ' connected'
    The output will show you what monitors are connected and their details.
    Code:
    stuart@office:~$ xrandr |grep ' connected'
    DisplayPort-0 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 621mm x 341mm
    DisplayPort-1 connected 3840x2160+3840+0 (normal left inverted right x axis y axis) 621mm x 341mm
    ​
    In my case, DisplayPort-0 is the left most and desired "Primary" monitor - the one I want the login screen on. This information "converts" to xrandr commands like so:

    xrandr --output DisplayPort-0 --mode 3840x2160 --pos 0x0
    xrandr --output DisplayPort-1 --mode 3840x2160 --pos 3840x0

    The above "--mode" is the resolution and "--pos" is the relative XY position on a cartesian plane. This means "0x0" is the center of the plane and the upper left corner of DisplayPort-0 and "3840x0" means that DisplayPort-1 is aligned at the top and to the right of DisplayPort-0.

    Your set up may be wildly different. For example, if your secondary display is to the left of the primary, you use a negative X number, like "-3840x0". The Y axis can vary if your second monitor is a different resolution or above (negative number) or below (positive number) the primary.

    There are many other xrandr options but all you need should be revealed in the output.

    Step 2:
    To turn off all but the primary monitor, I put this in /usr/share/sddm/scripts/Xsetup (as suggested on various other posts on the internet):

    xrandr --output DisplayPort-0 --mode 3840x2160 --pos 0x0 --output DisplayPort-1 --off

    Notice it's a single command that controls both monitors. DisplayPort-0 is correctly set up and DisplayPort-1 is just "off".

    This results in a single screen with sddm on it and the second monitor is off, but as I mentioned above, it stayed off even after log in.

    Step 3:
    Finally, I needed to turn on the second monitor at log in. The series of events is sddm hands off to the login in scripts which source a couple others and end up at /etc/sddm/Xsession which looks for these three files and sources the first one of the three it finds:

    $HOME/.bash_profile
    $HOME/.bash_login
    $HOME/.profile

    Default *buntus don't have the first two files so I edited .profile in my home folder and added this line at the top:

    xrandr --output DisplayPort-0 --primary --mode 3840x2160 --pos 0x0 --output DisplayPort-1 --mode 3840x2160 --pos 3840x0

    Note I added "--primary" to DisplayPort-0 and the second monitor is now activated as it should be. I'm not 100% sure what --primary will do for me if anything, but I figured it wouldn't hurt.

    Also note that if you have more than one user you would have to edit all the .profile files or locate the command elsewhere. I feel like since the X session is run at the user level, it's more "proper" to execute the command as the user.

    I would love to be able to do this with GRUB also, but everything I read says GRUB follows the BIOS settings as far as active screens and it doesn't appear I can control that with my PC and external video card.


    If you try this, please post that you did and what your results are. Thanks.

    Please Read Me

    #2
    I rarely have two screens connected to my main computer. I had connected the TV some time ago and I also observed what you described above.

    In case I wanted to additionally connect the TV again I will keep your post in mind - thank you very much!
    Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
    Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

    get rid of Snap script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
    install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

    Comment


      #3
      Originally posted by Schwarzer Kater View Post
      I rarely have two screens connected to my main computer. I had connected the TV some time ago and I also observed what you described above.

      In case I wanted to additionally connect the TV again I will keep your post in mind - thank you very much!
      In that situation, you would want to add in a detection action to determine if the TV was connected or not. That way it would be plug-n-play for any setup

      Please Read Me

      Comment


        #4
        I am occasionally looking for the correct solution for an SDDM instance that runs as a Wayland session (xrandr is not relevant in this, and won't be for some time for most people.)
        Ya, early adopter here for sure, but this exact sort of situation made me look at how to do this, way down the road.
        I *think* is is just finding the correct Plasma-related commands to turn off one monitor. I just haven't dug in deeply enough yet.
        I will add my finding, if I ever bother do do a dive again. Would be useful for multimonitor usage, as well as those who use vertical layouts, I'd think.


        For reference, SDDM runs in its own X11 session for login (separate from whatever desktop session type the user has chosen), so xrandr similar commands are used to modify the screen settings there.
        In its current version (not in Kubuntu yet, iirc, maybe 23.10?) you can use a Wayland session instead. Why start up xorg, blah blah get rid of useless services blah blah.
        I am not aware of any discussion on having this login manager switching to run using Wayland protocols by defualt just yet, though

        GDM3 already does, iirc.
        Last edited by claydoh; Nov 13, 2023, 04:28 PM.

        Comment

        Working...
        X