Skip to content

fix: more stable output arrangement for identical external displays#1988

Open
hojjatabdollahi wants to merge 2 commits intopop-os:masterfrom
hojjatabdollahi:hojjat/fix-output-arrangement
Open

fix: more stable output arrangement for identical external displays#1988
hojjatabdollahi wants to merge 2 commits intopop-os:masterfrom
hojjatabdollahi:hojjat/fix-output-arrangement

Conversation

@hojjatabdollahi
Copy link
Contributor

@hojjatabdollahi hojjatabdollahi commented Jan 14, 2026

Monitors connected to an external USB C dock may get assigned different connectors (DP-5, DP-6...) on every reconnection or when the OS sleeps depending on the order the kernel sees them. This causes the outputs to rearrange often. This commit removes the connector as a part of the hash key for the outputs if and only if all outputs are unique (when their EDID is considered). This way no matter where the monitor is connected or if the USB C dock randomly assigns a different connector to it, the arrangements of the outputs stays the same.

If the external monitors have identical EDID info, then their connector is taken into account as a fallback, similar to what exists in cosmic-comp now.

The outputs.ron now looks like this:

        [
            (
                make: "LG Electronics",
                model: "LG HDR 4K",
                edid: Some((
                    manufacturer: ('G', 'S', 'M'),
                    product: 30470,
                    serial: Some(178300),
                    manufacture_week: 6,
                    manufacture_year: 2024,
                    model_year: None,
                )),
            ),
            (
                make: "LG Electronics",
                model: "LG HDR 4K",
                edid: Some((
                    manufacturer: ('G', 'S', 'M'),
                    product: 30470,
                    serial: Some(178311),
                    manufacture_week: 6,
                    manufacture_year: 2024,
                    model_year: None,
                )),
            ),
            (
                make: "BOE",
                model: "0x095F",
                edid: Some((
                    manufacturer: ('B', 'O', 'E'),
                    product: 2399,
                    serial: None,
                    manufacture_week: 23,
                    manufacture_year: 2019,
                    model_year: None,
                )),
            ),
        ]: [
<details>
        ],

As opposed to something like this:

        [
            (
                connector: "DP-5",
                make: "LG Electronics",
                model: "LG HDR 4K",
            ),
            (
                connector: "DP-6",
                make: "LG Electronics",
                model: "LG HDR 4K",
            ),
            (
                connector: "eDP-1",
                make: "BOE",
                model: "0x095F",
            ),
        ]: [
<details>
        ],

I've marked this as a draft since I guess we need to update cosmic-greeter and cosmic-randr because cosmic-greeter also reads outputs.ron and applies it using cosmic-randr. But I'm not sure if that's true and would like your input.

More importantly I'm interested to know what the team thinks of this approach? To me it makes sense since workspaces are assigned using this exact data structure. And in case you have completely identical monitors, then it just revert back to using the connector id as we do now. So, no regressions.

@hojjatabdollahi
Copy link
Contributor Author

I have been using this for the past few days and it has fixed the annoying random assignment of outputs to monitors after each sleep, or every time I connect my USB C dock.

This saves the config the way @Drakulix mentioned a while back: #1575 (comment). And is fairly human readable.

If this approach is satisfactory I can update other packages that need to be updated to use this format too.

@hojjatabdollahi
Copy link
Contributor Author

I noticed that cosmic-greeter have to update to avoid ruining the outputs.ron file. I did that last week and I've had a very nice experience since then. I moved the logic for matching the outputs to their config to cosmic-comp-config to avoid duplicating the logic. The last commit needs some clean up. But I'll do that if you guys are onboard with this approach. This has fixed the most annoying issue I've had with COSMIC since last year that I got these external monitors.

@hojjatabdollahi hojjatabdollahi force-pushed the hojjat/fix-output-arrangement branch from 3ef448b to a6ec098 Compare January 21, 2026 20:20
@hojjatabdollahi hojjatabdollahi force-pushed the hojjat/fix-output-arrangement branch 2 times, most recently from 3953081 to 6724d1f Compare February 5, 2026 21:05
@hojjatabdollahi hojjatabdollahi marked this pull request as ready for review February 5, 2026 21:05
@hojjatabdollahi
Copy link
Contributor Author

I clean up this PR. It's two small commits now, a lot more readable. The code in 6724d1f is mostly coming from cosmic-greeter.

It's ready for review.

@hojjatabdollahi hojjatabdollahi force-pushed the hojjat/fix-output-arrangement branch 3 times, most recently from ea0aa20 to e8fab0d Compare February 13, 2026 18:38
@hojjatabdollahi hojjatabdollahi force-pushed the hojjat/fix-output-arrangement branch 3 times, most recently from bcb78bc to 7495692 Compare February 23, 2026 19:22
@jacobgkau jacobgkau requested review from a team February 23, 2026 23:00
Copy link

@garrettjwilke garrettjwilke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new outputs.ron file correctly distinguishes between similar displays.

This code is moved from cosmic-greeter to avoid needing to duplicate the
matching logic in multiple places
@hojjatabdollahi hojjatabdollahi force-pushed the hojjat/fix-output-arrangement branch from 7495692 to 6a01219 Compare March 2, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants