nikitabobko / AeroSpace

AeroSpace is an i3-like tiling window manager for macOS
https://nikitabobko.github.io/AeroSpace/guide
MIT License
5.54k stars 88 forks source link

Wrong monitors order compared to other tools like sketchybar #336

Open tobiasgiese opened 1 month ago

tobiasgiese commented 1 month ago

AeroSpace is using a custom order for the monitors.

https://github.com/nikitabobko/AeroSpace/blob/b0ed972dd26d37dc0552d2865bf7de56f8c0d388/Sources/AppBundle/model/Monitor.swift#L82-L84

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 ```bash 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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

@tobiasgiese Thanks for reporting! Should be fixed in 0.13.2