Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Disable/enable monitors #16

Closed
kiasoc5 opened this issue Jan 17, 2022 · 10 comments
Closed

Feature request: Disable/enable monitors #16

kiasoc5 opened this issue Jan 17, 2022 · 10 comments

Comments

@kiasoc5
Copy link

kiasoc5 commented Jan 17, 2022

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
Copy link
Author

kiasoc5 commented Jan 17, 2022

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
Copy link
Owner

And it autoupdates when the config is saved
😁

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
Copy link
Author

kiasoc5 commented Jan 18, 2022

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
Copy link
Owner

alex-courtis commented Jan 19, 2022

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:

  • Implement some sort of profile system like kanshi

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 alex-courtis changed the title Feature request: Turn monitors on/off in the order field Feature request: Disable/enable monitors Jan 19, 2022
@alex-courtis
Copy link
Owner

alex-courtis commented Jan 19, 2022

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 #16 (comment)

@kiasoc5
Copy link
Author

kiasoc5 commented Jan 20, 2022

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

alex-courtis added a commit that referenced this issue Jan 21, 2022
@alex-courtis
Copy link
Owner

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
Copy link
Author

kiasoc5 commented Jan 21, 2022

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
Copy link
Owner

alex-courtis commented Jan 22, 2022

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 added a commit that referenced this issue Jan 22, 2022
alex-courtis added a commit that referenced this issue Jan 22, 2022
@alex-courtis
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants