You are not logged in.
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
If you plug in something, there is a chance it produces a dbus event. I would start looking there.
Offline
srandrd should be able to do that, but maybe there is a better way to check the monitor status.
Offline
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
fiyou 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