0

With Ubuntu 18.04, I need the command line xrandr --output DP-1 --scale 0.5x0.5. How can I automate that command when I power on my computer?

EDIT

I created the /etc/rc.local file, and in that file I have written

#!/bin/bash

xrandr --output DP-1 --scale 0.5x0.5

exit 0

The problem is if I restart the computer, the screen is identical and wrong. It seems to work if I run the command bash /etc/rc.local, but not if I restart the computer. How can I fix that?

  • Did you try to run your script via crontab? See for instance Getting a script to run on boot, not on login. – Marc Vanhoomissen Jul 8 '19 at 14:40
  • 1
    I don't want a cronjob. I just want to run a script automatically when I start up the computer – J.Doe Jul 8 '19 at 14:41
  • Question has been changed after an answer has been given. Should be reverted to the original question. One can always ask a new question. – vanadium Jul 8 '19 at 20:17
  • @vanadium the edit didn't change the main question at all. Did you read somewhere that it's not ok to change question or just made it up? – int_ua Jul 9 '19 at 7:47
  • 1
    @int_ua indeed, I support this. I did not consider the specific command, only indicated how one can autoexecute a command during startup, and that might have been wrong. – vanadium Jul 9 '19 at 13:52
0

xrandr will not work from rc.local because it needs Xorg (graphical mode) running. You need to use a way to autostart commands/applications for your Desktop Environment after you logged in as some user. AFAIU For default Ubuntu 18.04 this method should work.

If you want the changes to affect Display Manager (the thing you see before logging in as a user) too that's more difficult, please add what DM you are using either by edit or comment.

Not the answer you're looking for? Browse other questions tagged or ask your own question.