Commit Graph
69 Commits
Author SHA1 Message Date
LGUG2Z fa6ce669f7 fix(wm): use absolute monitor sizes and fix deadlock
This commit switches to using absolute intead of relative monitor sizes,
I don't fully understand by the NS APIs and the CG APIs return totally
different coordinate systems.

There was also a deadlock in the monitor reconciliator which I think I
figured out; it's a little ugly both in code and in execution but the
deadlocks and pkill -9s can be put away from now.

Cross-monitor moves aren't working which I'll look into next.
2025-09-26 09:53:37 -07:00
LGUG2Z f7afe4f8ec fix(wm): change ws on cmd+tab across ws
This is gonna drive me insane. Previous fix for something broke this.
Now we only try to focus in FocusChange on a base case if the workspace
we are on contains the target window.

This lets us fall through to the end of the handler which will try to
switch workspace if we know it's on another workspace.

Also fixed another bug around focusing the correct window on the
workspace switched to (since all the apps fire AX events when the
workspace is switched) by introducing a new ManualNotification which
lets us target the specific window that was cmd+tabbed to.
2025-09-25 17:54:47 -07:00
LGUG2Z a6ced512d7 feat(wm): migrate monitor reconciliator
I have no idea if this works at this point, I just tried to get
everything compiling and adhering to the macOS threading model for
access to NSScreen.
2025-09-25 17:20:01 -07:00
LGUG2Z 7217f311f2 feat(wm): implement replace configuration
I think this is the last SocketMessage variant I'll be bringing over
before working on docs. Haven't tested this one but it should work
pretty much the same as on Windows.
2025-09-25 14:32:08 -07:00
LGUG2Z c66db5a0bd feat(cli): implement display index preference cmd
This commit implements the komorebic display-index-preference command
for updating display index preferences, however the monitor
reconciliator module has not been reimplemented completely yet so these
values will not have any effect.
2025-09-25 14:23:43 -07:00
LGUG2Z 61369df025 feat(wm): impl window debugging socket message
I think this was only used in komorebi-gui before. I should see how
difficult it'll be to migrate that for macOS as well.
2025-09-25 14:09:51 -07:00
LGUG2Z 563c3b8446 feat(cli): implement save/load resize dimensions cmds 2025-09-25 13:53:35 -07:00
LGUG2Z 8f36549fae feat(cli): implement generate-static-config cmd 2025-09-25 12:41:10 -07:00
LGUG2Z c59e882a2d feat(cli): implement manage and unmanage cmds
In implementing these two I'm diverging from how komorebi for Windows
handles these a little by tracking the window IDs of manually unmanaged
applications in a global vec UNMANAGED_WINDOW_IDS.

This is due to other changes in how Show and Destroy are handled in
komorebi for macOS which means we can't just piggy-back on those
handlers like we used to.
2025-09-25 12:34:07 -07:00
LGUG2Z 20d6121568 feat(cli): implement close cmd 2025-09-25 10:29:29 -07:00
LGUG2Z a89b9cf5ac feat(cli): implement minimize cmd 2025-09-25 10:19:11 -07:00
LGUG2Z 8c4c1963bc refactor(wm): tidy up 3a24b51
Instead of doing an adhoc check just against PERMAIGNORE classes, we
might as well construct a temporary Window to check the result of the
full Window.should_manage call.
2025-09-25 10:18:38 -07:00
LGUG2Z e478ab8d0a feat(wm): implement stop handlers
This commit implements the Stop and StopIgnoreRestore SocketMessage
variants and sends them from the komorebic stop command. The ctrl-c
handler in main.rs now exits with code 130, while the Stop handlers will
exit cleanly with code 0.
2025-09-25 07:30:28 -07:00
LGUG2Z 3a24b51111 fix(wm): be more discerning with input event listener
This commit fixes a couple of subtle bugs. The InputEventListener will
now only emit a custom Show event if the CGEvent was a LeftMouseUp.

AXDialog subroles have been added to PERMAIGNORE_CLASSES, and an
additional check against PERMAIGNORE_CLASSES has been added in the Show
handler because apparently windows can change their roles after they are
created.

I had also missed a line to make sure we focus windows in a base case in
the FocusChange handler, which has now been added.
2025-09-24 21:23:26 -07:00
LGUG2Z e1be883dab feat(wm): add targeted container lock socket messages
This commit migrates the LockMonitorWorkspaceContainer and
UnlockMonitorWorkspaceContainer SocketMessage variants, which if I'm
remembering correctly were implemented to help with functionality on the
komorebi-bar.
2025-09-24 18:38:55 -07:00
LGUG2Z 20c3bbd9a1 docs(schema): add cmd to generate notification schema 2025-09-24 18:27:04 -07:00
LGUG2Z 8a17e0ad00 feat(wm): add socket subscriptions
This commit adds in the ability for users to subscribe to notifications
via a Unix domain socket. Code was mostly just migrated from komorebi.
Tested with "nc -vklU $(komorebic datadir)/test.sock" to create the
socket and listen and then "komorebic subscribe-socket test.sock" to
subscribe for notifications.
2025-09-24 16:30:44 -07:00
LGUG2Z 795ffdfa33 docs(schema): add schemars feature + schemagen cmds
Starting to think about documentation and adding in commands to generate
JSON schemas for the ApplicationSpecificConfiguration, SocketSchema and
StaticConfig.

schemars 0.8 > 0.9 has way too many breaking changes for me to care
about right now, let around 0.8 > 1.0. I'm happy being pinned on 0.8 for
now.
2025-09-24 15:18:06 -07:00
LGUG2Z 8d9d60b2e1 feat(cli): migrate more cli cfg cmds
I think this is all of the config commands migrated to komorebic now.

I still need to look in to the ManageFocusedWindow and
UnmanageFocusedWindow SocketMessage variants, as well as everything to
do with monitor reconciliation, but next I think I'll focus on trying to
generate the schemas.
2025-09-24 14:49:25 -07:00
LGUG2Z b2d4dff929 feat(cli): migrate a bunch of cfg cmds
This commit migrates a whole bunch of interactive runtime configuration
komorebic commands and implements their corresponding SocketMessage
variants.

Largely lifted as-is from komorebi for Windows.
2025-09-24 08:39:54 -07:00
LGUG2Z 0b17721580 feat(cli): implement eager-focus cmd
This commit implements SocketMessage::EagerFocus and the corresponding
komorebic eager-focus command. Mostly a straight migration from
komorebi.
2025-09-23 21:29:03 -07:00
LGUG2Z 7178609daf feat(cli): implement a bunch of rule cmds
This commit implements a whole bunch of commands around runtime
manipulation of ignore rules, manage rules and workspace rules. Mostly
lifted straight from komorebi.
2025-09-23 19:35:18 -07:00
LGUG2Z 10aabdac2c fix(wm): prune duplicate windows on ws
Got into a weird state after turning on my monitor where the same
window_id appeared in two separate containers on the workspace, so this
commit ensures that we always prune duplicate windows before updating
the workspace layout.
2025-09-23 15:04:54 -07:00
LGUG2Z dddd79d39d refactor(wm): migrate entire socketmessage enum
To give me a better idea of how the question for SocketMessage handling
parity is going, I have copied over the entire SocketCommand enum from
the Windows repo and commented out anything not yet implemented.
2025-09-23 14:37:21 -07:00
LGUG2Z a31dcbc54c refactor(cli): migrate entire subcommand enum
To give me a better idea of how the quest for komorebic command parity
is going, I have copied over the entire SubCommand enum from the Windows
repo and commented out anything not yet implemented.
2025-09-23 14:31:44 -07:00
LGUG2Z d49de398b6 feat(wm): handle various ws overrides for new windows
This commit migrates a bunch of code from komorebi that deals with how
new windows should be handled according to the various floating and
container behaviour overrides.

To help test this functionality I also finished migrating the
SessionFloatRule, SessionFloatRules and ClearSessionFloatRules
SocketMessage variants.
2025-09-23 14:18:00 -07:00
LGUG2Z 0ede90ae5d feat(wm): handle show events for apps that don't emit them
This commit introduces a little hack to emit a WindowManagerEvent::Show
every time the input event listener callback is triggered.

This is needed because some apps like Ghostty and Safari do not trigger
any events when a tab is split out into an independent window.

To keep things a little cleaner, a new SystemNotification::Manual
variant has been added which takes a ManualNotification variant.

The idea is to be able to use one of these whenever we manually emit a
notification to the window manager event listener to hopefully save my
sanity when we have to debug something in the future.
2025-09-23 13:34:50 -07:00
LGUG2Z 712f2d86a0 fix(wm): handle destruction of 1st native tab
This commit implements some fixes (still not ideal) to handle the
closing of the 1st tab of an application which uses native tabs.

When the 1st tab is destroyed, the window AXUIElement gets rendered
invalid, so we have to reap that window, and then emit our own Show
event for the tab that is becoming the new 1st tab and set that as the
window.

There is an edge case now where if this happens while the window is
floating, our emitted show event will result in that window being
integrated into the layout rather than staying tiling, but I think this
is better than having a completely janky workspace and possibly having
to restart komorebi.
2025-09-23 10:04:15 -07:00
LGUG2Z 627d150241 feat(wm): impl state queries
This commit implements SocketMessage::Query and responds correctly to
all of the various StateQuery options when komorebic query is called.
2025-09-22 21:40:24 -07:00
LGUG2Z f3b256bcbf fix(wm): handle native tabs (mostly)
This commit adds a global list of user-define-able applications which
use native tabs (I'll expose a config option for later). This is used to
improve handling of tabs.

I have tested with Ghostty and Finder. It's possible to add tabs with
cmd+t, close them with cmd+w, and also to drag them into their own
windows.

It's also possible to cmd+n to create a new window instance in Finder,
but when doing this with Ghostty, it doesn't emit an event (I think this
is a bug in Ghostty, since it works fine with Finder).
2025-09-22 18:59:40 -07:00
LGUG2Z b020b5bb69 feat(cli): add start and stop commands 2025-09-22 16:37:30 -07:00
LGUG2Z d77ae2d03a feat(cli): add log cmd
This commit adds logs written to files in the app's datadir, which can
then be tailed by the komorebic log command. temp_dir() was being weird
so I just stuck with DATA_DIR.
2025-09-22 15:55:19 -07:00
LGUG2Z 7467b8e30a feat(cli): add config and datadir commands 2025-09-22 15:45:04 -07:00
LGUG2Z 474f7e26d8 feat(wm): ensure we don't run multiple komorebi procs 2025-09-22 15:42:19 -07:00
LGUG2Z a8de084a85 refactor(clippy): apply rustc 1.90.0 lints 2025-09-22 15:06:39 -07:00
LGUG2Z de2c105fe1 chore(deps): flake.lock: Update
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/d599ae4847e7f87603e7082d73ca673aa93c916d' (2025-09-06)
  → 'github:ipetkov/crane/a669fe77a8b0cd6f11419d89ea45a16691ca5121' (2025-09-18)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/c23193b943c6c689d70ee98ce3128239ed9e32d1' (2025-09-13)
  → 'github:nixos/nixpkgs/8eaee110344796db060382e15d3af0a9fc396e0e' (2025-09-19)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/09442765a05c2ca617c20ed68d9613da92a2d96b' (2025-09-15)
  → 'github:oxalica/rust-overlay/d2bac276ac7e669a1f09c48614538a37e3eb6d0f' (2025-09-22)
2025-09-22 15:02:23 -07:00
LGUG2Z 465fa02afc feat(cli): add fetch-asc cmd
Now that we have an applications.mac.json file in the asc repo, this commit adds a fetcher command.
2025-09-22 14:46:28 -07:00
LGUG2Z 84d27f83e0 fix(wm): make hidden windows take up less space 2025-09-22 14:26:21 -07:00
LGUG2Z f6997577f1 fix(wm): respect workspace window rules
This commit adds window ID tracking like we do in komorebi for Windows
and fixes a bunch of bugs that were happening when a window on another
workspace was focused either via the Dock or cmd+tab, and also a bug in
workspace rules where on launch, a window would not respect workspace
rules due to another workaround that had been added to make Apple apps
work nicely.
2025-09-22 13:31:45 -07:00
LGUG2Z 02523d8b34 feat(wm): enrich monitors with serial id
This commit does some wrangling of the ioreg output to enrich monitors
with product names and serial number IDs, the latter of which is very
important to maintain compatibility with komorebi for Windows.

I can't get the equivalent of device and device_id on macOS, but these
are legacy things in komorebi for Windows so I think I'll leave them
out.

To verify monitor information, SocketMessage::MonitorInformation has
been implemented.
2025-09-22 12:16:32 -07:00
LGUG2Z c84db9a894 feat(wm): impl state, global-state and visible-windows
This commit implements the State, GlobalState and VisibleWindows
SocketMessage variants. These are the first of the SocketMessage
variants send by komorebic which receive a reply which is printed out to
the console.

I think the next thing to do will probably be to get the extended
display info so that the MonitorInformation variant can be handled too.
2025-09-21 21:07:52 -07:00
LGUG2Z d9a8634559 feat(config): migrate most of static config
This commit migrates everything needed to get to the point where I can
load my existing Windows komorebi.json file and have the key parts
working as expected (workspace rules, manage rules, ignore rules,
floating applications etc.)

A lot of lift and shift, some wrangling things to work with the subtle
changes in this codebase, but overall I'm very happy with this.
2025-09-21 19:33:48 -07:00
LGUG2Z 34beecdb22 feat(wm): migrate asc and config generation primitives 2025-09-21 17:28:33 -07:00
LGUG2Z 8b9b578217 feat(wm): enrich window with info needed for rules
This commit enriches the Window struct with functions that we'll need to
be able to fetch the relevant information to implement matching rules.
2025-09-21 16:04:12 -07:00
LGUG2Z d5919112d9 feat(wm): add reaper and input event listener
This commit adds a reaper module which gets notified whenever an
AXUIElement is invalid (so far this is notified when a set_position call
on a Window fails), and an input event listener which somewhat coarsely
emits an event whenever a mouse-up or key-up is registered.

This is to handle Apple applications like Notes and Mail which don't
fire any events at all when a window is closed.

Pretty gross. Will see if this can be improved in the future.
2025-09-21 14:53:29 -07:00
LGUG2Z c45090c5c5 feat(wm): handle monitor resizes on the main thread
Got some weird behaviour when calculating the work area offset when
resuming from sleep so I bit the bullet and added an AtomicBool flag
that gets set when we need to call into NSScreen to get the correct work
area and size after a display resizes.

The flag gets checked in the same loop on the main thread which is
checking for ctrl-c signals.
2025-09-21 10:59:02 -07:00
LGUG2Z 98616c4288 feat(wm): add display reconfiguration listener
This commit adds a display reconfiguration listener which emits
notifications to a monitor reconciliator module which operates on a
background thread.

So far I'm only handling the resize notification because I have to
change the scaling when I'm recording devlogs and I don't want to have
to restart komorebi every time I do that.
2025-09-21 10:31:24 -07:00
LGUG2Z a4bc40aa5e feat(wm): add notification center listener
This commit adds a listener for the NotificationCenter of the
SharedWorkspace, which allows us to be notified of acts like new app
creation, app termination (different from app window destruction),
application hides and application unhides, among many others.

There are a lot of the AppKit notifications which can be registered with
observers on the notification center; for now I have just modeled the
AppKitWorkspaceNotification enum which seems to hold the most
interesting notifications for our use case.

NSWorkspaceDidLaunchApplicationNotification and
NSWorkspaceDidTerminateApplicationNotification are now hooked in to the
Show and Destroy WindowManagerEvents, but I still need to think about
how to hook in the events around hiding and unhiding as these are
temporary/reversible actions which operate across multiple application
windows, unlike minimize/restore which only operate on one application
window at a time.
2025-09-21 09:22:54 -07:00
LGUG2Z b7ce8c03b5 refactor(rust): standardize on ok_or_eyre and bail!
This commit standardizes the codebase to disallow usage of the raw eyre!
macro for creating errors, instead using ok_or_eyre() when constructing
ad-hoc errors from Result and Option types, and otherwise using the
bail! macro in response to failed boolean conditions.
2025-09-20 10:24:42 -07:00
LGUG2Z 63d3b4e33a fix(wm): allow closed windows to be reaped
Instead of erroring out when a window position can't be set due to the
AXUIElement no longer existing, log a warning and let the invalid
application window reaper clean it up.
2025-09-19 14:58:12 -07:00