Tuesday, August 1, 2017

Saving Second Monitor Settings Across Reboots in Ubuntu 16.04

I recently used a second monitor with my Ubuntu 16.04 laptop. After a while, I realized that whenever the HDMI is re-plugged or if the computer is rebooted, the setting reset back!

For example, if I set the monitor to be at the left of my monitor through preferences -> display, it got reset back to be at the right of my laptop after a reboot.

The solution is to use xrandr:
First, run:

#This gives out information about ID of display that is currently running on the system.

xrandr


#After that, run command like the following to update the setting
xrandr --output HDMI2 --left-of eDP1


#Finally, the command can be persisted by writing it to ~/.xprofile file
echo "xrandr --output HDMI2 --left-of eDP1" > ~/.xprofile


For more information. look at this documentation:
https://wiki.ubuntu.com/X/Config/Resolution#Setting_xrandr_commands_in_.xprofile