Multiple monitors with Aerospace + SketchyBar #624
Replies: 4 comments
-
Up! 🚀 Actually facing the same conundrum at the moment as well. |
Beta Was this translation helpful? Give feedback.
-
I'm encountering the same issue and currently relying on a workaround in my SketchyBar config, which is far from ideal and prone to breaking. Here's the function I use in my setup using SbarLua: -- Map monitor IDs between AeroSpace and SketchyBar
local function sketchyBarMonitorId(monitor_id, total_monitors)
return (total_monitors > 1 and monitor_id == 1) and 2 or (monitor_id == 2 and 1 or monitor_id)
end A good workaournd would be to have a SketchyBar command that directly outputs a monitor ID-to-name mapping. Similar to what AeroSpace provides:
|
Beta Was this translation helpful? Give feedback.
-
It's not super ideal, but I was hacking at this and came up with a few workarounds here: #607 |
Beta Was this translation helpful? Give feedback.
-
I have been living with a similar setup for a while (all workspaces are displayed on all sketchybars). A couple days ago I decided to fix it so that the sketchybar on each display only renders the aerospace workspaces associated with that display. The commit where I implemented it is here. My solution works well and handles:
The crux of it is that aerospace lets you format the output of queries and so they can be formatted to return the NSScreen screen ID for anything (workspace, window, etc.) so I use that to determine which sketchybar monitor to render items on. Here's the code for that: # Get the system monitor ID of the specified workspace.
# Expects the workspace ID as the first argument
# Returns the monitor ID of the workspace
# returns nothing (empty string) if the workspace has no windows.
get_workspace_monitor_id() {
local workspace_id="$1"
# aerospace command that returns all windows in the workspace, formatted as only the system monitor ID
# each workspace is 1 character long, so truncate the output to only the first character
local aerospace_result=$(aerospace list-windows --workspace $workspace_id --format "%{monitor-appkit-nsscreen-screens-id}")
local monitor_id=${aerospace_result:0:1}
echo $monitor_id
} and consuming the # monitor_id will contain the monitor ID of the workspace
# or an empty string if the workspace has no windows
local monitor_id=$(get_workspace_monitor_id $sid) The one case I haven't handled which comes up fairly often for me is when the number of attached displays changes. I work on a laptop and sometimes connect an external display, sometimes not. When I transition from a display being connected to not connected, the sketchybar items on the disconnected display don't get moved to the built-in display. If anyone knows how to listen for an event that the number of connected displays changed, I'd be really grateful for info about how to do that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!
I used to use yabai + sketchybar, but I'm migrating to aerospace + sketchybar.
In a multi-monitor setup, I'm having a hard time getting the desired behavior. I'd like each monitor to only display the workspaces associated with it. I've tried a few approaches, like multiple bars, items associated to specific displays, but I haven't managed to get anything to look good.
Currently what I have is that all the bars appear on all monitors and when I change the workspace in one display, the change (i.e., the highlighted workspace in the bar) happens on all monitors (leading to wrong highlighting on displays other than the one where the change happened).
The important sections of my config files are:
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions