Skip to content
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

Wrong monitors order compared to other tools like sketchybar #336

Open
tobiasgiese opened this issue Jul 22, 2024 · 9 comments
Open

Wrong monitors order compared to other tools like sketchybar #336

tobiasgiese opened this issue Jul 22, 2024 · 9 comments
Labels
problem Neither a bug, nor a feature request

Comments

@tobiasgiese
Copy link
Sponsor

tobiasgiese commented Jul 22, 2024

AeroSpace is using a custom order for the monitors.

var sortedMonitors: [Monitor] {
monitors.sorted(using: [SelectorComparator(selector: \.rect.minX), SelectorComparator(selector: \.rect.minY)])
}

Other tools like Sketchybar are using a different order. The first monitor is always the primary monitor.
AeroSpaces first monitor is always the most left monitor, regardless if it's the primary monitor or not.

This makes it pretty hard to use aerospace list-workspaces and aerospace --add event [...] display=$monitorID for instance.

In my case I have the Macbook on the left side of the monitor -- where my external monitor is primary.
Running the following command will add all workspaces to the wrong monitor:

for monitorID in $(aerospace list-monitors | awk '{print $1}'); do
    for sid in $(aerospace list-workspaces --monitor $monitorID); do
        sketchybar --add item \
            space.$sid left \
            display=$monitorID
            # [...] and some more parameters
    done
done
Snippet to reproduce
for monitorID in $(aerospace list-monitors | awk '{print $1}'); do
    sketchybar --add item find.mon.$monitorID left \
        --set find.mon.$monitorID \
        icon="$monitorID" \
        display=$monitorID
done

IMO it is worth the effort to give the users the ability to adjust the order. Something like an additional command parameter to select if it will be ordered align to the X and Y axis or if we want to have the primary monitor always as the first one.

@nikitabobko
Copy link
Owner

Other tools like Sketchybar are using a different order. The first monitor is always the primary monitor.

What is the order of the remaining monitors?

@tobiasgiese
Copy link
Sponsor Author

What is the order of the remaining monitors?

Unfortunately, I don't know the order of the remaining monitors. I only have 2 monitors (1 external) 🙂

@apoxa
Copy link

apoxa commented Jul 22, 2024

I can reproduce this issue.
When using 3 monitors, the order in aerospace list-monitors is from left to right as arranged in the Display section of System Settings.app. image

When 2 monitors are on top of each other the order is from top to bottom, left to right:
image

This is a bit unexpected, because what's numbered 3 is my main display, where the other 2 are configured as extended displays.

@tobiasgiese
Copy link
Sponsor Author

Easy snippet to reproduce the issue, put this somewhere in your sketchybarrc (maybe before your aersoapce stuff):

for monitorID in $(aerospace list-monitors | awk '{print $1}'); do
    sketchybar --add item find.mon.$monitorID left \
        --set find.mon.$monitorID \
        icon="$monitorID" \
        display=$monitorID
done

@apoxa
Copy link

apoxa commented Jul 22, 2024

Thanks for the snippet! Here's the order from my first arrangement:

Aerospace Sketchybar
1 3
2 2
3 1

In the second arrangment it's ordered another way:

Aerospace Sketchybar
1 2
2 no ID shown
3 1

@tobiasgiese
Copy link
Sponsor Author

tobiasgiese commented Jul 23, 2024

Tested with a 3rd 10" display.
What I can see is that the sketchybar arrangement is also ordered as the Mac Display arrangement in the system settings, except for the main display which is always 1st.

tl;dr: if we put the main display on position 1 we can order the rest as already implemented.


image

Results in the following sketchybar arrangement:

1: LG HDR WQHD+
2: MPI107
3: Built-in Retina Display
image

Sketchybar result:

1: LG HDR WQHD+
2: Built-in Retina Display
3: MPI107
image

Sketchybar result:

1: LG HDR WQHD+
2: Built-in Retina Display
3: MPI107

And one last test. with the small 10" display as main display

image
1: MPI107
2: Built-in Retina Display
3: LG HDR WQHD+

@tobiasgiese
Copy link
Sponsor Author

tobiasgiese commented Jul 25, 2024

Just FYI, wrote a small bash script to fix the order for sketchybar:

mainMonitor="LG HDR WQHD+"

monitors=$(aerospace list-monitors)
monitorsSorted=("$(grep "$mainMonitor" <<< "$monitors")")
monitorsSorted+=("$(grep -v "$mainMonitor" <<< "$monitors")")

printf '%s\n' "${monitorsSorted[@]}" | sed "$1,1!d" | awk '{print $1}'

@tobiasgiese
Copy link
Sponsor Author

tobiasgiese commented Jul 28, 2024

@nikitabobko with the most recent beta version v0.13.1-beta the monitor list is broken (at least for me).

❯ aerospace list-monitors
0 | Built-in Retina Display
❯ aerospace list-workspaces --monitor 0
Invalid monitor ID: 0
❯ aerospace list-workspaces --monitor 1
1
2
3
4
5
6
7
8
9
10

Should I open a separate issue for this?

@nikitabobko
Copy link
Owner

@tobiasgiese Thanks for reporting! Should be fixed in 0.13.2

jakenvac pushed a commit to jakenvac/AeroSpace that referenced this issue Aug 16, 2024
@nikitabobko nikitabobko added the problem Neither a bug, nor a feature request label Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Neither a bug, nor a feature request
Projects
None yet
Development

No branches or pull requests

3 participants