Shell command to turn on/off a specific monitor

Hello, since the Corona pandemic, I’m doing a lot of home-office. So I’m using a second laptop and I’m sharing my biggest monitor with both laptops. One Laptop (Win) is connected via HDMI and my Ubuntu-Laptop is connected via Display-Port.
When I have my Win-Laptop connected via HDMI, I want to disable this monitor on my Ubuntu machine, without needing to remove the Display-Port cable. Is there a shell-command to disable this monitor easily? (DBus or similar)?

Does any answer here help?

1 Like

Thanks, I additionaly had to adjust the position of the monitors with --pos since I want to turn on/off the middle monitor (3-monitor setup).

Here are the commands I use:

# Get positions and names of monitors:
xrandr -q

# Turn off middle monitor DP-1 and adjust position of DP-0
xrandr --output DP-1 --off --output DP-0 --auto --pos 1920x0 #monitor-off

# Turn back on the middle monitor (DP-1) and adjust position of monitor DP-0
xrandr --output DP-1 --auto --pos 1920x0 --output DP-0 --auto --pos 4480x0 #monitor-on
1 Like