Hi this is a small patch to fix crashes while using wsl-randr.
I joined the output of wlr-randr on my system. As you can see, I disabled one of my monitors. This lead to crashes.
monitors = []
display = Gdk.Display.get_default()
for i in range(display.get_n_monitors()):
monitor = display.get_monitor(i)
monitors.append(monitor)
idx = 0
for key in outputs_dict:
outputs_dict[key]["monitor"] = monitors[idx]
idx += 1
The first loop ask GDK what are the displays available on my system. Which as far as Gdk is concerned there is only one "DP-1".
But since wlr-randr listed 2 displays output_dict contains my 2 display. this means that during the second iteration of the second loop we try to access monitors[1] which is out of bound. and crash python.
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.12/nwg-panel", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/lib/python3.12/site-packages/nwg_panel/main.py", line 575, in main
common.outputs = list_outputs(sway=sway, tree=tree)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/nwg_panel/tools.py", line 377, in list_outputs
outputs_dict[key]["monitor"] = monitors[idx]
~~~~~~~~^^^^^
Hi this is a small patch to fix crashes while using wsl-randr.
I joined the output of wlr-randr on my system. As you can see, I disabled one of my monitors. This lead to crashes.
The first loop ask GDK what are the displays available on my system. Which as far as Gdk is concerned there is only one "DP-1".
But since wlr-randr listed 2 displays output_dict contains my 2 display. this means that during the second iteration of the second loop we try to access monitors[1] which is out of bound. and crash python.