On Wed, 01 Mar 2017, Marcus MERIGHI <mcmer-open...@tor.at> wrote:
> sc...@ggr.com (Scott Bonds), 2017.02.28 (Tue) 02:21 (CET):
>> I'm polling using xrandr to check whether a new display was plugged
>> in, so I can run a script to switch to it, i.e. plug in an external
>> VGA monitor and it lights up automatically, unplug it and my laptop
>> automatically switches back to using its internal display. 
>
> I have wanted the same and found no way to avoid polling xrandr(1).
>
> If you find a way, would you be so kind to share the solution?

The Other Operating System has something called udev rules.

I have a file called /etc/acpi/hotplug-monitor.sh which queries for
connected displays and includes logic to set them up (falling back on
xrandr --auto if nothing else makes sense).

The file is invoked by udev, per another file named
/etc/udev/rules.d/80-hotplug-monitor.rules which has this one line:

SUBSYSTEM=="drm", ACTION=="change", RUN+="/etc/acpi/hotplug-monitor.sh"

I don't have any OpenBSD box nearby (:C), but perhaps there's something
in /var/log/* about a new monitor being plugged in? A process could
follow the file and trigger events.

<3,K.

Reply via email to