You are not logged in.

#1 2012-08-20 03:06:27

toaster2
Member
Registered: 2011-10-19
Posts: 7

Automatic dynamic multi-monitor setup

Hi all.  I was wondering if there is any way to automatically extend my display using xorg or xrandr based on whether a monitor is plugged in or not.  The use case is as follows: 

I have a laptop and monitor, but I don't always have my laptop plugged into my monitor.  I want to extend the display when its plugged in, but fallback to only the laptop's screen when it's not, without hotkeys.  Is there any way to do this?

Last edited by toaster2 (2012-08-20 03:06:58)

Offline

#2 2012-08-20 07:25:31

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: Automatic dynamic multi-monitor setup

If you plug in something, there is a chance it produces a dbus event. I would start looking there.

Offline

#3 2012-08-20 08:13:58

xduugu
Member
Registered: 2008-10-16
Posts: 292

Re: Automatic dynamic multi-monitor setup

srandrd should be able to do that, but maybe there is a better way to check the monitor status.

Offline

#4 2012-08-20 08:37:05

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Automatic dynamic multi-monitor setup

I use this:

/etc/udev/rules.d/10-local.rules

KERNEL=="card0", ACTION=="change", ENV{XAUTHORITY}="/home/<user>/.Xauthority", ENV{DISPLAY}=":0.0", RUN+="/path/to/hdmi-script.sh"

hdmi-script.sh

#!/bin/bash

if [[ $(< /sys/class/drm/card0-HDMI-A-1/status) = "connected" ]]; then
	xrandr --output HDMI-1 --primary --auto --output LVDS-1 --auto --left-of HDMI-1
else
	xrandr --auto
fi

you will have to change the output names and the /sys path accordingly.
btw, this is with nouveau and there is no way to make this work with the binary nvidia driver because it doesn't trigger an udev event. Should work fine with intel too, no idea about AMD.

Offline

Board footer

Powered by FluxBB