How to use properly xrandr to get the appropriate resolution on both monitors

mike_linux

Member
Joined
Nov 20, 2020
Messages
56
Reaction score
39
Credits
556
Hello, I have two monitors with the following resolutions:
1. DELL 3840x2160
2. HP 3440x1440
and I am using Ubuntu 18.04.LTS.

Both monitors are aligned such that the DELL monitor is my main monitor on the left and the Dell monitor is on the right. When I am working on my main monitor and setup the resolution so that it looks good, when I push for example the file explorer to the right monitor the font gets really big. After searching via google I have found that there is a program called xrandr which fixes
this problem and that gets described here archlinux. Because I don't want to get a wired behavior I would like to ask you before I issue the following command xrandr --output "DVI-D-0" --auto --output "HDMI-0" --right-of "DVI-D-0", which I got based on this video How To Use Multiple Monitors On Linux (With Xrandr). Is this the right one?. Thank you for your help.

OUTPUT OF XRANDR
Bash:
[email protected]:~$ xrandr
Screen 0: minimum 8 x 8, current 7280 x 2160, maximum 32767 x 32767
DVI-D-0 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
   3840x2160     30.00*+  29.97    25.00    23.98 
   1920x1200     59.88 
   1920x1080     60.00    60.00    59.94    50.00    23.98    60.05    60.00    50.04 
   1680x1050     59.95 
   1600x1200     60.00 
   1280x1024     75.02    60.02 
   1280x800      59.81 
   1280x720      60.00    59.94    50.00 
   1152x864      75.00 
   1024x768      75.03    60.00 
   800x600       75.00    60.32 
   720x576       50.00 
   720x480       59.94 
   640x480       75.00    59.93    59.94 
HDMI-0 connected 3440x1440+3840+0 (normal left inverted right x axis y axis) 797mm x 333mm
   3440x1440     59.94*+  99.98    29.95    24.97 
   1920x1200     59.88 
   1920x1080     60.00    59.94    50.00    60.00    50.04 
   1680x1050     59.95 
   1600x1200     60.00 
   1600x900      60.00 
   1440x900      59.89 
   1280x1024     60.02 
   1280x720      60.00    59.94    50.00 
   1024x768      60.00 
   800x600       60.32 
   720x576       50.00 
   720x480       59.94 
   640x480       59.94    59.93 
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 disconnected (normal left inverted right x axis y axis)
[email protected]:~$
 


OP
mike_linux

mike_linux

Member
Joined
Nov 20, 2020
Messages
56
Reaction score
39
Credits
556
Hello again folks, I have figured it out by myself :). Using the following command I am able to adjust the monitor resolution based on the resolution of each monitor. The scaling factor I used is based on my monitor properties, but you can adjust it based on yours. For example, lowering the scale to 1.25x1.25 adjusts the resolution much lower.
Code:
xrandr --output DVI-D-0 --auto --output HDMI-0 --auto --scale 1.65x1.65 --right-of DVI-D-0

The only problem I have is that I do not know which file to edit to make this change permanently. I have tried to edit the ~/.bashrc file based on this post Making xrandr settings permanent, but it doesn't work (the right monitor keeps black). If someone knows the right place to edit please help me out. THX.
 

stan

Well-Known Member
Joined
Mar 19, 2018
Messages
985
Reaction score
1,105
Credits
9,112
I have tried to edit the ~/.bashrc file
Hi Mike. Yeah, I don't think .bashrc is the right tool. That file is used when you open a terminal, not when you boot into your desktop. Glad you found the right xrandr command... nice work!

With Linux, there are usually at least a couple of ways to do things. Maybe a couple of dozen ways! ;) I think that I would make a Bash script with your xrandr command. Give it a name, such as mon2.sh (for "monitor 2"... any name you want but I would avoid spaces in the filename). Make the script executable with sudo chmod +x mon2.sh. Test it from a terminal to be sure it works, using ./mon2.sh.

If all is good, you can call the script from rc.local, or with crontab, or with Ubuntu's "Startup Applications" app. Some examples to show you these three methods are here and here (video).
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
6,633
Reaction score
5,396
Credits
19,688
Love it when they get it sorted themselves, I can put in for a redundancy payment ;)

are aligned such that the DELL monitor is my main monitor on the left and the Dell monitor is on the right.

BTW Mike - above confuses a little, is one of those the HP?

Avagudweegend

Wizard
 

stan

Well-Known Member
Joined
Mar 19, 2018
Messages
985
Reaction score
1,105
Credits
9,112
With a little more Googling, maybe rc.local is not a very good choice, Mike, and especially with a systemd-based OS like Ubuntu. Probably the graphical "Startup Applications" is the best choice.

Keep your xrandr notes in a file that is saved somewhere for future need, like when you upgrade to 20.04. :)
 

stan

Well-Known Member
Joined
Mar 19, 2018
Messages
985
Reaction score
1,105
Credits
9,112
Just to be clear, you don't need to store your script in the same location as the video shows other built in user apps. So you can probably stop watching the video after about 1 minute. :)

Just keep the script in your home folder. Or if you want a special location, maybe create ~/scripts/. Whatever location you use, just use that in the Startup Applications config. To be safe, give it the full path, like /home/mike/mon2.sh or /home/mike/scripts/mon2.sh.

Keeping stuff like that in your home folder helps to make sure that it gets backed up later and not forgotten if stored someplace weird. :)
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,321
Reaction score
1,870
Credits
8,343
You could add those xrandr commands to a file in your home directory called:
~/.xsession or maybe ~/.xprofile

That should set xrandr whenever you log into any desktop session.
There are a few other options, but I’m away from home this weekend, without my laptop....

I’ll try to revisit this when I get home and will see what I can come up with. In the meantime, try my initial suggestion and see if that works for you...
 
OP
mike_linux

mike_linux

Member
Joined
Nov 20, 2020
Messages
56
Reaction score
39
Credits
556
Hi guys, nice :),

Just to be clear, you don't need to store your script in the same location as the video shows other built in user apps. So you can probably stop watching the video after about 1 minute. :)
THX @stan I will try that sounds like a good solution. You're right the bashrch file is only for terminal purposes (stupid that I did not recognize that).

Love it when they get it sorted themselves, I can put in for a redundancy payment ;)
@wizardfromoz Haha, that sounds good :).

BTW Mike - above confuses a little, is one of those the HP?
@wizardfromoz The left monitor is the Dell one and the right monitor is the HP one. In other words
DVI-D-0 => Dell and the HDMI-0 => HP. In wordsI have understood the following for the command:
Code:
xrandr --output DVI-D-0 --auto --output HDMI-0 --auto --scale 1.65x1.65 --right-of DVI-D-0
Set the monitor DVI-D-0 scale (Dell) yourself and put the output monitor HDMI-0 (HP) with a scale of 1.65x1.64 to the right of the DVI-D-0 monitor also scaling before yourself.

You could add those xrandr commands to a file in your home directory called:
~/.xsession or maybe ~/.xprofile
@wizardfromoz Ok, I will do that soon.

THX guys for your help again. Best forum ever by far :).
 

stan

Well-Known Member
Joined
Mar 19, 2018
Messages
985
Reaction score
1,105
Credits
9,112
BTW Mike - above confuses a little, is one of those the HP?
@wizardfromoz The left monitor is the Dell one and the right monitor is the HP one.
Chris is poking you that you called both monitors a Dell in post #1, both left and right (even after listing one as Dell and one as HP). That was the confusion. ;)


You could add those xrandr commands to a file in your home directory called:
~/.xsession or maybe ~/.xprofile
That was @JasKinasis (a wizard in his own right), and advice from him is ALWAYS good to consider! While there may be many ways to do something, Jas usually knows the best way. :cool::)
 
OP
mike_linux

mike_linux

Member
Joined
Nov 20, 2020
Messages
56
Reaction score
39
Credits
556
Chris is poking you that you called both monitors a Dell in post #1, both left and right (even after listing one as Dell and one as HP). That was the confusion. ;)
Oh, right I did not recognize that :eek:.

That was @JasKinasis (a wizard in his own right), and advice from him is ALWAYS good to consider! While there may be many ways to do something, Jas usually knows the best way. :cool::)
Ups yes, that is right I replied to the wrong person sorry @JasKinasis my fault :rolleyes:.
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,321
Reaction score
1,870
Credits
8,343
How to convert av to hdmi for n64?

First up - this should be in it's own thread. Hijacking someone elses thread with something irrelevant is generally frowned upon here.
But with any luck @wizardfromoz , or one of the other admins here will move it into it's own thread later.
Perhaps moving it to a new thread in general computing, or off-topic (seeing as it isn't strictly linux related!)

In answer to your question:
With an AV to HDMI adaptor. Plug your RCA cables from your N64 into one side of it and run your HDMI cable to your TV/monitor from the other side.
You can get them from most web-stores that sell electronics. They range in price.
Here's a cheap one on Amazon, I found with a quick bit of duckduckgofu:
 
OP
mike_linux

mike_linux

Member
Joined
Nov 20, 2020
Messages
56
Reaction score
39
Credits
556
Hi guys,

You could add those xrandr commands to a file in your home directory called:
~/.xsession or maybe ~/.xprofile
@JasKinasis both files are not available in 18.04.LTS (I didn't found them)

This How to Set Any Program to Load on Startup on Ubuntu 18.04 LTS also doesn't work for me. The solution that worked for me is this here solution where you have to put the command xrandr --output DVI-D-0 --auto --output HDMI-0 --auto --scale 1.30x1.30 --right-of DVI-D-0 in the .xinitrc file.

Nevertheless, thank you for the help guys :).
 
Last edited:

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,321
Reaction score
1,870
Credits
8,343
@JasKinasis both files are not available in 18.04.LTS (I didn't found them)

If they don't exist - simply create one of them?!
It should work. It's a standard user config for X.

EDIT:
xinitrc! Of course - that was one of the "other options" I was talking about in my original post.
There are several options that may or may not work. It depends on which desktop you're running and various other factors.
I think .xsession might actually be incorrect. I think that one is used by the login manager and can be used to specify a default desktop session for yourself.
I think .xprofile should work. But xinitrc, yes - that should do it too!
 
Last edited:

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
6,633
Reaction score
5,396
Credits
19,688
@petermeritt , @JasKinasis

I'll move those 2 posts to a new Thread in Peter's name, in this same subforum.

I'll tweak out the first paragraph from Jas, to give a clean slate, but note the protocol, Peter. Thanks

Chris Turner
wizardfromoz
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top