xrandr scale monitor output by default

10,411

Patterned from the scripts found here you can create your own.

First, create a udev script for the hot-plugging of your monitors. Copy and paste the following in a terminal window:

sudo bash -c 'echo "ACTION==\"change\", SUBSYSTEM==\"drm\", ENV{HOTPLUG}==\"1\", RUN+=\"/usr/local/bin/monitor-hotplug.sh\"" > /etc/udev/rules.d/99-monitor-hotplug.rules'

Then create your script that will be called from the udev:

sudo bash -c 'echo "xrandr --output DP-4 --scale 1.5x1.5" > /usr/local/bin/monitor-hotplug.sh'

Then make the script executable:

sudo chmod +x /usr/local/bin/monitor-hotplug.sh

You might have to reboot your host for this to take effect.

Hope this helps!

Share:
10,411

Related videos on Youtube

Marc Bacvanski
Author by

Marc Bacvanski

CS @ Northeastern

Updated on September 18, 2022

Comments

  • Marc Bacvanski
    Marc Bacvanski over 1 year

    I've installed ubuntu on a retina Macbook Pro, and have managed to get the things to look at a reasonable size by scaling the display:

    xrandr --output DP-2 --scale 0.9x0.9
    

    When I connect my external monitor, I scale it like so:

    xrandr --output DP-4 --scale 1.5x1.5
    

    These work great, except after I unplug my external monitor and plug it back in again, I have to re-run the command to scale it to the size I would like.

    How can I have this done automatically? (I would like to avoid just creating a macro to just run that command; I'd like it to run automatically each time I plug in my monitor)

    • Terrance
      Terrance over 7 years
      Maybe look at github.com/codingtony/udev-monitor-hotplug and see if that might be something you're looking for.
    • Marc Bacvanski
      Marc Bacvanski over 7 years
      It seems like it should be such a primitive function of the OS; is there a way to do it without any third-party tools?
    • Terrance
      Terrance over 7 years
      It's just showing scripts you can use and where to put them. One that the GIT person already did.
    • Terrance
      Terrance over 7 years
      I wrote an answer based on that. Maybe it might work for you.
    • Jacob Vlijm
      Jacob Vlijm over 7 years
      Possible duplicate of Run script when monitor is connected