Skip to content

fix: resolve AeroSpace display ID mismatch with iterative fallback#506

Open
Etzeo wants to merge 2 commits intoJean-Tinland:masterfrom
Etzeo:fix-aerospace-display-matching
Open

fix: resolve AeroSpace display ID mismatch with iterative fallback#506
Etzeo wants to merge 2 commits intoJean-Tinland:masterfrom
Etzeo:fix-aerospace-display-matching

Conversation

@Etzeo
Copy link
Copy Markdown

@Etzeo Etzeo commented Mar 31, 2026

(I found a better solution, will push it up soon, ignore this PR for now)

Description

Problem

Übersicht assigns widget display IDs based on NSScreenNumber but keeps counting phantom displays (closed lid, previously connected monitors) even after they're disconnected. The previous workaround only subtracted 1 when the built-in display was missing, which broke with multiple phantom displays or different configurations.

e.g. I have 2 external display plugged in, ubersichtDisplayId 1 on my bult-in display, and 2 and 3 for the two external displays. When I disconnect my 1st external display, ubersichtDisplayId for built-in display will stay as 1, and for 2nd external display's ubersichtDisplayId will stay at 3 even after ubersicht is restarted, I'm not sure what/when/how this is ever re-loaded

Proposed Solution

This is my humble attempt at amending the issue for my own use, thought I'll share it here as well. My approach is to instead of guessing how many phantom displays exist, the new approach iterates from the Übersicht display ID downward until finding a display that AeroSpace actually reports. This works regardless of how many phantom displays exist. Hopefully this helps somebody out! 😄

Changes

  • Refactor: Separated getDisplayIndex into two distinct functions — getMonitorIndex (reads AeroSpace's sequential monitor-id) and getScreenIndex (reads monitor-appkit-nsscreen-screens-id). Updated some calls to use the appropriate function to match the display vs match the screen we want to render onto the display.

  • Fix: Replaced the fragile "Built-in Retina Display" detection workaround with an iterative fallback approach. The new logic walks down from the Übersicht display ID until finding a matching AeroSpace display, handling all phantom display scenarios: closed MacBook lid, previously connected monitors, and any number of disconnected displays that Übersicht still counts.

Disclaimer

  • I only thoroughly tested this with Aerospace, with various configurations with the two external monitors I have, setting different monitors as the main display. I'm not familiar with yabai and am unsure if I broke anything there, hopefully i didn't.

Fixes: #486 without relying on Übersicht fork (more like a workaround, than a fix)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test with 2 external displays, then detaching on at a time.
  • Test with 2 external displays, with MacBook closed lid
  • Test to make sure yabai behaviour isn't affected (have not been done)

Test Configuration:

  • OS version: Tahoe 26.3.1
  • aerospace version (output of aerospace -v)
aerospace CLI client version: 0.20.3-Beta 6dde91ba43f62b407b2faf3739b837318266e077
AeroSpace.app server version: 0.20.3-Beta 6dde91ba43f62b407b2faf3739b837318266e077
  • Übersicht version: Version 1.6 (82)

Checklist:

  • My code follows the style guidelines of this project (I think it does, but I'm not 100% sure)
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas (make use of JSDoc if necessary)
  • My changes generate no new warnings

Changes to make to the documentation

  • unsure if there's any needed

Etzeo added 2 commits March 31, 2026 23:31
Refactor getDisplayIndex to read monitor-id (closer resembled ubersicht display id from `window.location.pathname`)
and add new getScreenIndex to read monitor-appkit-nsscreen-screens-id that returns which screen should be render for each display.
Update all call sites to use the appropriate function for their context.
Replace the built-in Retina Display fix with an iterative
approach that walks down from the Übersicht display ID until finding
a matching AeroSpace display. This handles all phantom display scenarios:
closed MacBook lid, previously connected monitors, and any number of
disconnected displays that Übersicht still counts.
@Etzeo Etzeo changed the title fix(simple-bar): resolve AeroSpace display ID mismatch with iterative fallback fix: resolve AeroSpace display ID mismatch with iterative fallback Mar 31, 2026
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.

Stable Monitors by name support

1 participant