Skip to content

Add aerospace subscribe command for real-time event streaming#1927

Open
ojowwalker77 wants to merge 3 commits intonikitabobko:mainfrom
ojowwalker77:main
Open

Add aerospace subscribe command for real-time event streaming#1927
ojowwalker77 wants to merge 3 commits intonikitabobko:mainfrom
ojowwalker77:main

Conversation

@ojowwalker77
Copy link

@ojowwalker77 ojowwalker77 commented Jan 31, 2026

Closes #1514

Allows external tools (status bars, scripts) to receive real-time event notifications over the existing socket protocol without modifying config.

Events

  • focus-changed - window/workspace/monitor focus
  • workspace-changed - workspace switches
  • focused-monitor-changed - monitor focus
  • mode-changed - binding mode changes
  • window-detected - new windows
  • binding-triggered - keybinding executed

Usage

aerospace subscribe workspace-changed focus-changed
aerospace subscribe --all

Output (JSON lines)

{"event":"focus-changed","windowId":1234,"workspace":"1","monitorId":0}
{"event":"workspace-changed","workspace":"2","prevWorkspace":"1"}

Initial state (current focus/mode) is sent on connect. Tested with rapid workspace switching.

image

Allows external tools (status bars, scripts) to receive real-time event
notifications over the existing socket protocol without modifying config.

Events: focus-changed, workspace-changed, focused-monitor-changed,
mode-changed, window-detected, binding-triggered

Usage: aerospace subscribe [--all] [<event>...]

Initial state (current focus/mode) is sent on connect. Events are
streamed as JSON lines until the client disconnects.

Closes nikitabobko#1514
@ojowwalker77
Copy link
Author

hey man! @nikitabobko
im bringing Barik back to life
this would be great

Copy link
Owner

@nikitabobko nikitabobko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks, I send you the first review iteration

@ojowwalker77
Copy link
Author

on it!

….write

Previously, header and payload were sent as two separate writes which could
interleave with concurrent writes. Now they are combined into a single Data
before sending.
- Subscribe to specific events: focus-changed, focused-monitor-changed,
  focused-workspace-changed, mode-changed, window-detected, binding-triggered
- Events streamed as JSON lines over persistent socket connection
- Initial state sent on connect for stateful events
- Use --all flag to subscribe to all event types
- Duplicate event args are rejected
- ServerEvent uses static factory methods for type safety
- monitorId is now 1-based (0 means unknown) in event output
- Documentation and shell completion updated
nikitabobko added a commit that referenced this pull request Feb 6, 2026
Allows external tools (status bars, scripts) to receive real-time event
notifications over the existing socket protocol without modifying config.

Events: focus-changed, workspace-changed, focused-monitor-changed,
mode-changed, window-detected, binding-triggered

Initial state (current focus/mode) is sent on connect. Events are
streamed as JSON lines until the client disconnects.

#1514
closes #1927

Co-authored-by: Nikita Bobko <git@bobko.xyz>
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.

Expose AeroSpace callbacks via socket protocol

2 participants