Open regisverdin opened 8 months ago
aerospace list-windows --workspace $(aerospace list-workspaces --focused)
This can be simplified to: aerospace list-windows --workspace focused
However, I can't help you with sketchybar integration, since I don't use any bars. Hopefully, somebody else can
(piggybacking on this question, since this is in the same area :) )
I use exec-on-workspace-change
to propagate "workspace-changed" event to sketchybar which let's me to change active workspace and change window title.
Is there any event to detect when window title changes? For example, when I change tab.
I haven't seen anything that would fit, but I might be missing something.
(I thought that it's something that could be solved by on-window-detected
, but exec-and-forget
command is not accepted in run
)
I thought that it's something that could be solved by
on-window-detected
, butexec-and-forget
command is not accepted inrun
on-window-detected
is not invoked on the window's title changes, so allowing exec-and-forget
in on-window-detected
won't help here
Currently AeroSpace doesn't listen for "window changed title" events. I see that there is an API for it, so technically it should be possible. Tracking issue: #177
I've no idea why on my environment M3 Max Macbook, exec-on-workspace-change
can't work, it just doesn't trigger the event.
I implemented a focused workspace indicator using SbarLua, used this sketchybar config as a starting point.
I post here for anyone who is interested.
items/aerospaces.lua
local sbar = require("sketchybar")
local colors = require("colors")
local settings = require("settings")
local workspace = sbar.add("item", "aerospace", {
position = "right",
label = {
string = "",
color = colors.white,
highlight_color = colors.green,
font = {
family = settings.font.numbers,
style = settings.font.style_map["Bold"],
size = 20.0,
},
drawing = true,
},
padding_right = 12,
})
local function highlight_focused_workspace(env)
sbar.exec("aerospace list-workspaces --focused", function(focused_workspace)
for id in focused_workspace:gmatch("%S+") do
local is_focused = tostring(id) == focused_workspace:match("%S+")
sbar.animate("sin", 10, function()
workspace:set({
icon = {
highlight = is_focused
},
label = {
highlight = is_focused,
string = id,
},
})
end)
end
end)
end
-- Subscribe to the front_app_switched event to highlight the focused workspace
workspace:subscribe("front_app_switched", highlight_focused_workspace)
-- Initially highlight the focused workspace
highlight_focused_workspace()
return workspace
@nohzafk great, thank you! I installed sketchybar with the script from your second link (repo by FelixKratz) and then put in aerospaces.lua in the "items" folder and adding this to the init.lua in the same directory: require("items.aerospaces")
i now have sketchybar with a green indicator/number that tells me which workspace is active. do you also have a visible indication of workspaces that have applications on it but are not on a screen as well?
@agenttank I do have some customize scripts for indicators, but not exactly what you want. You can use this example as a starting point to utilize hammerspoon window events to trigger sketchybar event.
and at the sbarlua side, write functions to call aerospace commands to get the windows/apps information
there's also this very nice sketchybar for AeroSpace configuration that actually works and the creator shared it here.
https://github.com/forteleaf/sketkchybar-with-aerospace/tree/main
there's also this very nice sketchybar for AeroSpace configuration that actually works and the creator shared it here.
https://github.com/forteleaf/sketkchybar-with-aerospace/tree/main
This is quite nice. Only problem is that it is slow to update, not sure if everyone has it, but I'm not the only one.
I've starting building a cli app to integrate sketchybar with aerospace, because I find sketchybarrc to be pretty limited & slow and bash honestly suck.
it's far far from complete, but the init & update are instant this way, i'll ping there when it's done.
pic
video: https://github.com/user-attachments/assets/4a238f9f-dd4a-4e7b-9a6f-e458564acca7
sneak peek of the current status.
feel free to fork and use it ;)
I'm just missing the event to "redraw" applications available in the workspace. For this I would need to be notified when a window was opened or closed. Currently we only have an event when a workspace was changed which is not enough.
Let's say you just closed the last firefox windows in a last "F" workspace. Technically you are still in it, no "workspace" changed event was triggered, no way to remove "firefox" app from the "F" workspace.
Maybe aerospace could implement custom events via NSDistributedNotificationCenter: https://felixkratz.github.io/SketchyBar/config/events#creating-custom-events for a various of actions:
workspace-to-monitor-force-assignment
taken placeI'm just missing the event to "redraw" applications available in the workspace. For this I would need to be notified when a window was opened or closed. Currently we only have an event when a workspace was changed which is not enough.
Let's say you just closed the last firefox windows in a last "F" workspace. Technically you are still in it, no "workspace" changed event was triggered, no way to remove "firefox" app from the "F" workspace.
Maybe aerospace could implement custom events via NSDistributedNotificationCenter: https://felixkratz.github.io/SketchyBar/config/events#creating-custom-events for a various of actions:
- Windows added / removed from the workspace
- Workspace added/removed
i just use "on-focus-changed" good enough for me
like so https://github.com/agenttank/dotfiles_macos/blob/main/aerospace/aerospace.toml
i just use "on-focus-changed"
Actually this gave me a better responsiveness than the default "exec on workspace changed", thank you!
hello, nice discussions and work to make the interface more reflective - I am wondering on the other direction, are there minimal configs that can enable aerospace's workspace more intuitive?
The situation I often encounter with aerospace is that I lost awareness of which workspace I am on, or what is in this workspace, currently I am trying to mitigate this issue by:
Drag the aerospace menu item all the way to the right (command + drag)
Use raycast to query what's in my current workspace by a raycast Script to call:
aerospace list-windows --workspace focused
thanks @nikitabobko Not sure what could be some setups that is minimal and provide some good visual 'feedback/reflection', that it can be known quickly/intuitively which workspace is on, and what is on this workspace.
Thanks!
Hey there. I've been trying to build a proper dock-like menu bar for aerospace using sketchybar, and have run into some issues. I'm posting this in the hopes that someone else has tried this with more success, or has some suggestions. This is where I got:
It should support the following:
My impression is that there should be a better integration between aerospace and sketchybar, or else aerospace should just implement it's own menu bar. The communication between aerospace and sketchybar here is really messy (although I think this is mostly on sketchybar's side... it's very hard to manage state in sketchybar)
I think this would be a really useful tool to have, especially for users with many workspaces who want a quick way to keep track of what is where.
Here are my config files I hacked together. This is as far as I got before giving up.
aerospace.toml:
sketchybarrc:
aerospace.sh: