2

I would like a command to execute when my PC starts up. My OS is Ubuntu 18.04 LTS. The command is:

xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync && xrandr --addmode VGA-1 1920x1080_60.00 && xrandr --output VGA-1 --mode 1920x1080_60.00

It works perfectly when I execute it (from the Terminal) after the pc has booted up. I have tried various options (after internet searches) but can't get any of them to work - have tried both command line and GUI profferings - none has worked.

pomsky
  • 68,507
Duncan
  • 1,053
  • 3
    xrandr commands affect the X server, The X server starts after you login, so using all the boot tools (cron @reboot, systemd services, runlevel 3, etc) that run before login won't work. Try putting it into a script and placing the script in ~.config/autostart, which runs each time you login after X server is up and running. – user535733 May 16 '20 at 12:07
  • 2
    Does this answer your question? How to run scripts on start up? See this answer: https://askubuntu.com/a/500147/480481 – pomsky May 16 '20 at 12:12
  • Xrandr, and usually keyboard- related commands need a little break https://github.com/algent-al/solus-extra-repo/tree/master/packages – Jacob Vlijm May 16 '20 at 13:37
  • Thanks - I have tried some of these but get lost - they assume knowledge I don't have (70-year-old noob). I will try all of them then come back here. I do appreciate your help and don't wan't to be a nuisance. – Duncan May 16 '20 at 14:09
  • 1
    This looks like an XY problem. You don't necessarily want to run xrandr anything, you actually want your screen resolution to be something other than what it is when you start up. You should instead look into why the resolution is different in the first place, as that will lead to a proper solution. – Michael Hampton May 16 '20 at 23:14
  • Many thanks, this did the trick! I used the Startup application and the following codeline: /bin/bash -c "sleep 15 && cvt 1920 1080 && xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync && xrandr --addmode VGA-1 1920x1080_60.00 && xrandr --output VGA-1 --mode 1920x1080_60.00" - So very grateful for your help - you people are MAGNIFICENT! Thanks so much. – Duncan May 17 '20 at 13:50
  • To Michael Hampton: I did look into why the optimal screen resolution was not being implemented (it was working for a number of YEARS!). The optimal screen resolution was not offered when I went to select it under settings - looks like a bug has been introduced into my Ubuntu 18.04. That is why I took this route. Thanks for your time anyway. – Duncan May 17 '20 at 14:03

1 Answers1

3

You could try putting the command in /etc/rc.local.

  • 1
    Thank you for your response. However, I am a 70-year-old noob and not sure how to do this. Could you elaborate? I would be most grateful. (If I should be posting this elsewhere, do please let me know - I don't want to irritate anyone). – Duncan May 16 '20 at 14:01