domferr / tilingshell

Extend Gnome Shell with advanced tiling window management. Supports multiple monitors, Windows 11 Snap Assistant, Fancy Zones, customised tiling layouts and more.
https://extensions.gnome.org/extension/7065/tiling-shell/
GNU General Public License v2.0
618 stars 17 forks source link

[Feature Request] Distinguish between monitors of the same model #81

Open aidanlw505 opened 4 months ago

aidanlw505 commented 4 months ago

Describe the feature you'd like Currently, if all of your monitors are of the same model, they have the exact same name. This makes it hard to know which one you're changing the layout for.

image

I think taking the monitor's number that's shown in display settings and including it in the title would be really helpful.

domferr commented 4 months ago

Hey @aidanlw505 thank you for sharing the issue and a possible solution! I agree with you. This will be fixed in the way you suggested by the next update

milhauzindahauz commented 4 months ago

@domferr I would like to try to implement that.

domferr commented 4 months ago

Hey @milhauzindahauz that's great!

The code to be changed is only in the file defaultMenu.ts. At line 172 there is the function _computeMonitorsDetails which runs a subprocess to retrieve the monitor's name. The idea would be to:

  1. parse the monitor details got by the subprocess into JSON. This is already done at line 191:

    const monitorsDetails = JSON.parse(stdout);

    where monitorsDetails is a constant array. Each element of the array has type { name: string, x: number, y: number, height: number, width: number }

  2. rename the monitors that have the same name by appending to it the index of the monitor (since the monitor details are an array, it is enough to use the position in the array)

Please feel free to ask any question! I'm more than happy to provide any help :smile:

Side notes:

milhauzindahauz commented 4 months ago

Thank for the guidance. But I got to the correct place by myself with the same idea. I found out that on X11 server names are null. I am trying to figure out how to obtain details on X11.

Further more: https://github.com/domferr/tilingshell/blob/5e855765d055ed29c08a64d62891c4f3d4e15a9c/src/indicator/defaultMenu.ts#L82-L90 This method will update all monitors with same details of Monitor 1. Or am I missing anything?

domferr commented 4 months ago

But I got to the correct place by myself with the same idea.

That's awesome!

I found out that on X11 server names are null. I am trying to figure out how to obtain details on X11.

Oh no, I didn't know that! Thank you!

This method will update all monitors with same details of Monitor 1. Or am I missing anything?

The DefaultMenu shows one LayoutsRow for each monitor (and it stores them into this._layoutsRows). For each monitor m, a LayoutsRow is created and the monitor m is passed to it. The updateMonitorName method is a member of the LayoutsRow class, so it will update the monitor name's label of only one LayoutsRow, based on the monitor m (this._monitor) passed via the constructor.

I'm not sure this answer to your question, let me know otherwise!

milhauzindahauz commented 4 months ago

The DefaultMenu shows one LayoutsRow for each monitor (and it stores them into this._layoutsRows). For each monitor m, a LayoutsRow is created and the monitor m is passed to it. The updateMonitorName method is a member of the LayoutsRow class, so it will update the monitor name's label of only one LayoutsRow, based on the monitor m (this._monitor) passed via the constructor.

This make sense. You are updating in by the details of the subprocess result. But lets have the situation as described above. @aidanlw505 has three monitors with same resolutions. If I would got array of the details for that I got three items in array and their resolutions are the same. And after that I try updateMonitorName by finding the same resolution three times. I should stop the finding on the first match that means first item with same resolution in the array => same detail (item at index 0) for all of them.

GuillaumeAmat commented 4 months ago

FWIW, the numbers attributed by GNOME to my monitors are not fixed at all :sweat_smile:

I have 2 external screens, and they get numbers 2 and 3 interchangeably, each time I (un)plug my laptop.

It's probably fair to say that I should not be the only one experiencing this issue so, what do you think of the following addition?

  1. Open the Tiling Shell top bar menu
  2. Hover a layout on one of the monitors' line
  3. The related layout is drawn on the related monitor

That way, no matter the names/numbers are, you directly see where the layout is supposed to be used.

domferr commented 4 months ago

The DefaultMenu shows one LayoutsRow for each monitor (and it stores them into this._layoutsRows). For each monitor m, a LayoutsRow is created and the monitor m is passed to it. The updateMonitorName method is a member of the LayoutsRow class, so it will update the monitor name's label of only one LayoutsRow, based on the monitor m (this._monitor) passed via the constructor.

This make sense. You are updating in by the details of the subprocess result. But lets have the situation as described above. @aidanlw505 has three monitors with same resolutions. If I would got array of the details for that I got three items in array and their resolutions are the same. And after that I try updateMonitorName by finding the same resolution three times. I should stop the finding on the first match that means first item with same resolution in the array => same detail (item at index 0) for all of them.

Yeah, I agree! I'd make the changes into the function _computeMonitorsDetails: after parsing the monitor details got by the subprocess into JSON (done at line 191), maybe it is a good idea to append the index to the monitor's name if there are other monitors with the same name. A possible solution would be something like:

  1. create a map names that maps for each monitor's name an array of numbers, where the numbers are the indexes of the monitors in the monitorDetails array
  2. for each name in the map, if the associated array has multiple elements, you have the indexes of all the monitors that have the same name. For each index i, you can append i+1 to monitorDetails[i].name

I'm happy to know your thoughts about it! Feel free to implement any other idea or this one, as you prefer. I don't think we should care too much about time complexity because the monitors are going to be 2 or 3, at most 4 or 5 for very lucky people ahaha

domferr commented 4 months ago

I have 2 external screens, and they get numbers 2 and 3 interchangeably, each time I (un)plug my laptop.

Hey @GuillaumeAmat, that's annoying ahaha :cry:

The idea you are sharing is good imho. I would still keep a different name (something like LG Electronics 34" 1, LG Electronics 34" 2) for people who want to know as quick as possible which monitor that row is referring to.

GuillaumeAmat commented 4 months ago

The idea you are sharing is good imho. I would still keep a different name (something like LG Electronics 34" 1, LG Electronics 34" 2) for people who want to know as quick as possible which monitor that row is referring to.

Sure! That was just a suggestion to be added on top of what you already planned :pray: