Can't get xrandr to execute at start up from ~/.xprofile

Hello,

I have just started using Ubuntu mate. I like it a lot. I am trying to fix the resolution to suit my laptop. I have enabled HiDPI in Mate Tweaks and this makes everything enormous. After much googling I found out that this command fixes everything:
xrandr --output LVDS-1 --scale 1.6x1.5

I start off with a resolution of 1920x1080 and that makes the resolution 3072x1620
I read that this goes in a .xprofile file in home folder..

I read that you can create that file with this little series of commands:

RES="3072 1620 60" &&
DISP=$(xrandr | grep -e " connected [^(]" | sed -e "s/([A-Z0-9]+) connected./\1/") &&
MODELINE=$(cvt $(echo $RES) | grep -e "Modeline [^(]" | sed -r 's/.Modeline (.)/\1/') &&
MODERES=$(echo $MODELINE | grep -o -P '(?<=").
(?=")') &&
cat > ~/.xprofile << _EOF
#!/bin/sh
xrandr --newmode $MODELINE
xrandr --addmode $DISP $MODERES
_EOF

Well this is the contents of my .xprofile (I changed the shebang thing to be bash instead of sh)

#!/bin/bash
xrandr --newmode "3072x1620_60.00" 423.75 3072 3312 3640 4208 1620 1623 163>
xrandr --addmode LVDS-1 3072x1620_60.00
xrandr --output LVDS-1 --mode 3072x1620_60.00

After a reboot I can see that newmode added to the output of xrandr so I guess that script does run but the resolution doesn't change on my monitor.

I have rebooted about 10 times testing this but every time it doesn't change the resolution. I end up with a rectangle about 1/3 of the screen so I have to open Terminal and run this command to fix things:
xrandr --output LVDS-1 --scale 1.6x1.5

I also tried putting just that command in .xprofile but it doesn't work either after boot up.

I tried creating a file: /etc/xdg/autostart/fix-resolution.desktop
But likewise it doesn't change the resolution at bootup.

Here are the first few lines of what the xrandr command gives after bootup:

flex@flex-ubuntu:~/Desktop$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
LVDS-1 connected primary 3072x1620+0+0 (normal left inverted right x axis y axis) 344mm x 194mm

And after I run xrandr --output LVDS-1 --scale 1.6x1.5

flex@flex-ubuntu:~/Desktop$ xrandr --output LVDS-1 --scale 1.6x1.5
flex@flex-ubuntu:~/Desktop$ xrandr
Screen 0: minimum 320 x 200, current 3072 x 1620, maximum 16384 x 16384
LVDS-1 connected primary 3072x1620+0+0 (normal left inverted right x axis y axis) 344mm x 194mm

I don't know what's the difference between Screen 0: and LVDS-1? It seems that I need Screen 0: to be current 3072 x 1620 at bootup instead of current 1920 x 1080.

Running that command fixes things but how do I get it to run at a reboot?

Cheers,

Flex

I think my problem is the xrandr --output command runs either too soon or too late? This has been mentioned in various sites like here and here.

I took advice from this comment in a thread about changing DPI with xrandr and added the line bash -c "sleep 15; xrandr --output LVDS-1 --scale 1.6x1.5" to a custom Startup Application and this did work so the resolution was set to 3072x1620 on startup.

In fact changing the resolution this way was then interfering with a Windows VM guest I had running in Virtualbox so now my current thinking is to stick with the 96dpi 1920x1080 mate gives me by default. Just seems hard on my eyes... especially the menus and URL bar in Brave Browser that seem too small and I don't know how else to make them bigger.

Flex

for Brave font size, check brave://settings

Try playing with the font DPI. Like you, I needed more from my menus and title bars. Right now my DPI is set to 126.

@pavlos_kairis

Changing the font size in Brave browser has no affect on the font size in the menus and url bar. I tried with Google Chrome and it is the same. I (re)installed Firefox and it looks much better and is really customizable so I think I will stay with Firefox.

Flex

@mdooley

But when I increase dpi then every thing takes up more space so I have to make muliple changes to font sizes and such elsewhere and it still never looks right.

A pity Brave and Chrome don't scale well in Ubuntu. They look fine at the same resolution in Windows. In the end I think I'll switch to Firefox because you can customise it about any way you need. I left my screen dpi at 96, resolution at 1920x1080 and bumped up a few font size categorises. The firefox url bar and menus are much more legible and I can change bookmark folders back to yellow!

Cheers,

Flex

Perhaps this might help you in your scaling endeavor -

1 Like