alex-courtis / way-displays

way-displays: Auto Manage Your Wayland Displays
MIT License
246 stars 12 forks source link

Feature request: Disable/enable monitors #16

Closed kiasoc5 closed 2 years ago

kiasoc5 commented 2 years ago

First of all I love this program, I like that way-displays turns on all monitors when you first run it without configuration, and the config is very straightforward. And it autoupdates when the config is saved, much faster than wlr-randr and wdisplays.

But currently all monitors are turned on by default. It would be great to specify which monitors are powered on or off. One way to implement this in the config is to only turn on monitors listed in the ORDER. For example:

eDP-1 on only:

ORDER:
    - 'eDP-1'

HDMI-1 on only:

ORDER:
    - 'HDMI-1'

Both on: (and keep the current behavior of turning all monitors on if the order key is undefined or empty)

ORDER:
    - 'eDP-1'
    - 'HDMI-1'

Maybe ORDER could also be renamed to DISPLAYS to be more intuitive.

What do you think?

kiasoc5 commented 2 years ago

Actually doing it in the ORDER field might not make sense because if you plug another monitor in it's more user-friendly to have that monitor turn on automatically than to have to reach into the config. Maybe an IGNORE field to list displays to ignore is better. For example turn off the laptop screen:

IGNORE:
    - 'eDP-1'
alex-courtis commented 2 years ago

And it autoupdates when the config is saved :grin:

It would be great to specify which monitors are powered on or off.

Yes, we can do this.

The use case for powering off an unwanted monitor is clear. I'm not quite sure when/why it is turned on.

Perhaps you could outline your workflow throughout the day, so that we can come up with a good solution.

One way to implement this in the config is to only turn on monitors listed in the ORDER

As you said, this won't work. Some users (including me) list only the left/top monitor in ORDER, and expect others to appear afterwards.

Maybe an IGNORE field to list displays to ignore is better.

This seems like a workable solution.

However, it doesn't seem very user friendly: you would need to remove the monitor from this section to be able to use it. I don't think I am properly understanding your use case.

A dirty hack like On Games And Scale could be used, however that is a very temporary workaround.

kiasoc5 commented 2 years ago

Perhaps you could outline your workflow throughout the day, so that we can come up with a good solution.

I have two monitors plugged into a thunderbolt dock that connects to my laptop. I want to turn my laptop screen off and my monitors on when I plug in the dock. While I could get two monitors if I close the lid on my laptop, the fan is in the hinge and it gets unbearably hot if I do that. So I prefer to just turn the monitor off.

This supposed to be possible with kanshi but I never got it to work.

alex-courtis commented 2 years ago

While I could get two monitors if I close the lid on my laptop, the fan is in the hinge and it gets unbearably hot if I do that.

I understand. We need a mechanism that allows you to disable/enable a monitor when you instruct.

Automated options:

This is very complex to implement and, as you say, difficult to "program" as a user. Not practical.

Manual options:

  1. Update IGNORE in cfg.yaml by hand
  2. Use a script like On Games And Scale to update IGNORE
  3. Add an IPC API that would allow the user to request, amongst other things, enable/disable of a monitor. Something like swaymsg

3 would be the ideal solution, however complex and time consuming to build. I would happily review a PR for such solution.

It seems that 1 and 2 are the practical solution, via the "cfg file API". Are you happy with that, if I add IGNORE?

I am not completely comfortable with 1/2 as it is a very clunky solution that requires fiddly interactions from the user, resulting in a poor experience. However, I cannot conceive of any other practical alternatives.

alex-courtis commented 2 years ago

~This is how we would achieve 2:~

yq -y '.DISABLE |= . + [ "eDP-1" ]' cfg.yaml
yq -y 'if .DISABLE then .DISABLE |= . - [ "eDP-1" ] else . end' cfg.yaml

Edit: see https://github.com/alex-courtis/way-displays/issues/16#issuecomment-1018056213

kiasoc5 commented 2 years ago

Yes, let's try it and see how it goes.

alex-courtis commented 2 years ago

Please test on the feature branch:

git clone git@github.com:alex-courtis/way-displays.git
cd way-displays
git checkout 16-disable-displays
make
sudo make install

Once you're done, you can remove the test version from /usr/local:

sudo make uninstall

You can use yq: disable:

yq -y -i 'if .DISABLED then .DISABLED |= . - [ "eDP-1" ] else . end' ~/.config/way-displays/cfg.yaml

enable:

yq -y -i 'if .DISABLED then .DISABLED |= . - [ "eDP-1" ] else . end | .DISABLED |= . + [ "eDP-1"]' ~/.config/way-displays/cfg.yaml
kiasoc5 commented 2 years ago

Thanks, it works as expected. A side note, wl-randr cannot be used to turn on/off monitors when way-displays is running. Maybe mention this in the readme. I don't know if sway 1.7 with the output dpms toggle command will work the same.

alex-courtis commented 2 years ago

A side note, wl-randr cannot be used to turn on/off monitors when way-displays is running.

That is working as intended; way-displays will turn them back on, unless they are disabled or the lid is closed. I might add that to the README, thanks.

I don't know if sway 1.7 with the output dpms toggle command will work the same.

dpms has no effect; the displays are still there and enabled, just not displaying anything. I guess it is that way so that your workspaces are not interrupted during "screensaver".

alex-courtis commented 2 years ago

Thank you for your ideas and testing @kiasoc5 - released as 1.3.0