Definitely won't work on my Wayland desktop running Niri. xrandr doesn't return anything useful under Wayland, unless I'm mistaken.
But cool to see some use out of nushell! ๐
Definitely won't work on my Wayland desktop running Niri. xrandr doesn't return anything useful under Wayland, unless I'm mistaken.
But cool to see some use out of nushell! ๐
Niri does not allow xrandr to disable the monitors, I'd assume other compositors are also like that, sounds like a very out of scope thing to do through xwayland. If that assumption is correct, this won't work on most modern systems.
Also, the way it's done looks kind of hacky with constant enabling and disabling of displays. I'm sure xrandr does something to prevent useless commands like that from actually working, but I'd do something to not issue them in the first place.
My first thought is checking /sys/class/drm for whatever state you want, as in with something like this you can see which ports have a display on the other side currently:
# This is sh, by the way
for a in /sys/class/drm/*/status; do echo "$a: $(cat "$a")"; done
And you can listen to udev changes with something like this:
udevadm monitor --kernel --subsystem-match=drm
If an event is emitted, we check if the state of the port we are interested in changed and then do whatever we need.
Though, I'm also not sure if manually disabling the monitor is the correct way, maybe there is a better way of handling it in X11? I'd imagine it wanting to have at least one display enabled is configurable.
A community for everything relating to the GNU/Linux operating system (except the memes!)
Also, check out:
Original icon base courtesy of lewing@isc.tamu.edu and The GIMP