nwg-piotr / nwg-displays

Output management utility for sway and Hyprland.
MIT License
336 stars 22 forks source link

Add checkbox to choose custom mode resolution #6

Closed dydyamotya closed 2 years ago

dydyamotya commented 2 years ago

I've added a checkbox to use custom resolution. It is very useful, if you have Ultra wide monitor. I've changed import of tools file, because otherwise it uses the system package. I'm opened, if there are some mistakes, but for me it works like a charm.

dydyamotya commented 2 years ago
  1. Opps, sorry, didn't test it through.Certainly, need to change it back in imports.
  2. As I understand, one needs to add --custom flag to mode command to have it work like you expect. I tried to set custom resolution without --custom flag and nothing happened. Manually execution of command with --custom flag worked and I've decided to add "custom" checkbox. This PR added "custom" flag to sway https://github.com/swaywm/sway/pull/4675
nwg-piotr commented 2 years ago

I understand. If so, we can add the --custom flag, but place the checkbox in another place, please. I expect the form to fit horizontally in a half of full HD screen, so we have not enough space in the bottom row. I think we just need one more row below the one that contains 'Size', 'Refresh' and the 'Modes' combo.

dydyamotya commented 2 years ago

I've changed widgets position. Look, pls, if it fits your estimations.

nwg-piotr commented 2 years ago

Very well. I'll take a look when I'm back home. If I find the layout not yet ready, I'll correct it myself. I want nwg-displays , nwg-shell-config and nwg-look to have coherent layouts.

nwg-piotr commented 2 years ago

main.py, line 470:

item["active"], item["dpms"], item["adaptive_sync_status"], "disabled", item["focused"], item["monitor"]

The form_custom_mode check button value is not persistent between consecutive runs. It seems we can't get this value in the list_outputs() function, so it should be saved somewhere. I suggest a list of output names w/ custom mode turned on in the config dictionary, e.g. like this:

{
  "view-scale": 0.15,
  "snap-threshold": 10,
  "indicator-timeout": 500,
  "custom-mode": ["HDMI-A-1", "DP-1"]
}

You could use it something like this:

outputs = list_outputs()
    for key in outputs:
        item = outputs[key]
        custom_mode = key in config["custom-mode"]
        b = DisplayButton(key, item["description"], item["x"], item["y"], round(item["width"]), round(item["height"]),
                          item["transform"], item["scale"], item["scale_filter"], item["refresh"], item["modes"],
                          item["active"], item["dpms"], item["adaptive_sync_status"], custom_mode, item["focused"], item["monitor"])

Of course you'd also need to save config on the check button "toggled" event.

dydyamotya commented 2 years ago

Hi! I've implemented config thing, check it out, please.

nwg-piotr commented 2 years ago

Great, thanks! I'll be at my desk later tonight.

nwg-piotr commented 2 years ago

Definitely this not a feature for beginners, as it may potentially brake ones sway configuration. Hope no one gets hurt.

dydyamotya commented 2 years ago

Definitely this not a feature for beginners, as it may potentially brake ones sway configuration. Hope no one gets hurt.

Really? Why? Nonetheless, you can't set up resolution on ultrawide monitors by another way. So, I think it is a nice feature)

nwg-piotr commented 2 years ago

Really? Why?

I managed to crash sway with the --custom flag. Needed to edit ~/config/sway/outputs in console.

I think it is a nice feature

Indeed, thank you for the contribution. I added a tooltip to warn users that they need to think twice.