How to make ARandR changes default?

Forum Forums New users New Users and General Questions How to make ARandR changes default?

  • This topic has 8 replies, 5 voices, and was last updated Dec 30-11:49 pm by BobC.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #47956
    Member
    wb8tyw

      I can set the proper profile for my laptop the external monitor using ARandR.

      And I can save the profile, which I can load and activate after login.

      What I can not find is how to set it up as the default configuration both for when I boot the laptop or when I login to the laptop.

      #47960
      Member
      sybok
        Helpful
        Up
        0
        ::

        Hi, what can be done is to
        1) Use command-line interface (CLI) ‘xrandr’, combine all the commands into a BASH script ‘~/desktop-session/custom_xrandr_setting.sh’
        I’ve briefly checked the man-page (‘man xrandr’) and did not find an option to load existing profile.
        Feel free to verify it.
        2) Add a line
        bash ~/desktop-session/custom_xrandr_setting.sh
        that will call this script into ‘~/desktop-session/startup’

        Perhaps, someone will be able to provide a simpler method.

        Comments:
        C-1) Maybe (wishful thinking), the ‘xrandr’ commands are in the stored profile.
        EDIT: BobC’s later comment sort-of verifies it, you can use the code he posted.
        C-2) Example of a BASH script to set a resolution on a VGA monitor:

        #!/bin/bash
        
        # One could use the below output to check whether any external monitor is connected:
        #xrandr --listactivemonitors 
        #echo "$(xrandr --listactivemonitors | grep '^Monitors:' | head -1 | awk -F':' ' { print $2 } ')" #<-- number of monitors?
        
        cvt 1152 864 60
        xrandr --newmode '1152x864_60.00' 81.75  1152 1216 1336 1520  864 867 871 897 -hsync +vsync
        xrandr --addmode VGA-0 1152x864_60.00
        xrandr --output VGA-0 --mode 1152x864_60.00
        • This reply was modified 2 years, 4 months ago by sybok. Reason: Formatting fixed
        • This reply was modified 2 years, 4 months ago by sybok.
        • This reply was modified 2 years, 4 months ago by sybok. Reason: Edit based on BobC's comment
        #47965
        Moderator
        BobC
          Helpful
          Up
          0
          ::

          Here is what I use:

          The arandr code gets added to ~/.desktop-session startup near the top (after I set the path). When you go into arandr, change the setup to the way you want it, and apply, then save it to $HOME/.screenlayout/default.sh. From then on, the system will run that script to set it up that way when you reboot or login.

          I also included my other tweaks I have there to add my own bin directory to the path (be careful only to put known good program there) and check for internet connection/help fix it if none, and set the time. PPC made the internet connection one very nice.

          #!/bin/bash
          
          # set PATH so it includes user's private bin if it exists
          if [ -d "$HOME/bin" ] ; then
              # Add $HOME/bin directory to PATH if not already there.
              [ -z "${PATH##*$HOME/bin*}" ] || PATH=$HOME/bin:$PATH
          fi
          
          # set screen resolution to my default
          if [ -x "$HOME/.screenlayout/default.sh" ] ; then
          	(sleep 3 && . $HOME/.screenlayout/default.sh && sleep 3)
          else
          	if [ ! -d "$HOME/.screenlayout" ] ; then
          		mkdir $HOME/.screenlayout
          	fi
          	echo "" > $HOME/.screenlayout/default.sh && chmod +x $HOME/.screenlayout/default.sh
          	# fix HiDPI screen if necessary
          	cd $HOME/.screenlayout
          	arandr
          	cd $HOME
          fi
          
          ##Check for connectivity. If no network connection is detected, activate wi-fi networks, open connman and go straight to the wi-fi connections tab...
          connected_addr=$(ip addr | grep "inet " | sed '/ scope host /d')
          if [ -z "$connected_addr" ]; then
             sleep 2
             pkill cmst
             connmanctl enable wifi && cmst -d & sleep 1 && xdotool key Alt+w
             else
             echo 'Network connection detected, no need to configure anything'
          fi
          
          # update time
          sudo ntpdate pool.ntp.org &
          
          #47973
          Member
          ex_Koo
            Helpful
            Up
            0
            ::

            Have a look at this video..
            https://www.youtube.com/watch?v=MfgkyQrtm5g

            Or this

            https://www.youtube.com/watch?v=IMJuuQXDNN0

            • This reply was modified 2 years, 4 months ago by ex_Koo.
            #48013
            Member
            PPC
              Helpful
              Up
              0
              ::

              Off topic:

              PPC made the internet connection one very nice.

              Hey Bob, could you please test my upgraded network detection script (it does not launch connman gui if no wifi hardware was detected- handy for non wi-fi capable desktops)

              
              ##Check for connectivity. If no network connection is detected, try to activate wi-fi networks, then, if wifi capable hardware is detected, open connman and go straight to the wi-fi connections tab...
              connected_addr=$(ip addr | grep "inet " | sed '/ scope host /d')
              if [ -z "$connected_addr" ]; then
                 sleep 2
                 pkill cmst
                 connmanctl enable wifi 
                  ##only try to configure wifi network if the right hardware was detected, if not, do nothing:
              	connmanctl technologies | grep '/net/connman/technology/wifi' &> /dev/null
              	if [ $? == 0 ]; then
              			echo "Wi-fi hardware detected- configure your connection using the GUI" && cmst -d & sleep 1 && xdotool key Alt+w
              	 else echo "No wi-fi hardware detected"
              	fi
                 else
              	echo 'No need to configure anything-  network was already detected'
              fi

              Happy holidays, everyone
              P.

              • This reply was modified 2 years, 4 months ago by PPC.
              #48019
              Moderator
              BobC
                Helpful
                Up
                0
                ::

                PPC, Sure, I’d be happy to test something new, but we don’t know if the user has hard wired internet available or a wifi hub or whatever, so the reason why I popped the program itself up anytime there was no connection was to make it so I would know there was no connection and make it easy to figure out/decide what to do at that point rather than have other things failing. You are correct that it will do no good to enable wifi or go to the wifi tab if there is no wifi. Some people might need to connect via another method, but in my case it might be that I need to plug it in 🙂

                Your thoughts?

                My thoughts…

                ##Check for connectivity. If no network connection is detected, try to activate wi-fi networks, then, if wifi capable hardware is detected, open connman and go straight to the wi-fi connections tab...
                connected_addr=$(ip addr | grep "inet " | sed '/ scope host /d')
                if [ -z "$connected_addr" ]; then
                   sleep 2
                   pkill cmst
                   connmanctl enable wifi 
                    ##only try to configure wifi network if the right hardware was detected, if not, do nothing:
                	connmanctl technologies | grep '/net/connman/technology/wifi' &> /dev/null
                	if [ $? == 0 ]; then
                			echo "Wi-fi hardware detected- configure your connection using the GUI" && cmst -d & sleep 1 && xdotool key Alt+w
                	 else 
                		echo "No wi-fi hardware detected, have you got another way to connect?"
                		cmst -d & 
                	fi
                else
                	echo 'No need to configure anything-  network was already detected'
                fi
                • This reply was modified 2 years, 4 months ago by BobC.
                #48024
                Moderator
                BobC
                  Helpful
                  Up
                  0
                  ::

                  BTW, wb8tyw, Do you have any 4K very high resolution screens? They don’t work quite right currently unless the are configured correctly, but we are testing a fix for that.

                  #48267
                  Member
                  wb8tyw
                    Helpful
                    Up
                    0
                    ::

                    With that script, things are working after login.

                    Before login, the default configuration is used, which is not real useful of a default.

                    The remaining problem is that before login, the second screen is assumed to be on the left side of the laptop monitor, and is also apparently defined as the default monitor.

                    That would not be so bad, but the login box, instead of being centered on the laptop monitor as would be expected, has the left half with the text prompts on the right side of the external monitor on the right side the box where you type in data on the left edge of the laptop monitor.

                    This laptop is too old to support UHD displays.

                    As far as networking goes I have two sub networks behind NAT Wifi routers. The main network is wired to the laptop, the Wifi is connected to the second network which when the laptop is at home is primarily used for network attached storage. The second network is currently NATed to the primary NATed network. I am not sure that long term I will keep that second NAT connection, right now it is mainly used so that I can access that NAT Wifi router from the primary network.

                    #48576
                    Moderator
                    BobC
                      Helpful
                      Up
                      0
                      ::

                      Yes, the latest update includes a fix for the login being split between 2 screens. I had that problems too. It will put the login prompt at the top left of whatever monitor your system has as being on the left initially. It won’t switch the screens before login, sorry, because the process that does the switching doesn’t run till afterwards. Try updating your packages today and watch to see if “slim” related ones get updated. You can test it afterwards by doing a Logout.

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • You must be logged in to reply to this topic.