-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Monitor names are swapped on X11 #202
Comments
TL;DR - I have This is very strange... |
LOL, you made me launch Openbox first time in a couple of years. If configured well with arandr, outputs show up properly on my side. I have no idea what goes wrong on your machine. I abandoned X11 years ago.
|
As a X11 user I can confirm I don't remember what happiness feels like. Any idea where to take a look or ways to debug this? None of the other tools such as arandr or wallpaper / monitor configuration tools from KDE/GNOME seem to report monitor names incorrectly. |
On X11 Azote detects monitors on the basis of the Line 235 in 9ced6a3
The code is old, untouched for years, and could be optimized, but it should probably work well. |
import subprocess
names = (
subprocess.check_output("xrandr | awk '/ connected/{print $1}'", shell=True)
.decode("utf-8")
.splitlines()
)
res = (
subprocess.check_output("xrandr | awk '/[*]/{print $1}'", shell=True)
.decode("utf-8")
.splitlines()
)
coords = (
subprocess.check_output("xrandr --listmonitors | awk '{print $3}'", shell=True)
.decode("utf-8")
.splitlines()
)
displays = []
for i in range(len(res)):
w_h = res[i].split("x")
try:
x_y = coords[i + 1].split("+")
except: # noqa: E722
x_y = (0, 0, 0)
displays.append({
"name": names[i],
"x": x_y[1],
"y": x_y[2],
"width": int(w_h[0]),
"height": int(w_h[1]),
"xrandr-idx": i,
})
print(sorted(displays, key=lambda x: (x.get("x"), x.get("y")))) I've extracted that part of code and tested it in isolation. This is definitely the root cause of the bug. The ProblemIt assumes that In reality,
This explains why the name and resolution were swapped when both monitors were enabled.
When a monitor is disabled using
But in
This explains the wrong name and correct resolution in the second screenshot, when I disabled HDMI-0. Looks like you were extremely lucky (or unlucky?) to have the output of xrandr and listmonitors always aligned every time you tested Azote on your setup LOL |
It shouldn't be too hard to fix, I'll return with a PR during the weekends. The surrounding code could also use some work. |
@nwg-piotr Do you mind adding an extra optional dependency, Dealing with the On the other hand, this is how clean it gets if we use a dedicated library instead. from Xlib import display
display = display.Display()
root = display.screen().root
for i, m in enumerate(root.xrandr_get_monitors().monitors):
print({
"name": display.get_atom_name(m.name),
"x": m.x,
"y": m.y,
"width": m.width_in_pixels,
"height": m.height_in_pixels,
"xrandr-idx": i,
})
|
Haha, I started this repo right after migrating all my stuff from i3 to sway, back in 2019. I added some X11 support via feh, but never actually used it. Add the Xlib dependency if you need, but from now on you're responsible for X11-related stuff in this program. ;) Please make it optional: the program cannot crash when Xlib absent. |
Describe the bug
I have 2 monitors connected, HDMI-0 and DP-0.
The above screenshot was captured on DP-0, the 2560x1440 one.
For some reason, the monitor names seem to be swapped with each other.
When I set a wallpaper for HDMI-0 it is applied to DP-0 and vice versa.
If I disable HDMI-0 and have only DP-0 enabled, only HDMI-0 is shown in Azote.
And of course, it is actually linked with DP-0.
I have yet to test what happens if I plug in 3 monitors because I don't have a third one.
Perhaps is there an off-by-one indexing error for getting the monitor names?
Desktop (please complete the following information):
Azote version (please state it clearly if you use -git version):
The text was updated successfully, but these errors were encountered: