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?

J.Doe
  • 53
  • 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 08 '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 08 '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 08 '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 09 '19 at 07:47
  • @int_ua That is indeed the house rules. You can change a question to improve clarity. This site would however become hectic if everybody started to fundamentally change and add to the question all the time, making already posted answers to a previous version obsolete. This site has a specific format: it is not a support forum. It aims to be a knowledge base. If OP has new questions specifically to xrandr started from /etc/rc.local, then that is a different question here. – vanadium Jul 09 '19 at 11:11
  • @vanadium you suggested rc.local yourself it was a clarification after your incorrect answer. And now you make up "rules" to cover up? Let's just close it as duplicate as correctly determined by Jacob – int_ua Jul 09 '19 at 12:05
  • 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 09 '19 at 13:52
  • @vanadium Thank you, deeply appreciated. – int_ua Jul 09 '19 at 14:37

1 Answers1

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.

int_ua
  • 8,574