On 2019-10-14 19:33, Marcus MERIGHI wrote: > j...@begriffs.com (Joe Nelson), 2019.10.14 (Mon) 04:32 (CEST): >> I'd like to write a daemon to change machdep.lidaction and the xrandr output >> as >> an external monitor or power is attached/detached from my laptop. Is there a >> way to detect those events from a C program? > > x-on-resize[1] might help with detecting plug/unplug events of external > monitors. > > [1] > https://keithp.com/blogs/x-on-resize/ > git://people.freedesktop.org/~keithp/x-on-resize > https://github.com/thedward/x-on-resize > https://marc.info/?l=openbsd-misc&m=148839239518671
I was about to mention x-on-resize. I use it to invoke autorandr. https://pypi.org/project/autorandr/ And for power there's already sensorsd $ sysctl hw.sensors.acpibat0.raw0 hw.sensors.acpibat0.raw0=1 (battery discharging), OK Not sure how you will transition from this state: >> Power Mon Open | Sleep Display >> --------------------------+------------------ >> x | asleep to this one: >> x x | awake external I.e. wake up from standby when power is applied, without opening the laptop - machdep.lidaction won't help with that. t > Marcus > >> Here is how I want the sleep state and output display to change based on >> whether power is connected, an external monitor is attached, and the laptop >> is >> open: >> >> Power Mon Open | Sleep Display >> --------------------------+------------------ >> x x x | awake both >> x x | awake external >> x x | awake laptop >> x | asleep >> x x | awake both >> x | asleep >> x | awake laptop >> | asleep >> >> -- >> Joe Nelson https://begriffs.com >> >