Implement dpms off on laptop lid close
Wayfire idle plugin implements dpms_timeout - so in general it can save power, but this can only be controlled manually. To make it work on laptop lid state I see 2 varians
- Implement something like DBUS messaging (like swaymsg dpms off commang in sway), so it can be triggered by acpid daemon taking care about detecting/handling lid switch state
2)Implement SWITCH inputs handling in Wayfire itself as it works with mouse and keyboard events and add one more binding to idle plugin setting dpms_timeout to 1sec when lid is closed.
I've also tried wlr-randr to switch display off/on using acpid - but that ends up in crash os some programs (screen openes with less windows on it) and if the closed lid time is long enough (more that about 15 seconds) - wayfire crash completely. So maybe there is a third way to make wayfire work Ok without any display connected - but that's something I do not understand at all.
Take a look at this issue: https://github.com/WayfireWM/wayfire/issues/455
There is a command that you can use to trigger DPMS on and off, and I think it should be relatively easy to listen to ACPID events or something of the sort with a script (like your approach 1)
I've also tried wlr-randr to switch display off/on using acpid - but that ends up in crash os some programs (screen openes with less windows on it) and if the closed lid time is long enough (more that about 15 seconds) - wayfire crash completely. So maybe there is a third way to make wayfire work Ok without any display connected - but that's something I do not understand at all.
wlr-randr will turn the monitor on and off which is a more 'serious' operation, if you can collect logs from the crash, it will be good to fix the bug, I expect it can happen during monitor hotplug.
I guess monitor hotplug is a bit different - you still have your built-in screen so on plugin in and out external monitor it just moves the windows to available output. I've tried that many times works like a charm. But when there is no output available at all
Closing since the solution is to set the DPMS state in acpid, either via the wlroots example client or by using something like https://sr.ht/~leon_plickat/wlopm/.