Saving monitor settings?











up vote
14
down vote

favorite
3












Is there a way to save my monitor settings? I have an external monitor at work, but each morning i have to plug it in, rearrange the windows from being side by side to being on top of each other. Can I just save this?










share|improve this question


























    up vote
    14
    down vote

    favorite
    3












    Is there a way to save my monitor settings? I have an external monitor at work, but each morning i have to plug it in, rearrange the windows from being side by side to being on top of each other. Can I just save this?










    share|improve this question
























      up vote
      14
      down vote

      favorite
      3









      up vote
      14
      down vote

      favorite
      3






      3





      Is there a way to save my monitor settings? I have an external monitor at work, but each morning i have to plug it in, rearrange the windows from being side by side to being on top of each other. Can I just save this?










      share|improve this question













      Is there a way to save my monitor settings? I have an external monitor at work, but each morning i have to plug it in, rearrange the windows from being side by side to being on top of each other. Can I just save this?







      hardware multiple-monitors thinkpad settings lenovo






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 11 '10 at 21:05









      Oscar Godson

      75041729




      75041729






















          8 Answers
          8






          active

          oldest

          votes

















          up vote
          5
          down vote













          Configuration for all your monitors - hot-plugged or not - should be stored in $HOME/.config/monitors.xml by the xrandr plugin for gnome-settings-daemon, which is what actually applies the configuration you make in the Monitors capplet.



          Since it seems that this isn't working properly for everyone, there's clearly a bug somewhere. Urgh.






          share|improve this answer





















          • Yeah, and as maco says, if i shut off the computer and boot it back up, it remembers, just not when it's already on.
            – Oscar Godson
            Oct 12 '10 at 16:39


















          up vote
          4
          down vote













          First three steps to connect your external monitor the way you want and 4th is to save the settings.





          1. Connect your external monitor and check its supported resolution:



            xrandr -q



          2. Give the following command (This will disable your laptop monitor):



            xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal



          3. If you want both laptop and external enabled:



            xrandr --output LVDS1 --mode yyyyXzzzz --pos 0x0 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal


            (yyyyXzzzz - your laptop resolution.)



            The above configuration will clone your screen. Play with "--right-of / --left-of" option if you want.




          4. If you need this settings while login, add the checks in /etc/X11/Xsession.d/45custom_xrandr-settings (You might need to create one).



            xrandr |grep VGA1 | grep " connected " | if [ $? -eq 0 ]; then xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal  #Change the way u need ; fi







          share|improve this answer






























            up vote
            3
            down vote













            Long story short (that is: do what Nicolas Bernaerts suggests, but I spare you the details): monitors configuration is actually saved in ~/.config/monitors.xml, but it's not applied at startup/login.



            The steps to overcome this are:



            Log in with the wrong monitors configuration.



            Remove current monitor configuration:



            cd .config
            mv monitors.xml{,.bak}


            Use the Displays application to arrange the monitors as you wish (I have one side monitor rotated counterclockwise).
            arrange your monitors as you wish



            Once you press Apply, a new monitors.xml is created.



            Now, download and make executable the script and the launcher that force the monitor configuration based on the newly created config file:



            $ sudo wget -O /usr/local/sbin/update-monitor-position https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position
            $ sudo chmod +x /usr/local/sbin/update-monitor-position
            $ sudo wget -O /usr/share/applications/update-monitor-position.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position.desktop
            $ sudo chmod +x /usr/share/applications/update-monitor-position.desktop


            At this point, the monitors' configuration can be fixed by launching the update monitor position application.



            If you want this to be automatic, simply add a startup application, with the following entries:




            • Name: Update Monitors Position

            • Command: update-monitor-position 5

            • Comment: Force monitors position 5 seconds after login


            enter image description here






            share|improve this answer





















            • Great, this helped. Thanks! Is there a bug report for this?
              – Ondra Žižka
              Sep 20 '16 at 11:47








            • 1




              bugs.launchpad.net/launchpad/+bug/1625600
              – Ondra Žižka
              Sep 20 '16 at 12:02










            • I think this is the best answer. I updated the script to support multiple profiles: gist.github.com/relet/66a965cdf728e5278fbf52c9d1433be0 - just copy your monitors.xml to e.g. monitors-office.xml if you want to run "update-monitor-position office"
              – relet
              Aug 23 '17 at 9:35


















            up vote
            1
            down vote













            Ubuntu 12.04 remembers hot-plugged monitor settings. But they are only applied when you reopen the System configuration > Displays applet. This is the case for me, at least, and this is definitively a bug.






            share|improve this answer




























              up vote
              1
              down vote













              At office, I have 3 monitors on my laptop, and 2 at home. Two of office monitors are set vertical, while other monitors are at normal orientation.



              A. monitors.xml is in ~/.config.




              1. Delete it

              2. Set the display at office setup

              3. Rename just created "monitors.xml" to "monitors-office.xml".


              B. Get shell script, "update-monitor-position".




              1. Change the "MONITOR_XML" definition, "monitors.xml" to
                "monitors-office.xml".


              2. Save it as "update-monitor-position-office", in executable path (/usr/local/sbin/).


              3. Touch the permission -> executable by "Me".


              C. Get desktop shortcut, "update-monitor-position.desktop"




              1. Change "Exec" definition, "update-monitor-position" to

                "update-monitor-position-office".

              2. Save it as "update-monitor-position-office.desktop"

              3. Touch the permission -> executable by "Me".


              update-monitor-position-office.desktop:



              [Desktop Entry]
              Type=Application
              Exec=update-monitor-position-office
              Hidden=false
              NoDisplay=false
              X-GNOME-Autostart-enabled=true
              Name[en_US]=Office Monitors Position
              Name=Office Monitors Position
              Comment[en_US]=Force monitors position from monitor-office.xml
              Comment=Force monitors position from monitor-office.xml
              Icon=display


              Shell script, update-monitor-position-office



              #!/bin/bash
              # -------------------------------------------------
              # Get monitors configuration from monitor.xml and apply it for current user session.
              # In case of multiple definitions in monitor.xml only first one is used.
              #
              # See http://bernaerts.dyndns.org/linux/74-ubuntu/309-ubuntu-dual-display-monitor-position-lost
              # for instructions
              #
              # Parameters :
              # $1 : waiting time in sec. before forcing configuration (optional)
              #
              # Revision history :
              # 19/04/2014, V1.0 - Creation by N. Bernaerts
              # 10/07/2014, V1.1 - Wait 5 seconds for X to fully initialize
              # 01/09/2014, V1.2 - Correct NULL file bug (thanks to Ivan Harmady) and handle rotation
              # 07/10/2014, V1.3 - Add monitors size and rate handling (idea from jescalante)
              # 08/10/2014, V1.4 - Handle primary display parameter
              # 08/12/2014, V1.5 - Waiting time in seconds becomes a parameter
              # -------------------------------------------------

              # monitor.xml path
              MONITOR_XML="$HOME/.config/monitors-office.xml"

              # get number of declared monitors
              NUM=$(xmllint --xpath 'count(//monitors/configuration['1']/output)' $MONITOR_XML)

              # loop thru declared monitors to create the command line parameters
              for (( i=1; i<=$NUM; i++)); do
              # get attributes of current monitor (name and x & y positions)
              NAME=$(xmllint --xpath 'string(//monitors/configuration['1']/output['$i']/@name)' $MONITOR_XML 2>/dev/null)
              POS_X=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/x/text()' $MONITOR_XML 2>/dev/null)
              POS_Y=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/y/text()' $MONITOR_XML 2>/dev/null)
              ROTATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rotation/text()' $MONITOR_XML 2>/dev/null)
              WIDTH=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/width/text()' $MONITOR_XML 2>/dev/null)
              HEIGHT=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/height/text()' $MONITOR_XML 2>/dev/null)
              RATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rate/text()' $MONITOR_XML 2>/dev/null)
              PRIMARY=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/primary/text()' $MONITOR_XML 2>/dev/null)

              # if position is defined for current monitor, add its position and orientation to command line parameters
              [ -n "$POS_X" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--output" "$NAME" "--pos" "${POS_X}x${POS_Y}" "--fbmm" "${WIDTH}x${HEIGHT}" "--rate" "$RATE" "--rotate" "$ROTATE")

              # if monitor is defined as primary, adds it to command line parameters
              [ "$PRIMARY" = "yes" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--primary")
              done

              # if needed, wait for some seconds (for X to finish initialisation)
              [ -n "$1" ] && sleep $1

              # position all monitors
              xrandr "${PARAM_ARR[@]}"





              share|improve this answer





















              • Hey @jey, you answered this in January 2018. (while Nicolas script is 4 years old...). May I assume this is still working under a recent Ubuntu 16.x / 18.x? – And: do you have any assumption, if it would work under Ubuntu-MATE as well? (I do see said monitors.xml on my system...)
                – Frank Nocke
                Aug 2 at 7:37












              • Frank, mine says "16.04.5 LTS". One point, after "dist-upgrade", I had to go through the process, and then reboot. The "System Settings -> Displays" works funny on my system. I am not in the mode to try 18.x. Thanks,
                – jay
                Aug 3 at 14:33


















              up vote
              1
              down vote













              jay's answer almost worked for me, but I needed to do a couple extra steps. I'd make this a comment on his answer but I don't have the reputation.



              In the file update-monitor-position-office:




              1. My version of bash (4.3.48) complained about the lack of a space following "i++" on line 28.

              2. My version of xrandr (1.5) did not recognize the "--fbmm" option on line 40. I had to change this to "--mode". This was hard to diagnose because xrandr did not actually give me an error, it just executed the command without doing anything.






              share|improve this answer








              New contributor




              Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

























                up vote
                1
                down vote













                I prefer to run this script from a terminal since I open one first after login.



                First login with the bad configuration - monitors not placed correctly:



                cd ~/.config
                mv ~/.config/monitors.xml{,.bak}


                Now set your monitors with system settings to create a new ~/.config/monitors.xml file with proper settings.



                Copy Nicolas Bernaerts's fixed script from my repo: https://raw.githubusercontent.com/alextomko/monitors/master/monitors and put it in a path to run from terminal.



                $ ls -l ~/bin
                # if you don't have this directory then create it - do not be logged in as root here.

                $ mkdir /home/$USER/bin

                $ echo $PATH
                # should show /home/username/bin if the dir existed or if you had to create.

                $ wget -P ~/bin https://raw.githubusercontent.com/alextomko/monitors/master/monitors
                $ chmod +x ~/bin/monitors

                # Log out, lock, reboot or whatever it takes to make monitor settings lost for you and run the script.
                $ monitors





                share|improve this answer






























                  up vote
                  0
                  down vote













                  No, there's no way to save configurations on hot-plugged monitors. If you plug in before boot, GNOME should remember the configuration on each boot on a per-device basis (ie, connecting to your monitor at work versus the one at home).






                  share|improve this answer





















                  • Damn, ok. Is there a third party application than can do this? I know Mac OS X does this, and Windows 7 (from what I've tried with the little experience I have with W7).
                    – Oscar Godson
                    Oct 11 '10 at 21:16










                  • The GNOME monitor configuration should save this information for hotplugged monitors, too. It does for me.
                    – RAOF
                    Oct 11 '10 at 23:11










                  • RAOF: weird, since discussion on the ubuntu-devel mailing list earlier this week said it doesn't.
                    – maco
                    Oct 11 '10 at 23:31










                  • the configuration is actually saved in ~/.config/monitors.xml, but it is not applied at startup
                    – Alessandro Cuttin
                    Jan 4 '16 at 9:04











                  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',
                  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%2f6137%2fsaving-monitor-settings%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  8 Answers
                  8






                  active

                  oldest

                  votes








                  8 Answers
                  8






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes








                  up vote
                  5
                  down vote













                  Configuration for all your monitors - hot-plugged or not - should be stored in $HOME/.config/monitors.xml by the xrandr plugin for gnome-settings-daemon, which is what actually applies the configuration you make in the Monitors capplet.



                  Since it seems that this isn't working properly for everyone, there's clearly a bug somewhere. Urgh.






                  share|improve this answer





















                  • Yeah, and as maco says, if i shut off the computer and boot it back up, it remembers, just not when it's already on.
                    – Oscar Godson
                    Oct 12 '10 at 16:39















                  up vote
                  5
                  down vote













                  Configuration for all your monitors - hot-plugged or not - should be stored in $HOME/.config/monitors.xml by the xrandr plugin for gnome-settings-daemon, which is what actually applies the configuration you make in the Monitors capplet.



                  Since it seems that this isn't working properly for everyone, there's clearly a bug somewhere. Urgh.






                  share|improve this answer





















                  • Yeah, and as maco says, if i shut off the computer and boot it back up, it remembers, just not when it's already on.
                    – Oscar Godson
                    Oct 12 '10 at 16:39













                  up vote
                  5
                  down vote










                  up vote
                  5
                  down vote









                  Configuration for all your monitors - hot-plugged or not - should be stored in $HOME/.config/monitors.xml by the xrandr plugin for gnome-settings-daemon, which is what actually applies the configuration you make in the Monitors capplet.



                  Since it seems that this isn't working properly for everyone, there's clearly a bug somewhere. Urgh.






                  share|improve this answer












                  Configuration for all your monitors - hot-plugged or not - should be stored in $HOME/.config/monitors.xml by the xrandr plugin for gnome-settings-daemon, which is what actually applies the configuration you make in the Monitors capplet.



                  Since it seems that this isn't working properly for everyone, there's clearly a bug somewhere. Urgh.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 12 '10 at 1:15









                  RAOF

                  10.8k12646




                  10.8k12646












                  • Yeah, and as maco says, if i shut off the computer and boot it back up, it remembers, just not when it's already on.
                    – Oscar Godson
                    Oct 12 '10 at 16:39


















                  • Yeah, and as maco says, if i shut off the computer and boot it back up, it remembers, just not when it's already on.
                    – Oscar Godson
                    Oct 12 '10 at 16:39
















                  Yeah, and as maco says, if i shut off the computer and boot it back up, it remembers, just not when it's already on.
                  – Oscar Godson
                  Oct 12 '10 at 16:39




                  Yeah, and as maco says, if i shut off the computer and boot it back up, it remembers, just not when it's already on.
                  – Oscar Godson
                  Oct 12 '10 at 16:39












                  up vote
                  4
                  down vote













                  First three steps to connect your external monitor the way you want and 4th is to save the settings.





                  1. Connect your external monitor and check its supported resolution:



                    xrandr -q



                  2. Give the following command (This will disable your laptop monitor):



                    xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal



                  3. If you want both laptop and external enabled:



                    xrandr --output LVDS1 --mode yyyyXzzzz --pos 0x0 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal


                    (yyyyXzzzz - your laptop resolution.)



                    The above configuration will clone your screen. Play with "--right-of / --left-of" option if you want.




                  4. If you need this settings while login, add the checks in /etc/X11/Xsession.d/45custom_xrandr-settings (You might need to create one).



                    xrandr |grep VGA1 | grep " connected " | if [ $? -eq 0 ]; then xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal  #Change the way u need ; fi







                  share|improve this answer



























                    up vote
                    4
                    down vote













                    First three steps to connect your external monitor the way you want and 4th is to save the settings.





                    1. Connect your external monitor and check its supported resolution:



                      xrandr -q



                    2. Give the following command (This will disable your laptop monitor):



                      xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal



                    3. If you want both laptop and external enabled:



                      xrandr --output LVDS1 --mode yyyyXzzzz --pos 0x0 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal


                      (yyyyXzzzz - your laptop resolution.)



                      The above configuration will clone your screen. Play with "--right-of / --left-of" option if you want.




                    4. If you need this settings while login, add the checks in /etc/X11/Xsession.d/45custom_xrandr-settings (You might need to create one).



                      xrandr |grep VGA1 | grep " connected " | if [ $? -eq 0 ]; then xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal  #Change the way u need ; fi







                    share|improve this answer

























                      up vote
                      4
                      down vote










                      up vote
                      4
                      down vote









                      First three steps to connect your external monitor the way you want and 4th is to save the settings.





                      1. Connect your external monitor and check its supported resolution:



                        xrandr -q



                      2. Give the following command (This will disable your laptop monitor):



                        xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal



                      3. If you want both laptop and external enabled:



                        xrandr --output LVDS1 --mode yyyyXzzzz --pos 0x0 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal


                        (yyyyXzzzz - your laptop resolution.)



                        The above configuration will clone your screen. Play with "--right-of / --left-of" option if you want.




                      4. If you need this settings while login, add the checks in /etc/X11/Xsession.d/45custom_xrandr-settings (You might need to create one).



                        xrandr |grep VGA1 | grep " connected " | if [ $? -eq 0 ]; then xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal  #Change the way u need ; fi







                      share|improve this answer














                      First three steps to connect your external monitor the way you want and 4th is to save the settings.





                      1. Connect your external monitor and check its supported resolution:



                        xrandr -q



                      2. Give the following command (This will disable your laptop monitor):



                        xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal



                      3. If you want both laptop and external enabled:



                        xrandr --output LVDS1 --mode yyyyXzzzz --pos 0x0 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal


                        (yyyyXzzzz - your laptop resolution.)



                        The above configuration will clone your screen. Play with "--right-of / --left-of" option if you want.




                      4. If you need this settings while login, add the checks in /etc/X11/Xsession.d/45custom_xrandr-settings (You might need to create one).



                        xrandr |grep VGA1 | grep " connected " | if [ $? -eq 0 ]; then xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal  #Change the way u need ; fi








                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Aug 13 '12 at 11:39









                      thonixx

                      5523926




                      5523926










                      answered Jan 5 '11 at 0:36







                      user8361





























                          up vote
                          3
                          down vote













                          Long story short (that is: do what Nicolas Bernaerts suggests, but I spare you the details): monitors configuration is actually saved in ~/.config/monitors.xml, but it's not applied at startup/login.



                          The steps to overcome this are:



                          Log in with the wrong monitors configuration.



                          Remove current monitor configuration:



                          cd .config
                          mv monitors.xml{,.bak}


                          Use the Displays application to arrange the monitors as you wish (I have one side monitor rotated counterclockwise).
                          arrange your monitors as you wish



                          Once you press Apply, a new monitors.xml is created.



                          Now, download and make executable the script and the launcher that force the monitor configuration based on the newly created config file:



                          $ sudo wget -O /usr/local/sbin/update-monitor-position https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position
                          $ sudo chmod +x /usr/local/sbin/update-monitor-position
                          $ sudo wget -O /usr/share/applications/update-monitor-position.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position.desktop
                          $ sudo chmod +x /usr/share/applications/update-monitor-position.desktop


                          At this point, the monitors' configuration can be fixed by launching the update monitor position application.



                          If you want this to be automatic, simply add a startup application, with the following entries:




                          • Name: Update Monitors Position

                          • Command: update-monitor-position 5

                          • Comment: Force monitors position 5 seconds after login


                          enter image description here






                          share|improve this answer





















                          • Great, this helped. Thanks! Is there a bug report for this?
                            – Ondra Žižka
                            Sep 20 '16 at 11:47








                          • 1




                            bugs.launchpad.net/launchpad/+bug/1625600
                            – Ondra Žižka
                            Sep 20 '16 at 12:02










                          • I think this is the best answer. I updated the script to support multiple profiles: gist.github.com/relet/66a965cdf728e5278fbf52c9d1433be0 - just copy your monitors.xml to e.g. monitors-office.xml if you want to run "update-monitor-position office"
                            – relet
                            Aug 23 '17 at 9:35















                          up vote
                          3
                          down vote













                          Long story short (that is: do what Nicolas Bernaerts suggests, but I spare you the details): monitors configuration is actually saved in ~/.config/monitors.xml, but it's not applied at startup/login.



                          The steps to overcome this are:



                          Log in with the wrong monitors configuration.



                          Remove current monitor configuration:



                          cd .config
                          mv monitors.xml{,.bak}


                          Use the Displays application to arrange the monitors as you wish (I have one side monitor rotated counterclockwise).
                          arrange your monitors as you wish



                          Once you press Apply, a new monitors.xml is created.



                          Now, download and make executable the script and the launcher that force the monitor configuration based on the newly created config file:



                          $ sudo wget -O /usr/local/sbin/update-monitor-position https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position
                          $ sudo chmod +x /usr/local/sbin/update-monitor-position
                          $ sudo wget -O /usr/share/applications/update-monitor-position.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position.desktop
                          $ sudo chmod +x /usr/share/applications/update-monitor-position.desktop


                          At this point, the monitors' configuration can be fixed by launching the update monitor position application.



                          If you want this to be automatic, simply add a startup application, with the following entries:




                          • Name: Update Monitors Position

                          • Command: update-monitor-position 5

                          • Comment: Force monitors position 5 seconds after login


                          enter image description here






                          share|improve this answer





















                          • Great, this helped. Thanks! Is there a bug report for this?
                            – Ondra Žižka
                            Sep 20 '16 at 11:47








                          • 1




                            bugs.launchpad.net/launchpad/+bug/1625600
                            – Ondra Žižka
                            Sep 20 '16 at 12:02










                          • I think this is the best answer. I updated the script to support multiple profiles: gist.github.com/relet/66a965cdf728e5278fbf52c9d1433be0 - just copy your monitors.xml to e.g. monitors-office.xml if you want to run "update-monitor-position office"
                            – relet
                            Aug 23 '17 at 9:35













                          up vote
                          3
                          down vote










                          up vote
                          3
                          down vote









                          Long story short (that is: do what Nicolas Bernaerts suggests, but I spare you the details): monitors configuration is actually saved in ~/.config/monitors.xml, but it's not applied at startup/login.



                          The steps to overcome this are:



                          Log in with the wrong monitors configuration.



                          Remove current monitor configuration:



                          cd .config
                          mv monitors.xml{,.bak}


                          Use the Displays application to arrange the monitors as you wish (I have one side monitor rotated counterclockwise).
                          arrange your monitors as you wish



                          Once you press Apply, a new monitors.xml is created.



                          Now, download and make executable the script and the launcher that force the monitor configuration based on the newly created config file:



                          $ sudo wget -O /usr/local/sbin/update-monitor-position https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position
                          $ sudo chmod +x /usr/local/sbin/update-monitor-position
                          $ sudo wget -O /usr/share/applications/update-monitor-position.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position.desktop
                          $ sudo chmod +x /usr/share/applications/update-monitor-position.desktop


                          At this point, the monitors' configuration can be fixed by launching the update monitor position application.



                          If you want this to be automatic, simply add a startup application, with the following entries:




                          • Name: Update Monitors Position

                          • Command: update-monitor-position 5

                          • Comment: Force monitors position 5 seconds after login


                          enter image description here






                          share|improve this answer












                          Long story short (that is: do what Nicolas Bernaerts suggests, but I spare you the details): monitors configuration is actually saved in ~/.config/monitors.xml, but it's not applied at startup/login.



                          The steps to overcome this are:



                          Log in with the wrong monitors configuration.



                          Remove current monitor configuration:



                          cd .config
                          mv monitors.xml{,.bak}


                          Use the Displays application to arrange the monitors as you wish (I have one side monitor rotated counterclockwise).
                          arrange your monitors as you wish



                          Once you press Apply, a new monitors.xml is created.



                          Now, download and make executable the script and the launcher that force the monitor configuration based on the newly created config file:



                          $ sudo wget -O /usr/local/sbin/update-monitor-position https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position
                          $ sudo chmod +x /usr/local/sbin/update-monitor-position
                          $ sudo wget -O /usr/share/applications/update-monitor-position.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position.desktop
                          $ sudo chmod +x /usr/share/applications/update-monitor-position.desktop


                          At this point, the monitors' configuration can be fixed by launching the update monitor position application.



                          If you want this to be automatic, simply add a startup application, with the following entries:




                          • Name: Update Monitors Position

                          • Command: update-monitor-position 5

                          • Comment: Force monitors position 5 seconds after login


                          enter image description here







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 4 '16 at 9:25









                          Alessandro Cuttin

                          333516




                          333516












                          • Great, this helped. Thanks! Is there a bug report for this?
                            – Ondra Žižka
                            Sep 20 '16 at 11:47








                          • 1




                            bugs.launchpad.net/launchpad/+bug/1625600
                            – Ondra Žižka
                            Sep 20 '16 at 12:02










                          • I think this is the best answer. I updated the script to support multiple profiles: gist.github.com/relet/66a965cdf728e5278fbf52c9d1433be0 - just copy your monitors.xml to e.g. monitors-office.xml if you want to run "update-monitor-position office"
                            – relet
                            Aug 23 '17 at 9:35


















                          • Great, this helped. Thanks! Is there a bug report for this?
                            – Ondra Žižka
                            Sep 20 '16 at 11:47








                          • 1




                            bugs.launchpad.net/launchpad/+bug/1625600
                            – Ondra Žižka
                            Sep 20 '16 at 12:02










                          • I think this is the best answer. I updated the script to support multiple profiles: gist.github.com/relet/66a965cdf728e5278fbf52c9d1433be0 - just copy your monitors.xml to e.g. monitors-office.xml if you want to run "update-monitor-position office"
                            – relet
                            Aug 23 '17 at 9:35
















                          Great, this helped. Thanks! Is there a bug report for this?
                          – Ondra Žižka
                          Sep 20 '16 at 11:47






                          Great, this helped. Thanks! Is there a bug report for this?
                          – Ondra Žižka
                          Sep 20 '16 at 11:47






                          1




                          1




                          bugs.launchpad.net/launchpad/+bug/1625600
                          – Ondra Žižka
                          Sep 20 '16 at 12:02




                          bugs.launchpad.net/launchpad/+bug/1625600
                          – Ondra Žižka
                          Sep 20 '16 at 12:02












                          I think this is the best answer. I updated the script to support multiple profiles: gist.github.com/relet/66a965cdf728e5278fbf52c9d1433be0 - just copy your monitors.xml to e.g. monitors-office.xml if you want to run "update-monitor-position office"
                          – relet
                          Aug 23 '17 at 9:35




                          I think this is the best answer. I updated the script to support multiple profiles: gist.github.com/relet/66a965cdf728e5278fbf52c9d1433be0 - just copy your monitors.xml to e.g. monitors-office.xml if you want to run "update-monitor-position office"
                          – relet
                          Aug 23 '17 at 9:35










                          up vote
                          1
                          down vote













                          Ubuntu 12.04 remembers hot-plugged monitor settings. But they are only applied when you reopen the System configuration > Displays applet. This is the case for me, at least, and this is definitively a bug.






                          share|improve this answer

























                            up vote
                            1
                            down vote













                            Ubuntu 12.04 remembers hot-plugged monitor settings. But they are only applied when you reopen the System configuration > Displays applet. This is the case for me, at least, and this is definitively a bug.






                            share|improve this answer























                              up vote
                              1
                              down vote










                              up vote
                              1
                              down vote









                              Ubuntu 12.04 remembers hot-plugged monitor settings. But they are only applied when you reopen the System configuration > Displays applet. This is the case for me, at least, and this is definitively a bug.






                              share|improve this answer












                              Ubuntu 12.04 remembers hot-plugged monitor settings. But they are only applied when you reopen the System configuration > Displays applet. This is the case for me, at least, and this is definitively a bug.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Aug 15 '13 at 18:38









                              Jens

                              1618




                              1618






















                                  up vote
                                  1
                                  down vote













                                  At office, I have 3 monitors on my laptop, and 2 at home. Two of office monitors are set vertical, while other monitors are at normal orientation.



                                  A. monitors.xml is in ~/.config.




                                  1. Delete it

                                  2. Set the display at office setup

                                  3. Rename just created "monitors.xml" to "monitors-office.xml".


                                  B. Get shell script, "update-monitor-position".




                                  1. Change the "MONITOR_XML" definition, "monitors.xml" to
                                    "monitors-office.xml".


                                  2. Save it as "update-monitor-position-office", in executable path (/usr/local/sbin/).


                                  3. Touch the permission -> executable by "Me".


                                  C. Get desktop shortcut, "update-monitor-position.desktop"




                                  1. Change "Exec" definition, "update-monitor-position" to

                                    "update-monitor-position-office".

                                  2. Save it as "update-monitor-position-office.desktop"

                                  3. Touch the permission -> executable by "Me".


                                  update-monitor-position-office.desktop:



                                  [Desktop Entry]
                                  Type=Application
                                  Exec=update-monitor-position-office
                                  Hidden=false
                                  NoDisplay=false
                                  X-GNOME-Autostart-enabled=true
                                  Name[en_US]=Office Monitors Position
                                  Name=Office Monitors Position
                                  Comment[en_US]=Force monitors position from monitor-office.xml
                                  Comment=Force monitors position from monitor-office.xml
                                  Icon=display


                                  Shell script, update-monitor-position-office



                                  #!/bin/bash
                                  # -------------------------------------------------
                                  # Get monitors configuration from monitor.xml and apply it for current user session.
                                  # In case of multiple definitions in monitor.xml only first one is used.
                                  #
                                  # See http://bernaerts.dyndns.org/linux/74-ubuntu/309-ubuntu-dual-display-monitor-position-lost
                                  # for instructions
                                  #
                                  # Parameters :
                                  # $1 : waiting time in sec. before forcing configuration (optional)
                                  #
                                  # Revision history :
                                  # 19/04/2014, V1.0 - Creation by N. Bernaerts
                                  # 10/07/2014, V1.1 - Wait 5 seconds for X to fully initialize
                                  # 01/09/2014, V1.2 - Correct NULL file bug (thanks to Ivan Harmady) and handle rotation
                                  # 07/10/2014, V1.3 - Add monitors size and rate handling (idea from jescalante)
                                  # 08/10/2014, V1.4 - Handle primary display parameter
                                  # 08/12/2014, V1.5 - Waiting time in seconds becomes a parameter
                                  # -------------------------------------------------

                                  # monitor.xml path
                                  MONITOR_XML="$HOME/.config/monitors-office.xml"

                                  # get number of declared monitors
                                  NUM=$(xmllint --xpath 'count(//monitors/configuration['1']/output)' $MONITOR_XML)

                                  # loop thru declared monitors to create the command line parameters
                                  for (( i=1; i<=$NUM; i++)); do
                                  # get attributes of current monitor (name and x & y positions)
                                  NAME=$(xmllint --xpath 'string(//monitors/configuration['1']/output['$i']/@name)' $MONITOR_XML 2>/dev/null)
                                  POS_X=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/x/text()' $MONITOR_XML 2>/dev/null)
                                  POS_Y=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/y/text()' $MONITOR_XML 2>/dev/null)
                                  ROTATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rotation/text()' $MONITOR_XML 2>/dev/null)
                                  WIDTH=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/width/text()' $MONITOR_XML 2>/dev/null)
                                  HEIGHT=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/height/text()' $MONITOR_XML 2>/dev/null)
                                  RATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rate/text()' $MONITOR_XML 2>/dev/null)
                                  PRIMARY=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/primary/text()' $MONITOR_XML 2>/dev/null)

                                  # if position is defined for current monitor, add its position and orientation to command line parameters
                                  [ -n "$POS_X" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--output" "$NAME" "--pos" "${POS_X}x${POS_Y}" "--fbmm" "${WIDTH}x${HEIGHT}" "--rate" "$RATE" "--rotate" "$ROTATE")

                                  # if monitor is defined as primary, adds it to command line parameters
                                  [ "$PRIMARY" = "yes" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--primary")
                                  done

                                  # if needed, wait for some seconds (for X to finish initialisation)
                                  [ -n "$1" ] && sleep $1

                                  # position all monitors
                                  xrandr "${PARAM_ARR[@]}"





                                  share|improve this answer





















                                  • Hey @jey, you answered this in January 2018. (while Nicolas script is 4 years old...). May I assume this is still working under a recent Ubuntu 16.x / 18.x? – And: do you have any assumption, if it would work under Ubuntu-MATE as well? (I do see said monitors.xml on my system...)
                                    – Frank Nocke
                                    Aug 2 at 7:37












                                  • Frank, mine says "16.04.5 LTS". One point, after "dist-upgrade", I had to go through the process, and then reboot. The "System Settings -> Displays" works funny on my system. I am not in the mode to try 18.x. Thanks,
                                    – jay
                                    Aug 3 at 14:33















                                  up vote
                                  1
                                  down vote













                                  At office, I have 3 monitors on my laptop, and 2 at home. Two of office monitors are set vertical, while other monitors are at normal orientation.



                                  A. monitors.xml is in ~/.config.




                                  1. Delete it

                                  2. Set the display at office setup

                                  3. Rename just created "monitors.xml" to "monitors-office.xml".


                                  B. Get shell script, "update-monitor-position".




                                  1. Change the "MONITOR_XML" definition, "monitors.xml" to
                                    "monitors-office.xml".


                                  2. Save it as "update-monitor-position-office", in executable path (/usr/local/sbin/).


                                  3. Touch the permission -> executable by "Me".


                                  C. Get desktop shortcut, "update-monitor-position.desktop"




                                  1. Change "Exec" definition, "update-monitor-position" to

                                    "update-monitor-position-office".

                                  2. Save it as "update-monitor-position-office.desktop"

                                  3. Touch the permission -> executable by "Me".


                                  update-monitor-position-office.desktop:



                                  [Desktop Entry]
                                  Type=Application
                                  Exec=update-monitor-position-office
                                  Hidden=false
                                  NoDisplay=false
                                  X-GNOME-Autostart-enabled=true
                                  Name[en_US]=Office Monitors Position
                                  Name=Office Monitors Position
                                  Comment[en_US]=Force monitors position from monitor-office.xml
                                  Comment=Force monitors position from monitor-office.xml
                                  Icon=display


                                  Shell script, update-monitor-position-office



                                  #!/bin/bash
                                  # -------------------------------------------------
                                  # Get monitors configuration from monitor.xml and apply it for current user session.
                                  # In case of multiple definitions in monitor.xml only first one is used.
                                  #
                                  # See http://bernaerts.dyndns.org/linux/74-ubuntu/309-ubuntu-dual-display-monitor-position-lost
                                  # for instructions
                                  #
                                  # Parameters :
                                  # $1 : waiting time in sec. before forcing configuration (optional)
                                  #
                                  # Revision history :
                                  # 19/04/2014, V1.0 - Creation by N. Bernaerts
                                  # 10/07/2014, V1.1 - Wait 5 seconds for X to fully initialize
                                  # 01/09/2014, V1.2 - Correct NULL file bug (thanks to Ivan Harmady) and handle rotation
                                  # 07/10/2014, V1.3 - Add monitors size and rate handling (idea from jescalante)
                                  # 08/10/2014, V1.4 - Handle primary display parameter
                                  # 08/12/2014, V1.5 - Waiting time in seconds becomes a parameter
                                  # -------------------------------------------------

                                  # monitor.xml path
                                  MONITOR_XML="$HOME/.config/monitors-office.xml"

                                  # get number of declared monitors
                                  NUM=$(xmllint --xpath 'count(//monitors/configuration['1']/output)' $MONITOR_XML)

                                  # loop thru declared monitors to create the command line parameters
                                  for (( i=1; i<=$NUM; i++)); do
                                  # get attributes of current monitor (name and x & y positions)
                                  NAME=$(xmllint --xpath 'string(//monitors/configuration['1']/output['$i']/@name)' $MONITOR_XML 2>/dev/null)
                                  POS_X=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/x/text()' $MONITOR_XML 2>/dev/null)
                                  POS_Y=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/y/text()' $MONITOR_XML 2>/dev/null)
                                  ROTATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rotation/text()' $MONITOR_XML 2>/dev/null)
                                  WIDTH=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/width/text()' $MONITOR_XML 2>/dev/null)
                                  HEIGHT=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/height/text()' $MONITOR_XML 2>/dev/null)
                                  RATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rate/text()' $MONITOR_XML 2>/dev/null)
                                  PRIMARY=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/primary/text()' $MONITOR_XML 2>/dev/null)

                                  # if position is defined for current monitor, add its position and orientation to command line parameters
                                  [ -n "$POS_X" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--output" "$NAME" "--pos" "${POS_X}x${POS_Y}" "--fbmm" "${WIDTH}x${HEIGHT}" "--rate" "$RATE" "--rotate" "$ROTATE")

                                  # if monitor is defined as primary, adds it to command line parameters
                                  [ "$PRIMARY" = "yes" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--primary")
                                  done

                                  # if needed, wait for some seconds (for X to finish initialisation)
                                  [ -n "$1" ] && sleep $1

                                  # position all monitors
                                  xrandr "${PARAM_ARR[@]}"





                                  share|improve this answer





















                                  • Hey @jey, you answered this in January 2018. (while Nicolas script is 4 years old...). May I assume this is still working under a recent Ubuntu 16.x / 18.x? – And: do you have any assumption, if it would work under Ubuntu-MATE as well? (I do see said monitors.xml on my system...)
                                    – Frank Nocke
                                    Aug 2 at 7:37












                                  • Frank, mine says "16.04.5 LTS". One point, after "dist-upgrade", I had to go through the process, and then reboot. The "System Settings -> Displays" works funny on my system. I am not in the mode to try 18.x. Thanks,
                                    – jay
                                    Aug 3 at 14:33













                                  up vote
                                  1
                                  down vote










                                  up vote
                                  1
                                  down vote









                                  At office, I have 3 monitors on my laptop, and 2 at home. Two of office monitors are set vertical, while other monitors are at normal orientation.



                                  A. monitors.xml is in ~/.config.




                                  1. Delete it

                                  2. Set the display at office setup

                                  3. Rename just created "monitors.xml" to "monitors-office.xml".


                                  B. Get shell script, "update-monitor-position".




                                  1. Change the "MONITOR_XML" definition, "monitors.xml" to
                                    "monitors-office.xml".


                                  2. Save it as "update-monitor-position-office", in executable path (/usr/local/sbin/).


                                  3. Touch the permission -> executable by "Me".


                                  C. Get desktop shortcut, "update-monitor-position.desktop"




                                  1. Change "Exec" definition, "update-monitor-position" to

                                    "update-monitor-position-office".

                                  2. Save it as "update-monitor-position-office.desktop"

                                  3. Touch the permission -> executable by "Me".


                                  update-monitor-position-office.desktop:



                                  [Desktop Entry]
                                  Type=Application
                                  Exec=update-monitor-position-office
                                  Hidden=false
                                  NoDisplay=false
                                  X-GNOME-Autostart-enabled=true
                                  Name[en_US]=Office Monitors Position
                                  Name=Office Monitors Position
                                  Comment[en_US]=Force monitors position from monitor-office.xml
                                  Comment=Force monitors position from monitor-office.xml
                                  Icon=display


                                  Shell script, update-monitor-position-office



                                  #!/bin/bash
                                  # -------------------------------------------------
                                  # Get monitors configuration from monitor.xml and apply it for current user session.
                                  # In case of multiple definitions in monitor.xml only first one is used.
                                  #
                                  # See http://bernaerts.dyndns.org/linux/74-ubuntu/309-ubuntu-dual-display-monitor-position-lost
                                  # for instructions
                                  #
                                  # Parameters :
                                  # $1 : waiting time in sec. before forcing configuration (optional)
                                  #
                                  # Revision history :
                                  # 19/04/2014, V1.0 - Creation by N. Bernaerts
                                  # 10/07/2014, V1.1 - Wait 5 seconds for X to fully initialize
                                  # 01/09/2014, V1.2 - Correct NULL file bug (thanks to Ivan Harmady) and handle rotation
                                  # 07/10/2014, V1.3 - Add monitors size and rate handling (idea from jescalante)
                                  # 08/10/2014, V1.4 - Handle primary display parameter
                                  # 08/12/2014, V1.5 - Waiting time in seconds becomes a parameter
                                  # -------------------------------------------------

                                  # monitor.xml path
                                  MONITOR_XML="$HOME/.config/monitors-office.xml"

                                  # get number of declared monitors
                                  NUM=$(xmllint --xpath 'count(//monitors/configuration['1']/output)' $MONITOR_XML)

                                  # loop thru declared monitors to create the command line parameters
                                  for (( i=1; i<=$NUM; i++)); do
                                  # get attributes of current monitor (name and x & y positions)
                                  NAME=$(xmllint --xpath 'string(//monitors/configuration['1']/output['$i']/@name)' $MONITOR_XML 2>/dev/null)
                                  POS_X=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/x/text()' $MONITOR_XML 2>/dev/null)
                                  POS_Y=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/y/text()' $MONITOR_XML 2>/dev/null)
                                  ROTATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rotation/text()' $MONITOR_XML 2>/dev/null)
                                  WIDTH=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/width/text()' $MONITOR_XML 2>/dev/null)
                                  HEIGHT=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/height/text()' $MONITOR_XML 2>/dev/null)
                                  RATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rate/text()' $MONITOR_XML 2>/dev/null)
                                  PRIMARY=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/primary/text()' $MONITOR_XML 2>/dev/null)

                                  # if position is defined for current monitor, add its position and orientation to command line parameters
                                  [ -n "$POS_X" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--output" "$NAME" "--pos" "${POS_X}x${POS_Y}" "--fbmm" "${WIDTH}x${HEIGHT}" "--rate" "$RATE" "--rotate" "$ROTATE")

                                  # if monitor is defined as primary, adds it to command line parameters
                                  [ "$PRIMARY" = "yes" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--primary")
                                  done

                                  # if needed, wait for some seconds (for X to finish initialisation)
                                  [ -n "$1" ] && sleep $1

                                  # position all monitors
                                  xrandr "${PARAM_ARR[@]}"





                                  share|improve this answer












                                  At office, I have 3 monitors on my laptop, and 2 at home. Two of office monitors are set vertical, while other monitors are at normal orientation.



                                  A. monitors.xml is in ~/.config.




                                  1. Delete it

                                  2. Set the display at office setup

                                  3. Rename just created "monitors.xml" to "monitors-office.xml".


                                  B. Get shell script, "update-monitor-position".




                                  1. Change the "MONITOR_XML" definition, "monitors.xml" to
                                    "monitors-office.xml".


                                  2. Save it as "update-monitor-position-office", in executable path (/usr/local/sbin/).


                                  3. Touch the permission -> executable by "Me".


                                  C. Get desktop shortcut, "update-monitor-position.desktop"




                                  1. Change "Exec" definition, "update-monitor-position" to

                                    "update-monitor-position-office".

                                  2. Save it as "update-monitor-position-office.desktop"

                                  3. Touch the permission -> executable by "Me".


                                  update-monitor-position-office.desktop:



                                  [Desktop Entry]
                                  Type=Application
                                  Exec=update-monitor-position-office
                                  Hidden=false
                                  NoDisplay=false
                                  X-GNOME-Autostart-enabled=true
                                  Name[en_US]=Office Monitors Position
                                  Name=Office Monitors Position
                                  Comment[en_US]=Force monitors position from monitor-office.xml
                                  Comment=Force monitors position from monitor-office.xml
                                  Icon=display


                                  Shell script, update-monitor-position-office



                                  #!/bin/bash
                                  # -------------------------------------------------
                                  # Get monitors configuration from monitor.xml and apply it for current user session.
                                  # In case of multiple definitions in monitor.xml only first one is used.
                                  #
                                  # See http://bernaerts.dyndns.org/linux/74-ubuntu/309-ubuntu-dual-display-monitor-position-lost
                                  # for instructions
                                  #
                                  # Parameters :
                                  # $1 : waiting time in sec. before forcing configuration (optional)
                                  #
                                  # Revision history :
                                  # 19/04/2014, V1.0 - Creation by N. Bernaerts
                                  # 10/07/2014, V1.1 - Wait 5 seconds for X to fully initialize
                                  # 01/09/2014, V1.2 - Correct NULL file bug (thanks to Ivan Harmady) and handle rotation
                                  # 07/10/2014, V1.3 - Add monitors size and rate handling (idea from jescalante)
                                  # 08/10/2014, V1.4 - Handle primary display parameter
                                  # 08/12/2014, V1.5 - Waiting time in seconds becomes a parameter
                                  # -------------------------------------------------

                                  # monitor.xml path
                                  MONITOR_XML="$HOME/.config/monitors-office.xml"

                                  # get number of declared monitors
                                  NUM=$(xmllint --xpath 'count(//monitors/configuration['1']/output)' $MONITOR_XML)

                                  # loop thru declared monitors to create the command line parameters
                                  for (( i=1; i<=$NUM; i++)); do
                                  # get attributes of current monitor (name and x & y positions)
                                  NAME=$(xmllint --xpath 'string(//monitors/configuration['1']/output['$i']/@name)' $MONITOR_XML 2>/dev/null)
                                  POS_X=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/x/text()' $MONITOR_XML 2>/dev/null)
                                  POS_Y=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/y/text()' $MONITOR_XML 2>/dev/null)
                                  ROTATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rotation/text()' $MONITOR_XML 2>/dev/null)
                                  WIDTH=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/width/text()' $MONITOR_XML 2>/dev/null)
                                  HEIGHT=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/height/text()' $MONITOR_XML 2>/dev/null)
                                  RATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rate/text()' $MONITOR_XML 2>/dev/null)
                                  PRIMARY=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/primary/text()' $MONITOR_XML 2>/dev/null)

                                  # if position is defined for current monitor, add its position and orientation to command line parameters
                                  [ -n "$POS_X" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--output" "$NAME" "--pos" "${POS_X}x${POS_Y}" "--fbmm" "${WIDTH}x${HEIGHT}" "--rate" "$RATE" "--rotate" "$ROTATE")

                                  # if monitor is defined as primary, adds it to command line parameters
                                  [ "$PRIMARY" = "yes" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--primary")
                                  done

                                  # if needed, wait for some seconds (for X to finish initialisation)
                                  [ -n "$1" ] && sleep $1

                                  # position all monitors
                                  xrandr "${PARAM_ARR[@]}"






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Jan 8 at 15:22









                                  jay

                                  111




                                  111












                                  • Hey @jey, you answered this in January 2018. (while Nicolas script is 4 years old...). May I assume this is still working under a recent Ubuntu 16.x / 18.x? – And: do you have any assumption, if it would work under Ubuntu-MATE as well? (I do see said monitors.xml on my system...)
                                    – Frank Nocke
                                    Aug 2 at 7:37












                                  • Frank, mine says "16.04.5 LTS". One point, after "dist-upgrade", I had to go through the process, and then reboot. The "System Settings -> Displays" works funny on my system. I am not in the mode to try 18.x. Thanks,
                                    – jay
                                    Aug 3 at 14:33


















                                  • Hey @jey, you answered this in January 2018. (while Nicolas script is 4 years old...). May I assume this is still working under a recent Ubuntu 16.x / 18.x? – And: do you have any assumption, if it would work under Ubuntu-MATE as well? (I do see said monitors.xml on my system...)
                                    – Frank Nocke
                                    Aug 2 at 7:37












                                  • Frank, mine says "16.04.5 LTS". One point, after "dist-upgrade", I had to go through the process, and then reboot. The "System Settings -> Displays" works funny on my system. I am not in the mode to try 18.x. Thanks,
                                    – jay
                                    Aug 3 at 14:33
















                                  Hey @jey, you answered this in January 2018. (while Nicolas script is 4 years old...). May I assume this is still working under a recent Ubuntu 16.x / 18.x? – And: do you have any assumption, if it would work under Ubuntu-MATE as well? (I do see said monitors.xml on my system...)
                                  – Frank Nocke
                                  Aug 2 at 7:37






                                  Hey @jey, you answered this in January 2018. (while Nicolas script is 4 years old...). May I assume this is still working under a recent Ubuntu 16.x / 18.x? – And: do you have any assumption, if it would work under Ubuntu-MATE as well? (I do see said monitors.xml on my system...)
                                  – Frank Nocke
                                  Aug 2 at 7:37














                                  Frank, mine says "16.04.5 LTS". One point, after "dist-upgrade", I had to go through the process, and then reboot. The "System Settings -> Displays" works funny on my system. I am not in the mode to try 18.x. Thanks,
                                  – jay
                                  Aug 3 at 14:33




                                  Frank, mine says "16.04.5 LTS". One point, after "dist-upgrade", I had to go through the process, and then reboot. The "System Settings -> Displays" works funny on my system. I am not in the mode to try 18.x. Thanks,
                                  – jay
                                  Aug 3 at 14:33










                                  up vote
                                  1
                                  down vote













                                  jay's answer almost worked for me, but I needed to do a couple extra steps. I'd make this a comment on his answer but I don't have the reputation.



                                  In the file update-monitor-position-office:




                                  1. My version of bash (4.3.48) complained about the lack of a space following "i++" on line 28.

                                  2. My version of xrandr (1.5) did not recognize the "--fbmm" option on line 40. I had to change this to "--mode". This was hard to diagnose because xrandr did not actually give me an error, it just executed the command without doing anything.






                                  share|improve this answer








                                  New contributor




                                  Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.






















                                    up vote
                                    1
                                    down vote













                                    jay's answer almost worked for me, but I needed to do a couple extra steps. I'd make this a comment on his answer but I don't have the reputation.



                                    In the file update-monitor-position-office:




                                    1. My version of bash (4.3.48) complained about the lack of a space following "i++" on line 28.

                                    2. My version of xrandr (1.5) did not recognize the "--fbmm" option on line 40. I had to change this to "--mode". This was hard to diagnose because xrandr did not actually give me an error, it just executed the command without doing anything.






                                    share|improve this answer








                                    New contributor




                                    Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.




















                                      up vote
                                      1
                                      down vote










                                      up vote
                                      1
                                      down vote









                                      jay's answer almost worked for me, but I needed to do a couple extra steps. I'd make this a comment on his answer but I don't have the reputation.



                                      In the file update-monitor-position-office:




                                      1. My version of bash (4.3.48) complained about the lack of a space following "i++" on line 28.

                                      2. My version of xrandr (1.5) did not recognize the "--fbmm" option on line 40. I had to change this to "--mode". This was hard to diagnose because xrandr did not actually give me an error, it just executed the command without doing anything.






                                      share|improve this answer








                                      New contributor




                                      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.









                                      jay's answer almost worked for me, but I needed to do a couple extra steps. I'd make this a comment on his answer but I don't have the reputation.



                                      In the file update-monitor-position-office:




                                      1. My version of bash (4.3.48) complained about the lack of a space following "i++" on line 28.

                                      2. My version of xrandr (1.5) did not recognize the "--fbmm" option on line 40. I had to change this to "--mode". This was hard to diagnose because xrandr did not actually give me an error, it just executed the command without doing anything.







                                      share|improve this answer








                                      New contributor




                                      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.









                                      share|improve this answer



                                      share|improve this answer






                                      New contributor




                                      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.









                                      answered Nov 13 at 22:27









                                      Chris

                                      111




                                      111




                                      New contributor




                                      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.





                                      New contributor





                                      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.






                                      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.






















                                          up vote
                                          1
                                          down vote













                                          I prefer to run this script from a terminal since I open one first after login.



                                          First login with the bad configuration - monitors not placed correctly:



                                          cd ~/.config
                                          mv ~/.config/monitors.xml{,.bak}


                                          Now set your monitors with system settings to create a new ~/.config/monitors.xml file with proper settings.



                                          Copy Nicolas Bernaerts's fixed script from my repo: https://raw.githubusercontent.com/alextomko/monitors/master/monitors and put it in a path to run from terminal.



                                          $ ls -l ~/bin
                                          # if you don't have this directory then create it - do not be logged in as root here.

                                          $ mkdir /home/$USER/bin

                                          $ echo $PATH
                                          # should show /home/username/bin if the dir existed or if you had to create.

                                          $ wget -P ~/bin https://raw.githubusercontent.com/alextomko/monitors/master/monitors
                                          $ chmod +x ~/bin/monitors

                                          # Log out, lock, reboot or whatever it takes to make monitor settings lost for you and run the script.
                                          $ monitors





                                          share|improve this answer



























                                            up vote
                                            1
                                            down vote













                                            I prefer to run this script from a terminal since I open one first after login.



                                            First login with the bad configuration - monitors not placed correctly:



                                            cd ~/.config
                                            mv ~/.config/monitors.xml{,.bak}


                                            Now set your monitors with system settings to create a new ~/.config/monitors.xml file with proper settings.



                                            Copy Nicolas Bernaerts's fixed script from my repo: https://raw.githubusercontent.com/alextomko/monitors/master/monitors and put it in a path to run from terminal.



                                            $ ls -l ~/bin
                                            # if you don't have this directory then create it - do not be logged in as root here.

                                            $ mkdir /home/$USER/bin

                                            $ echo $PATH
                                            # should show /home/username/bin if the dir existed or if you had to create.

                                            $ wget -P ~/bin https://raw.githubusercontent.com/alextomko/monitors/master/monitors
                                            $ chmod +x ~/bin/monitors

                                            # Log out, lock, reboot or whatever it takes to make monitor settings lost for you and run the script.
                                            $ monitors





                                            share|improve this answer

























                                              up vote
                                              1
                                              down vote










                                              up vote
                                              1
                                              down vote









                                              I prefer to run this script from a terminal since I open one first after login.



                                              First login with the bad configuration - monitors not placed correctly:



                                              cd ~/.config
                                              mv ~/.config/monitors.xml{,.bak}


                                              Now set your monitors with system settings to create a new ~/.config/monitors.xml file with proper settings.



                                              Copy Nicolas Bernaerts's fixed script from my repo: https://raw.githubusercontent.com/alextomko/monitors/master/monitors and put it in a path to run from terminal.



                                              $ ls -l ~/bin
                                              # if you don't have this directory then create it - do not be logged in as root here.

                                              $ mkdir /home/$USER/bin

                                              $ echo $PATH
                                              # should show /home/username/bin if the dir existed or if you had to create.

                                              $ wget -P ~/bin https://raw.githubusercontent.com/alextomko/monitors/master/monitors
                                              $ chmod +x ~/bin/monitors

                                              # Log out, lock, reboot or whatever it takes to make monitor settings lost for you and run the script.
                                              $ monitors





                                              share|improve this answer














                                              I prefer to run this script from a terminal since I open one first after login.



                                              First login with the bad configuration - monitors not placed correctly:



                                              cd ~/.config
                                              mv ~/.config/monitors.xml{,.bak}


                                              Now set your monitors with system settings to create a new ~/.config/monitors.xml file with proper settings.



                                              Copy Nicolas Bernaerts's fixed script from my repo: https://raw.githubusercontent.com/alextomko/monitors/master/monitors and put it in a path to run from terminal.



                                              $ ls -l ~/bin
                                              # if you don't have this directory then create it - do not be logged in as root here.

                                              $ mkdir /home/$USER/bin

                                              $ echo $PATH
                                              # should show /home/username/bin if the dir existed or if you had to create.

                                              $ wget -P ~/bin https://raw.githubusercontent.com/alextomko/monitors/master/monitors
                                              $ chmod +x ~/bin/monitors

                                              # Log out, lock, reboot or whatever it takes to make monitor settings lost for you and run the script.
                                              $ monitors






                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited 2 days ago

























                                              answered Nov 14 at 22:41









                                              Alex Tomko

                                              1113




                                              1113






















                                                  up vote
                                                  0
                                                  down vote













                                                  No, there's no way to save configurations on hot-plugged monitors. If you plug in before boot, GNOME should remember the configuration on each boot on a per-device basis (ie, connecting to your monitor at work versus the one at home).






                                                  share|improve this answer





















                                                  • Damn, ok. Is there a third party application than can do this? I know Mac OS X does this, and Windows 7 (from what I've tried with the little experience I have with W7).
                                                    – Oscar Godson
                                                    Oct 11 '10 at 21:16










                                                  • The GNOME monitor configuration should save this information for hotplugged monitors, too. It does for me.
                                                    – RAOF
                                                    Oct 11 '10 at 23:11










                                                  • RAOF: weird, since discussion on the ubuntu-devel mailing list earlier this week said it doesn't.
                                                    – maco
                                                    Oct 11 '10 at 23:31










                                                  • the configuration is actually saved in ~/.config/monitors.xml, but it is not applied at startup
                                                    – Alessandro Cuttin
                                                    Jan 4 '16 at 9:04















                                                  up vote
                                                  0
                                                  down vote













                                                  No, there's no way to save configurations on hot-plugged monitors. If you plug in before boot, GNOME should remember the configuration on each boot on a per-device basis (ie, connecting to your monitor at work versus the one at home).






                                                  share|improve this answer





















                                                  • Damn, ok. Is there a third party application than can do this? I know Mac OS X does this, and Windows 7 (from what I've tried with the little experience I have with W7).
                                                    – Oscar Godson
                                                    Oct 11 '10 at 21:16










                                                  • The GNOME monitor configuration should save this information for hotplugged monitors, too. It does for me.
                                                    – RAOF
                                                    Oct 11 '10 at 23:11










                                                  • RAOF: weird, since discussion on the ubuntu-devel mailing list earlier this week said it doesn't.
                                                    – maco
                                                    Oct 11 '10 at 23:31










                                                  • the configuration is actually saved in ~/.config/monitors.xml, but it is not applied at startup
                                                    – Alessandro Cuttin
                                                    Jan 4 '16 at 9:04













                                                  up vote
                                                  0
                                                  down vote










                                                  up vote
                                                  0
                                                  down vote









                                                  No, there's no way to save configurations on hot-plugged monitors. If you plug in before boot, GNOME should remember the configuration on each boot on a per-device basis (ie, connecting to your monitor at work versus the one at home).






                                                  share|improve this answer












                                                  No, there's no way to save configurations on hot-plugged monitors. If you plug in before boot, GNOME should remember the configuration on each boot on a per-device basis (ie, connecting to your monitor at work versus the one at home).







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Oct 11 '10 at 21:12









                                                  maco

                                                  12.4k32334




                                                  12.4k32334












                                                  • Damn, ok. Is there a third party application than can do this? I know Mac OS X does this, and Windows 7 (from what I've tried with the little experience I have with W7).
                                                    – Oscar Godson
                                                    Oct 11 '10 at 21:16










                                                  • The GNOME monitor configuration should save this information for hotplugged monitors, too. It does for me.
                                                    – RAOF
                                                    Oct 11 '10 at 23:11










                                                  • RAOF: weird, since discussion on the ubuntu-devel mailing list earlier this week said it doesn't.
                                                    – maco
                                                    Oct 11 '10 at 23:31










                                                  • the configuration is actually saved in ~/.config/monitors.xml, but it is not applied at startup
                                                    – Alessandro Cuttin
                                                    Jan 4 '16 at 9:04


















                                                  • Damn, ok. Is there a third party application than can do this? I know Mac OS X does this, and Windows 7 (from what I've tried with the little experience I have with W7).
                                                    – Oscar Godson
                                                    Oct 11 '10 at 21:16










                                                  • The GNOME monitor configuration should save this information for hotplugged monitors, too. It does for me.
                                                    – RAOF
                                                    Oct 11 '10 at 23:11










                                                  • RAOF: weird, since discussion on the ubuntu-devel mailing list earlier this week said it doesn't.
                                                    – maco
                                                    Oct 11 '10 at 23:31










                                                  • the configuration is actually saved in ~/.config/monitors.xml, but it is not applied at startup
                                                    – Alessandro Cuttin
                                                    Jan 4 '16 at 9:04
















                                                  Damn, ok. Is there a third party application than can do this? I know Mac OS X does this, and Windows 7 (from what I've tried with the little experience I have with W7).
                                                  – Oscar Godson
                                                  Oct 11 '10 at 21:16




                                                  Damn, ok. Is there a third party application than can do this? I know Mac OS X does this, and Windows 7 (from what I've tried with the little experience I have with W7).
                                                  – Oscar Godson
                                                  Oct 11 '10 at 21:16












                                                  The GNOME monitor configuration should save this information for hotplugged monitors, too. It does for me.
                                                  – RAOF
                                                  Oct 11 '10 at 23:11




                                                  The GNOME monitor configuration should save this information for hotplugged monitors, too. It does for me.
                                                  – RAOF
                                                  Oct 11 '10 at 23:11












                                                  RAOF: weird, since discussion on the ubuntu-devel mailing list earlier this week said it doesn't.
                                                  – maco
                                                  Oct 11 '10 at 23:31




                                                  RAOF: weird, since discussion on the ubuntu-devel mailing list earlier this week said it doesn't.
                                                  – maco
                                                  Oct 11 '10 at 23:31












                                                  the configuration is actually saved in ~/.config/monitors.xml, but it is not applied at startup
                                                  – Alessandro Cuttin
                                                  Jan 4 '16 at 9:04




                                                  the configuration is actually saved in ~/.config/monitors.xml, but it is not applied at startup
                                                  – Alessandro Cuttin
                                                  Jan 4 '16 at 9:04


















                                                   

                                                  draft saved


                                                  draft discarded



















































                                                   


                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f6137%2fsaving-monitor-settings%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

                                                  Quarter-circle Tiles

                                                  build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                                                  Mont Emei