Multi-monitor setup with xrandr












0















Up to now, I have been using my laptop screen (3840x2160) alone, and I'm now trying to set up a secondary monitor (1920x1080). Since my primary monitor is double the resolution of my secondary, this has proven quite awkward to configure how I want it. Initially, when I connected the second monitor, my laptop was reduced to 1920x1080, and my scaling to 100%. This leads to problems for two reasons:




  • I want to retain the 3840x2160 my laptop monitor supports

  • My application scaling was set to 200% as otherwise, many applications don't look good on the 4K monitor


Setting the monitor back to 3840x2160 creates another problem: with the laptop monitor being double the size of the secondary one, the cursor only transitions from the laptop to the external monitor if it moves through the top half of the right side of my screen. The cursor cannot move through the bottom half.



Additionally, if I set the scaling back to 200%, the applications which are scaling to display well on the 4K monitor look bad on the FHD monitor.



In an attempt to resolve the problem, I've been looking at this answer: Is it possible to have different DPI configurations for two different screens?
. Following its instructions whilst adjusting for my monitors, I found that whilst the second monitor did display as I hoped, I could not move my cursor outside of its first quadrant. These are the commands I executed (DP-1 is my external monitor, and eDP-1 is my laptop one):



xrandr --output DP-1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output eDP-1 --scale 1x1 --pos 0x0


After running various other commands in an attempt to achieve what I'm after, I managed to get it working - though not in such a way that it's clear to see which of my steps did the job. I essentially ran xrandr with various options I was testing until it worked. I've restarted my system since, and I've recorded one set of commands that sets the monitor configuration to how I want it, listed below (note that after restart the dash was no longer in my output names).



xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output DP1 --panning 3840x2160
xrandr --output DP1 --panning 1920x1080
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 140 (RANDR)
Minor opcode of failed request: 7 (RRSetScreenSize)
Serial number of failed request: 40
Current serial number in output stream: 41
xrandr --output DP1 --scale 1x1
xrandr --output DP1 --scale 2x2
xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output DP1 --panning 1920x1080
xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output eDP1 --scale 1x1 --pos 0x0
xrandr --output DP1 --pos 3840x0
xrandr --output eDP1 --pos 0x0


In an attempt to figure out which steps are necessary and which aren't, I've tried omitting commands I didn't think were responsible when configuring the setup. The problem is, messing it up can cause my displays to get in a pseudo-frozen state, where I can move my mouse but none of the other graphical elements will move - I have to restart when experiencing this.



Initially, when the system boots, my external monitor's application content (including the cursor) appears quite zoomed in. I run the commands in the order that they are listed, and on the penultimate step the graphics freeze like I described in the last section - though continuing to type in the final command despite this causes the system to return to normal, and to be configured how I hoped.



Note that the "X Error of failed request" message doesn't seem to be tied to the panning command directly - in one test where I omitted this line, the message appeared instead for the line that took its place (the scale line).



What's the best way for me to resolve my problem directly, rather than running the series of commands that (somehow) work for me currently?










share|improve this question



























    0















    Up to now, I have been using my laptop screen (3840x2160) alone, and I'm now trying to set up a secondary monitor (1920x1080). Since my primary monitor is double the resolution of my secondary, this has proven quite awkward to configure how I want it. Initially, when I connected the second monitor, my laptop was reduced to 1920x1080, and my scaling to 100%. This leads to problems for two reasons:




    • I want to retain the 3840x2160 my laptop monitor supports

    • My application scaling was set to 200% as otherwise, many applications don't look good on the 4K monitor


    Setting the monitor back to 3840x2160 creates another problem: with the laptop monitor being double the size of the secondary one, the cursor only transitions from the laptop to the external monitor if it moves through the top half of the right side of my screen. The cursor cannot move through the bottom half.



    Additionally, if I set the scaling back to 200%, the applications which are scaling to display well on the 4K monitor look bad on the FHD monitor.



    In an attempt to resolve the problem, I've been looking at this answer: Is it possible to have different DPI configurations for two different screens?
    . Following its instructions whilst adjusting for my monitors, I found that whilst the second monitor did display as I hoped, I could not move my cursor outside of its first quadrant. These are the commands I executed (DP-1 is my external monitor, and eDP-1 is my laptop one):



    xrandr --output DP-1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
    xrandr --output eDP-1 --scale 1x1 --pos 0x0


    After running various other commands in an attempt to achieve what I'm after, I managed to get it working - though not in such a way that it's clear to see which of my steps did the job. I essentially ran xrandr with various options I was testing until it worked. I've restarted my system since, and I've recorded one set of commands that sets the monitor configuration to how I want it, listed below (note that after restart the dash was no longer in my output names).



    xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
    xrandr --output DP1 --panning 3840x2160
    xrandr --output DP1 --panning 1920x1080
    X Error of failed request: BadMatch (invalid parameter attributes)
    Major opcode of failed request: 140 (RANDR)
    Minor opcode of failed request: 7 (RRSetScreenSize)
    Serial number of failed request: 40
    Current serial number in output stream: 41
    xrandr --output DP1 --scale 1x1
    xrandr --output DP1 --scale 2x2
    xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
    xrandr --output DP1 --panning 1920x1080
    xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
    xrandr --output eDP1 --scale 1x1 --pos 0x0
    xrandr --output DP1 --pos 3840x0
    xrandr --output eDP1 --pos 0x0


    In an attempt to figure out which steps are necessary and which aren't, I've tried omitting commands I didn't think were responsible when configuring the setup. The problem is, messing it up can cause my displays to get in a pseudo-frozen state, where I can move my mouse but none of the other graphical elements will move - I have to restart when experiencing this.



    Initially, when the system boots, my external monitor's application content (including the cursor) appears quite zoomed in. I run the commands in the order that they are listed, and on the penultimate step the graphics freeze like I described in the last section - though continuing to type in the final command despite this causes the system to return to normal, and to be configured how I hoped.



    Note that the "X Error of failed request" message doesn't seem to be tied to the panning command directly - in one test where I omitted this line, the message appeared instead for the line that took its place (the scale line).



    What's the best way for me to resolve my problem directly, rather than running the series of commands that (somehow) work for me currently?










    share|improve this question

























      0












      0








      0








      Up to now, I have been using my laptop screen (3840x2160) alone, and I'm now trying to set up a secondary monitor (1920x1080). Since my primary monitor is double the resolution of my secondary, this has proven quite awkward to configure how I want it. Initially, when I connected the second monitor, my laptop was reduced to 1920x1080, and my scaling to 100%. This leads to problems for two reasons:




      • I want to retain the 3840x2160 my laptop monitor supports

      • My application scaling was set to 200% as otherwise, many applications don't look good on the 4K monitor


      Setting the monitor back to 3840x2160 creates another problem: with the laptop monitor being double the size of the secondary one, the cursor only transitions from the laptop to the external monitor if it moves through the top half of the right side of my screen. The cursor cannot move through the bottom half.



      Additionally, if I set the scaling back to 200%, the applications which are scaling to display well on the 4K monitor look bad on the FHD monitor.



      In an attempt to resolve the problem, I've been looking at this answer: Is it possible to have different DPI configurations for two different screens?
      . Following its instructions whilst adjusting for my monitors, I found that whilst the second monitor did display as I hoped, I could not move my cursor outside of its first quadrant. These are the commands I executed (DP-1 is my external monitor, and eDP-1 is my laptop one):



      xrandr --output DP-1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output eDP-1 --scale 1x1 --pos 0x0


      After running various other commands in an attempt to achieve what I'm after, I managed to get it working - though not in such a way that it's clear to see which of my steps did the job. I essentially ran xrandr with various options I was testing until it worked. I've restarted my system since, and I've recorded one set of commands that sets the monitor configuration to how I want it, listed below (note that after restart the dash was no longer in my output names).



      xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output DP1 --panning 3840x2160
      xrandr --output DP1 --panning 1920x1080
      X Error of failed request: BadMatch (invalid parameter attributes)
      Major opcode of failed request: 140 (RANDR)
      Minor opcode of failed request: 7 (RRSetScreenSize)
      Serial number of failed request: 40
      Current serial number in output stream: 41
      xrandr --output DP1 --scale 1x1
      xrandr --output DP1 --scale 2x2
      xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output DP1 --panning 1920x1080
      xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output eDP1 --scale 1x1 --pos 0x0
      xrandr --output DP1 --pos 3840x0
      xrandr --output eDP1 --pos 0x0


      In an attempt to figure out which steps are necessary and which aren't, I've tried omitting commands I didn't think were responsible when configuring the setup. The problem is, messing it up can cause my displays to get in a pseudo-frozen state, where I can move my mouse but none of the other graphical elements will move - I have to restart when experiencing this.



      Initially, when the system boots, my external monitor's application content (including the cursor) appears quite zoomed in. I run the commands in the order that they are listed, and on the penultimate step the graphics freeze like I described in the last section - though continuing to type in the final command despite this causes the system to return to normal, and to be configured how I hoped.



      Note that the "X Error of failed request" message doesn't seem to be tied to the panning command directly - in one test where I omitted this line, the message appeared instead for the line that took its place (the scale line).



      What's the best way for me to resolve my problem directly, rather than running the series of commands that (somehow) work for me currently?










      share|improve this question














      Up to now, I have been using my laptop screen (3840x2160) alone, and I'm now trying to set up a secondary monitor (1920x1080). Since my primary monitor is double the resolution of my secondary, this has proven quite awkward to configure how I want it. Initially, when I connected the second monitor, my laptop was reduced to 1920x1080, and my scaling to 100%. This leads to problems for two reasons:




      • I want to retain the 3840x2160 my laptop monitor supports

      • My application scaling was set to 200% as otherwise, many applications don't look good on the 4K monitor


      Setting the monitor back to 3840x2160 creates another problem: with the laptop monitor being double the size of the secondary one, the cursor only transitions from the laptop to the external monitor if it moves through the top half of the right side of my screen. The cursor cannot move through the bottom half.



      Additionally, if I set the scaling back to 200%, the applications which are scaling to display well on the 4K monitor look bad on the FHD monitor.



      In an attempt to resolve the problem, I've been looking at this answer: Is it possible to have different DPI configurations for two different screens?
      . Following its instructions whilst adjusting for my monitors, I found that whilst the second monitor did display as I hoped, I could not move my cursor outside of its first quadrant. These are the commands I executed (DP-1 is my external monitor, and eDP-1 is my laptop one):



      xrandr --output DP-1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output eDP-1 --scale 1x1 --pos 0x0


      After running various other commands in an attempt to achieve what I'm after, I managed to get it working - though not in such a way that it's clear to see which of my steps did the job. I essentially ran xrandr with various options I was testing until it worked. I've restarted my system since, and I've recorded one set of commands that sets the monitor configuration to how I want it, listed below (note that after restart the dash was no longer in my output names).



      xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output DP1 --panning 3840x2160
      xrandr --output DP1 --panning 1920x1080
      X Error of failed request: BadMatch (invalid parameter attributes)
      Major opcode of failed request: 140 (RANDR)
      Minor opcode of failed request: 7 (RRSetScreenSize)
      Serial number of failed request: 40
      Current serial number in output stream: 41
      xrandr --output DP1 --scale 1x1
      xrandr --output DP1 --scale 2x2
      xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output DP1 --panning 1920x1080
      xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
      xrandr --output eDP1 --scale 1x1 --pos 0x0
      xrandr --output DP1 --pos 3840x0
      xrandr --output eDP1 --pos 0x0


      In an attempt to figure out which steps are necessary and which aren't, I've tried omitting commands I didn't think were responsible when configuring the setup. The problem is, messing it up can cause my displays to get in a pseudo-frozen state, where I can move my mouse but none of the other graphical elements will move - I have to restart when experiencing this.



      Initially, when the system boots, my external monitor's application content (including the cursor) appears quite zoomed in. I run the commands in the order that they are listed, and on the penultimate step the graphics freeze like I described in the last section - though continuing to type in the final command despite this causes the system to return to normal, and to be configured how I hoped.



      Note that the "X Error of failed request" message doesn't seem to be tied to the panning command directly - in one test where I omitted this line, the message appeared instead for the line that took its place (the scale line).



      What's the best way for me to resolve my problem directly, rather than running the series of commands that (somehow) work for me currently?







      multiple-monitors display xrandr






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 7 hours ago









      VortixDevVortixDev

      1064




      1064






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I have a laptop with an external monitor, both with the same resolution as you. But I use my external monitor in portrait. My monitor is to the left of the laptop - I had problems getting xrandr to do what I wanted when it is to the right. I plug my monitor into one of two ports so the script works out where it is. Without the --autos I found the external display could be occasionally disabled, causing much head scratching until I found it disabled in the GUI settings (I use kubuntu 18.04). Here is my script, it includes comments about the maths involved:



          #!/bin/bash

          # 2mon: adjusts displays after plugging or plugging second monitor

          # Main laptop display is eDP-1 3840x2160 landscape
          # Second ASUS monitor is DP-1 or DP-2 1920x1080 portrait ie. 1080x1920
          # has to have 2x2 scale or everything appears huge

          # Find current monitors
          tmp=~/tmp/xrandr.txt
          xrandr>$tmp

          # Set $dp to DP-1 or DP-2 as appropriate
          # xrandr prints "DP-1 connected" and "DP-2 disconnected" or vice versa. But
          # don't match eDP-1...
          dp=
          if (grep "^DP-1 connected" $tmp >/dev/null); then dp=DP-1;
          elif (grep "^DP-2 connected" $tmp >/dev/null); then dp=DP-2; fi

          if [ "$dp" = "" ]; then
          echo External monitor is not connected

          # Reset pos and frame buffer size in case second monitor was previously connected
          xrandr --output eDP-1 --auto --scale 1x1 --pos 0x0 --fb 3840x2160 --primary
          else
          echo External monitor is on $dp

          # External monitor to left of main display

          # Main display starts at 2*1080=2160 (2* because of 2x scale)
          # Frame Buffer -fb x-direction is 2*1080=2160 (external) + 3840 (main) = 6000
          # y-direction is largest of 2*external y= 3840 and main y = 3840
          xrandr --output $dp --auto --scale 2x2 --pos 0x0 --fb 6000x3840 --left-of eDP-1 --rotate left
          xrandr --output eDP-1 --auto --scale 1x1 --pos 2160x0 --primary
          fi





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1110171%2fmulti-monitor-setup-with-xrandr%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I have a laptop with an external monitor, both with the same resolution as you. But I use my external monitor in portrait. My monitor is to the left of the laptop - I had problems getting xrandr to do what I wanted when it is to the right. I plug my monitor into one of two ports so the script works out where it is. Without the --autos I found the external display could be occasionally disabled, causing much head scratching until I found it disabled in the GUI settings (I use kubuntu 18.04). Here is my script, it includes comments about the maths involved:



            #!/bin/bash

            # 2mon: adjusts displays after plugging or plugging second monitor

            # Main laptop display is eDP-1 3840x2160 landscape
            # Second ASUS monitor is DP-1 or DP-2 1920x1080 portrait ie. 1080x1920
            # has to have 2x2 scale or everything appears huge

            # Find current monitors
            tmp=~/tmp/xrandr.txt
            xrandr>$tmp

            # Set $dp to DP-1 or DP-2 as appropriate
            # xrandr prints "DP-1 connected" and "DP-2 disconnected" or vice versa. But
            # don't match eDP-1...
            dp=
            if (grep "^DP-1 connected" $tmp >/dev/null); then dp=DP-1;
            elif (grep "^DP-2 connected" $tmp >/dev/null); then dp=DP-2; fi

            if [ "$dp" = "" ]; then
            echo External monitor is not connected

            # Reset pos and frame buffer size in case second monitor was previously connected
            xrandr --output eDP-1 --auto --scale 1x1 --pos 0x0 --fb 3840x2160 --primary
            else
            echo External monitor is on $dp

            # External monitor to left of main display

            # Main display starts at 2*1080=2160 (2* because of 2x scale)
            # Frame Buffer -fb x-direction is 2*1080=2160 (external) + 3840 (main) = 6000
            # y-direction is largest of 2*external y= 3840 and main y = 3840
            xrandr --output $dp --auto --scale 2x2 --pos 0x0 --fb 6000x3840 --left-of eDP-1 --rotate left
            xrandr --output eDP-1 --auto --scale 1x1 --pos 2160x0 --primary
            fi





            share|improve this answer




























              0














              I have a laptop with an external monitor, both with the same resolution as you. But I use my external monitor in portrait. My monitor is to the left of the laptop - I had problems getting xrandr to do what I wanted when it is to the right. I plug my monitor into one of two ports so the script works out where it is. Without the --autos I found the external display could be occasionally disabled, causing much head scratching until I found it disabled in the GUI settings (I use kubuntu 18.04). Here is my script, it includes comments about the maths involved:



              #!/bin/bash

              # 2mon: adjusts displays after plugging or plugging second monitor

              # Main laptop display is eDP-1 3840x2160 landscape
              # Second ASUS monitor is DP-1 or DP-2 1920x1080 portrait ie. 1080x1920
              # has to have 2x2 scale or everything appears huge

              # Find current monitors
              tmp=~/tmp/xrandr.txt
              xrandr>$tmp

              # Set $dp to DP-1 or DP-2 as appropriate
              # xrandr prints "DP-1 connected" and "DP-2 disconnected" or vice versa. But
              # don't match eDP-1...
              dp=
              if (grep "^DP-1 connected" $tmp >/dev/null); then dp=DP-1;
              elif (grep "^DP-2 connected" $tmp >/dev/null); then dp=DP-2; fi

              if [ "$dp" = "" ]; then
              echo External monitor is not connected

              # Reset pos and frame buffer size in case second monitor was previously connected
              xrandr --output eDP-1 --auto --scale 1x1 --pos 0x0 --fb 3840x2160 --primary
              else
              echo External monitor is on $dp

              # External monitor to left of main display

              # Main display starts at 2*1080=2160 (2* because of 2x scale)
              # Frame Buffer -fb x-direction is 2*1080=2160 (external) + 3840 (main) = 6000
              # y-direction is largest of 2*external y= 3840 and main y = 3840
              xrandr --output $dp --auto --scale 2x2 --pos 0x0 --fb 6000x3840 --left-of eDP-1 --rotate left
              xrandr --output eDP-1 --auto --scale 1x1 --pos 2160x0 --primary
              fi





              share|improve this answer


























                0












                0








                0







                I have a laptop with an external monitor, both with the same resolution as you. But I use my external monitor in portrait. My monitor is to the left of the laptop - I had problems getting xrandr to do what I wanted when it is to the right. I plug my monitor into one of two ports so the script works out where it is. Without the --autos I found the external display could be occasionally disabled, causing much head scratching until I found it disabled in the GUI settings (I use kubuntu 18.04). Here is my script, it includes comments about the maths involved:



                #!/bin/bash

                # 2mon: adjusts displays after plugging or plugging second monitor

                # Main laptop display is eDP-1 3840x2160 landscape
                # Second ASUS monitor is DP-1 or DP-2 1920x1080 portrait ie. 1080x1920
                # has to have 2x2 scale or everything appears huge

                # Find current monitors
                tmp=~/tmp/xrandr.txt
                xrandr>$tmp

                # Set $dp to DP-1 or DP-2 as appropriate
                # xrandr prints "DP-1 connected" and "DP-2 disconnected" or vice versa. But
                # don't match eDP-1...
                dp=
                if (grep "^DP-1 connected" $tmp >/dev/null); then dp=DP-1;
                elif (grep "^DP-2 connected" $tmp >/dev/null); then dp=DP-2; fi

                if [ "$dp" = "" ]; then
                echo External monitor is not connected

                # Reset pos and frame buffer size in case second monitor was previously connected
                xrandr --output eDP-1 --auto --scale 1x1 --pos 0x0 --fb 3840x2160 --primary
                else
                echo External monitor is on $dp

                # External monitor to left of main display

                # Main display starts at 2*1080=2160 (2* because of 2x scale)
                # Frame Buffer -fb x-direction is 2*1080=2160 (external) + 3840 (main) = 6000
                # y-direction is largest of 2*external y= 3840 and main y = 3840
                xrandr --output $dp --auto --scale 2x2 --pos 0x0 --fb 6000x3840 --left-of eDP-1 --rotate left
                xrandr --output eDP-1 --auto --scale 1x1 --pos 2160x0 --primary
                fi





                share|improve this answer













                I have a laptop with an external monitor, both with the same resolution as you. But I use my external monitor in portrait. My monitor is to the left of the laptop - I had problems getting xrandr to do what I wanted when it is to the right. I plug my monitor into one of two ports so the script works out where it is. Without the --autos I found the external display could be occasionally disabled, causing much head scratching until I found it disabled in the GUI settings (I use kubuntu 18.04). Here is my script, it includes comments about the maths involved:



                #!/bin/bash

                # 2mon: adjusts displays after plugging or plugging second monitor

                # Main laptop display is eDP-1 3840x2160 landscape
                # Second ASUS monitor is DP-1 or DP-2 1920x1080 portrait ie. 1080x1920
                # has to have 2x2 scale or everything appears huge

                # Find current monitors
                tmp=~/tmp/xrandr.txt
                xrandr>$tmp

                # Set $dp to DP-1 or DP-2 as appropriate
                # xrandr prints "DP-1 connected" and "DP-2 disconnected" or vice versa. But
                # don't match eDP-1...
                dp=
                if (grep "^DP-1 connected" $tmp >/dev/null); then dp=DP-1;
                elif (grep "^DP-2 connected" $tmp >/dev/null); then dp=DP-2; fi

                if [ "$dp" = "" ]; then
                echo External monitor is not connected

                # Reset pos and frame buffer size in case second monitor was previously connected
                xrandr --output eDP-1 --auto --scale 1x1 --pos 0x0 --fb 3840x2160 --primary
                else
                echo External monitor is on $dp

                # External monitor to left of main display

                # Main display starts at 2*1080=2160 (2* because of 2x scale)
                # Frame Buffer -fb x-direction is 2*1080=2160 (external) + 3840 (main) = 6000
                # y-direction is largest of 2*external y= 3840 and main y = 3840
                xrandr --output $dp --auto --scale 2x2 --pos 0x0 --fb 6000x3840 --left-of eDP-1 --rotate left
                xrandr --output eDP-1 --auto --scale 1x1 --pos 2160x0 --primary
                fi






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 4 hours ago









                B.TannerB.Tanner

                9431814




                9431814






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1110171%2fmulti-monitor-setup-with-xrandr%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    香粉寮

                    GameSpot