Quickly enable/disable a second display in LinuxFebruary 12, 2019
QRG on enabling and disabling a secondary monitor from the command line. I ran into issues when trying to run Steam with two active displays. It appears (at time of writing) that the Steam client is hardcoded to output to display co-ordinates 0x0 and (unfortunately) ignores whatever display is marked as default.
In the case of my setup I have one display stacked directly above the other, so the top display is 0x0 and the bottom is 0x1080. Also you can’t use negative co-ordinates as xrandr will automatically do the math to make the values positive again. The only solution is to disable the above display so only the bottom one is active (as that is the monitor I want to game on). The same reasoning would apply for a much more common horizontal display setup (0x0 on left, 1920x0 on right).
Disabling the top display (which is HDMI in my case)
xrandr --output HDMI-0 --off
Enabling both displays (HDMI on top, DP on bottom)
xrandr --output DP-0 --primary --mode 1920x1080 --rate 164.83 --pos 0x1080 --output HDMI-0 --mode 1920x1080 --rate 164.83 --pos 0x0
Shortcut (alias) binding
Add in .bashrc
alias hdmioff=‘xrandr –output HDMI-0 –off’ alias hdmion=‘xrandr –output DP-0 –primary –mode 1920x1080 –rate 164.83 –pos 0x1080 –output HDMI-0 –mode 1920x1080 –rate 164.83 –pos 0x0’
You may also have a .bash_aliases file where you can add this instead, if you want to stay organized.