Ein paar Ergänzungen/Anregungen zu dem Thema:
1.
autorandr-git
2. Bin auf folgendes gestoßen:
http://finalrewind.org/interblag/entry/automatically-connecting-external-monitors-udev-xrandr
Zur besseren Referenzierung hier mal der O-Ton:
Ugly hack to automatically connect external monitors using xrandr and udev:
Write SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/local/libexec/some-x-script.sh" into a udev rules file. This script will (at least on my system ;-) ) now get called every time you either plug in an external VGA connector or remove it.
In this script, you can now use xrandr to set up the monitor. To find out whether it is called after connecting or disconnecting, check /sys/class/drm/card0-VGA-1/enabled (or similar). [...] Happy hacking.
By the way, note that disconnecting the monitor before deconfiguring it with xrandr may break stuff. At least my system doesn not like it and does not accept other monitors until a reboot afterwards - manually calling xrandr --off first will work, of course. YMMV.
und das Beispielskript:
#!/bin/sh
dmode="$(cat /sys/class/drm/card0-VGA-1/status)"
# This script is called as root and without X knowledge
export DISPLAY=:0.0
if [ "${dmode}" = disconnected ]; then
xrandr --output VGA1 --off
elif [ "${dmode}" = connected ]; then
xrandr --output VGA1 --auto
xrandr --output VGA1 --below LVDS1
fi
3. Bin aber mittlerweile auch Creshals Meinung, dass der udev-Ansatz nicht der Beste ist ("Ugly hack"), zumal ich nicht sicher bin, ob alle Grafikkarten udev-events erzeugen (DRM/KMS?). Es wäre wohl tatsächlich besser X-events zu nutzen. Hier mal mein output von xev beim Ein-/Auspluggen eines externen Monitors, vielleicht bringt's jemanden auf eine passende Idee:
RRScreenChangeNotify event, serial 34, synthetic NO, window 0x2c00001,
root 0xae, timestamp 24705699, config_timestamp 28714272
size_index 0, subpixel_order SubPixelHorizontalRGB
rotation RR_Rotate_0
width 1366, height 768, mwidth 355, mheight 199
RRNotify event, serial 34, synthetic NO, window 0x2c00001,
subtype XRROutputChangeNotifyEvent
output VGA1, crtc None, mode None
rotation RR_Rotate_0
connection RR_Connected, subpixel_order SubPixelUnknown
RRNotify event, serial 39, synthetic NO, window 0x2c00001,
subtype XRROutputPropertyChangeNotifyEvent
output VGA1, property EDID, timestamp 28717094, state Delete
RRScreenChangeNotify event, serial 39, synthetic NO, window 0x2c00001,
root 0xae, timestamp 24705699, config_timestamp 28717286
size_index 0, subpixel_order SubPixelHorizontalRGB
rotation RR_Rotate_0
width 1366, height 768, mwidth 355, mheight 199
RRNotify event, serial 39, synthetic NO, window 0x2c00001,
subtype XRROutputChangeNotifyEvent
output VGA1, crtc None, mode None
rotation RR_Rotate_0
connection RR_Disconnected, subpixel_order SubPixelUnknown