nwg-piotr / nwg-displays

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

nwg-displays 0.3.10-1 dies in list_outputs when display is disabled #42

Closed nergdron closed 5 months ago

nergdron commented 6 months ago

just trying out nwg on hyprland, and I mostly love it. definitely makes things a lot easier to configure and deal with. however, on my arch install of version 0.3.10-1 of nwg-displays, I disabled a display output (my VR headset, which shouldn't be active all the time), and now nwg-displays just crashes when I try to launch it, so I can't do any further display configuration:

Settings: {'view-scale': 0.25, 'snap-threshold': 10, 'indicator-timeout': 500, 'custom-mode': [], 'use-desc': False}
Running on Hyprland
Traceback (most recent call last):
  File "/usr/bin/nwg-displays", line 33, in <module>
    sys.exit(load_entry_point('nwg-displays==0.3.10', 'gui_scripts', 'nwg-displays')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nwg_displays/main.py", line 1224, in main
    create_display_buttons()
  File "/usr/lib/python3.11/site-packages/nwg_displays/main.py", line 548, in create_display_buttons
    outputs = list_outputs()
              ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nwg_displays/tools.py", line 186, in list_outputs
    if int(outputs_dict[key]["x"]) == geometry.x and int(outputs_dict[key]["y"]) == geometry.y:
           ~~~~~~~~~~~~~~~~~^^^^^
KeyError: 'x'

any theory on what's going on, and how I might modify things so that the VR headset remains disabled but I can still use the app?

nwg-piotr commented 6 months ago

Well, for now I couldn't reproduce the crash on my side. Which way did you disable the output? What the wlr-randr output looks like with it turned on and off?

kRHYME7 commented 6 months ago

Got this also, I remembered I disabled the 2nd monitor, then exit the nwg. Then I remove the monitor. I'm testing which configurations can be retained. Launch nwg again and give this error.

This might not the specific way to repro this.

I randomly found this issue when a few moments ago I tested nwg and got those errors.

Thank for the hardwork.

nwg-piotr commented 6 months ago

Thanks in advance for further info.

nergdron commented 6 months ago

for reference, I have 3 display output devices. 2 is my monitor, 3 is the VR headset, and 1 is a home theater receiver via HDMI for audio. I disabled #2, saved, closed nwg-displays, and then later tried to open it again to check VRR status on my monitor, and got this error. I've since edited monitors.conf by hand to add VRR and 10 bit output, but nwg-displays still gives me the error. here's the current contents of my monitors.conf:

# Generated by nwg-displays on 2023-12-28 at 20:54:52. Do not edit manually.

monitor=HDMI-A-1,1920x1080@60.0,3840x2160,1.0
monitor=DP-2,3840x2160@59.997002,0x0,1.5,bitdepth,10,vrr,1
monitor=DP-3,disable

here's the current wlr-randr output:

DP-2 "LG Electronics LG Ultra HD 0x0004714D (DP-2)"
  Make: LG Electronics
  Model: LG Ultra HD
  Serial: 0x0004714D
  Physical size: 600x340 mm
  Enabled: yes
  Modes:
    3840x2160 px, 59.997002 Hz (preferred, current)
    3840x2160 px, 60.023998 Hz
    3840x2160 px, 50.005001 Hz
    3840x2160 px, 48.006001 Hz
    3840x2160 px, 30.000000 Hz
    2560x1440 px, 59.951000 Hz
    1920x1200 px, 59.997002 Hz
    1920x1080 px, 60.000000 Hz
    1920x1080 px, 60.000000 Hz
    1920x1080 px, 59.939999 Hz
    1600x1200 px, 59.997002 Hz
    1680x1050 px, 59.997002 Hz
    1600x900 px, 60.000000 Hz
    1280x1024 px, 60.020000 Hz
    1440x900 px, 59.997002 Hz
    1280x800 px, 59.810001 Hz
    1152x864 px, 59.972000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 59.939999 Hz
    1024x768 px, 60.004002 Hz
    800x600 px, 60.317001 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 59.939999 Hz
    640x480 px, 60.000000 Hz
    640x480 px, 59.939999 Hz
    640x480 px, 59.939999 Hz
  Position: 0,0
  Transform: normal
  Scale: 1.500000
  Adaptive Sync: disabled
DP-3 "(null) (null) (DP-3)"
  Make: (null)
  Model: (null)
  Serial: (null)
  Enabled: no
  Modes:
    640x480 px, 59.939999 Hz
HDMI-A-1 "DENON, Ltd. DENON-AVAMP 0x01010101 (HDMI-A-1)"
  Make: DENON, Ltd.
  Model: DENON-AVAMP
  Serial: 0x01010101
  Physical size: 800x450 mm
  Enabled: yes
  Modes:
    1920x1080 px, 60.000000 Hz (current)
    1920x1080 px, 59.939999 Hz
    1920x1080 px, 50.000000 Hz
    1920x1080 px, 24.000000 Hz
    1920x1080 px, 23.976000 Hz
    2880x576 px, 50.000000 Hz
    2880x576 px, 50.000000 Hz
    2880x480 px, 60.000000 Hz
    2880x480 px, 60.000000 Hz
    2880x480 px, 59.939999 Hz
    2880x480 px, 59.939999 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 59.939999 Hz
    1280x720 px, 50.000000 Hz
    1280x720 px, 50.000000 Hz
    1440x576 px, 50.000000 Hz
    1440x576 px, 50.000000 Hz
    1440x480 px, 60.000000 Hz
    1440x480 px, 60.000000 Hz
    1440x480 px, 59.939999 Hz
    1440x480 px, 59.939999 Hz
    720x576 px, 50.000000 Hz
    720x576 px, 50.000000 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 59.939999 Hz
    720x480 px, 59.939999 Hz
    720x480 px, 59.939999 Hz
    640x480 px, 60.000000 Hz
    640x480 px, 59.939999 Hz
    640x480 px, 59.939999 Hz
  Position: 3840,2160
  Transform: normal
  Scale: 1.000000
  Adaptive Sync: enabled
nergdron commented 6 months ago

I just tried re-enabling DP-3 in the config file, and once I do, then nwg-displays works normally for me again. so it must be something to do with having that display disabled. I've set it and HDMI-A-1 to mirror the main display so my cursor doesn't go off screen into some void of non-real displays, and that seems like it'll work for now.

for reference, here's the wlr-randr output after re-enabling it:

DP-3 "(null) (null) (DP-3)"
  Make: (null)
  Model: (null)
  Serial: (null)
  Enabled: yes
  Modes:
    640x480 px, 59.939999 Hz (current)
  Position: 0,0
  Transform: normal
  Scale: 1.000000
  Adaptive Sync: disabled
HDMI-A-1 "DENON, Ltd. DENON-AVAMP 0x01010101 (HDMI-A-1)"
  Make: DENON, Ltd.
  Model: DENON-AVAMP
  Serial: 0x01010101
  Physical size: 800x450 mm
  Enabled: yes
  Modes:
    1920x1080 px, 60.000000 Hz (current)
    1920x1080 px, 59.939999 Hz
    1920x1080 px, 50.000000 Hz
    1920x1080 px, 24.000000 Hz
    1920x1080 px, 23.976000 Hz
    2880x576 px, 50.000000 Hz
    2880x576 px, 50.000000 Hz
    2880x480 px, 60.000000 Hz
    2880x480 px, 60.000000 Hz
    2880x480 px, 59.939999 Hz
    2880x480 px, 59.939999 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 59.939999 Hz
    1280x720 px, 50.000000 Hz
    1280x720 px, 50.000000 Hz
    1440x576 px, 50.000000 Hz
    1440x576 px, 50.000000 Hz
    1440x480 px, 60.000000 Hz
    1440x480 px, 60.000000 Hz
    1440x480 px, 59.939999 Hz
    1440x480 px, 59.939999 Hz
    720x576 px, 50.000000 Hz
    720x576 px, 50.000000 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 59.939999 Hz
    720x480 px, 59.939999 Hz
    720x480 px, 59.939999 Hz
    640x480 px, 60.000000 Hz
    640x480 px, 59.939999 Hz
    640x480 px, 59.939999 Hz
  Position: 0,0
  Transform: normal
  Scale: 1.000000
  Adaptive Sync: enabled
DP-2 "LG Electronics LG Ultra HD 0x0004714D (DP-2)"
  Make: LG Electronics
  Model: LG Ultra HD
  Serial: 0x0004714D
  Physical size: 600x340 mm
  Enabled: yes
  Modes:
    3840x2160 px, 59.997002 Hz (preferred, current)
    3840x2160 px, 60.023998 Hz
    3840x2160 px, 50.005001 Hz
    3840x2160 px, 48.006001 Hz
    3840x2160 px, 30.000000 Hz
    2560x1440 px, 59.951000 Hz
    1920x1200 px, 59.997002 Hz
    1920x1080 px, 60.000000 Hz
    1920x1080 px, 60.000000 Hz
    1920x1080 px, 59.939999 Hz
    1600x1200 px, 59.997002 Hz
    1680x1050 px, 59.997002 Hz
    1600x900 px, 60.000000 Hz
    1280x1024 px, 60.020000 Hz
    1440x900 px, 59.997002 Hz
    1280x800 px, 59.810001 Hz
    1152x864 px, 59.972000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 60.000000 Hz
    1280x720 px, 59.939999 Hz
    1024x768 px, 60.004002 Hz
    800x600 px, 60.317001 Hz
    720x480 px, 60.000000 Hz
    720x480 px, 59.939999 Hz
    640x480 px, 60.000000 Hz
    640x480 px, 59.939999 Hz
    640x480 px, 59.939999 Hz
  Position: 0,0
  Transform: normal
  Scale: 1.500000
  Adaptive Sync: enabled

the problem headset in question is a Valve Index, and all the reported nulls in different things are pretty suspicious, so I imagine they might be related to the problems nwg-displays is having. it should obviously also be capable of might higher resolutions and refresh rates, so something funky is going on with it under linux. :woman_shrugging:

nwg-piotr commented 6 months ago

The crash itself is possible to avoid, but we have another issue: disabled DP monitors disappear from the output of hyprctl monitors (why?!), but remain in the output of wlr-randr (unfortunately with Enabled: yes!). At the same time HDMI outputs once disabled, became invisible to both commands. We no longer detect them in any way. Even if we edit the config file manually, we need to restart Hyprland to bring them back to life. This is most likely a bug in Hyprland, as previously they didn't behave this way. I'm going to wait for Hyprland 0.34 to appear on Arch before taking further steps.

nergdron commented 6 months ago

oooof yeah, that definitely feels like an upstream bug, not your issue. good diagnosis, thanks! I'll report back once the new release is available.

nergdron commented 5 months ago

alright, I'm running hyprland-0.34.0-1, and I'm still seeing the issue:

Settings: {'view-scale': 0.25, 'snap-threshold': 10, 'indicator-timeout': 500, 'custom-mode': [], 'use-desc': False}
Running on Hyprland
HDMI-A-1 {'description': 'DENON, Ltd. DENON-AVAMP 0x01010101', 'active': True, 'focused': False, 'modes': [{'width': 1920, 'height': 1080, 'refresh': 60000.0}, {'width': 1920, 'height': 1080, 'refresh': 59939.999}, {'width': 1920, 'height': 1080, 'refresh': 50000.0}, {'width': 1920, 'height': 1080, 'refresh': 24000.0}, {'width': 1920, 'height': 1080, 'refresh': 23976.0}, {'width': 2880, 'height': 576, 'refresh': 50000.0}, {'width': 2880, 'height': 576, 'refresh': 50000.0}, {'width': 2880, 'height': 480, 'refresh': 60000.0}, {'width': 2880, 'height': 480, 'refresh': 60000.0}, {'width': 2880, 'height': 480, 'refresh': 59939.999}, {'width': 2880, 'height': 480, 'refresh': 59939.999}, {'width': 1280, 'height': 720, 'refresh': 60000.0}, {'width': 1280, 'height': 720, 'refresh': 60000.0}, {'width': 1280, 'height': 720, 'refresh': 59939.999}, {'width': 1280, 'height': 720, 'refresh': 50000.0}, {'width': 1280, 'height': 720, 'refresh': 50000.0}, {'width': 1440, 'height': 576, 'refresh': 50000.0}, {'width': 1440, 'height': 576, 'refresh': 50000.0}, {'width': 1440, 'height': 480, 'refresh': 60000.0}, {'width': 1440, 'height': 480, 'refresh': 60000.0}, {'width': 1440, 'height': 480, 'refresh': 59939.999}, {'width': 1440, 'height': 480, 'refresh': 59939.999}, {'width': 720, 'height': 576, 'refresh': 50000.0}, {'width': 720, 'height': 576, 'refresh': 50000.0}, {'width': 720, 'height': 480, 'refresh': 60000.0}, {'width': 720, 'height': 480, 'refresh': 60000.0}, {'width': 720, 'height': 480, 'refresh': 59939.999}, {'width': 720, 'height': 480, 'refresh': 59939.999}, {'width': 720, 'height': 480, 'refresh': 59939.999}, {'width': 640, 'height': 480, 'refresh': 60000.0}, {'width': 640, 'height': 480, 'refresh': 59939.999}, {'width': 640, 'height': 480, 'refresh': 59939.999}], 'scale_filter': None, 'dpms': None, 'mirror': 'DP-2', 'monitor': <__gi__.GdkWaylandMonitor object at 0x7f467b0c7240 (GdkWaylandMonitor at 0x55b42d0074c0)>, 'adaptive_sync_status': 'Sync:', 'physical-width': 1920, 'physical-height': 1080, 'refresh': 60.0, 'x': 0, 'y': 0, 'transform': 'normal', 'scale': 1.0, 'logical-width': 1920.0, 'logical-height': 1080.0}
DP-3 {'description': '(null)', 'active': False, 'focused': False, 'modes': [{'width': 640, 'height': 480, 'refresh': 59939.999}], 'scale_filter': None, 'dpms': None, 'mirror': '', 'monitor': None, 'adaptive_sync_status': False}
DP-2 {'description': 'LG Electronics LG Ultra HD 0x0004714D', 'active': True, 'focused': False, 'modes': [{'width': 3840, 'height': 2160, 'refresh': 59997.002}, {'width': 3840, 'height': 2160, 'refresh': 60023.998}, {'width': 3840, 'height': 2160, 'refresh': 50005.001}, {'width': 3840, 'height': 2160, 'refresh': 48006.001}, {'width': 3840, 'height': 2160, 'refresh': 30000.0}, {'width': 2560, 'height': 1440, 'refresh': 59951.0}, {'width': 1920, 'height': 1200, 'refresh': 59997.002}, {'width': 1920, 'height': 1080, 'refresh': 60000.0}, {'width': 1920, 'height': 1080, 'refresh': 60000.0}, {'width': 1920, 'height': 1080, 'refresh': 59939.999}, {'width': 1600, 'height': 1200, 'refresh': 59997.002}, {'width': 1680, 'height': 1050, 'refresh': 59997.002}, {'width': 1600, 'height': 900, 'refresh': 60000.0}, {'width': 1280, 'height': 1024, 'refresh': 60020.0}, {'width': 1440, 'height': 900, 'refresh': 59997.002}, {'width': 1280, 'height': 800, 'refresh': 59810.001}, {'width': 1152, 'height': 864, 'refresh': 59972.0}, {'width': 1280, 'height': 720, 'refresh': 60000.0}, {'width': 1280, 'height': 720, 'refresh': 60000.0}, {'width': 1280, 'height': 720, 'refresh': 59939.999}, {'width': 1024, 'height': 768, 'refresh': 60004.002}, {'width': 800, 'height': 600, 'refresh': 60317.001}, {'width': 720, 'height': 480, 'refresh': 60000.0}, {'width': 720, 'height': 480, 'refresh': 59939.999}, {'width': 640, 'height': 480, 'refresh': 60000.0}, {'width': 640, 'height': 480, 'refresh': 59939.999}, {'width': 640, 'height': 480, 'refresh': 59939.999}], 'scale_filter': None, 'dpms': None, 'mirror': '', 'monitor': None, 'adaptive_sync_status': 'enabled', 'physical-width': 3840, 'physical-height': 2160, 'refresh': 59.997002, 'x': 0, 'y': 0, 'transform': 'normal', 'scale': 1.5, 'logical-width': 2560.0, 'logical-height': 1440.0}
Traceback (most recent call last):
  File "/usr/bin/nwg-displays", line 33, in <module>
    sys.exit(load_entry_point('nwg-displays==0.3.10', 'gui_scripts', 'nwg-displays')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nwg_displays/main.py", line 1224, in main
    create_display_buttons()
  File "/usr/lib/python3.11/site-packages/nwg_displays/main.py", line 552, in create_display_buttons
    b = DisplayButton(key, item["description"], item["x"], item["y"], round(item["physical-width"]),
                                                ~~~~^^^^^
KeyError: 'x'
nwg-piotr commented 5 months ago

Yes. I have a fix to avoid crashes, but it won't allow to detect disabled monitors on Hyprland. It's impossible with hyprctl monitors, and wlr-randr gives partially wrong results. I think I'll apply what I have and try to raise the issue on the Hyprland tracker.

nwg-piotr commented 5 months ago

Closed by accident. The commit above should prevent us from crashes, but won't allow to detect disabled monitors, as said above.

kRHYME7 commented 5 months ago

The crash itself is possible to avoid, but we have another issue: disabled DP monitors disappear from the output of hyprctl monitors (why?!)

Maybe I misread something did you mean hyprctl monitor all ?

with all flag image

but with this dpmsstatus still is 1 maybe we can compare what is with all and without all flags to get the disabled monitor.

active workspace: -1 () also gives a hint.

nwg-piotr commented 5 months ago

Yes, it will be worked on. I need to rewrite this party of code from scratch.

kRHYME7 commented 5 months ago

Thanks!