From 2b99a68ed8f0b01551f02ce62bb1671fbdcc8487 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 16 Sep 2025 16:52:01 -0700 Subject: [PATCH 001/305] feat(wm): initial commit --- .envrc | 1 + .gitignore | 4 + Cargo.lock | 695 ++++++++++++++++++ Cargo.toml | 6 + LICENSE.md | 108 +++ README.md | 111 +++ deny.toml | 56 ++ dependencies.json | 147 ++++ flake.lock | 112 +++ flake.nix | 61 ++ justfile | 34 + komorebi/Cargo.toml | 16 + .../src/accessibility/attribute_constants.rs | 162 ++++ komorebi/src/accessibility/error.rs | 85 +++ komorebi/src/accessibility/mod.rs | 158 ++++ .../accessibility/notification_constants.rs | 43 ++ komorebi/src/application.rs | 140 ++++ komorebi/src/layout.rs | 82 +++ komorebi/src/lib.rs | 25 + komorebi/src/main.rs | 221 ++++++ komorebi/src/rect.rs | 32 + komorebi/src/window.rs | 281 +++++++ rust-toolchain.toml | 2 + rustfmt.toml | 1 + shell.nix | 14 + 25 files changed, 2597 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 deny.toml create mode 100644 dependencies.json create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 justfile create mode 100644 komorebi/Cargo.toml create mode 100644 komorebi/src/accessibility/attribute_constants.rs create mode 100644 komorebi/src/accessibility/error.rs create mode 100644 komorebi/src/accessibility/mod.rs create mode 100644 komorebi/src/accessibility/notification_constants.rs create mode 100644 komorebi/src/application.rs create mode 100644 komorebi/src/layout.rs create mode 100644 komorebi/src/lib.rs create mode 100644 komorebi/src/main.rs create mode 100644 komorebi/src/rect.rs create mode 100644 komorebi/src/window.rs create mode 100644 rust-toolchain.toml create mode 100644 rustfmt.toml create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..8392d159 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b824c3d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +/result +/.idea +/.direnv diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..fcf52752 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,695 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "backtrace" +version = "0.3.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "bitflags" +version = "2.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" + +[[package]] +name = "block2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2" +dependencies = [ + "objc2", +] + +[[package]] +name = "cfg-if" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "color-eyre" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + +[[package]] +name = "ctrlc" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881c5d0a13b2f1498e2306e82cbada78390e152d4b1378fb28a84f4dcd0dc4f3" +dependencies = [ + "dispatch", + "nix", + "windows-sys 0.61.0", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" +dependencies = [ + "bitflags", + "objc2", +] + +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "indenter" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" + +[[package]] +name = "komorebi" +version = "0.1.0" +dependencies = [ + "color-eyre", + "ctrlc", + "objc2", + "objc2-app-kit", + "objc2-application-services", + "objc2-core-foundation", + "objc2-core-graphics", + "thiserror", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.175" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" + +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "nix" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "objc2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "561f357ba7f3a2a61563a186a163d0a3a5247e1089524a3981d49adb775078bc" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc" +dependencies = [ + "bitflags", + "block2", + "libc", + "objc2", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-image", + "objc2-foundation", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-application-services" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9abc05b1f757ebfbd72f4f3f9a515662c67dfe66b26e71b37d818f56a1c2f17" +dependencies = [ + "bitflags", + "libc", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-services", + "objc2-foundation", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17614fdcd9b411e6ff1117dfb1d0150f908ba83a7df81b1f118005fe0a8ea15d" +dependencies = [ + "bitflags", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-data" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291fbbf7d29287518e8686417cf7239c74700fd4b607623140a7d4a3c834329d" +dependencies = [ + "bitflags", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166" +dependencies = [ + "bitflags", + "block2", + "dispatch2", + "libc", + "objc2", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4" +dependencies = [ + "bitflags", + "block2", + "dispatch2", + "libc", + "objc2", + "objc2-core-foundation", + "objc2-io-surface", + "objc2-metal", +] + +[[package]] +name = "objc2-core-image" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b3dc0cc4386b6ccf21c157591b34a7f44c8e75b064f85502901ab2188c007e" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-services" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "159be6e4cd366c7d236d798daa2aa71855230e5691cde045a0670ce01a06d664" +dependencies = [ + "dispatch2", + "objc2", + "objc2-core-foundation", + "objc2-security", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c" +dependencies = [ + "bitflags", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c" +dependencies = [ + "bitflags", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-metal" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f246c183239540aab1782457b35ab2040d4259175bd1d0c58e46ada7b47a874" +dependencies = [ + "bitflags", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ffb6a0cd5f182dc964334388560b12a57f7b74b3e2dec5e2722aa2dfb2ccd5" +dependencies = [ + "bitflags", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-security" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1f8e0ef3ab66b08c42644dcb34dba6ec0a574bbd8adbb8bdbdc7a2779731a44" +dependencies = [ + "bitflags", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "owo-colors" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "proc-macro2" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex-automata" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" + +[[package]] +name = "rustc-demangle" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "syn" +version = "2.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "unicode-ident" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "windows-link" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..272a0c63 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] + +resolver = "2" +members = [ + "komorebi", +] \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..8796dd2f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,108 @@ +# Komorebi License + +Version 2.0.0 + +## Acceptance + +In order to get any license under these terms, you must agree +to them as both strict obligations and conditions to all +your licenses. + +## Copyright License + +The licensor grants you a copyright license for the software +to do everything you might do with the software that would +otherwise infringe the licensor's copyright in it for any +permitted purpose. However, you may only distribute the source +code of the software according to the [Distribution License]( +#distribution-license), you may only make changes according +to the [Changes License](#changes-license), and you may not +otherwise distribute the software or new works based on the +software. + +## Distribution License + +The licensor grants you an additional copyright license to +distribute copies of the source code of the software. Your +license to distribute covers distributing the source code of +the software with changes permitted by the [Changes License]( +#changes-license). + +## Changes License + +The licensor grants you an additional copyright license to +make changes for any permitted purpose. + +## Patent License + +The licensor grants you a patent license for the software that +covers patent claims the licensor can license, or becomes able +to license, that you would infringe by using the software. + +## Personal Uses + +Personal use for research, experiment, and testing for +the benefit of public knowledge, personal study, private +entertainment, hobby projects, amateur pursuits, or religious +observance, without any anticipated commercial application, +is use for a permitted purpose. + +## Fair Use + +You may have "fair use" rights for the software under the +law. These terms do not limit them. + +## No Other Rights + +These terms do not allow you to sublicense or transfer any of +your licenses to anyone else, or prevent the licensor from +granting licenses to anyone else. These terms do not imply +any other licenses. + +## Patent Defense + +If you make any written claim that the software infringes or +contributes to infringement of any patent, your patent license +for the software granted under these terms ends immediately. If +your company makes such a claim, your patent license ends +immediately for work on behalf of your company. + +## Violations + +The first time you are notified in writing that you have +violated any of these terms, or done anything with the software +not covered by your licenses, your licenses can nonetheless +continue if you come into full compliance with these terms, +and take practical steps to correct past violations, within +32 days of receiving notice. Otherwise, all your licenses +end immediately. + +## No Liability + +***As far as the law allows, the software comes as is, without +any warranty or condition, and the licensor will not be liable +to you for any damages arising out of these terms or the use +or nature of the software, under any kind of legal claim.*** + +## Definitions + +The **licensor** is the individual or entity offering these +terms, and the **software** is the software the licensor makes +available under these terms. + +**You** refers to the individual or entity agreeing to these +terms. + +**Your company** is any legal entity, sole proprietorship, +or other kind of organization that you work for, plus all +organizations that have control over, are under the control of, +or are under common control with that organization. **Control** +means ownership of substantially all the assets of an entity, +or the power to direct its management and policies by vote, +contract, or otherwise. Control can be direct or indirect. + +**Your licenses** are all the licenses granted to you for the +software under these terms. + +**Use** means anything you do with the software requiring one +of your licenses. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..46adabbc --- /dev/null +++ b/README.md @@ -0,0 +1,111 @@ +# komorebi for Mac + +Tiling Window Management for macOS. + +

+ + Tech for Palestine + + +[//]: # ' GitHub Workflow Status' +[//]: # ' GitHub all releases' +[//]: # ' GitHub commits since latest release (by date) for a branch' + + Active Individual Commercial Use Licenses + + + Discord + + + GitHub Sponsors + + + Ko-fi + + + Notado Feed + + + YouTube + +

+ +## Overview + +_komorebi for Mac_ is a tiling window manager that works as an extension to the +standard macOS desktop environment. + +_komorebi for Mac_ aims to make _as few modifications as possible_ to the +operating system and desktop environment by default. + +_komorebi for Mac_ is currently under development, and this repository is +currently restricted to sponsors. + +## Community + +There is a [Discord server](https://discord.gg/mGkn66PHkx) available for +_komorebi_-related discussion, help, troubleshooting etc. If you have any +specific feature requests or bugs to report, please create an issue in this +repository. + +There is +a [YouTube channel](https://www.youtube.com/channel/UCeai3-do-9O4MNy9_xjO6mg) +where I post _komorebi_ development videos, feature previews and release +overviews. Subscribing to the channel (which is monetized as part of the YouTube +Partner Program) and watching videos is a really simple and passive way to +contribute financially to the development and maintenance of _komorebi_. + +There is an [Awesome List](https://github.com/LGUG2Z/awesome-komorebi) which +showcases the many awesome projects that exist in the _komorebi_ ecosystem. + +## Licensing for Personal Use + +`komorebi` +is [educational source software](https://lgug2z.com/articles/educational-source-software/). + +`komorebi` is licensed under +the [Komorebi 2.0.0 license](https://github.com/LGUG2Z/komorebi-license), which +is a fork of +the [PolyForm Strict 1.0.0 license](https://polyformproject.org/licenses/strict/1.0.0). +On a high level this means that you are free to do whatever you want with +`komorebi` for personal use other than redistribution, or distribution of new +works (i.e. hard-forks) based on the software. + +Anyone is free to make their own fork of `komorebi` with changes intended either +for personal use or for integration back upstream via pull requests. + +The [Komorebi 2.0.0 License](https://github.com/LGUG2Z/komorebi-license) does +not permit any kind of commercial use ( i.e. using `komorebi` at work). + +## Sponsorship for Personal Use + +_komorebi for Mac_ is a free and educational source project, and one that +encourages you to make charitable donations if you find the software to be +useful and have the financial means. + +I encourage you to make a charitable donation to +the [Palestine Children's Relief Fund](https://pcrf1.app.neoncrm.com/forms/gaza-recovery) +or to contribute to a [Gaza Funds campaign](https://gazafunds.com) before you +consider sponsoring me on GitHub. + +[GitHub Sponsors is enabled for this project](https://github.com/sponsors/LGUG2Z). +Sponsors can claim custom roles on the Discord server, get shout outs at the end +of _komorebi_-related videos on YouTube, gain the ability to submit feature +requests on the issue tracker, and receive releases of komorebi with "easter +eggs" on physical media. + +If you would like to tip or sponsor the project but are unable to use GitHub +Sponsors, you may also sponsor through [Ko-fi](https://ko-fi.com/lgug2z), or +make an anonymous Bitcoin donation to +`bc1qv73wzspc77k46uty4vp85x8sdp24mphvm58f6q`. + +## Licensing for Commercial Use + +A dedicated Individual Commercial Use License will eventually be made available +for those who want to use `komorebi` at work. + +The Individual Commerical Use License will add “Commercial Use” as a “Permitted +Use” for the licensed individual only, for the duration of a valid paid license +subscription only. All provisions and restrictions enumerated in +the [Komorebi License](https://github.com/LGUG2Z/komorebi-license) will continue +to apply. diff --git a/deny.toml b/deny.toml new file mode 100644 index 00000000..2b05403b --- /dev/null +++ b/deny.toml @@ -0,0 +1,56 @@ +[graph] +targets = [ + "aarch64-apple-darwin", +] +all-features = false +no-default-features = false + +[output] +feature-depth = 1 + +[advisories] +ignore = [] + +[licenses] +allow = [ + "0BSD", + "Apache-2.0", + "MIT", + "Unicode-3.0", + "Zlib", + "LicenseRef-Komorebi-2.0" + + # these are also ok, but not yet used + + # "Artistic-2.0", + # "BSD-2-Clause", + # "BSD-3-Clause", + # "BSL-1.0", + # "CC0-1.0", + # "ISC", + # "MIT-0", + # "MPL-2.0", + # "OFL-1.1", + # "Ubuntu-font-1.0", +] +confidence-threshold = 0.8 + +[[licenses.clarify]] +crate = "komorebi" +expression = "LicenseRef-Komorebi-2.0" +license-files = [] + +[bans] +multiple-versions = "allow" +wildcards = "allow" +highlight = "all" +workspace-default-features = "allow" +external-default-features = "allow" + +[sources] +unknown-registry = "deny" +unknown-git = "deny" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +allow-git = [ + # "https://github.com/LGUG2Z/komorebi-for-mac", +] \ No newline at end of file diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 00000000..c6e43704 --- /dev/null +++ b/dependencies.json @@ -0,0 +1,147 @@ +{ + "licenses": [ + [ + "0BSD", + [ + "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "Apache-2.0", + [ + "addr2line 0.24.2 registry+https://github.com/rust-lang/crates.io-index", + "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", + "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", + "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", + "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", + "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-data 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", + "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", + "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", + "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", + "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", + "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "MIT", + [ + "addr2line 0.24.2 registry+https://github.com/rust-lang/crates.io-index", + "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", + "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", + "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", + "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", + "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index", + "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", + "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-data 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-encode 4.1.0 registry+https://github.com/rust-lang/crates.io-index", + "objc2-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", + "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", + "owo-colors 4.2.2 registry+https://github.com/rust-lang/crates.io-index", + "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", + "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", + "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", + "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", + "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", + "tracing 0.1.41 registry+https://github.com/rust-lang/crates.io-index", + "tracing-attributes 0.1.30 registry+https://github.com/rust-lang/crates.io-index", + "tracing-core 0.1.34 registry+https://github.com/rust-lang/crates.io-index", + "tracing-error 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "tracing-log 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "Unicode-3.0", + [ + "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "Unlicense", + [ + "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "Zlib", + [ + "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-data 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index" + ] + ] + ] +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..35a34384 --- /dev/null +++ b/flake.lock @@ -0,0 +1,112 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1757183466, + "narHash": "sha256-kTdCCMuRE+/HNHES5JYsbRHmgtr+l9mOtf5dpcMppVc=", + "owner": "ipetkov", + "repo": "crane", + "rev": "d599ae4847e7f87603e7082d73ca673aa93c916d", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1757745802, + "narHash": "sha256-hLEO2TPj55KcUFUU1vgtHE9UEIOjRcH/4QbmfHNF820=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c23193b943c6c689d70ee98ce3128239ed9e32d1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1757930296, + "narHash": "sha256-Z9u5VszKs8rfEvg2AsFucWEjl7wMtAln9l1b78cfBh4=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "09442765a05c2ca617c20ed68d9613da92a2d96b", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..61198d2f --- /dev/null +++ b/flake.nix @@ -0,0 +1,61 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + crane.url = "github:ipetkov/crane"; + }; + + outputs = inputs: + with inputs; + flake-utils.lib.eachDefaultSystem ( + system: let + overlays = [ + (import rust-overlay) + ]; + pkgs = (import nixpkgs) { + inherit system overlays; + }; + + inherit (pkgs) lib; + + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + + pname = "komorebi"; + version = "0.1.0"; + + commonArgs = { + inherit pname version; + nativeBuildInputs = with pkgs; [ +# pkg-config + ]; + doCheck = false; + buildInputs = with pkgs; [ + gcc + libiconv + ]; + }; + + cargoArtifacts = craneLib.buildDepsOnly (commonArgs + // { + src = craneLib.cleanCargoSource (craneLib.path ./.); + }); + + komorebi = craneLib.buildPackage (commonArgs + // { + inherit cargoArtifacts; + src = ./.; + }); + in { + devShells = flake-utils.lib.flattenTree { + default = import ./shell.nix {inherit pkgs;}; + }; + + packages = flake-utils.lib.flattenTree rec { + inherit komorebi; + default = komorebi; + }; + } + ); +} \ No newline at end of file diff --git a/justfile b/justfile new file mode 100644 index 00000000..ad1d795e --- /dev/null +++ b/justfile @@ -0,0 +1,34 @@ +export RUST_BACKTRACE := "full" + +clean: + cargo clean + +fmt: + cargo +nightly fmt + cargo +stable clippy + prettier --write README.md + +install target: + cargo +stable install --path {{ target }} --locked + +build target: + cargo +stable build --package {{ target }} --locked --release + +run target: + cargo +stable run --bin {{ target }} --locked + +warn target $RUST_LOG="warn": + just run {{ target }} + +info target $RUST_LOG="info": + just run {{ target }} + +debug target $RUST_LOG="debug": + just run {{ target }} + +trace target $RUST_LOG="trace": + just run {{ target }} + +depgen: + cargo deny check + cargo deny list --format json | jq 'del(.unlicensed)' > dependencies.json \ No newline at end of file diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml new file mode 100644 index 00000000..5e80fef9 --- /dev/null +++ b/komorebi/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "komorebi" +version = "0.1.0" +edition = "2024" + +[dependencies] +color-eyre = { version = "0.6" } +ctrlc = { version = "3", features = ["termination"] } +objc2 = "0.6" +objc2-app-kit = "0.3" +objc2-application-services = "0.3" +objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } +objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } +thiserror = "1" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file diff --git a/komorebi/src/accessibility/attribute_constants.rs b/komorebi/src/accessibility/attribute_constants.rs new file mode 100644 index 00000000..0b0e9998 --- /dev/null +++ b/komorebi/src/accessibility/attribute_constants.rs @@ -0,0 +1,162 @@ +#![allow(non_upper_case_globals, unused)] + +pub const kAXRoleAttribute: &str = "AXRole"; +pub const kAXSubroleAttribute: &str = "AXSubrole"; +pub const kAXRoleDescriptionAttribute: &str = "AXRoleDescription"; +pub const kAXHelpAttribute: &str = "AXHelp"; +pub const kAXTitleAttribute: &str = "AXTitle"; +pub const kAXValueAttribute: &str = "AXValue"; +pub const kAXValueDescriptionAttribute: &str = "AXValueDescription"; +pub const kAXMinValueAttribute: &str = "AXMinValue"; +pub const kAXMaxValueAttribute: &str = "AXMaxValue"; +pub const kAXValueIncrementAttribute: &str = "AXValueIncrement"; +pub const kAXAllowedValuesAttribute: &str = "AXAllowedValues"; +pub const kAXPlaceholderValueAttribute: &str = "AXPlaceholderValue"; +pub const kAXEnabledAttribute: &str = "AXEnabled"; +pub const kAXElementBusyAttribute: &str = "AXElementBusy"; +pub const kAXFocusedAttribute: &str = "AXFocused"; +pub const kAXParentAttribute: &str = "AXParent"; +pub const kAXChildrenAttribute: &str = "AXChildren"; +pub const kAXSelectedChildrenAttribute: &str = "AXSelectedChildren"; +pub const kAXVisibleChildrenAttribute: &str = "AXVisibleChildren"; +pub const kAXWindowAttribute: &str = "AXWindow"; +pub const kAXTopLevelUIElementAttribute: &str = "AXTopLevelUIElement"; +pub const kAXPositionAttribute: &str = "AXPosition"; +pub const kAXSizeAttribute: &str = "AXSize"; +pub const kAXOrientationAttribute: &str = "AXOrientation"; +pub const kAXDescriptionAttribute: &str = "AXDescription"; +pub const kAXDescription: &str = "AXDescription"; // old name +pub const kAXSelectedTextAttribute: &str = "AXSelectedText"; +pub const kAXSelectedTextRangeAttribute: &str = "AXSelectedTextRange"; +pub const kAXSelectedTextRangesAttribute: &str = "AXSelectedTextRanges"; +pub const kAXVisibleCharacterRangeAttribute: &str = "AXVisibleCharacterRange"; +pub const kAXNumberOfCharactersAttribute: &str = "AXNumberOfCharacters"; +pub const kAXSharedTextUIElementsAttribute: &str = "AXSharedTextUIElements"; +pub const kAXSharedCharacterRangeAttribute: &str = "AXSharedCharacterRange"; +pub const kAXSharedFocusElementsAttribute: &str = "AXSharedFocusElements"; +pub const kAXInsertionPointLineNumberAttribute: &str = "AXInsertionPointLineNumber"; +pub const kAXMainAttribute: &str = "AXMain"; +pub const kAXMinimizedAttribute: &str = "AXMinimized"; +pub const kAXCloseButtonAttribute: &str = "AXCloseButton"; +pub const kAXZoomButtonAttribute: &str = "AXZoomButton"; +pub const kAXMinimizeButtonAttribute: &str = "AXMinimizeButton"; +pub const kAXToolbarButtonAttribute: &str = "AXToolbarButton"; +pub const kAXFullScreenButtonAttribute: &str = "AXFullScreenButton"; +pub const kAXProxyAttribute: &str = "AXProxy"; +pub const kAXGrowAreaAttribute: &str = "AXGrowArea"; +pub const kAXModalAttribute: &str = "AXModal"; +pub const kAXDefaultButtonAttribute: &str = "AXDefaultButton"; +pub const kAXCancelButtonAttribute: &str = "AXCancelButton"; +pub const kAXMenuItemCmdCharAttribute: &str = "AXMenuItemCmdChar"; +pub const kAXMenuItemCmdVirtualKeyAttribute: &str = "AXMenuItemCmdVirtualKey"; +pub const kAXMenuItemCmdGlyphAttribute: &str = "AXMenuItemCmdGlyph"; +pub const kAXMenuItemCmdModifiersAttribute: &str = "AXMenuItemCmdModifiers"; +pub const kAXMenuItemMarkCharAttribute: &str = "AXMenuItemMarkChar"; +pub const kAXMenuItemPrimaryUIElementAttribute: &str = "AXMenuItemPrimaryUIElement"; + +pub const kAXMenuItemModifierNone: u32 = 0; +pub const kAXMenuItemModifierShift: u32 = 1 << 0; +pub const kAXMenuItemModifierOption: u32 = 1 << 1; +pub const kAXMenuItemModifierControl: u32 = 1 << 2; +pub const kAXMenuItemModifierNoCommand: u32 = 1 << 3; + +pub const kAXMenuBarAttribute: &str = "AXMenuBar"; +pub const kAXWindowsAttribute: &str = "AXWindows"; +pub const kAXFrontmostAttribute: &str = "AXFrontmost"; +pub const kAXHiddenAttribute: &str = "AXHidden"; +pub const kAXMainWindowAttribute: &str = "AXMainWindow"; +pub const kAXFocusedWindowAttribute: &str = "AXFocusedWindow"; +pub const kAXFocusedUIElementAttribute: &str = "AXFocusedUIElement"; +pub const kAXExtrasMenuBarAttribute: &str = "AXExtrasMenuBar"; +pub const kAXHeaderAttribute: &str = "AXHeader"; +pub const kAXEditedAttribute: &str = "AXEdited"; +pub const kAXValueWrapsAttribute: &str = "AXValueWraps"; +pub const kAXTabsAttribute: &str = "AXTabs"; +pub const kAXTitleUIElementAttribute: &str = "AXTitleUIElement"; +pub const kAXHorizontalScrollBarAttribute: &str = "AXHorizontalScrollBar"; +pub const kAXVerticalScrollBarAttribute: &str = "AXVerticalScrollBar"; +pub const kAXOverflowButtonAttribute: &str = "AXOverflowButton"; +pub const kAXFilenameAttribute: &str = "AXFilename"; +pub const kAXExpandedAttribute: &str = "AXExpanded"; +pub const kAXSelectedAttribute: &str = "AXSelected"; +pub const kAXSplittersAttribute: &str = "AXSplitters"; +pub const kAXNextContentsAttribute: &str = "AXNextContents"; +pub const kAXDocumentAttribute: &str = "AXDocument"; +pub const kAXDecrementButtonAttribute: &str = "AXDecrementButton"; +pub const kAXIncrementButtonAttribute: &str = "AXIncrementButton"; +pub const kAXPreviousContentsAttribute: &str = "AXPreviousContents"; +pub const kAXContentsAttribute: &str = "AXContents"; +pub const kAXIncrementorAttribute: &str = "AXIncrementor"; +pub const kAXHourFieldAttribute: &str = "AXHourField"; +pub const kAXMinuteFieldAttribute: &str = "AXMinuteField"; +pub const kAXSecondFieldAttribute: &str = "AXSecondField"; +pub const kAXAMPMFieldAttribute: &str = "AXAMPMField"; +pub const kAXDayFieldAttribute: &str = "AXDayField"; +pub const kAXMonthFieldAttribute: &str = "AXMonthField"; +pub const kAXYearFieldAttribute: &str = "AXYearField"; +pub const kAXColumnTitleAttribute: &str = "AXColumnTitles"; +pub const kAXURLAttribute: &str = "AXURL"; +pub const kAXLabelUIElementsAttribute: &str = "AXLabelUIElements"; +pub const kAXLabelValueAttribute: &str = "AXLabelValue"; +pub const kAXShownMenuUIElementAttribute: &str = "AXShownMenuUIElement"; +pub const kAXServesAsTitleForUIElementsAttribute: &str = "AXServesAsTitleForUIElements"; +pub const kAXLinkedUIElementsAttribute: &str = "AXLinkedUIElements"; +pub const kAXRowsAttribute: &str = "AXRows"; +pub const kAXVisibleRowsAttribute: &str = "AXVisibleRows"; +pub const kAXSelectedRowsAttribute: &str = "AXSelectedRows"; +pub const kAXColumnsAttribute: &str = "AXColumns"; +pub const kAXVisibleColumnsAttribute: &str = "AXVisibleColumns"; +pub const kAXSelectedColumnsAttribute: &str = "AXSelectedColumns"; +pub const kAXSortDirectionAttribute: &str = "AXSortDirection"; +pub const kAXIndexAttribute: &str = "AXIndex"; +pub const kAXDisclosingAttribute: &str = "AXDisclosing"; +pub const kAXDisclosedRowsAttribute: &str = "AXDisclosedRows"; +pub const kAXDisclosedByRowAttribute: &str = "AXDisclosedByRow"; +pub const kAXDisclosureLevelAttribute: &str = "AXDisclosureLevel"; +pub const kAXMatteHoleAttribute: &str = "AXMatteHole"; +pub const kAXMatteContentUIElementAttribute: &str = "AXMatteContentUIElement"; +pub const kAXMarkerUIElementsAttribute: &str = "AXMarkerUIElements"; +pub const kAXUnitsAttribute: &str = "AXUnits"; +pub const kAXUnitDescriptionAttribute: &str = "AXUnitDescription"; +pub const kAXMarkerTypeAttribute: &str = "AXMarkerType"; +pub const kAXMarkerTypeDescriptionAttribute: &str = "AXMarkerTypeDescription"; +pub const kAXIsApplicationRunningAttribute: &str = "AXIsApplicationRunning"; +pub const kAXSearchButtonAttribute: &str = "AXSearchButton"; +pub const kAXClearButtonAttribute: &str = "AXClearButton"; +pub const kAXFocusedApplicationAttribute: &str = "AXFocusedApplication"; +pub const kAXRowCountAttribute: &str = "AXRowCount"; +pub const kAXColumnCountAttribute: &str = "AXColumnCount"; +pub const kAXOrderedByRowAttribute: &str = "AXOrderedByRow"; +pub const kAXWarningValueAttribute: &str = "AXWarningValue"; +pub const kAXCriticalValueAttribute: &str = "AXCriticalValue"; +pub const kAXSelectedCellsAttribute: &str = "AXSelectedCells"; +pub const kAXVisibleCellsAttribute: &str = "AXVisibleCells"; +pub const kAXRowHeaderUIElementsAttribute: &str = "AXRowHeaderUIElements"; +pub const kAXColumnHeaderUIElementsAttribute: &str = "AXColumnHeaderUIElements"; +pub const kAXRowIndexRangeAttribute: &str = "AXRowIndexRange"; +pub const kAXColumnIndexRangeAttribute: &str = "AXColumnIndexRange"; +pub const kAXHorizontalUnitsAttribute: &str = "AXHorizontalUnits"; +pub const kAXVerticalUnitsAttribute: &str = "AXVerticalUnits"; +pub const kAXHorizontalUnitDescriptionAttribute: &str = "AXHorizontalUnitDescription"; +pub const kAXVerticalUnitDescriptionAttribute: &str = "AXVerticalUnitDescription"; +pub const kAXHandlesAttribute: &str = "AXHandles"; +pub const kAXTextAttribute: &str = "AXText"; +pub const kAXVisibleTextAttribute: &str = "AXVisibleText"; +pub const kAXIsEditableAttribute: &str = "AXIsEditable"; +pub const kAXColumnTitlesAttribute: &str = "AXColumnTitles"; +pub const kAXIdentifierAttribute: &str = "AXIdentifier"; +pub const kAXAlternateUIVisibleAttribute: &str = "AXAlternateUIVisible"; +pub const kAXLineForIndexParameterizedAttribute: &str = "AXLineForIndex"; +pub const kAXRangeForLineParameterizedAttribute: &str = "AXRangeForLine"; +pub const kAXStringForRangeParameterizedAttribute: &str = "AXStringForRange"; +pub const kAXRangeForPositionParameterizedAttribute: &str = "AXRangeForPosition"; +pub const kAXRangeForIndexParameterizedAttribute: &str = "AXRangeForIndex"; +pub const kAXBoundsForRangeParameterizedAttribute: &str = "AXBoundsForRange"; +pub const kAXRTFForRangeParameterizedAttribute: &str = "AXRTFForRange"; +pub const kAXAttributedStringForRangeParameterizedAttribute: &str = "AXAttributedStringForRange"; +pub const kAXStyleRangeForIndexParameterizedAttribute: &str = "AXStyleRangeForIndex"; +pub const kAXCellForColumnAndRowParameterizedAttribute: &str = "AXCellForColumnAndRow"; +pub const kAXLayoutPointForScreenPointParameterizedAttribute: &str = "AXLayoutPointForScreenPoint"; +pub const kAXLayoutSizeForScreenSizeParameterizedAttribute: &str = "AXLayoutSizeForScreenSize"; +pub const kAXScreenPointForLayoutPointParameterizedAttribute: &str = "AXScreenPointForLayoutPoint"; +pub const kAXScreenSizeForLayoutSizeParameterizedAttribute: &str = "AXScreenSizeForLayoutSize"; diff --git a/komorebi/src/accessibility/error.rs b/komorebi/src/accessibility/error.rs new file mode 100644 index 00000000..9358c4b7 --- /dev/null +++ b/komorebi/src/accessibility/error.rs @@ -0,0 +1,85 @@ +use objc2_application_services::AXError; + +#[derive(thiserror::Error, Debug)] +pub enum AccessibilityError { + #[error(transparent)] + Api(AccessibilityApiError), + #[error(transparent)] + Custom(AccessibilityCustomError), +} + +#[derive(thiserror::Error, Debug)] +pub enum AccessibilityApiError { + #[error("AXError::Success")] + Success, + #[error("AXError::Failure")] + Failure, + #[error("AXError::IllegalArgument")] + IllegalArgument, + #[error("AXError::InvalidUIElement")] + InvalidUIElement, + #[error("AXError::InvalidUIElementObserver")] + InvalidUIElementObserver, + #[error("AXError::CannotComplete")] + CannotComplete, + #[error("AXError::AttributeUnsupported")] + AttributeUnsupported, + #[error("AXError::ActionUnsupported")] + ActionUnsupported, + #[error("AXError::NotificationUnsupported")] + NotificationUnsupported, + #[error("AXError::NotImplemented")] + NotImplemented, + #[error("AXError::NotificationAlreadyRegistered")] + NotificationAlreadyRegistered, + #[error("AXError::NotificationNotRegistered")] + NotificationNotRegistered, + #[error("AXError::APIDisabled")] + APIDisabled, + #[error("AXError::NoValue")] + NoValue, + #[error("AXError::ParameterizedAttributeUnsupported")] + ParameterizedAttributeUnsupported, + #[error("AXError::NotEnoughPrecision")] + NotEnoughPrecision, + #[error("AXError::Unknown {0}")] + Unknown(i32), +} + +#[derive(thiserror::Error, Debug)] +pub enum AccessibilityCustomError { + #[error("AXValue::create returned None")] + AxValueCreate, + #[error("NSRunningApplication could not be created for process {0}")] + NSRunningApplication(i32), +} + +impl From for AccessibilityApiError { + fn from(value: AXError) -> Self { + match value { + AXError::Success => Self::Success, + AXError::Failure => Self::Failure, + AXError::IllegalArgument => Self::IllegalArgument, + AXError::InvalidUIElement => Self::InvalidUIElement, + AXError::InvalidUIElementObserver => Self::InvalidUIElementObserver, + AXError::CannotComplete => Self::CannotComplete, + AXError::AttributeUnsupported => Self::AttributeUnsupported, + AXError::ActionUnsupported => Self::ActionUnsupported, + AXError::NotificationUnsupported => Self::NotificationUnsupported, + AXError::NotImplemented => Self::NotImplemented, + AXError::NotificationAlreadyRegistered => Self::NotificationAlreadyRegistered, + AXError::NotificationNotRegistered => Self::NotificationNotRegistered, + AXError::APIDisabled => Self::APIDisabled, + AXError::NoValue => Self::NoValue, + AXError::ParameterizedAttributeUnsupported => Self::ParameterizedAttributeUnsupported, + AXError::NotEnoughPrecision => Self::NotEnoughPrecision, + error => Self::Unknown(error.0), + } + } +} + +impl From for AccessibilityError { + fn from(value: AXError) -> Self { + Self::Api(AccessibilityApiError::from(value)) + } +} diff --git a/komorebi/src/accessibility/mod.rs b/komorebi/src/accessibility/mod.rs new file mode 100644 index 00000000..e79db36a --- /dev/null +++ b/komorebi/src/accessibility/mod.rs @@ -0,0 +1,158 @@ +use error::AccessibilityApiError; +use error::AccessibilityCustomError; +use error::AccessibilityError; +use objc2_application_services::AXObserver; +use objc2_application_services::AXObserverCallback; +use objc2_application_services::AXUIElement; +use objc2_application_services::AXValue; +use objc2_application_services::AXValueType; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; +use objc2_core_foundation::CFRunLoopSource; +use objc2_core_foundation::CFString; +use objc2_core_foundation::CFType; +use objc2_core_foundation::kCFRunLoopDefaultMode; +use std::ptr::NonNull; + +pub mod attribute_constants; +pub mod error; +pub mod notification_constants; + +pub struct AccessibilityApi; + +impl AccessibilityApi { + pub fn copy_attribute_value( + element: &AXUIElement, + attribute: &'static str, + ) -> Option> { + let mut receiver = std::ptr::null(); + + unsafe { + element.copy_attribute_value( + &CFString::from_static_str(attribute), + NonNull::from(&mut receiver), + ); + + NonNull::new(receiver.cast::().cast_mut()) + .map(|cf_type| CFRetained::from_raw(cf_type)) + } + } + + pub fn set_attribute_ax_value( + element: &AXUIElement, + attribute: &'static str, + value_type: AXValueType, + mut value: T, + ) -> Result<(), AccessibilityError> { + let pointer = NonNull::from_mut(&mut value).cast::(); + + unsafe { + let value = AXValue::new(value_type, pointer).ok_or(AccessibilityError::Custom( + AccessibilityCustomError::AxValueCreate, + ))?; + + match AccessibilityError::from( + element.set_attribute_value(&CFString::from_static_str(attribute), &value), + ) { + AccessibilityError::Api(AccessibilityApiError::Success) => Ok(()), + error => Err(error), + } + } + } + + pub fn set_attribute_cf_value( + element: &AXUIElement, + attribute: &'static str, + value: &CFType, + ) -> Result<(), AccessibilityError> { + unsafe { + match AccessibilityError::from( + element.set_attribute_value(&CFString::from_static_str(attribute), value), + ) { + AccessibilityError::Api(AccessibilityApiError::Success) => Ok(()), + error => Err(error), + } + } + } + + pub fn create_application(process_id: i32) -> CFRetained { + unsafe { AXUIElement::new_application(process_id) } + } + + pub fn create_observer( + process_id: i32, + callback: AXObserverCallback, + ) -> Result, AccessibilityError> { + let mut observer_ref = std::ptr::null_mut(); + + match AccessibilityError::from(unsafe { + AXObserver::create(process_id, callback, NonNull::from_mut(&mut observer_ref)) + }) { + AccessibilityError::Api(AccessibilityApiError::Success) => unsafe { + Ok(CFRetained::from_raw( + NonNull::new(observer_ref.cast::()).unwrap(), + )) + }, + error => Err(error), + } + } + + fn add_notifications_to_observer( + observer: &AXObserver, + element: &AXUIElement, + notifications: &[&'static str], + ) -> Result<(), AccessibilityError> { + for notification in notifications { + unsafe { + match AccessibilityError::from(AXObserver::add_notification( + observer, + element, + &CFString::from_str(notification), + std::ptr::null_mut(), + )) { + // we don't want to return until all the notifications have been added + AccessibilityError::Api(AccessibilityApiError::Success) => {} + // if the notification is already registered then we don't treat that as a true error + AccessibilityError::Api( + AccessibilityApiError::NotificationAlreadyRegistered, + ) => { + let mut pid = 0; + element.pid(NonNull::from_mut(&mut pid)); + tracing::info!( + "{notification} already exists on observer for process id {pid}" + ); + } + error => return Err(error), + } + } + } + + Ok(()) + } + + pub fn add_observer_to_run_loop( + observer: &AXObserver, + element: &AXUIElement, + notifications: &[&'static str], + run_loop: &CFRetained, + ) -> Result<(), AccessibilityError> { + AccessibilityApi::add_notifications_to_observer(observer, element, notifications)?; + + unsafe { + CFRunLoop::add_source( + run_loop, + Some(&observer.run_loop_source()), + kCFRunLoopDefaultMode, + ); + } + + Ok(()) + } + + pub fn invalidate_observer(observer: &AXObserver) { + unsafe { + // invalidate means that this will get removed from all run loops by the system + CFRunLoopSource::invalidate(&observer.run_loop_source()); + } + } +} diff --git a/komorebi/src/accessibility/notification_constants.rs b/komorebi/src/accessibility/notification_constants.rs new file mode 100644 index 00000000..6837505d --- /dev/null +++ b/komorebi/src/accessibility/notification_constants.rs @@ -0,0 +1,43 @@ +#![allow(non_upper_case_globals, unused)] + +pub const kAXMainWindowChangedNotification: &str = "AXMainWindowChanged"; +pub const kAXFocusedWindowChangedNotification: &str = "AXFocusedWindowChanged"; +pub const kAXFocusedUIElementChangedNotification: &str = "AXFocusedUIElementChanged"; +pub const kAXApplicationActivatedNotification: &str = "AXApplicationActivated"; +pub const kAXApplicationDeactivatedNotification: &str = "AXApplicationDeactivated"; +pub const kAXApplicationHiddenNotification: &str = "AXApplicationHidden"; +pub const kAXApplicationShownNotification: &str = "AXApplicationShown"; +pub const kAXWindowCreatedNotification: &str = "AXWindowCreated"; +pub const kAXWindowMovedNotification: &str = "AXWindowMoved"; +pub const kAXWindowResizedNotification: &str = "AXWindowResized"; +pub const kAXWindowMiniaturizedNotification: &str = "AXWindowMiniaturized"; +pub const kAXWindowDeminiaturizedNotification: &str = "AXWindowDeminiaturized"; +pub const kAXDrawerCreatedNotification: &str = "AXDrawerCreated"; +pub const kAXSheetCreatedNotification: &str = "AXSheetCreated"; +pub const kAXHelpTagCreatedNotification: &str = "AXHelpTagCreated"; +pub const kAXValueChangedNotification: &str = "AXValueChanged"; +pub const kAXUIElementDestroyedNotification: &str = "AXUIElementDestroyed"; +pub const kAXElementBusyChangedNotification: &str = "AXElementBusyChanged"; +pub const kAXMenuOpenedNotification: &str = "AXMenuOpened"; +pub const kAXMenuClosedNotification: &str = "AXMenuClosed"; +pub const kAXMenuItemSelectedNotification: &str = "AXMenuItemSelected"; +pub const kAXRowCountChangedNotification: &str = "AXRowCountChanged"; +pub const kAXRowExpandedNotification: &str = "AXRowExpanded"; +pub const kAXRowCollapsedNotification: &str = "AXRowCollapsed"; +pub const kAXSelectedCellsChangedNotification: &str = "AXSelectedCellsChanged"; +pub const kAXUnitsChangedNotification: &str = "AXUnitsChanged"; +pub const kAXSelectedChildrenMovedNotification: &str = "AXSelectedChildrenMoved"; +pub const kAXSelectedChildrenChangedNotification: &str = "AXSelectedChildrenChanged"; +pub const kAXResizedNotification: &str = "AXResized"; +pub const kAXMovedNotification: &str = "AXMoved"; +pub const kAXCreatedNotification: &str = "AXCreated"; +pub const kAXSelectedRowsChangedNotification: &str = "AXSelectedRowsChanged"; +pub const kAXSelectedColumnsChangedNotification: &str = "AXSelectedColumnsChanged"; +pub const kAXSelectedTextChangedNotification: &str = "AXSelectedTextChanged"; +pub const kAXTitleChangedNotification: &str = "AXTitleChanged"; +pub const kAXLayoutChangedNotification: &str = "AXLayoutChanged"; +pub const kAXAnnouncementRequestedNotification: &str = "AXAnnouncementRequested"; +pub const kAXUIElementsKey: &str = "AXUIElementsKey"; +pub const kAXPriorityKey: &str = "AXPriorityKey"; +pub const kAXAnnouncementKey: &str = "AXAnnouncementKey"; +pub const kAXUIElementTitleKey: &str = "AXUIElementTitleKey"; diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs new file mode 100644 index 00000000..0da446e0 --- /dev/null +++ b/komorebi/src/application.rs @@ -0,0 +1,140 @@ +use crate::accessibility::AccessibilityApi; +use crate::accessibility::attribute_constants::kAXTitleAttribute; +use crate::accessibility::attribute_constants::kAXWindowsAttribute; +use crate::accessibility::error::AccessibilityError; +use crate::accessibility::notification_constants::kAXApplicationActivatedNotification; +use crate::accessibility::notification_constants::kAXApplicationDeactivatedNotification; +use crate::accessibility::notification_constants::kAXApplicationHiddenNotification; +use crate::accessibility::notification_constants::kAXApplicationShownNotification; +use crate::accessibility::notification_constants::kAXMainWindowChangedNotification; +use crate::accessibility::notification_constants::kAXUIElementDestroyedNotification; +use crate::accessibility::notification_constants::kAXWindowCreatedNotification; +use crate::window::Window; +use objc2_application_services::AXObserver; +use objc2_application_services::AXUIElement; +use objc2_core_foundation::CFArray; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; +use objc2_core_foundation::CFString; +use std::ffi::c_void; +use std::ptr::NonNull; +use tracing::instrument; + +const NOTIFICATIONS: &[&str] = &[ + kAXApplicationActivatedNotification, + kAXApplicationDeactivatedNotification, + kAXApplicationHiddenNotification, + kAXApplicationShownNotification, + // this is when we change focus between two windows of the same app + kAXMainWindowChangedNotification, + // this is when the same app has a new window opened + kAXWindowCreatedNotification, + // this is when a window of an application is destroyed / closed + // when this fires, the app owner name won't be found, but the can be matched via PID + kAXUIElementDestroyedNotification, +]; + +#[derive(Debug, Clone)] +pub struct Application { + element: CFRetained, + pub process_id: i32, + pub observer: CFRetained, +} + +#[instrument(skip_all)] +unsafe extern "C-unwind" fn application_observer_callback( + _observer: NonNull, + element: NonNull, + notification: NonNull, + _context: *mut c_void, +) { + unsafe { + let name = + AccessibilityApi::copy_attribute_value::(element.as_ref(), kAXTitleAttribute) + .map(|s| s.to_string()); + + let mut pid = 0; + + element.as_ref().pid(NonNull::from_mut(&mut pid)); + + if let Some(name) = name + && !name.is_empty() + { + tracing::info!( + "notification: {}, process: {pid}, name: \"{name}\"", + notification.as_ref() + ); + } else { + tracing::info!("notification: {}, process: {pid}", notification.as_ref()); + } + } +} + +impl Drop for Application { + fn drop(&mut self) { + tracing::info!( + "invalidating application observer for process id {}", + self.process_id + ); + // make sure the observer gets removed from any run loops + AccessibilityApi::invalidate_observer(&self.observer); + } +} + +impl Application { + pub fn new(process_id: i32) -> Result { + Ok(Self { + element: AccessibilityApi::create_application(process_id), + process_id, + observer: AccessibilityApi::create_observer( + process_id, + Some(application_observer_callback), + )?, + }) + } + + pub fn name(&self) -> Option { + AccessibilityApi::copy_attribute_value::(&self.element, kAXTitleAttribute) + .map(|s| s.to_string()) + } + + #[tracing::instrument(skip_all)] + pub fn observe(&self, run_loop: &CFRetained) -> Result<(), AccessibilityError> { + tracing::info!( + "registering observer for process: {}, name: {}", + self.process_id, + self.name() + .unwrap_or_else(|| String::from("")) + ); + + AccessibilityApi::add_observer_to_run_loop( + &self.observer, + &self.element, + NOTIFICATIONS, + run_loop, + ) + } + + fn window_elements(&self) -> Option>> { + AccessibilityApi::copy_attribute_value::>( + &self.element, + kAXWindowsAttribute, + ) + } + + pub fn window_by_title(&self, title: &str) -> Option { + let mut target = None; + + for element in self.window_elements()? { + let window = Window::new(element, self.clone()).ok()?; + + if let Some(window_title) = window.title() + && window_title.eq(title) + { + target = Some(window); + } + } + + target + } +} diff --git a/komorebi/src/layout.rs b/komorebi/src/layout.rs new file mode 100644 index 00000000..3d30c6b7 --- /dev/null +++ b/komorebi/src/layout.rs @@ -0,0 +1,82 @@ +use crate::rect::Rect; + +pub fn recursive_fibonacci( + idx: usize, + count: usize, + area: &Rect, + resize_adjustments: Vec>, +) -> Vec { + let mut a = *area; + + let resized = if let Some(Some(r)) = resize_adjustments.get(idx) { + a.left += r.left; + a.top += r.top; + a.right += r.right; + a.bottom += r.bottom; + a + } else { + *area + }; + + // let half_width = area.right / 2.0; + // let half_height = area.bottom / 2.0; + let half_resized_width = resized.right / 2.0; + let half_resized_height = resized.bottom / 2.0; + + let (main_x, alt_x, alt_y, main_y); + + main_x = resized.left; + alt_x = resized.left + half_resized_width; + main_y = resized.top; + alt_y = resized.top + half_resized_height; + + #[allow(clippy::if_not_else)] + if count == 0 { + vec![] + } else if count == 1 { + vec![Rect { + left: resized.left, + top: resized.top, + right: resized.right, + bottom: resized.bottom, + }] + } else if idx % 2 != 0 { + let mut res = vec![Rect { + left: resized.left, + top: main_y, + right: resized.right, + bottom: half_resized_height, + }]; + res.append(&mut recursive_fibonacci( + idx + 1, + count - 1, + &Rect { + left: area.left, + top: alt_y, + right: area.right, + bottom: area.bottom - half_resized_height, + }, + resize_adjustments, + )); + res + } else { + let mut res = vec![Rect { + left: main_x, + top: resized.top, + right: half_resized_width, + bottom: resized.bottom, + }]; + res.append(&mut recursive_fibonacci( + idx + 1, + count - 1, + &Rect { + left: alt_x, + top: area.top, + right: area.right - half_resized_width, + bottom: area.bottom, + }, + resize_adjustments, + )); + res + } +} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs new file mode 100644 index 00000000..342c7905 --- /dev/null +++ b/komorebi/src/lib.rs @@ -0,0 +1,25 @@ +#![warn(clippy::all)] + +use objc2_core_foundation::CFArray; +use objc2_core_foundation::CFDictionary; +use objc2_core_foundation::CFString; +use std::ptr::NonNull; + +pub mod accessibility; +pub mod application; +pub mod layout; +pub mod rect; +pub mod window; + +pub fn cf_array_as(array: &CFArray) -> impl Iterator> + use<'_, T> { + let count = CFArray::count(array); + (0..count).flat_map(move |idx| { + NonNull::new(unsafe { CFArray::value_at_index(array, idx).cast_mut() }) + .map(|ptr| ptr.cast::()) + }) +} + +pub fn cf_dictionary_value(dict: &CFDictionary, key: &CFString) -> Option> { + let ptr = unsafe { CFDictionary::value(dict, NonNull::from(key).as_ptr().cast()) }; + NonNull::new(ptr.cast_mut()).map(|ptr| ptr.cast::()) +} diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs new file mode 100644 index 00000000..9432ea3e --- /dev/null +++ b/komorebi/src/main.rs @@ -0,0 +1,221 @@ +#![warn(clippy::all)] + +use color_eyre::eyre; +use color_eyre::eyre::eyre; +use komorebi::application::Application; +use komorebi::cf_array_as; +use komorebi::layout; +use komorebi::rect::Rect; +use komorebi::window::WindowInfo; +use objc2::rc::autoreleasepool; +use objc2_application_services::AXIsProcessTrusted; +use objc2_core_foundation::CFArray; +use objc2_core_foundation::CFDictionary; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; +use objc2_core_foundation::kCFRunLoopDefaultMode; +use objc2_core_graphics::CGDisplayBounds; +use objc2_core_graphics::CGMainDisplayID; +use objc2_core_graphics::CGPreflightScreenCaptureAccess; +use objc2_core_graphics::CGRequestScreenCaptureAccess; +use objc2_core_graphics::CGWindowListCopyWindowInfo; +use objc2_core_graphics::CGWindowListOption; +use objc2_core_graphics::kCGNullWindowID; +use std::collections::HashMap; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; +use std::sync::mpsc; +use tracing_subscriber::EnvFilter; + +fn check_permissions() -> eyre::Result<()> { + unsafe { + // check for screen capture access - this is needed to read window titles + if !CGPreflightScreenCaptureAccess() { + // if providing the dialog box failed, exit + if !CGRequestScreenCaptureAccess() { + eyre::bail!("failed to request screen capability"); + } + } + + if !AXIsProcessTrusted() { + eyre::bail!("komorebi needs to be added as a trusted accessibility process"); + } + + Ok(()) + } +} + +pub fn setup() -> eyre::Result<()> { + if std::env::var("RUST_LIB_BACKTRACE").is_err() { + unsafe { + std::env::set_var("RUST_LIB_BACKTRACE", "1"); + } + } + + color_eyre::install()?; + + if std::env::var("RUST_LOG").is_err() { + unsafe { + std::env::set_var("RUST_LOG", "info"); + } + } + tracing::subscriber::set_global_default( + tracing_subscriber::fmt::Subscriber::builder() + .with_env_filter(EnvFilter::from_default_env()) + .finish(), + )?; + + // https://github.com/tokio-rs/tracing/blob/master/examples/examples/panic_hook.rs + // Set a panic hook that records the panic as a `tracing` event at the + // `ERROR` verbosity level. + // + // If we are currently in a span when the panic occurred, the logged event + // will include the current span, allowing the context in which the panic + // occurred to be recorded. + std::panic::set_hook(Box::new(|panic| { + // If the panic has a source location, record it as structured fields. + panic.location().map_or_else( + || { + tracing::error!(message = %panic); + }, + |location| { + // On nightly Rust, where the `PanicInfo` type also exposes a + // `message()` method returning just the message, we could record + // just the message instead of the entire `fmt::Display` + // implementation, avoiding the duplciated location + tracing::error!( + message = %panic, + panic.file = location.file(), + panic.line = location.line(), + panic.column = location.column(), + ); + }, + ); + })); + + Ok(()) +} + +fn main() -> eyre::Result<()> { + setup()?; + check_permissions()?; + + let display_size = unsafe { CGDisplayBounds(CGMainDisplayID()) }; + tracing::info!("display size for main display is: {:?}", display_size); + + let run_loop = CFRunLoop::current().ok_or(eyre!("couldn't get CFRunLoop::current"))?; + + if let Some(window_info_list) = list_window_info() { + tracing::info!("{} windows found", window_info_list.len()); + + let mut windows = vec![]; + let mut applications = HashMap::new(); + + for entry in cf_array_as::(window_info_list.as_ref()) { + if let Some(info) = WindowInfo::new(entry).validated() { + let application = applications.entry(info.owner_pid).or_insert_with(|| { + let application = Application::new(info.owner_pid).unwrap_or_else(|_| { + panic!("failed to create application from pid {}", info.owner_pid) + }); + application + .observe(&run_loop) + .expect("application must be observable"); + application + }); + + if let Some(window) = application.window_by_title(&info.name) { + window.observe(&run_loop)?; + windows.push(window); + } + } + } + + tracing::info!("{} valid windows identified", windows.len()); + + let layouts = + layout::recursive_fibonacci(0, windows.len(), &Rect::from(display_size), vec![]); + + windows.iter().zip(layouts).for_each(|(window, layout)| { + if let Err(error) = window.set_position(&layout) { + tracing::error!( + "failed to position window: {} ({error})", + window + .title() + .unwrap_or_else(|| String::from("")) + ); + } + + // initial example to ensure that window focusing works + // if let Some(window_title) = window.title() + // && window_title.contains("Komorebi Community Server") + // { + // match window.focus() { + // Err(error) => { + // tracing::error!( + // "failed to focus window: {} ({error})", + // window + // .title() + // .unwrap_or_else(|| String::from("")) + // ); + // } + // Ok(()) => { + // tracing::info!( + // "focused window: {}", + // window + // .title() + // .unwrap_or_else(|| String::from("")) + // ); + // } + // } + // } + }); + + let quit_ctrlc = Arc::new(AtomicBool::new(false)); + let quit_thread = quit_ctrlc.clone(); + + std::thread::spawn(move || { + let (ctrlc_sender, ctrlc_receiver) = mpsc::channel(); + ctrlc::set_handler(move || { + ctrlc_sender + .send(()) + .expect("could not send signal on ctrl-c channel"); + }) + .expect("could not set ctrl-c handler"); + + ctrlc_receiver + .recv() + .expect("could not receive signal on ctrl-c channel"); + + tracing::info!("ctrl-c signal received"); + quit_ctrlc.store(true, Ordering::Relaxed); + }); + + tracing::info!("starting CFRunLoop to receive observer notifications"); + + loop { + if quit_thread.load(Ordering::Relaxed) { + tracing::info!("stopping CFRunLoop"); + break; + } + + // this gets our observer notification callbacks firing + autoreleasepool(|_| unsafe { + CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) + }); + } + } + + Ok(()) +} + +fn list_window_info() -> Option> { + unsafe { + CGWindowListCopyWindowInfo( + // this is still way too many bogus windows + CGWindowListOption::OptionOnScreenOnly | CGWindowListOption::ExcludeDesktopElements, + // required when using OnScreenOnly + kCGNullWindowID, + ) + } +} diff --git a/komorebi/src/rect.rs b/komorebi/src/rect.rs new file mode 100644 index 00000000..edc84d3e --- /dev/null +++ b/komorebi/src/rect.rs @@ -0,0 +1,32 @@ +use objc2_core_foundation::CGRect; +use objc2_core_foundation::CGSize; + +#[derive(Debug, Copy, Clone)] +pub struct Rect { + pub left: f32, + pub top: f32, + pub right: f32, + pub bottom: f32, +} + +impl From for Rect { + fn from(value: CGSize) -> Self { + Self { + left: 0.0, + top: 0.0, + right: value.width as f32, + bottom: value.height as f32, + } + } +} + +impl From for Rect { + fn from(value: CGRect) -> Self { + Self { + left: value.origin.x as f32, + top: value.origin.y as f32, + right: value.size.width as f32, + bottom: value.size.height as f32, + } + } +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs new file mode 100644 index 00000000..7d4127fa --- /dev/null +++ b/komorebi/src/window.rs @@ -0,0 +1,281 @@ +use crate::accessibility::AccessibilityApi; +use crate::accessibility::attribute_constants::kAXMainAttribute; +use crate::accessibility::attribute_constants::kAXPositionAttribute; +use crate::accessibility::attribute_constants::kAXSizeAttribute; +use crate::accessibility::attribute_constants::kAXTitleAttribute; +use crate::accessibility::error::AccessibilityCustomError; +use crate::accessibility::error::AccessibilityError; +use crate::accessibility::notification_constants::kAXTitleChangedNotification; +use crate::accessibility::notification_constants::kAXWindowDeminiaturizedNotification; +use crate::accessibility::notification_constants::kAXWindowMiniaturizedNotification; +use crate::accessibility::notification_constants::kAXWindowMovedNotification; +use crate::accessibility::notification_constants::kAXWindowResizedNotification; +use crate::application::Application; +use crate::cf_dictionary_value; +use crate::rect::Rect; +use objc2_app_kit::NSApplicationActivationOptions; +use objc2_app_kit::NSRunningApplication; +use objc2_application_services::AXObserver; +use objc2_application_services::AXUIElement; +use objc2_application_services::AXValueType; +use objc2_core_foundation::CFBoolean; +use objc2_core_foundation::CFDictionary; +use objc2_core_foundation::CFNumber; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; +use objc2_core_foundation::CFString; +use objc2_core_foundation::CGFloat; +use objc2_core_foundation::CGPoint; +use objc2_core_foundation::CGSize; +use objc2_core_graphics::kCGWindowAlpha; +use objc2_core_graphics::kCGWindowBounds; +use objc2_core_graphics::kCGWindowName; +use objc2_core_graphics::kCGWindowOwnerName; +use objc2_core_graphics::kCGWindowOwnerPID; +use std::ffi::c_void; +use std::ptr::NonNull; +use tracing::instrument; + +const NOTIFICATIONS: &[&str] = &[ + kAXWindowMiniaturizedNotification, + kAXWindowDeminiaturizedNotification, + kAXWindowMovedNotification, + kAXWindowResizedNotification, + kAXTitleChangedNotification, +]; + +#[instrument(skip_all)] +unsafe extern "C-unwind" fn window_observer_callback( + _observer: NonNull, + element: NonNull, + notification: NonNull, + _context: *mut c_void, +) { + unsafe { + let title = + AccessibilityApi::copy_attribute_value::(element.as_ref(), kAXTitleAttribute) + .map(|s| s.to_string()); + + let mut pid = 0; + + element.as_ref().pid(NonNull::from_mut(&mut pid)); + + if let Some(title) = title + && !title.is_empty() + { + tracing::info!( + "notification: {}, process: {pid}, title: \"{title}\"", + notification.as_ref() + ); + } else { + tracing::info!("notification: {}, process: {pid}", notification.as_ref()); + } + } +} + +#[derive(Debug, Default)] +pub struct WindowInfo { + name: Option, + owner_pid: i32, + owner_name: String, + alpha: f32, + bounds: WindowBounds, +} + +impl WindowInfo { + pub fn new(entry: NonNull) -> Self { + WindowInfo::from(unsafe { entry.as_ref() }) + } +} + +#[derive(Debug, Default)] +#[allow(unused)] +pub struct ValidWindowInfo { + pub name: String, + pub owner_pid: i32, + owner_name: String, + alpha: f32, + bounds: WindowBounds, +} + +impl WindowInfo { + pub fn validated(self) -> Option { + if let Some(name) = self.name + && self.alpha != 0.0 + && self.bounds.y != 0.0 + && self.bounds.height != 0.0 + && !name.is_empty() + { + return Some(ValidWindowInfo { + name, + owner_pid: self.owner_pid, + owner_name: self.owner_name, + alpha: self.alpha, + bounds: self.bounds, + }); + } + + None + } +} + +#[derive(Debug)] +#[allow(unused)] +pub struct Window { + element: CFRetained, + application: Application, + observer: CFRetained, +} + +impl Drop for Window { + fn drop(&mut self) { + // make sure the observer gets removed from any run loops + tracing::info!( + "invalidating window observer for {}", + self.title() + .unwrap_or_else(|| String::from("")) + ); + AccessibilityApi::invalidate_observer(&self.observer); + } +} + +impl Window { + pub fn new( + element: CFRetained, + application: Application, + ) -> Result { + let observer = AccessibilityApi::create_observer( + application.process_id, + Some(window_observer_callback), + )?; + + Ok(Self { + element, + application, + observer, + }) + } + + #[tracing::instrument(skip_all)] + pub fn observe(&self, run_loop: &CFRetained) -> Result<(), AccessibilityError> { + tracing::info!( + "registering observer for process: {}, title: {}", + self.application.process_id, + self.title() + .unwrap_or_else(|| String::from("")) + ); + + AccessibilityApi::add_observer_to_run_loop( + &self.observer, + &self.element, + NOTIFICATIONS, + run_loop, + ) + } + + pub fn title(&self) -> Option { + AccessibilityApi::copy_attribute_value::(&self.element, kAXTitleAttribute) + .map(|s| s.to_string()) + } + + pub fn set_position(&self, rect: &Rect) -> Result<(), AccessibilityError> { + self.set_point(CGPoint::new(rect.left as CGFloat, rect.top as CGFloat))?; + self.set_size(CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat)) + } + + pub fn focus(&self) -> Result<(), AccessibilityError> { + unsafe { + NSRunningApplication::runningApplicationWithProcessIdentifier( + self.application.process_id, + ) + .ok_or(AccessibilityError::Custom( + AccessibilityCustomError::NSRunningApplication(self.application.process_id), + ))? + .activateWithOptions(NSApplicationActivationOptions::empty()); + + let cf_boolean = CFBoolean::new(true); + let value = &**cf_boolean; + AccessibilityApi::set_attribute_cf_value(&self.element, kAXMainAttribute, value) + } + } + + pub fn set_point(&self, point: CGPoint) -> Result<(), AccessibilityError> { + AccessibilityApi::set_attribute_ax_value( + &self.element, + kAXPositionAttribute, + AXValueType::CGPoint, + point, + ) + } + + pub fn set_size(&self, size: CGSize) -> Result<(), AccessibilityError> { + AccessibilityApi::set_attribute_ax_value( + &self.element, + kAXSizeAttribute, + AXValueType::CGSize, + size, + ) + } +} + +impl From<&CFDictionary> for WindowInfo { + fn from(value: &CFDictionary) -> Self { + unsafe { + Self { + name: cf_dictionary_value::(value, kCGWindowName) + .map(|s| s.as_ref().to_string()) + .and_then(|s| if s.is_empty() { None } else { Some(s) }), + owner_pid: cf_dictionary_value::(value, kCGWindowOwnerPID) + .and_then(|s| s.as_ref().as_i32()) + .expect("window must have an owner process id"), + owner_name: cf_dictionary_value::(value, kCGWindowOwnerName) + .map(|s| s.as_ref().to_string()) + .expect("window must have an owner name"), + alpha: cf_dictionary_value::(value, kCGWindowAlpha) + .and_then(|s| s.as_ref().as_f32()) + .expect("window must have an alpha value"), + + bounds: if let Some(dict) = + cf_dictionary_value::(value, kCGWindowBounds).as_ref() + { + WindowBounds::from(dict.as_ref()) + } else { + Default::default() + }, + } + } + } +} + +#[derive(Default, Debug)] +#[allow(unused)] +struct WindowBounds { + height: f32, + width: f32, + x: f32, + y: f32, +} + +impl From<&CFDictionary> for WindowBounds { + fn from(value: &CFDictionary) -> Self { + unsafe { + Self { + height: cf_dictionary_value::( + value, + &CFString::from_static_str("Height"), + ) + .and_then(|val| val.as_ref().as_f32()) + .unwrap_or_default(), + width: cf_dictionary_value::(value, &CFString::from_static_str("Width")) + .and_then(|val| val.as_ref().as_f32()) + .unwrap_or_default(), + x: cf_dictionary_value::(value, &CFString::from_static_str("X")) + .and_then(|val| val.as_ref().as_f32()) + .unwrap_or_default(), + y: cf_dictionary_value::(value, &CFString::from_static_str("Y")) + .and_then(|val| val.as_ref().as_f32()) + .unwrap_or_default(), + } + } + } +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..31578d3b --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable" \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..74c8af67 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +imports_granularity = "Item" \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..1bb344ac --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +{pkgs ? import (fetchTarball "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz") {}}: +with pkgs; + mkShell { + name = "komorebi"; + + buildInputs = [ + just + gcc + libiconv + cargo-deny + jq + prettier + ]; + } \ No newline at end of file From a2b0207c28d6bfbddf7b71b572769be17a5f1a56 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 16 Sep 2025 18:10:03 -0700 Subject: [PATCH 002/305] feat(wm): add core graphics api wrapper module --- komorebi/src/core_graphics/error.rs | 48 +++++++++++++++++++++++++++++ komorebi/src/core_graphics/mod.rs | 43 ++++++++++++++++++++++++++ komorebi/src/lib.rs | 1 + komorebi/src/main.rs | 19 ++---------- 4 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 komorebi/src/core_graphics/error.rs create mode 100644 komorebi/src/core_graphics/mod.rs diff --git a/komorebi/src/core_graphics/error.rs b/komorebi/src/core_graphics/error.rs new file mode 100644 index 00000000..29907e24 --- /dev/null +++ b/komorebi/src/core_graphics/error.rs @@ -0,0 +1,48 @@ +use objc2_core_graphics::CGError; + +#[derive(thiserror::Error, Debug)] +pub enum CoreGraphicsError { + #[error("CGError::Success")] + Success, + #[error("CGError::Failure")] + Failure, + #[error("CGError::IllegalArgument")] + IllegalArgument, + #[error("CGError::InvalidConnection")] + InvalidConnection, + #[error("CGError::InvalidContext")] + InvalidContext, + #[error("CGError::CannotComplete")] + CannotComplete, + #[error("CGError::NotImplemented")] + NotImplemented, + #[error("CGError::RangeCheck")] + RangeCheck, + #[error("CGError::TypeCheck")] + TypeCheck, + #[error("CGError::InvalidOperation")] + InvalidOperation, + #[error("CGError::NoneAvailable")] + NoneAvailable, + #[error("CGError::Unknown {0}")] + Unknown(i32), +} + +impl From for CoreGraphicsError { + fn from(value: CGError) -> Self { + match value { + CGError::Success => Self::Success, + CGError::Failure => Self::Failure, + CGError::IllegalArgument => Self::IllegalArgument, + CGError::InvalidConnection => Self::InvalidConnection, + CGError::InvalidContext => Self::InvalidContext, + CGError::CannotComplete => Self::CannotComplete, + CGError::NotImplemented => Self::NotImplemented, + CGError::RangeCheck => Self::RangeCheck, + CGError::TypeCheck => Self::TypeCheck, + CGError::InvalidOperation => Self::InvalidOperation, + CGError::NoneAvailable => Self::NoneAvailable, + error => Self::Unknown(error.0), + } + } +} diff --git a/komorebi/src/core_graphics/mod.rs b/komorebi/src/core_graphics/mod.rs new file mode 100644 index 00000000..fbecd3e6 --- /dev/null +++ b/komorebi/src/core_graphics/mod.rs @@ -0,0 +1,43 @@ +use crate::core_graphics::error::CoreGraphicsError; +use objc2_core_foundation::CFArray; +use objc2_core_foundation::CFRetained; +use objc2_core_graphics::CGGetOnlineDisplayList; +use objc2_core_graphics::CGWindowListCopyWindowInfo; +use objc2_core_graphics::CGWindowListOption; +use objc2_core_graphics::kCGNullWindowID; + +pub mod error; + +pub struct CoreGraphicsApi; + +impl CoreGraphicsApi { + pub fn connected_display_ids() -> Result, CoreGraphicsError> { + let mut displays: Vec = Vec::with_capacity(16); + let mut display_count = 0; + + unsafe { + match CoreGraphicsError::from(CGGetOnlineDisplayList( + displays.capacity() as u32, + displays.as_mut_ptr(), + &mut display_count, + )) { + CoreGraphicsError::Success => { + displays.set_len(display_count as usize); + Ok(displays) + } + error => Err(error), + } + } + } + + pub fn window_list_info() -> Option> { + unsafe { + CGWindowListCopyWindowInfo( + // this is still way too many bogus windows + CGWindowListOption::OptionOnScreenOnly | CGWindowListOption::ExcludeDesktopElements, + // required when using OnScreenOnly + kCGNullWindowID, + ) + } + } +} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 342c7905..67920701 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -7,6 +7,7 @@ use std::ptr::NonNull; pub mod accessibility; pub mod application; +pub mod core_graphics; pub mod layout; pub mod rect; pub mod window; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 9432ea3e..8a8d9abf 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -4,23 +4,19 @@ use color_eyre::eyre; use color_eyre::eyre::eyre; use komorebi::application::Application; use komorebi::cf_array_as; +use komorebi::core_graphics::CoreGraphicsApi; use komorebi::layout; use komorebi::rect::Rect; use komorebi::window::WindowInfo; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; -use objc2_core_foundation::CFArray; use objc2_core_foundation::CFDictionary; -use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::kCFRunLoopDefaultMode; use objc2_core_graphics::CGDisplayBounds; use objc2_core_graphics::CGMainDisplayID; use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; -use objc2_core_graphics::CGWindowListCopyWindowInfo; -use objc2_core_graphics::CGWindowListOption; -use objc2_core_graphics::kCGNullWindowID; use std::collections::HashMap; use std::sync::Arc; use std::sync::atomic::AtomicBool; @@ -106,7 +102,7 @@ fn main() -> eyre::Result<()> { let run_loop = CFRunLoop::current().ok_or(eyre!("couldn't get CFRunLoop::current"))?; - if let Some(window_info_list) = list_window_info() { + if let Some(window_info_list) = CoreGraphicsApi::window_list_info() { tracing::info!("{} windows found", window_info_list.len()); let mut windows = vec![]; @@ -208,14 +204,3 @@ fn main() -> eyre::Result<()> { Ok(()) } - -fn list_window_info() -> Option> { - unsafe { - CGWindowListCopyWindowInfo( - // this is still way too many bogus windows - CGWindowListOption::OptionOnScreenOnly | CGWindowListOption::ExcludeDesktopElements, - // required when using OnScreenOnly - kCGNullWindowID, - ) - } -} From 326c4196665ea132b87254a5a9eef027da504cfc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 17 Sep 2025 09:07:45 -0700 Subject: [PATCH 003/305] feat(wm): add initial skeleton of wm state and initialization --- Cargo.lock | 46 ++++++++++-- dependencies.json | 8 +++ komorebi/Cargo.toml | 4 +- komorebi/src/accessibility/error.rs | 4 +- komorebi/src/core_graphics/mod.rs | 11 +++ komorebi/src/lib.rs | 15 ++++ komorebi/src/macos_api.rs | 94 ++++++++++++++++++++++++ komorebi/src/main.rs | 105 +++++++++++---------------- komorebi/src/rect.rs | 36 ++++++++++ komorebi/src/ring.rs | 106 ++++++++++++++++++++++++++++ komorebi/src/window.rs | 14 ++-- komorebi/src/window_manager.rs | 66 +++++++++++++++++ 12 files changed, 433 insertions(+), 76 deletions(-) create mode 100644 komorebi/src/macos_api.rs create mode 100644 komorebi/src/ring.rs create mode 100644 komorebi/src/window_manager.rs diff --git a/Cargo.lock b/Cargo.lock index fcf52752..c8ecb3cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,6 +155,8 @@ dependencies = [ "objc2-application-services", "objc2-core-foundation", "objc2-core-graphics", + "pastey", + "serde", "thiserror", "tracing", "tracing-subscriber", @@ -421,6 +423,12 @@ version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" +[[package]] +name = "pastey" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -468,6 +476,36 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" +[[package]] +name = "serde" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -496,18 +534,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.69" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.69" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" dependencies = [ "proc-macro2", "quote", diff --git a/dependencies.json b/dependencies.json index c6e43704..a7201307 100644 --- a/dependencies.json +++ b/dependencies.json @@ -37,12 +37,16 @@ "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", + "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "serde 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde_core 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive 1.0.225 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", @@ -93,12 +97,16 @@ "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", "owo-colors 4.2.2 registry+https://github.com/rust-lang/crates.io-index", + "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "serde 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde_core 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive 1.0.225 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 5e80fef9..6e29f99a 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -11,6 +11,8 @@ objc2-app-kit = "0.3" objc2-application-services = "0.3" objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } -thiserror = "1" +pastey = "0.1" +serde = { version = "1", features = ["derive"]} +thiserror = "2" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file diff --git a/komorebi/src/accessibility/error.rs b/komorebi/src/accessibility/error.rs index 9358c4b7..4231193b 100644 --- a/komorebi/src/accessibility/error.rs +++ b/komorebi/src/accessibility/error.rs @@ -3,9 +3,9 @@ use objc2_application_services::AXError; #[derive(thiserror::Error, Debug)] pub enum AccessibilityError { #[error(transparent)] - Api(AccessibilityApiError), + Api(#[from] AccessibilityApiError), #[error(transparent)] - Custom(AccessibilityCustomError), + Custom(#[from] AccessibilityCustomError), } #[derive(thiserror::Error, Debug)] diff --git a/komorebi/src/core_graphics/mod.rs b/komorebi/src/core_graphics/mod.rs index fbecd3e6..e3d8a8d4 100644 --- a/komorebi/src/core_graphics/mod.rs +++ b/komorebi/src/core_graphics/mod.rs @@ -1,7 +1,10 @@ use crate::core_graphics::error::CoreGraphicsError; use objc2_core_foundation::CFArray; use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CGRect; +use objc2_core_graphics::CGDisplayBounds; use objc2_core_graphics::CGGetOnlineDisplayList; +use objc2_core_graphics::CGRectIntersectsRect; use objc2_core_graphics::CGWindowListCopyWindowInfo; use objc2_core_graphics::CGWindowListOption; use objc2_core_graphics::kCGNullWindowID; @@ -11,6 +14,10 @@ pub mod error; pub struct CoreGraphicsApi; impl CoreGraphicsApi { + pub fn contains_rect(smaller: CGRect, bigger: CGRect) -> bool { + unsafe { CGRectIntersectsRect(smaller, bigger) } + } + pub fn connected_display_ids() -> Result, CoreGraphicsError> { let mut displays: Vec = Vec::with_capacity(16); let mut display_count = 0; @@ -30,6 +37,10 @@ impl CoreGraphicsApi { } } + pub fn display_bounds(display_id: u32) -> CGRect { + unsafe { CGDisplayBounds(display_id) } + } + pub fn window_list_info() -> Option> { unsafe { CGWindowListCopyWindowInfo( diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 67920701..aef1c7f4 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -1,16 +1,23 @@ #![warn(clippy::all)] +use crate::accessibility::error::AccessibilityError; +use crate::core_graphics::error::CoreGraphicsError; use objc2_core_foundation::CFArray; use objc2_core_foundation::CFDictionary; use objc2_core_foundation::CFString; use std::ptr::NonNull; +#[macro_use] +pub mod ring; + pub mod accessibility; pub mod application; pub mod core_graphics; pub mod layout; +pub mod macos_api; pub mod rect; pub mod window; +pub mod window_manager; pub fn cf_array_as(array: &CFArray) -> impl Iterator> + use<'_, T> { let count = CFArray::count(array); @@ -24,3 +31,11 @@ pub fn cf_dictionary_value(dict: &CFDictionary, key: &CFString) -> Option()) } + +#[derive(thiserror::Error, Debug)] +pub enum LibraryError { + #[error(transparent)] + Accessibility(#[from] AccessibilityError), + #[error(transparent)] + CoreGraphics(#[from] CoreGraphicsError), +} diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs new file mode 100644 index 00000000..ae2e986f --- /dev/null +++ b/komorebi/src/macos_api.rs @@ -0,0 +1,94 @@ +use crate::LibraryError; +use crate::application::Application; +use crate::cf_array_as; +use crate::core_graphics::CoreGraphicsApi; +use crate::rect::Rect; +use crate::ring::Ring; +use crate::window::WindowInfo; +use crate::window_manager::Container; +use crate::window_manager::Monitor; +use crate::window_manager::WindowManager; +use objc2_core_foundation::CFDictionary; +use std::collections::HashMap; + +pub struct MacosApi; + +impl MacosApi { + pub fn load_monitor_information(wm: &mut WindowManager) -> Result<(), LibraryError> { + for display_id in CoreGraphicsApi::connected_display_ids()? { + let size = Rect::from(CoreGraphicsApi::display_bounds(display_id)); + let monitor = Monitor::new(display_id, size); + wm.monitors.elements_mut().push_back(monitor); + } + + Ok(()) + } + + pub fn load_workspace_information(wm: &mut WindowManager) -> Result<(), LibraryError> { + let mut monitor_size_map = HashMap::new(); + let mut monitor_workspace_map = HashMap::new(); + let mut monitor_window_map = HashMap::new(); + let mut valid_window_count = 0; + + for (idx, monitor) in wm.monitors.elements_mut().iter_mut().enumerate() { + monitor_size_map.insert(idx, monitor.size); + monitor_workspace_map.insert(idx, monitor.focused_workspace_mut()); + } + + if let Some(window_list_info) = CoreGraphicsApi::window_list_info() { + tracing::info!("{} windows found", window_list_info.len()); + + for raw_window_info in cf_array_as::(&window_list_info) { + if let Some(info) = WindowInfo::new(raw_window_info).validated() { + let window_rect = Rect::from(info.bounds); + + for (monitor_idx, monitor_size) in &monitor_size_map { + if monitor_size.contains(&window_rect) { + let entry = monitor_window_map + .entry(monitor_idx) + .or_insert_with(Vec::new); + + let application = + wm.applications.entry(info.owner_pid).or_insert_with(|| { + let application = Application::new(info.owner_pid) + .unwrap_or_else(|_| { + panic!( + "failed to create application from pid {}", + info.owner_pid + ) + }); + application + .observe(&wm.run_loop) + .expect("application must be observable"); + application + }); + + if let Some(window) = application.window_by_title(&info.name) { + window.observe(&wm.run_loop)?; + entry.push(window); + valid_window_count += 1 + } + } + } + } + } + + tracing::info!("{valid_window_count} valid windows identified"); + } + + for (monitor_idx, windows) in monitor_window_map { + for window in windows { + let mut container = Container { + windows: Ring::default(), + }; + + container.windows_mut().push_back(window); + if let Some(Some(workspace)) = monitor_workspace_map.get_mut(monitor_idx) { + workspace.containers_mut().push_back(container); + } + } + } + + Ok(()) + } +} diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 8a8d9abf..2c0aa569 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -2,22 +2,17 @@ use color_eyre::eyre; use color_eyre::eyre::eyre; -use komorebi::application::Application; -use komorebi::cf_array_as; -use komorebi::core_graphics::CoreGraphicsApi; use komorebi::layout; use komorebi::rect::Rect; -use komorebi::window::WindowInfo; +use komorebi::window_manager::WindowManager; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; -use objc2_core_foundation::CFDictionary; use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::kCFRunLoopDefaultMode; use objc2_core_graphics::CGDisplayBounds; use objc2_core_graphics::CGMainDisplayID; use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; -use std::collections::HashMap; use std::sync::Arc; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; @@ -101,38 +96,27 @@ fn main() -> eyre::Result<()> { tracing::info!("display size for main display is: {:?}", display_size); let run_loop = CFRunLoop::current().ok_or(eyre!("couldn't get CFRunLoop::current"))?; + let mut wm = WindowManager::new(&run_loop); + wm.init()?; - if let Some(window_info_list) = CoreGraphicsApi::window_list_info() { - tracing::info!("{} windows found", window_info_list.len()); + let containers = wm + .monitors + .focused() + .expect("must have a monitor at this point") + .focused_workspace() + .expect("must have a workspace at this point") + .containers(); - let mut windows = vec![]; - let mut applications = HashMap::new(); + let layouts = + layout::recursive_fibonacci(0, containers.len(), &Rect::from(display_size), vec![]); - for entry in cf_array_as::(window_info_list.as_ref()) { - if let Some(info) = WindowInfo::new(entry).validated() { - let application = applications.entry(info.owner_pid).or_insert_with(|| { - let application = Application::new(info.owner_pid).unwrap_or_else(|_| { - panic!("failed to create application from pid {}", info.owner_pid) - }); - application - .observe(&run_loop) - .expect("application must be observable"); - application - }); - - if let Some(window) = application.window_by_title(&info.name) { - window.observe(&run_loop)?; - windows.push(window); - } - } - } - - tracing::info!("{} valid windows identified", windows.len()); - - let layouts = - layout::recursive_fibonacci(0, windows.len(), &Rect::from(display_size), vec![]); - - windows.iter().zip(layouts).for_each(|(window, layout)| { + containers + .iter() + .zip(layouts) + .for_each(|(container, layout)| { + let window = container + .focused_window() + .expect("must have a window at this point"); if let Err(error) = window.set_position(&layout) { tracing::error!( "failed to position window: {} ({error})", @@ -167,39 +151,36 @@ fn main() -> eyre::Result<()> { // } }); - let quit_ctrlc = Arc::new(AtomicBool::new(false)); - let quit_thread = quit_ctrlc.clone(); + let quit_ctrlc = Arc::new(AtomicBool::new(false)); + let quit_thread = quit_ctrlc.clone(); - std::thread::spawn(move || { - let (ctrlc_sender, ctrlc_receiver) = mpsc::channel(); - ctrlc::set_handler(move || { - ctrlc_sender - .send(()) - .expect("could not send signal on ctrl-c channel"); - }) - .expect("could not set ctrl-c handler"); + std::thread::spawn(move || { + let (ctrlc_sender, ctrlc_receiver) = mpsc::channel(); + ctrlc::set_handler(move || { + ctrlc_sender + .send(()) + .expect("could not send signal on ctrl-c channel"); + }) + .expect("could not set ctrl-c handler"); - ctrlc_receiver - .recv() - .expect("could not receive signal on ctrl-c channel"); + ctrlc_receiver + .recv() + .expect("could not receive signal on ctrl-c channel"); - tracing::info!("ctrl-c signal received"); - quit_ctrlc.store(true, Ordering::Relaxed); - }); + tracing::info!("ctrl-c signal received"); + quit_ctrlc.store(true, Ordering::Relaxed); + }); - tracing::info!("starting CFRunLoop to receive observer notifications"); + tracing::info!("starting CFRunLoop to receive observer notifications"); - loop { - if quit_thread.load(Ordering::Relaxed) { - tracing::info!("stopping CFRunLoop"); - break; - } - - // this gets our observer notification callbacks firing - autoreleasepool(|_| unsafe { - CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) - }); + loop { + if quit_thread.load(Ordering::Relaxed) { + tracing::info!("stopping CFRunLoop"); + break; } + + // this gets our observer notification callbacks firing + autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) }); } Ok(()) diff --git a/komorebi/src/rect.rs b/komorebi/src/rect.rs index edc84d3e..6f1b029d 100644 --- a/komorebi/src/rect.rs +++ b/komorebi/src/rect.rs @@ -1,3 +1,7 @@ +use crate::core_graphics::CoreGraphicsApi; +use crate::window::WindowBounds; +use objc2_core_foundation::CGFloat; +use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; @@ -30,3 +34,35 @@ impl From for Rect { } } } + +impl From<&Rect> for CGRect { + fn from(value: &Rect) -> Self { + Self { + origin: CGPoint { + x: value.left as CGFloat, + y: value.top as CGFloat, + }, + size: CGSize { + width: value.right as CGFloat, + height: value.bottom as CGFloat, + }, + } + } +} + +impl From for Rect { + fn from(value: WindowBounds) -> Self { + Self { + left: value.x, + top: value.y, + right: value.width, + bottom: value.height, + } + } +} + +impl Rect { + pub fn contains(&self, other: &Rect) -> bool { + CoreGraphicsApi::contains_rect(other.into(), self.into()) + } +} diff --git a/komorebi/src/ring.rs b/komorebi/src/ring.rs new file mode 100644 index 00000000..a473209c --- /dev/null +++ b/komorebi/src/ring.rs @@ -0,0 +1,106 @@ +use std::collections::VecDeque; + +use serde::Deserialize; +use serde::Serialize; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct Ring { + elements: VecDeque, + focused: usize, +} + +impl Default for Ring { + fn default() -> Self { + Self { + elements: VecDeque::default(), + focused: 0, + } + } +} + +impl Ring { + pub const fn elements(&self) -> &VecDeque { + &self.elements + } + + pub fn elements_mut(&mut self) -> &mut VecDeque { + &mut self.elements + } + + pub fn focus(&mut self, idx: usize) { + self.focused = idx; + } + + pub fn focused(&self) -> Option<&T> { + self.elements.get(self.focused) + } + + pub const fn focused_idx(&self) -> usize { + self.focused + } + + pub fn focused_mut(&mut self) -> Option<&mut T> { + self.elements.get_mut(self.focused) + } +} + +macro_rules! impl_ring_elements { + ($name:ty, $element:ident) => { + pastey::paste! { + impl $name { + pub const fn [<$element:lower s>](&self) -> &std::collections::VecDeque<$element> { + self.[<$element:lower s>].elements() + } + + pub fn [<$element:lower s_mut>](&mut self) -> &mut std::collections::VecDeque<$element> { + self.[<$element:lower s>].elements_mut() + } + + #[allow(dead_code)] + pub fn [](&self) -> Option<&$element> { + self.[<$element:lower s>].focused() + } + + pub const fn [](&self) -> usize { + self.[<$element:lower s>].focused_idx() + } + + pub fn [](&mut self) -> Option<&mut $element> { + self.[<$element:lower s>].focused_mut() + } + } + } + }; + // This allows passing a different name to be used for the functions. For instance, the + // `floating_windows` ring calls this as: + // ```rust + // impl_ring_elements!(Workspace, Window, "floating_window"); + // ``` + // Which allows using the `Window` element but name the functions as `floating_window` + ($name:ty, $element:ident, $el_name:literal) => { + pastey::paste! { + impl $name { + pub const fn [<$el_name:lower s>](&self) -> &std::collections::VecDeque<$element> { + self.[<$el_name:lower s>].elements() + } + + pub fn [<$el_name:lower s_mut>](&mut self) -> &mut std::collections::VecDeque<$element> { + self.[<$el_name:lower s>].elements_mut() + } + + #[allow(dead_code)] + pub fn [](&self) -> Option<&$element> { + self.[<$el_name:lower s>].focused() + } + + pub const fn [](&self) -> usize { + self.[<$el_name:lower s>].focused_idx() + } + + pub fn [](&mut self) -> Option<&mut $element> { + self.[<$el_name:lower s>].focused_mut() + } + } + } + }; +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 7d4127fa..c4197f33 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -95,7 +95,7 @@ pub struct ValidWindowInfo { pub owner_pid: i32, owner_name: String, alpha: f32, - bounds: WindowBounds, + pub bounds: WindowBounds, } impl WindowInfo { @@ -247,13 +247,13 @@ impl From<&CFDictionary> for WindowInfo { } } -#[derive(Default, Debug)] +#[derive(Default, Debug, Copy, Clone)] #[allow(unused)] -struct WindowBounds { - height: f32, - width: f32, - x: f32, - y: f32, +pub struct WindowBounds { + pub height: f32, + pub width: f32, + pub x: f32, + pub y: f32, } impl From<&CFDictionary> for WindowBounds { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs new file mode 100644 index 00000000..594b7391 --- /dev/null +++ b/komorebi/src/window_manager.rs @@ -0,0 +1,66 @@ +use crate::LibraryError; +use crate::application::Application; +use crate::macos_api::MacosApi; +use crate::rect::Rect; +use crate::ring::Ring; +use crate::window::Window; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; +use std::collections::HashMap; + +#[derive(Debug)] +pub struct WindowManager { + pub monitors: Ring, + pub applications: HashMap, + pub run_loop: CFRetained, +} + +impl WindowManager { + pub fn new(run_loop: &CFRetained) -> Self { + Self { + monitors: Ring::default(), + applications: Default::default(), + run_loop: run_loop.clone(), + } + } + + #[tracing::instrument(skip(self))] + pub fn init(&mut self) -> Result<(), LibraryError> { + tracing::info!("initializing"); + MacosApi::load_monitor_information(self)?; + MacosApi::load_workspace_information(self) + } +} + +impl_ring_elements!(Monitor, Workspace); +#[derive(Debug)] +pub struct Monitor { + pub id: u32, + pub workspaces: Ring, + pub size: Rect, +} + +impl Monitor { + pub fn new(id: u32, size: Rect) -> Self { + let mut workspaces = Ring::default(); + workspaces.elements_mut().push_back(Workspace::default()); + + Self { + id, + workspaces, + size, + } + } +} + +impl_ring_elements!(Workspace, Container); +#[derive(Debug, Default)] +pub struct Workspace { + pub containers: Ring, +} + +impl_ring_elements!(Container, Window); +#[derive(Debug)] +pub struct Container { + pub windows: Ring, +} From b6d19e6a12fb58aebe1d051b3c60c23d8e7cf889 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 17 Sep 2025 13:31:37 -0700 Subject: [PATCH 004/305] feat(wm): migrate workspace and layout code This commit migrates big chunks of code from komorebi for Windows which deal with state related to the Workspace struct, Layouts and the Arrangement trait. Layout remains an enum, but only the Layout::Default variant with DefaultLayout has been migrated because there are no plans to support EOL features in komorebi for Mac (custom layouts). The code for updating the layout in main.rs has been moved to Workspace.update, which is now called from main.rs instead. As part of this initial migration of code, this project has been restructured a little to match the layout of komorebi for Windows to minimize my own confusion. --- justfile | 6 +- komorebi/src/core/arrangement.rs | 1129 ++++++++++++++++++++++ komorebi/src/core/default_layout.rs | 200 ++++ komorebi/src/core/direction.rs | 347 +++++++ komorebi/src/core/layout.rs | 26 + komorebi/src/core/mod.rs | 15 + komorebi/src/core/operation_direction.rs | 58 ++ komorebi/src/core/rect.rs | 105 ++ komorebi/src/layout.rs | 82 -- komorebi/src/lib.rs | 4 +- komorebi/src/macos_api.rs | 2 +- komorebi/src/main.rs | 59 +- komorebi/src/rect.rs | 68 -- komorebi/src/window.rs | 2 +- komorebi/src/window_manager.rs | 23 +- komorebi/src/workspace.rs | 133 +++ 16 files changed, 2043 insertions(+), 216 deletions(-) create mode 100644 komorebi/src/core/arrangement.rs create mode 100644 komorebi/src/core/default_layout.rs create mode 100644 komorebi/src/core/direction.rs create mode 100644 komorebi/src/core/layout.rs create mode 100644 komorebi/src/core/mod.rs create mode 100644 komorebi/src/core/operation_direction.rs create mode 100644 komorebi/src/core/rect.rs delete mode 100644 komorebi/src/layout.rs delete mode 100644 komorebi/src/rect.rs create mode 100644 komorebi/src/workspace.rs diff --git a/justfile b/justfile index ad1d795e..6a068793 100644 --- a/justfile +++ b/justfile @@ -31,4 +31,8 @@ trace target $RUST_LOG="trace": depgen: cargo deny check - cargo deny list --format json | jq 'del(.unlicensed)' > dependencies.json \ No newline at end of file + cargo deny list --format json | jq 'del(.unlicensed)' > dependencies.json + +push: + git push origin master + git push komocorp master \ No newline at end of file diff --git a/komorebi/src/core/arrangement.rs b/komorebi/src/core/arrangement.rs new file mode 100644 index 00000000..c256ec1d --- /dev/null +++ b/komorebi/src/core/arrangement.rs @@ -0,0 +1,1129 @@ +use std::num::NonZeroUsize; + +use crate::core::default_layout::DefaultLayout; +use crate::core::default_layout::LayoutOptions; +use crate::core::rect::Rect; +use serde::Deserialize; +use serde::Serialize; + +pub trait Arrangement { + #[allow(clippy::too_many_arguments)] + fn calculate( + &self, + area: &Rect, + len: NonZeroUsize, + container_padding: Option, + layout_flip: Option, + resize_dimensions: &[Option], + focused_idx: usize, + layout_options: Option, + latest_layout: &[Rect], + ) -> Vec; +} + +impl Arrangement for DefaultLayout { + #[allow(clippy::too_many_lines, clippy::cognitive_complexity)] + fn calculate( + &self, + area: &Rect, + len: NonZeroUsize, + container_padding: Option, + layout_flip: Option, + resize_dimensions: &[Option], + focused_idx: usize, + layout_options: Option, + latest_layout: &[Rect], + ) -> Vec { + let len = usize::from(len); + let mut dimensions = match self { + Self::Scrolling => { + let column_count = layout_options + .and_then(|o| o.scrolling.map(|s| s.columns)) + .unwrap_or(3); + + let column_width = area.right / column_count as i32; + let mut layouts = Vec::with_capacity(len); + + match len { + // treat < 3 windows the same as the columns layout + len if len < 3 => { + layouts = columns(area, len); + + let adjustment = calculate_columns_adjustment(resize_dimensions); + layouts.iter_mut().zip(adjustment.iter()).for_each( + |(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }, + ); + + if matches!( + layout_flip, + Some(Axis::Horizontal | Axis::HorizontalAndVertical) + ) && let 2.. = len + { + columns_reverse(&mut layouts); + } + } + // treat >= column_count as scrolling + len => { + let visible_columns = area.right / column_width; + let first_visible: isize = if focused_idx == 0 { + // if focused idx is 0, we are at the beginning of the scrolling strip + 0 + } else { + let previous_first_visible = if latest_layout.is_empty() { + 0 + } else { + // previous first_visible based on the left position of the first visible window + let left_edge = area.left; + latest_layout + .iter() + .position(|rect| rect.left >= left_edge) + .unwrap_or(0) as isize + }; + + let focused_idx = focused_idx as isize; + + if focused_idx < previous_first_visible { + // focused window is off the left edge, we need to scroll left + focused_idx + } else if focused_idx + >= previous_first_visible + visible_columns as isize + { + // focused window is off the right edge, we need to scroll right + // and make sure it's the last visible window + (focused_idx + 1 - visible_columns as isize).max(0) + } else { + // focused window is already visible, we don't need to scroll + previous_first_visible + } + .min( + (len as isize) + .saturating_sub(visible_columns as isize) + .max(0), + ) + }; + + for i in 0..len { + let position = (i as isize) - first_visible; + let left = area.left + (position as i32 * column_width); + + layouts.push(Rect { + left, + top: area.top, + right: column_width, + bottom: area.bottom, + }); + } + + let adjustment = calculate_scrolling_adjustment(resize_dimensions); + layouts.iter_mut().zip(adjustment.iter()).for_each( + |(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }, + ); + } + } + + layouts + } + Self::BSP => recursive_fibonacci( + 0, + len, + area, + layout_flip, + calculate_resize_adjustments(resize_dimensions), + ), + Self::Columns => { + let mut layouts = columns(area, len); + + let adjustment = calculate_columns_adjustment(resize_dimensions); + layouts + .iter_mut() + .zip(adjustment.iter()) + .for_each(|(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }); + + if matches!( + layout_flip, + Some(Axis::Horizontal | Axis::HorizontalAndVertical) + ) && let 2.. = len + { + columns_reverse(&mut layouts); + } + + layouts + } + Self::Rows => { + let mut layouts = rows(area, len); + + let adjustment = calculate_rows_adjustment(resize_dimensions); + layouts + .iter_mut() + .zip(adjustment.iter()) + .for_each(|(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }); + + if matches!( + layout_flip, + Some(Axis::Vertical | Axis::HorizontalAndVertical) + ) && let 2.. = len + { + rows_reverse(&mut layouts); + } + + layouts + } + Self::VerticalStack => { + let mut layouts: Vec = vec![]; + + let primary_right = match len { + 1 => area.right, + _ => area.right / 2, + }; + + let main_left = area.left; + let stack_left = area.left + primary_right; + + if len >= 1 { + layouts.push(Rect { + left: main_left, + top: area.top, + right: primary_right, + bottom: area.bottom, + }); + + if len > 1 { + layouts.append(&mut rows( + &Rect { + left: stack_left, + top: area.top, + right: area.right - primary_right, + bottom: area.bottom, + }, + len - 1, + )); + } + } + + let adjustment = calculate_vertical_stack_adjustment(resize_dimensions); + layouts + .iter_mut() + .zip(adjustment.iter()) + .for_each(|(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }); + + if matches!( + layout_flip, + Some(Axis::Horizontal | Axis::HorizontalAndVertical) + ) && let 2.. = len + { + let (primary, rest) = layouts.split_at_mut(1); + let primary = &mut primary[0]; + + for rect in rest.iter_mut() { + rect.left = primary.left; + } + primary.left = rest[0].left + rest[0].right; + } + + if matches!( + layout_flip, + Some(Axis::Vertical | Axis::HorizontalAndVertical) + ) && let 3.. = len + { + rows_reverse(&mut layouts[1..]); + } + + layouts + } + Self::RightMainVerticalStack => { + // Shamelessly borrowed from LeftWM: https://github.com/leftwm/leftwm/commit/f673851745295ae7584a102535566f559d96a941 + let mut layouts: Vec = vec![]; + + let primary_width = match len { + 1 => area.right, + _ => area.right / 2, + }; + + let primary_left = match len { + 1 => 0, + _ => area.right - primary_width, + }; + + if len >= 1 { + layouts.push(Rect { + left: area.left + primary_left, + top: area.top, + right: primary_width, + bottom: area.bottom, + }); + + if len > 1 { + layouts.append(&mut rows( + &Rect { + left: area.left, + top: area.top, + right: primary_left, + bottom: area.bottom, + }, + len - 1, + )); + } + } + + let adjustment = calculate_right_vertical_stack_adjustment(resize_dimensions); + layouts + .iter_mut() + .zip(adjustment.iter()) + .for_each(|(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }); + + if matches!( + layout_flip, + Some(Axis::Horizontal | Axis::HorizontalAndVertical) + ) && let 2.. = len + { + let (primary, rest) = layouts.split_at_mut(1); + let primary = &mut primary[0]; + + primary.left = rest[0].left; + for rect in rest.iter_mut() { + rect.left = primary.left + primary.right; + } + } + + if matches!( + layout_flip, + Some(Axis::Vertical | Axis::HorizontalAndVertical) + ) && let 3.. = len + { + rows_reverse(&mut layouts[1..]); + } + + layouts + } + Self::HorizontalStack => { + let mut layouts: Vec = vec![]; + + let bottom = match len { + 1 => area.bottom, + _ => area.bottom / 2, + }; + + let main_top = area.top; + let stack_top = area.top + bottom; + + if len >= 1 { + layouts.push(Rect { + left: area.left, + top: main_top, + right: area.right, + bottom, + }); + + if len > 1 { + layouts.append(&mut columns( + &Rect { + left: area.left, + top: stack_top, + right: area.right, + bottom: area.bottom - bottom, + }, + len - 1, + )); + } + } + + let adjustment = calculate_horizontal_stack_adjustment(resize_dimensions); + layouts + .iter_mut() + .zip(adjustment.iter()) + .for_each(|(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }); + + if matches!( + layout_flip, + Some(Axis::Vertical | Axis::HorizontalAndVertical) + ) && let 2.. = len + { + let (primary, rest) = layouts.split_at_mut(1); + let primary = &mut primary[0]; + + for rect in rest.iter_mut() { + rect.top = primary.top; + } + primary.top = rest[0].top + rest[0].bottom; + } + + if matches!( + layout_flip, + Some(Axis::Horizontal | Axis::HorizontalAndVertical) + ) && let 3.. = len + { + columns_reverse(&mut layouts[1..]); + } + + layouts + } + Self::UltrawideVerticalStack => { + let mut layouts: Vec = vec![]; + + let primary_right = match len { + 1 => area.right, + _ => area.right / 2, + }; + + let secondary_right = match len { + 1 => 0, + 2 => area.right - primary_right, + _ => (area.right - primary_right) / 2, + }; + + let (primary_left, secondary_left, stack_left) = match len { + 1 => (area.left, 0, 0), + 2 => { + let primary = area.left + secondary_right; + let secondary = area.left; + + (primary, secondary, 0) + } + _ => { + let primary = area.left + secondary_right; + let secondary = area.left; + let stack = area.left + primary_right + secondary_right; + + (primary, secondary, stack) + } + }; + + if len >= 1 { + layouts.push(Rect { + left: primary_left, + top: area.top, + right: primary_right, + bottom: area.bottom, + }); + + if len >= 2 { + layouts.push(Rect { + left: secondary_left, + top: area.top, + right: secondary_right, + bottom: area.bottom, + }); + + if len > 2 { + layouts.append(&mut rows( + &Rect { + left: stack_left, + top: area.top, + right: secondary_right, + bottom: area.bottom, + }, + len - 2, + )); + } + } + } + + let adjustment = calculate_ultrawide_adjustment(resize_dimensions); + layouts + .iter_mut() + .zip(adjustment.iter()) + .for_each(|(layout, adjustment)| { + layout.top += adjustment.top; + layout.bottom += adjustment.bottom; + layout.left += adjustment.left; + layout.right += adjustment.right; + }); + + if matches!( + layout_flip, + Some(Axis::Horizontal | Axis::HorizontalAndVertical) + ) { + match len { + 2 => { + let (primary, secondary) = layouts.split_at_mut(1); + let primary = &mut primary[0]; + let secondary = &mut secondary[0]; + + primary.left = secondary.left; + secondary.left = primary.left + primary.right; + } + 3.. => { + let (primary, rest) = layouts.split_at_mut(1); + let (secondary, tertiary) = rest.split_at_mut(1); + let primary = &mut primary[0]; + let secondary = &mut secondary[0]; + + for rect in tertiary.iter_mut() { + rect.left = secondary.left; + } + primary.left = tertiary[0].left + tertiary[0].right; + secondary.left = primary.left + primary.right; + } + _ => {} + } + } + + if matches!( + layout_flip, + Some(Axis::Vertical | Axis::HorizontalAndVertical) + ) && let 4.. = len + { + rows_reverse(&mut layouts[2..]); + } + + layouts + } + #[allow( + clippy::cast_precision_loss, + clippy::cast_possible_truncation, + clippy::cast_possible_wrap + )] + Self::Grid => { + // Shamelessly lifted from LeftWM + // https://github.com/leftwm/leftwm/blob/18675067b8450e520ef75db2ebbb0d973aa1199e/leftwm-core/src/layouts/grid_horizontal.rs + let mut layouts: Vec = vec![]; + layouts.resize(len, Rect::default()); + + let len = len as i32; + + let num_cols = (len as f32).sqrt().ceil() as i32; + let mut iter = layouts.iter_mut().enumerate().peekable(); + + for col in 0..num_cols { + let iter_peek = iter.peek().map(|x| x.0).unwrap_or_default() as i32; + let remaining_windows = len - iter_peek; + let remaining_columns = num_cols - col; + let num_rows_in_this_col = remaining_windows / remaining_columns; + + let win_height = area.bottom / num_rows_in_this_col; + let win_width = area.right / num_cols; + + for row in 0..num_rows_in_this_col { + if let Some((_idx, win)) = iter.next() { + let mut left = area.left + win_width * col; + let mut top = area.top + win_height * row; + + match layout_flip { + Some(Axis::Horizontal) => { + left = area.right - win_width * (col + 1) + area.left; + } + Some(Axis::Vertical) => { + top = area.bottom - win_height * (row + 1) + area.top; + } + Some(Axis::HorizontalAndVertical) => { + left = area.right - win_width * (col + 1) + area.left; + top = area.bottom - win_height * (row + 1) + area.top; + } + None => {} // No flip + } + + win.bottom = win_height; + win.right = win_width; + win.left = left; + win.top = top; + } + } + } + + layouts + } + }; + + dimensions + .iter_mut() + .for_each(|l| l.add_padding(container_padding.unwrap_or_default())); + + dimensions + } +} + +#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] +pub enum Axis { + Horizontal, + Vertical, + HorizontalAndVertical, +} + +#[must_use] +fn columns(area: &Rect, len: usize) -> Vec { + #[allow(clippy::cast_possible_wrap, clippy::cast_possible_truncation)] + let right = area.right / len as i32; + let mut left = 0; + + let mut layouts: Vec = vec![]; + for _ in 0..len { + layouts.push(Rect { + left: area.left + left, + top: area.top, + right, + bottom: area.bottom, + }); + + left += right; + } + + layouts +} + +#[must_use] +fn rows(area: &Rect, len: usize) -> Vec { + #[allow(clippy::cast_possible_wrap, clippy::cast_possible_truncation)] + let bottom = area.bottom / len as i32; + let mut top = 0; + + let mut layouts: Vec = vec![]; + for _ in 0..len { + layouts.push(Rect { + left: area.left, + top: area.top + top, + right: area.right, + bottom, + }); + + top += bottom; + } + + layouts +} + +fn columns_reverse(columns: &mut [Rect]) { + let len = columns.len(); + columns[len - 1].left = columns[0].left; + for i in (0..len - 1).rev() { + columns[i].left = columns[i + 1].left + columns[i + 1].right; + } +} + +fn rows_reverse(rows: &mut [Rect]) { + let len = rows.len(); + rows[len - 1].top = rows[0].top; + for i in (0..len - 1).rev() { + rows[i].top = rows[i + 1].top + rows[i + 1].bottom; + } +} + +fn calculate_resize_adjustments(resize_dimensions: &[Option]) -> Vec> { + let mut resize_adjustments = resize_dimensions.to_vec(); + + // This needs to be aware of layout flips + for (i, opt) in resize_dimensions.iter().enumerate() { + if let Some(resize_ref) = opt + && i > 0 + { + if resize_ref.left != 0 { + #[allow(clippy::if_not_else)] + let range = if i == 1 { + 0..1 + } else if i & 1 != 0 { + i - 1..i + } else { + i - 2..i + }; + + for n in range { + let should_adjust = n % 2 == 0; + if should_adjust { + if let Some(Some(adjacent_resize)) = resize_adjustments.get_mut(n) { + adjacent_resize.right += resize_ref.left; + } else { + resize_adjustments[n] = Option::from(Rect { + left: 0, + top: 0, + right: resize_ref.left, + bottom: 0, + }); + } + } + } + + if let Some(rr) = resize_adjustments[i].as_mut() { + rr.left = 0; + } + } + + if resize_ref.top != 0 { + let range = if i == 1 { + 0..1 + } else if i & 1 == 0 { + i - 1..i + } else { + i - 2..i + }; + + for n in range { + let should_adjust = n % 2 != 0; + if should_adjust { + if let Some(Some(adjacent_resize)) = resize_adjustments.get_mut(n) { + adjacent_resize.bottom += resize_ref.top; + } else { + resize_adjustments[n] = Option::from(Rect { + left: 0, + top: 0, + right: 0, + bottom: resize_ref.top, + }); + } + } + } + + if let Some(Some(resize)) = resize_adjustments.get_mut(i) { + resize.top = 0; + } + } + } + } + + let cleaned_resize_adjustments: Vec<_> = resize_adjustments + .iter() + .map(|adjustment| match adjustment { + None => None, + Some(rect) if rect.eq(&Rect::default()) => None, + Some(_) => *adjustment, + }) + .collect(); + + cleaned_resize_adjustments +} + +#[allow(clippy::only_used_in_recursion)] +fn recursive_fibonacci( + idx: usize, + count: usize, + area: &Rect, + layout_flip: Option, + resize_adjustments: Vec>, +) -> Vec { + let mut a = *area; + + let resized = if let Some(Some(r)) = resize_adjustments.get(idx) { + a.left += r.left; + a.top += r.top; + a.right += r.right; + a.bottom += r.bottom; + a + } else { + *area + }; + + let half_width = area.right / 2; + let half_height = area.bottom / 2; + let half_resized_width = resized.right / 2; + let half_resized_height = resized.bottom / 2; + + let (main_x, alt_x, alt_y, main_y); + + if let Some(flip) = layout_flip { + match flip { + Axis::Horizontal => { + main_x = resized.left + half_width + (half_width - half_resized_width); + alt_x = resized.left; + + alt_y = resized.top + half_resized_height; + main_y = resized.top; + } + Axis::Vertical => { + main_y = resized.top + half_height + (half_height - half_resized_height); + alt_y = resized.top; + + main_x = resized.left; + alt_x = resized.left + half_resized_width; + } + Axis::HorizontalAndVertical => { + main_x = resized.left + half_width + (half_width - half_resized_width); + alt_x = resized.left; + main_y = resized.top + half_height + (half_height - half_resized_height); + alt_y = resized.top; + } + } + } else { + main_x = resized.left; + alt_x = resized.left + half_resized_width; + main_y = resized.top; + alt_y = resized.top + half_resized_height; + } + + #[allow(clippy::if_not_else)] + if count == 0 { + vec![] + } else if count == 1 { + vec![Rect { + left: resized.left, + top: resized.top, + right: resized.right, + bottom: resized.bottom, + }] + } else if idx % 2 != 0 { + let mut res = vec![Rect { + left: resized.left, + top: main_y, + right: resized.right, + bottom: half_resized_height, + }]; + res.append(&mut recursive_fibonacci( + idx + 1, + count - 1, + &Rect { + left: area.left, + top: alt_y, + right: area.right, + bottom: area.bottom - half_resized_height, + }, + layout_flip, + resize_adjustments, + )); + res + } else { + let mut res = vec![Rect { + left: main_x, + top: resized.top, + right: half_resized_width, + bottom: resized.bottom, + }]; + res.append(&mut recursive_fibonacci( + idx + 1, + count - 1, + &Rect { + left: alt_x, + top: area.top, + right: area.right - half_resized_width, + bottom: area.bottom, + }, + layout_flip, + resize_adjustments, + )); + res + } +} + +fn calculate_columns_adjustment(resize_dimensions: &[Option]) -> Vec { + let len = resize_dimensions.len(); + let mut result = vec![Rect::default(); len]; + match len { + 0 | 1 => (), + _ => { + for (i, rect) in resize_dimensions.iter().enumerate() { + if let Some(rect) = rect { + if i != 0 { + resize_right(&mut result[i - 1], rect.left); + resize_left(&mut result[i], rect.left); + } + + if i != len - 1 { + resize_right(&mut result[i], rect.right); + resize_left(&mut result[i + 1], rect.right); + } + } + } + } + }; + + result +} + +fn calculate_rows_adjustment(resize_dimensions: &[Option]) -> Vec { + let len = resize_dimensions.len(); + let mut result = vec![Rect::default(); len]; + match len { + 0 | 1 => (), + _ => { + for (i, rect) in resize_dimensions.iter().enumerate() { + if let Some(rect) = rect { + if i != 0 { + resize_bottom(&mut result[i - 1], rect.top); + resize_top(&mut result[i], rect.top); + } + + if i != len - 1 { + resize_bottom(&mut result[i], rect.bottom); + resize_top(&mut result[i + 1], rect.bottom); + } + } + } + } + }; + + result +} + +fn calculate_vertical_stack_adjustment(resize_dimensions: &[Option]) -> Vec { + let len = resize_dimensions.len(); + let mut result = vec![Rect::default(); len]; + match len { + // One container can't be resized + 0 | 1 => (), + _ => { + let (master, stack) = result.split_at_mut(1); + let primary = &mut master[0]; + + if let Some(resize) = resize_dimensions[0] { + resize_right(primary, resize.right); + for s in &mut *stack { + resize_left(s, resize.right); + } + } + + // Handle stack on the right + for (i, rect) in resize_dimensions[1..].iter().enumerate() { + if let Some(rect) = rect { + resize_right(primary, rect.left); + stack + .iter_mut() + .for_each(|vertical_element| resize_left(vertical_element, rect.left)); + + // Containers in stack except first can be resized up displacing container + // above them + if i != 0 { + resize_bottom(&mut stack[i - 1], rect.top); + resize_top(&mut stack[i], rect.top); + } + + // Containers in stack except last can be resized down displacing container + // below them + if i != stack.len() - 1 { + resize_bottom(&mut stack[i], rect.bottom); + resize_top(&mut stack[i + 1], rect.bottom); + } + } + } + } + }; + + result +} + +fn calculate_right_vertical_stack_adjustment(resize_dimensions: &[Option]) -> Vec { + let len = resize_dimensions.len(); + let mut result = vec![Rect::default(); len]; + match len { + // One container can't be resized + 0 | 1 => (), + _ => { + let (master, stack) = result.split_at_mut(1); + let primary = &mut master[0]; + + if let Some(resize) = resize_dimensions[0] { + resize_left(primary, resize.left); + for s in &mut *stack { + resize_right(s, resize.left); + } + } + + // Handle stack on the left + for (i, rect) in resize_dimensions[1..].iter().enumerate() { + if let Some(rect) = rect { + resize_left(primary, rect.right); + stack + .iter_mut() + .for_each(|vertical_element| resize_right(vertical_element, rect.right)); + + // Containers in stack except first can be resized up displacing container + // above them + if i != 0 { + resize_bottom(&mut stack[i - 1], rect.top); + resize_top(&mut stack[i], rect.top); + } + + // Containers in stack except last can be resized down displacing container + // below them + if i != stack.len() - 1 { + resize_bottom(&mut stack[i], rect.bottom); + resize_top(&mut stack[i + 1], rect.bottom); + } + } + } + } + }; + + result +} + +fn calculate_horizontal_stack_adjustment(resize_dimensions: &[Option]) -> Vec { + let len = resize_dimensions.len(); + let mut result = vec![Rect::default(); len]; + match len { + 0 | 1 => (), + _ => { + let (primary, rest) = result.split_at_mut(1); + let primary = &mut primary[0]; + if let Some(resize_primary) = resize_dimensions[0] { + resize_bottom(primary, resize_primary.bottom); + + for horizontal_element in &mut *rest { + resize_top(horizontal_element, resize_primary.bottom); + } + } + + for (i, rect) in resize_dimensions[1..].iter().enumerate() { + if let Some(rect) = rect { + resize_bottom(primary, rect.top); + rest.iter_mut() + .for_each(|vertical_element| resize_top(vertical_element, rect.top)); + + if i != 0 { + resize_right(&mut rest[i - 1], rect.left); + resize_left(&mut rest[i], rect.left); + } + + if i != rest.len() - 1 { + resize_right(&mut rest[i], rect.right); + resize_left(&mut rest[i + 1], rect.right); + } + } + } + } + }; + + result +} + +fn calculate_ultrawide_adjustment(resize_dimensions: &[Option]) -> Vec { + let len = resize_dimensions.len(); + let mut result = vec![Rect::default(); len]; + match len { + // One container can't be resized + 0 | 1 => (), + 2 => { + let (primary, secondary) = result.split_at_mut(1); + let primary = &mut primary[0]; + let secondary = &mut secondary[0]; + // With two containers on screen container 0 is on the right + if let Some(resize_primary) = resize_dimensions[0] { + resize_left(primary, resize_primary.left); + resize_right(secondary, resize_primary.left); + } + + if let Some(resize_secondary) = resize_dimensions[1] { + resize_left(primary, resize_secondary.right); + resize_right(secondary, resize_secondary.right); + } + } + _ => { + let (primary, rest) = result.split_at_mut(1); + let (secondary, tertiary) = rest.split_at_mut(1); + let primary = &mut primary[0]; + let secondary = &mut secondary[0]; + // With three or more containers container 0 is in the center + if let Some(resize_primary) = resize_dimensions[0] { + resize_left(primary, resize_primary.left); + resize_right(primary, resize_primary.right); + + resize_right(secondary, resize_primary.left); + + for vertical_element in &mut *tertiary { + resize_left(vertical_element, resize_primary.right); + } + } + + // Container 1 is on the left + if let Some(resize_secondary) = resize_dimensions[1] { + resize_left(primary, resize_secondary.right); + resize_right(secondary, resize_secondary.right); + } + + // Handle stack on the right + for (i, rect) in resize_dimensions[2..].iter().enumerate() { + if let Some(rect) = rect { + resize_right(primary, rect.left); + tertiary + .iter_mut() + .for_each(|vertical_element| resize_left(vertical_element, rect.left)); + + // Containers in stack except first can be resized up displacing container + // above them + if i != 0 { + resize_bottom(&mut tertiary[i - 1], rect.top); + resize_top(&mut tertiary[i], rect.top); + } + + // Containers in stack except last can be resized down displacing container + // below them + if i != tertiary.len() - 1 { + resize_bottom(&mut tertiary[i], rect.bottom); + resize_top(&mut tertiary[i + 1], rect.bottom); + } + } + } + } + }; + + result +} + +fn calculate_scrolling_adjustment(resize_dimensions: &[Option]) -> Vec { + let len = resize_dimensions.len(); + let mut result = vec![Rect::default(); len]; + + if len <= 1 { + return result; + } + + for (i, rect) in resize_dimensions.iter().enumerate() { + if let Some(rect) = rect { + let is_leftmost = i == 0; + let is_rightmost = i == len - 1; + + resize_left(&mut result[i], rect.left); + resize_right(&mut result[i], rect.right); + resize_top(&mut result[i], rect.top); + resize_bottom(&mut result[i], rect.bottom); + + if !is_leftmost && rect.left != 0 { + resize_right(&mut result[i - 1], rect.left); + } + + if !is_rightmost && rect.right != 0 { + resize_left(&mut result[i + 1], rect.right); + } + } + } + + result +} + +fn resize_left(rect: &mut Rect, resize: i32) { + rect.left += resize / 2; + rect.right += -resize / 2; +} + +fn resize_right(rect: &mut Rect, resize: i32) { + rect.right += resize / 2; +} + +fn resize_top(rect: &mut Rect, resize: i32) { + rect.top += resize / 2; + rect.bottom += -resize / 2; +} + +fn resize_bottom(rect: &mut Rect, resize: i32) { + rect.bottom += resize / 2; +} diff --git a/komorebi/src/core/default_layout.rs b/komorebi/src/core/default_layout.rs new file mode 100644 index 00000000..43f208a4 --- /dev/null +++ b/komorebi/src/core/default_layout.rs @@ -0,0 +1,200 @@ +use crate::core::Sizing; +use crate::core::operation_direction::OperationDirection; +use crate::core::rect::Rect; +use serde::Deserialize; +use serde::Serialize; + +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +pub enum DefaultLayout { + BSP, + Columns, + Rows, + VerticalStack, + HorizontalStack, + UltrawideVerticalStack, + Grid, + RightMainVerticalStack, + Scrolling, + // NOTE: If any new layout is added, please make sure to register the same in `DefaultLayout::cycle` +} + +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +pub struct LayoutOptions { + /// Options related to the Scrolling layout + pub scrolling: Option, +} + +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +pub struct ScrollingLayoutOptions { + /// Desired number of visible columns (default: 3) + pub columns: usize, +} + +impl DefaultLayout { + pub fn leftmost_index(&self, len: usize) -> usize { + match self { + Self::UltrawideVerticalStack | Self::RightMainVerticalStack => match len { + n if n > 1 => 1, + _ => 0, + }, + Self::Scrolling => 0, + DefaultLayout::BSP + | DefaultLayout::Columns + | DefaultLayout::Rows + | DefaultLayout::VerticalStack + | DefaultLayout::HorizontalStack + | DefaultLayout::Grid => 0, + } + } + + pub fn rightmost_index(&self, len: usize) -> usize { + match self { + DefaultLayout::BSP + | DefaultLayout::Columns + | DefaultLayout::Rows + | DefaultLayout::VerticalStack + | DefaultLayout::HorizontalStack + | DefaultLayout::Grid => len.saturating_sub(1), + DefaultLayout::UltrawideVerticalStack => match len { + 2 => 0, + _ => len.saturating_sub(1), + }, + DefaultLayout::RightMainVerticalStack => 0, + DefaultLayout::Scrolling => len.saturating_sub(1), + } + } + + #[must_use] + #[allow(clippy::cast_precision_loss, clippy::only_used_in_recursion)] + pub fn resize( + &self, + unaltered: &Rect, + resize: &Option, + edge: OperationDirection, + sizing: Sizing, + delta: i32, + ) -> Option { + if !matches!( + self, + Self::BSP + | Self::Columns + | Self::Rows + | Self::VerticalStack + | Self::RightMainVerticalStack + | Self::HorizontalStack + | Self::UltrawideVerticalStack + | Self::Scrolling + ) { + return None; + }; + + let mut r = resize.unwrap_or_default(); + + let resize_delta = delta; + + match edge { + OperationDirection::Left => match sizing { + Sizing::Increase => { + // Some final checks to make sure the user can't infinitely resize to + // the point of pushing other windows out of bounds + + // Note: These checks cannot take into account the changes made to the + // edges of adjacent windows at operation time, so it is still possible + // to push windows out of bounds by maxing out an Increase Left on a + // Window with index 1, and then maxing out a Decrease Right on a Window + // with index 0. I don't think it's worth trying to defensively program + // against this; if people end up in this situation they are better off + // just hitting the retile command + let diff = ((r.left + -resize_delta) as f32).abs(); + if diff < unaltered.right as f32 { + r.left += -resize_delta; + } + } + Sizing::Decrease => { + let diff = ((r.left - -resize_delta) as f32).abs(); + if diff < unaltered.right as f32 { + r.left -= -resize_delta; + } + } + }, + OperationDirection::Up => match sizing { + Sizing::Increase => { + let diff = ((r.top + resize_delta) as f32).abs(); + if diff < unaltered.bottom as f32 { + r.top += -resize_delta; + } + } + Sizing::Decrease => { + let diff = ((r.top - resize_delta) as f32).abs(); + if diff < unaltered.bottom as f32 { + r.top -= -resize_delta; + } + } + }, + OperationDirection::Right => match sizing { + Sizing::Increase => { + let diff = ((r.right + resize_delta) as f32).abs(); + if diff < unaltered.right as f32 { + r.right += resize_delta; + } + } + Sizing::Decrease => { + let diff = ((r.right - resize_delta) as f32).abs(); + if diff < unaltered.right as f32 { + r.right -= resize_delta; + } + } + }, + OperationDirection::Down => match sizing { + Sizing::Increase => { + let diff = ((r.bottom + resize_delta) as f32).abs(); + if diff < unaltered.bottom as f32 { + r.bottom += resize_delta; + } + } + Sizing::Decrease => { + let diff = ((r.bottom - resize_delta) as f32).abs(); + if diff < unaltered.bottom as f32 { + r.bottom -= resize_delta; + } + } + }, + }; + + if r.eq(&Rect::default()) { + None + } else { + Option::from(r) + } + } + + #[must_use] + pub const fn cycle_next(self) -> Self { + match self { + Self::BSP => Self::Columns, + Self::Columns => Self::Rows, + Self::Rows => Self::VerticalStack, + Self::VerticalStack => Self::HorizontalStack, + Self::HorizontalStack => Self::UltrawideVerticalStack, + Self::UltrawideVerticalStack => Self::Grid, + Self::Grid => Self::RightMainVerticalStack, + Self::RightMainVerticalStack => Self::Scrolling, + Self::Scrolling => Self::BSP, + } + } + + #[must_use] + pub const fn cycle_previous(self) -> Self { + match self { + Self::Scrolling => Self::RightMainVerticalStack, + Self::RightMainVerticalStack => Self::Grid, + Self::Grid => Self::UltrawideVerticalStack, + Self::UltrawideVerticalStack => Self::HorizontalStack, + Self::HorizontalStack => Self::VerticalStack, + Self::VerticalStack => Self::Rows, + Self::Rows => Self::Columns, + Self::Columns => Self::BSP, + Self::BSP => Self::RightMainVerticalStack, + } + } +} diff --git a/komorebi/src/core/direction.rs b/komorebi/src/core/direction.rs new file mode 100644 index 00000000..2d8238f0 --- /dev/null +++ b/komorebi/src/core/direction.rs @@ -0,0 +1,347 @@ +use crate::core::default_layout::DefaultLayout; +use crate::core::operation_direction::OperationDirection; + +pub trait Direction { + fn index_in_direction( + &self, + op_direction: OperationDirection, + idx: usize, + count: usize, + ) -> Option; + + fn is_valid_direction( + &self, + op_direction: OperationDirection, + idx: usize, + count: usize, + ) -> bool; + fn up_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize; + fn down_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize; + fn left_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize; + fn right_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize; +} + +impl Direction for DefaultLayout { + fn index_in_direction( + &self, + op_direction: OperationDirection, + idx: usize, + count: usize, + ) -> Option { + match op_direction { + OperationDirection::Left => { + if self.is_valid_direction(op_direction, idx, count) { + Option::from(self.left_index(Some(op_direction), idx, Some(count))) + } else { + None + } + } + OperationDirection::Right => { + if self.is_valid_direction(op_direction, idx, count) { + Option::from(self.right_index(Some(op_direction), idx, Some(count))) + } else { + None + } + } + OperationDirection::Up => { + if self.is_valid_direction(op_direction, idx, count) { + Option::from(self.up_index(Some(op_direction), idx, Some(count))) + } else { + None + } + } + OperationDirection::Down => { + if self.is_valid_direction(op_direction, idx, count) { + Option::from(self.down_index(Some(op_direction), idx, Some(count))) + } else { + None + } + } + } + } + + fn is_valid_direction( + &self, + op_direction: OperationDirection, + idx: usize, + count: usize, + ) -> bool { + if count < 2 { + return false; + } + + match op_direction { + OperationDirection::Up => match self { + Self::BSP => idx != 0 && idx != 1, + Self::Columns => false, + Self::Rows | Self::HorizontalStack => idx != 0, + Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != 1, + Self::UltrawideVerticalStack => idx > 2, + Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Scrolling => false, + }, + OperationDirection::Down => match self { + Self::BSP => idx != count - 1 && idx % 2 != 0, + Self::Columns => false, + Self::Rows => idx != count - 1, + Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != count - 1, + Self::HorizontalStack => idx == 0, + Self::UltrawideVerticalStack => idx > 1 && idx != count - 1, + Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Scrolling => false, + }, + OperationDirection::Left => match self { + Self::BSP => idx != 0, + Self::Columns | Self::VerticalStack => idx != 0, + Self::RightMainVerticalStack => idx == 0, + Self::Rows => false, + Self::HorizontalStack => idx != 0 && idx != 1, + Self::UltrawideVerticalStack => idx != 1, + Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Scrolling => idx != 0, + }, + OperationDirection::Right => match self { + Self::BSP => idx % 2 == 0 && idx != count - 1, + Self::Columns => idx != count - 1, + Self::Rows => false, + Self::VerticalStack => idx == 0, + Self::RightMainVerticalStack => idx != 0, + Self::HorizontalStack => idx != 0 && idx != count - 1, + Self::UltrawideVerticalStack => match count { + 2 => idx != 0, + _ => idx < 2, + }, + Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Scrolling => idx != count - 1, + }, + } + } + + fn up_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize { + match self { + Self::BSP => { + if idx % 2 == 0 { + idx - 1 + } else { + idx - 2 + } + } + Self::Columns => unreachable!(), + Self::Rows + | Self::VerticalStack + | Self::UltrawideVerticalStack + | Self::RightMainVerticalStack => idx - 1, + Self::HorizontalStack => 0, + Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Scrolling => unreachable!(), + } + } + + fn down_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize { + match self { + Self::BSP + | Self::Rows + | Self::VerticalStack + | Self::UltrawideVerticalStack + | Self::RightMainVerticalStack => idx + 1, + Self::Columns => unreachable!(), + Self::HorizontalStack => 1, + Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Scrolling => unreachable!(), + } + } + + fn left_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize { + match self { + Self::BSP => { + if idx % 2 == 0 { + idx - 2 + } else { + idx - 1 + } + } + Self::Columns | Self::HorizontalStack => idx - 1, + Self::Rows => unreachable!(), + Self::VerticalStack => 0, + Self::RightMainVerticalStack => 1, + Self::UltrawideVerticalStack => match idx { + 0 => 1, + 1 => unreachable!(), + _ => 0, + }, + Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Scrolling => idx - 1, + } + } + + fn right_index( + &self, + op_direction: Option, + idx: usize, + count: Option, + ) -> usize { + match self { + Self::BSP | Self::Columns | Self::HorizontalStack => idx + 1, + Self::Rows => unreachable!(), + Self::VerticalStack => 1, + Self::RightMainVerticalStack => 0, + Self::UltrawideVerticalStack => match idx { + 1 => 0, + 0 => 2, + _ => unreachable!(), + }, + Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Scrolling => idx + 1, + } + } +} + +struct GridItem { + state: GridItemState, + row: usize, + num_rows: usize, + touching_edges: GridTouchingEdges, +} + +enum GridItemState { + Valid, + Invalid, +} + +#[allow(clippy::struct_excessive_bools)] +struct GridTouchingEdges { + left: bool, + right: bool, + up: bool, + down: bool, +} + +#[allow( + clippy::cast_possible_truncation, + clippy::cast_precision_loss, + clippy::cast_sign_loss +)] +fn get_grid_item(idx: usize, count: usize) -> GridItem { + let num_cols = (count as f32).sqrt().ceil() as usize; + let mut iter = 0; + + for col in 0..num_cols { + let remaining_windows = count - iter; + let remaining_columns = num_cols - col; + let num_rows_in_this_col = remaining_windows / remaining_columns; + + for row in 0..num_rows_in_this_col { + if iter == idx { + return GridItem { + state: GridItemState::Valid, + row: row + 1, + num_rows: num_rows_in_this_col, + touching_edges: GridTouchingEdges { + left: col == 0, + right: col == num_cols - 1, + up: row == 0, + down: row == num_rows_in_this_col - 1, + }, + }; + } + + iter += 1; + } + } + + GridItem { + state: GridItemState::Invalid, + row: 0, + num_rows: 0, + touching_edges: GridTouchingEdges { + left: true, + right: true, + up: true, + down: true, + }, + } +} + +fn is_grid_edge(op_direction: OperationDirection, idx: usize, count: usize) -> bool { + let item = get_grid_item(idx, count); + + match item.state { + GridItemState::Invalid => false, + GridItemState::Valid => match op_direction { + OperationDirection::Left => item.touching_edges.left, + OperationDirection::Right => item.touching_edges.right, + OperationDirection::Up => item.touching_edges.up, + OperationDirection::Down => item.touching_edges.down, + }, + } +} + +fn grid_neighbor( + op_direction: Option, + idx: usize, + count: Option, +) -> usize { + let Some(op_direction) = op_direction else { + return 0; + }; + + let Some(count) = count else { + return 0; + }; + + let item = get_grid_item(idx, count); + + match op_direction { + OperationDirection::Left => { + let item_from_prev_col = get_grid_item(idx - item.row, count); + + if item.touching_edges.up && item.num_rows != item_from_prev_col.num_rows { + return idx - (item.num_rows - 1); + } + + if item.num_rows != item_from_prev_col.num_rows && !item.touching_edges.down { + return idx - (item.num_rows - 1); + } + + idx - item.num_rows + } + OperationDirection::Right => idx + item.num_rows, + OperationDirection::Up => idx - 1, + OperationDirection::Down => idx + 1, + } +} diff --git a/komorebi/src/core/layout.rs b/komorebi/src/core/layout.rs new file mode 100644 index 00000000..dd4131b6 --- /dev/null +++ b/komorebi/src/core/layout.rs @@ -0,0 +1,26 @@ +use crate::core::arrangement::Arrangement; +use crate::core::default_layout::DefaultLayout; +use crate::core::direction::Direction; +use serde::Deserialize; +use serde::Serialize; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub enum Layout { + Default(DefaultLayout), +} + +impl Layout { + #[must_use] + pub fn as_boxed_direction(&self) -> Box { + match self { + Layout::Default(layout) => Box::new(*layout), + } + } + + #[must_use] + pub fn as_boxed_arrangement(&self) -> Box { + match self { + Layout::Default(layout) => Box::new(*layout), + } + } +} diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs new file mode 100644 index 00000000..2daf9079 --- /dev/null +++ b/komorebi/src/core/mod.rs @@ -0,0 +1,15 @@ +use serde::Deserialize; +use serde::Serialize; + +pub mod arrangement; +pub mod default_layout; +pub mod direction; +pub mod layout; +pub mod operation_direction; +pub mod rect; + +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub enum Sizing { + Increase, + Decrease, +} diff --git a/komorebi/src/core/operation_direction.rs b/komorebi/src/core/operation_direction.rs new file mode 100644 index 00000000..0c66d6bf --- /dev/null +++ b/komorebi/src/core/operation_direction.rs @@ -0,0 +1,58 @@ +use std::num::NonZeroUsize; + +use crate::core::arrangement::Axis; +use crate::core::direction::Direction; +use serde::Deserialize; +use serde::Serialize; + +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub enum OperationDirection { + Left, + Right, + Up, + Down, +} + +impl OperationDirection { + #[must_use] + pub const fn opposite(self) -> Self { + match self { + Self::Left => Self::Right, + Self::Right => Self::Left, + Self::Up => Self::Down, + Self::Down => Self::Up, + } + } + + fn flip(self, layout_flip: Option) -> Self { + layout_flip.map_or(self, |flip| match self { + Self::Left => match flip { + Axis::Horizontal | Axis::HorizontalAndVertical => Self::Right, + Axis::Vertical => self, + }, + Self::Right => match flip { + Axis::Horizontal | Axis::HorizontalAndVertical => Self::Left, + Axis::Vertical => self, + }, + Self::Up => match flip { + Axis::Vertical | Axis::HorizontalAndVertical => Self::Down, + Axis::Horizontal => self, + }, + Self::Down => match flip { + Axis::Vertical | Axis::HorizontalAndVertical => Self::Up, + Axis::Horizontal => self, + }, + }) + } + + #[must_use] + pub fn destination( + self, + layout: &dyn Direction, + layout_flip: Option, + idx: usize, + len: NonZeroUsize, + ) -> Option { + layout.index_in_direction(self.flip(layout_flip), idx, len.get()) + } +} diff --git a/komorebi/src/core/rect.rs b/komorebi/src/core/rect.rs new file mode 100644 index 00000000..a125effd --- /dev/null +++ b/komorebi/src/core/rect.rs @@ -0,0 +1,105 @@ +use crate::core_graphics::CoreGraphicsApi; +use crate::window::WindowBounds; +use objc2_core_foundation::CGFloat; +use objc2_core_foundation::CGPoint; +use objc2_core_foundation::CGRect; +use objc2_core_foundation::CGSize; + +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Rect { + pub left: i32, + pub top: i32, + pub right: i32, + pub bottom: i32, +} + +impl From for Rect { + fn from(value: CGSize) -> Self { + Self { + left: 0, + top: 0, + right: value.width as i32, + bottom: value.height as i32, + } + } +} + +impl From for Rect { + fn from(value: CGRect) -> Self { + Self { + left: value.origin.x as i32, + top: value.origin.y as i32, + right: value.size.width as i32, + bottom: value.size.height as i32, + } + } +} + +impl From<&Rect> for CGRect { + fn from(value: &Rect) -> Self { + Self { + origin: CGPoint { + x: value.left as CGFloat, + y: value.top as CGFloat, + }, + size: CGSize { + width: value.right as CGFloat, + height: value.bottom as CGFloat, + }, + } + } +} + +impl From for Rect { + fn from(value: WindowBounds) -> Self { + Self { + left: value.x as i32, + top: value.y as i32, + right: value.width as i32, + bottom: value.height as i32, + } + } +} + +impl Rect { + pub fn contains(&self, other: &Rect) -> bool { + CoreGraphicsApi::contains_rect(other.into(), self.into()) + } + + /// Decrease the size of self by the padding amount. + pub fn add_padding(&mut self, padding: T) + where + T: Into>, + { + if let Some(padding) = padding.into() { + self.left += padding; + self.top += padding; + self.right -= padding * 2; + self.bottom -= padding * 2; + } + } + + /// Increase the size of self by the margin amount. + pub fn add_margin(&mut self, margin: i32) { + self.left -= margin; + self.top -= margin; + self.right += margin * 2; + self.bottom += margin * 2; + } + + pub fn left_padding(&mut self, padding: i32) { + self.left += padding; + } + + pub fn right_padding(&mut self, padding: i32) { + self.right -= padding; + } + + #[must_use] + pub const fn contains_point(&self, point: (i32, i32)) -> bool { + point.0 >= self.left + && point.0 <= self.left + self.right + && point.1 >= self.top + && point.1 <= self.top + self.bottom + } +} diff --git a/komorebi/src/layout.rs b/komorebi/src/layout.rs deleted file mode 100644 index 3d30c6b7..00000000 --- a/komorebi/src/layout.rs +++ /dev/null @@ -1,82 +0,0 @@ -use crate::rect::Rect; - -pub fn recursive_fibonacci( - idx: usize, - count: usize, - area: &Rect, - resize_adjustments: Vec>, -) -> Vec { - let mut a = *area; - - let resized = if let Some(Some(r)) = resize_adjustments.get(idx) { - a.left += r.left; - a.top += r.top; - a.right += r.right; - a.bottom += r.bottom; - a - } else { - *area - }; - - // let half_width = area.right / 2.0; - // let half_height = area.bottom / 2.0; - let half_resized_width = resized.right / 2.0; - let half_resized_height = resized.bottom / 2.0; - - let (main_x, alt_x, alt_y, main_y); - - main_x = resized.left; - alt_x = resized.left + half_resized_width; - main_y = resized.top; - alt_y = resized.top + half_resized_height; - - #[allow(clippy::if_not_else)] - if count == 0 { - vec![] - } else if count == 1 { - vec![Rect { - left: resized.left, - top: resized.top, - right: resized.right, - bottom: resized.bottom, - }] - } else if idx % 2 != 0 { - let mut res = vec![Rect { - left: resized.left, - top: main_y, - right: resized.right, - bottom: half_resized_height, - }]; - res.append(&mut recursive_fibonacci( - idx + 1, - count - 1, - &Rect { - left: area.left, - top: alt_y, - right: area.right, - bottom: area.bottom - half_resized_height, - }, - resize_adjustments, - )); - res - } else { - let mut res = vec![Rect { - left: main_x, - top: resized.top, - right: half_resized_width, - bottom: resized.bottom, - }]; - res.append(&mut recursive_fibonacci( - idx + 1, - count - 1, - &Rect { - left: alt_x, - top: area.top, - right: area.right - half_resized_width, - bottom: area.bottom, - }, - resize_adjustments, - )); - res - } -} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index aef1c7f4..aaf8e6ea 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -12,12 +12,12 @@ pub mod ring; pub mod accessibility; pub mod application; +pub mod core; pub mod core_graphics; -pub mod layout; pub mod macos_api; -pub mod rect; pub mod window; pub mod window_manager; +pub mod workspace; pub fn cf_array_as(array: &CFArray) -> impl Iterator> + use<'_, T> { let count = CFArray::count(array); diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index ae2e986f..5020e12d 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -1,8 +1,8 @@ use crate::LibraryError; use crate::application::Application; use crate::cf_array_as; +use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; -use crate::rect::Rect; use crate::ring::Ring; use crate::window::WindowInfo; use crate::window_manager::Container; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 2c0aa569..8c434763 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -2,8 +2,6 @@ use color_eyre::eyre; use color_eyre::eyre::eyre; -use komorebi::layout; -use komorebi::rect::Rect; use komorebi::window_manager::WindowManager; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; @@ -99,57 +97,12 @@ fn main() -> eyre::Result<()> { let mut wm = WindowManager::new(&run_loop); wm.init()?; - let containers = wm - .monitors - .focused() - .expect("must have a monitor at this point") - .focused_workspace() - .expect("must have a workspace at this point") - .containers(); - - let layouts = - layout::recursive_fibonacci(0, containers.len(), &Rect::from(display_size), vec![]); - - containers - .iter() - .zip(layouts) - .for_each(|(container, layout)| { - let window = container - .focused_window() - .expect("must have a window at this point"); - if let Err(error) = window.set_position(&layout) { - tracing::error!( - "failed to position window: {} ({error})", - window - .title() - .unwrap_or_else(|| String::from("")) - ); - } - - // initial example to ensure that window focusing works - // if let Some(window_title) = window.title() - // && window_title.contains("Komorebi Community Server") - // { - // match window.focus() { - // Err(error) => { - // tracing::error!( - // "failed to focus window: {} ({error})", - // window - // .title() - // .unwrap_or_else(|| String::from("")) - // ); - // } - // Ok(()) => { - // tracing::info!( - // "focused window: {}", - // window - // .title() - // .unwrap_or_else(|| String::from("")) - // ); - // } - // } - // } - }); + wm.monitors + .focused_mut() + .unwrap() + .focused_workspace_mut() + .unwrap() + .update()?; let quit_ctrlc = Arc::new(AtomicBool::new(false)); let quit_thread = quit_ctrlc.clone(); diff --git a/komorebi/src/rect.rs b/komorebi/src/rect.rs deleted file mode 100644 index 6f1b029d..00000000 --- a/komorebi/src/rect.rs +++ /dev/null @@ -1,68 +0,0 @@ -use crate::core_graphics::CoreGraphicsApi; -use crate::window::WindowBounds; -use objc2_core_foundation::CGFloat; -use objc2_core_foundation::CGPoint; -use objc2_core_foundation::CGRect; -use objc2_core_foundation::CGSize; - -#[derive(Debug, Copy, Clone)] -pub struct Rect { - pub left: f32, - pub top: f32, - pub right: f32, - pub bottom: f32, -} - -impl From for Rect { - fn from(value: CGSize) -> Self { - Self { - left: 0.0, - top: 0.0, - right: value.width as f32, - bottom: value.height as f32, - } - } -} - -impl From for Rect { - fn from(value: CGRect) -> Self { - Self { - left: value.origin.x as f32, - top: value.origin.y as f32, - right: value.size.width as f32, - bottom: value.size.height as f32, - } - } -} - -impl From<&Rect> for CGRect { - fn from(value: &Rect) -> Self { - Self { - origin: CGPoint { - x: value.left as CGFloat, - y: value.top as CGFloat, - }, - size: CGSize { - width: value.right as CGFloat, - height: value.bottom as CGFloat, - }, - } - } -} - -impl From for Rect { - fn from(value: WindowBounds) -> Self { - Self { - left: value.x, - top: value.y, - right: value.width, - bottom: value.height, - } - } -} - -impl Rect { - pub fn contains(&self, other: &Rect) -> bool { - CoreGraphicsApi::contains_rect(other.into(), self.into()) - } -} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index c4197f33..d28fbb43 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -12,7 +12,7 @@ use crate::accessibility::notification_constants::kAXWindowMovedNotification; use crate::accessibility::notification_constants::kAXWindowResizedNotification; use crate::application::Application; use crate::cf_dictionary_value; -use crate::rect::Rect; +use crate::core::rect::Rect; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; use objc2_application_services::AXObserver; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 594b7391..558594a5 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1,9 +1,10 @@ use crate::LibraryError; use crate::application::Application; +use crate::core::rect::Rect; use crate::macos_api::MacosApi; -use crate::rect::Rect; use crate::ring::Ring; use crate::window::Window; +use crate::workspace::Workspace; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use std::collections::HashMap; @@ -41,9 +42,21 @@ pub struct Monitor { } impl Monitor { + #[allow(clippy::field_reassign_with_default)] pub fn new(id: u32, size: Rect) -> Self { let mut workspaces = Ring::default(); - workspaces.elements_mut().push_back(Workspace::default()); + let mut workspace = Workspace::default(); + workspace.work_area = size; + workspace.container_padding = Some(20); + workspace.workspace_padding = Some(20); + workspace.work_area_offset = Some(Rect { + left: 0, + top: 0, + right: 0, + bottom: 40, + }); + + workspaces.elements_mut().push_back(workspace); Self { id, @@ -53,12 +66,6 @@ impl Monitor { } } -impl_ring_elements!(Workspace, Container); -#[derive(Debug, Default)] -pub struct Workspace { - pub containers: Ring, -} - impl_ring_elements!(Container, Window); #[derive(Debug)] pub struct Container { diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs new file mode 100644 index 00000000..51d6a663 --- /dev/null +++ b/komorebi/src/workspace.rs @@ -0,0 +1,133 @@ +use crate::core::arrangement::Axis; +use crate::core::default_layout::DefaultLayout; +use crate::core::default_layout::LayoutOptions; +use crate::core::layout::Layout; +use crate::core::rect::Rect; +use crate::ring::Ring; +use crate::window_manager::Container; +use color_eyre::eyre; +use color_eyre::eyre::eyre; +use std::num::NonZeroUsize; + +impl_ring_elements!(Workspace, Container); + +#[derive(Debug)] +pub struct Workspace { + pub containers: Ring, + pub workspace_padding: Option, + pub container_padding: Option, + pub resize_dimensions: Vec>, + pub layout: Layout, + pub work_area: Rect, + pub work_area_offset: Option, + pub latest_layout: Vec, + pub layout_flip: Option, + pub layout_options: Option, + pub globals: WorkspaceGlobals, + pub tile: bool, +} + +impl Default for Workspace { + fn default() -> Self { + Self { + containers: Default::default(), + workspace_padding: None, + container_padding: None, + resize_dimensions: vec![], + layout: Layout::Default(DefaultLayout::UltrawideVerticalStack), + work_area: Default::default(), + work_area_offset: None, + latest_layout: vec![], + layout_flip: None, + layout_options: None, + globals: Default::default(), + tile: true, + } + } +} + +#[derive(Debug, Default, Copy, Clone, PartialEq)] +/// Settings setup either by the parent monitor or by the `WindowManager` +pub struct WorkspaceGlobals { + pub container_padding: Option, + pub workspace_padding: Option, + pub border_width: i32, + pub border_offset: i32, + pub work_area: Rect, + pub work_area_offset: Option, + pub window_based_work_area_offset: Option, + pub window_based_work_area_offset_limit: isize, +} + +impl Workspace { + pub fn update(&mut self) -> eyre::Result<()> { + // make sure we are never holding on to empty containers + self.containers_mut().retain(|c| !c.windows().is_empty()); + + let container_padding = self + .container_padding + .or(self.globals.container_padding) + .unwrap_or_default(); + let workspace_padding = self + .workspace_padding + .or(self.globals.workspace_padding) + .unwrap_or_default(); + // let border_width = self.globals.border_width; + // let border_offset = self.globals.border_offset; + let work_area = self.globals.work_area; + let work_area_offset = self.work_area_offset.or(self.globals.work_area_offset); + // let window_based_work_area_offset = self.globals.window_based_work_area_offset; + // let window_based_work_area_offset_limit = + // self.globals.window_based_work_area_offset_limit; + + let mut adjusted_work_area = work_area_offset.map_or_else( + || self.work_area, + |offset| { + let mut with_offset = work_area; + with_offset.left += offset.left; + with_offset.top += offset.top; + with_offset.right -= offset.right; + with_offset.bottom -= offset.bottom; + + with_offset + }, + ); + + adjusted_work_area.add_padding(workspace_padding); + + #[allow(clippy::collapsible_if)] + if self.tile { + if !self.containers().is_empty() { + let mut layouts = self.layout.as_boxed_arrangement().calculate( + &adjusted_work_area, + NonZeroUsize::new(self.containers().len()).ok_or_else(|| { + eyre!( + "there must be at least one container to calculate a workspace layout" + ) + })?, + Some(container_padding), + self.layout_flip, + &self.resize_dimensions, + self.focused_container_idx(), + self.layout_options, + &self.latest_layout, + ); + + let containers = self.containers_mut(); + + for (i, container) in containers.iter_mut().enumerate() { + if let Some(layout) = layouts.get_mut(i) { + layout.add_padding(container_padding); + for window in container.windows() { + if let Err(error) = window.set_position(layout) { + tracing::warn!("failed to set window position: {error}"); + } + } + } + } + } + } + + Ok(()) + } +} From df9ceee17ec1cb6e1a9d562ce5d625c5d65ac4f2 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 17 Sep 2025 16:18:04 -0700 Subject: [PATCH 005/305] feat(wm): migrate ipc and impl basic socket messages This commit migrates another bunch of code from komorebi to start implementing inter-process communication using Unix domain sockets. For this commit a small subsection of the SocketMessage with maximum utility has been migrated: FocusWindow, MoveWindow, ChangeLayout, and TogglePause. This includes migrating their handlers in process_command, and setting up a UnixListener when creating a WindowManager instance. To be able to test this functionality I also implemented a basic skeleton of komorebic and migrated the komorebi-client library. There are some random fixes included here now that we are listening to a UnixListener on a separate thread, which includes wrapping structs from the objc2 crate which don't have Send and Sync implemented, so that they can be implemented in the komorebi lib. I also took the time to figure out how to calculate a monitor's work area size, excluding the dock and the menu bar, and started to split out Workspace and Monitor into their own modules. It looks like a lot of changes but most if this is just pulling in stuff from the Windows implementation. --- .gitignore | 2 +- Cargo.lock | 922 ++++++++++++++++++++++- Cargo.toml | 16 +- flake.nix | 37 +- komorebi-client/Cargo.toml | 8 + komorebi-client/src/lib.rs | 54 ++ komorebi/Cargo.toml | 15 +- komorebi/src/accessibility/mod.rs | 2 +- komorebi/src/application.rs | 14 +- komorebi/src/core/default_layout.rs | 3 +- komorebi/src/core/mod.rs | 31 + komorebi/src/core/operation_direction.rs | 6 +- komorebi/src/core/pathext.rs | 196 +++++ komorebi/src/core_graphics/mod.rs | 15 + komorebi/src/lib.rs | 70 ++ komorebi/src/lockable_sequence.rs | 363 +++++++++ komorebi/src/macos_api.rs | 72 +- komorebi/src/main.rs | 19 +- komorebi/src/monitor.rs | 88 +++ komorebi/src/process_command.rs | 122 +++ komorebi/src/window.rs | 23 +- komorebi/src/window_manager.rs | 255 ++++++- komorebi/src/workspace.rs | 29 +- komorebic/Cargo.toml | 13 + komorebic/src/main.rs | 100 +++ shell.nix | 3 +- 26 files changed, 2375 insertions(+), 103 deletions(-) create mode 100644 komorebi-client/Cargo.toml create mode 100644 komorebi-client/src/lib.rs create mode 100644 komorebi/src/core/pathext.rs create mode 100644 komorebi/src/lockable_sequence.rs create mode 100644 komorebi/src/monitor.rs create mode 100644 komorebi/src/process_command.rs create mode 100644 komorebic/Cargo.toml create mode 100644 komorebic/src/main.rs diff --git a/.gitignore b/.gitignore index b824c3d8..d7ae555d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /target -/result +/result* /.idea /.direnv diff --git a/Cargo.lock b/Cargo.lock index c8ecb3cb..cd2874b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,6 +26,71 @@ dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +dependencies = [ + "windows-sys 0.60.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.60.2", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + [[package]] name = "backtrace" version = "0.3.75" @@ -38,9 +103,15 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "2.9.4" @@ -56,6 +127,22 @@ dependencies = [ "objc2", ] +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "cc" +version = "1.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" +dependencies = [ + "find-msvc-tools", + "shlex", +] + [[package]] name = "cfg-if" version = "1.0.3" @@ -68,6 +155,59 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chrono" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +dependencies = [ + "iana-time-zone", + "num-traits", + "serde", + "windows-link 0.2.0", +] + +[[package]] +name = "clap" +version = "4.5.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.5.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + [[package]] name = "color-eyre" version = "0.6.5" @@ -95,6 +235,18 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "ctrlc" version = "3.5.0" @@ -106,6 +258,72 @@ dependencies = [ "windows-sys 0.61.0", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "deranged" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.0", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -122,6 +340,28 @@ dependencies = [ "objc2", ] +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.0", +] + [[package]] name = "eyre" version = "0.6.12" @@ -132,36 +372,185 @@ dependencies = [ "once_cell", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "gimli" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "iana-time-zone" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indenter" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92119844f513ffa41556430369ab02c295a3578af21cf945caa3e9e0c2481ac3" +dependencies = [ + "equivalent", + "hashbrown 0.15.5", + "serde", + "serde_core", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852f13bec5eba4ba9afbeb93fd7c13fe56147f055939ae21c43a29a0ecb2702e" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + [[package]] name = "komorebi" version = "0.1.0" dependencies = [ + "clap", "color-eyre", "ctrlc", + "dirs", + "lazy_static", "objc2", "objc2-app-kit", "objc2-application-services", "objc2-core-foundation", "objc2-core-graphics", + "parking_lot", "pastey", "serde", + "serde_json_lenient", + "serde_with", + "strum", "thiserror", "tracing", "tracing-subscriber", ] +[[package]] +name = "komorebi-client" +version = "0.1.0" +dependencies = [ + "komorebi", + "serde_json_lenient", +] + +[[package]] +name = "komorebic" +version = "0.1.0" +dependencies = [ + "clap", + "color-eyre", + "dirs", + "komorebi-client", + "lazy_static", + "pastey", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -174,6 +563,32 @@ version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" +[[package]] +name = "libredox" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.28" @@ -225,6 +640,21 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "objc2" version = "0.6.2" @@ -417,12 +847,47 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "owo-colors" version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + [[package]] name = "pastey" version = "0.1.1" @@ -435,6 +900,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "proc-macro2" version = "1.0.101" @@ -453,6 +924,46 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_syscall" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "ref-cast" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex-automata" version = "0.4.10" @@ -476,6 +987,61 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" +[[package]] +name = "rustix" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.0", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "serde" version = "1.0.225" @@ -506,6 +1072,63 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] +name = "serde_json_lenient" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e033097bf0d2b59a62b42c18ebbb797503839b26afdda2c4e1415cb6c813540" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.11.3", + "schemars 0.9.0", + "schemars 1.0.4", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -515,12 +1138,45 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "syn" version = "2.0.106" @@ -532,6 +1188,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "terminal_size" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b8cb979cb11c32ce1603f8137b22262a9d131aaa5c37b5678025f22b8becd0" +dependencies = [ + "rustix", + "windows-sys 0.60.2", +] + [[package]] name = "thiserror" version = "2.0.16" @@ -561,6 +1227,36 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "time" +version = "0.3.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" + +[[package]] +name = "time-macros" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tracing" version = "0.1.41" @@ -638,25 +1334,164 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "valuable" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab10a69fbd0a177f5f649ad4d8d3305499c42bab9aef2f7ff592d0ec8f833819" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb702423545a6007bbc368fde243ba47ca275e549c8a28617f56f6ba53b1d1c" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc65f4f411d91494355917b605e1480033152658d71f722a90647f56a70c88a0" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc003a991398a8ee604a401e194b6b3a39677b3173d6e74495eb51b82e99a32" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "293c37f4efa430ca14db3721dfbe48d8c33308096bd44d80ebaa775ab71ba1cf" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "windows-core" +version = "0.62.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.0", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-link" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +[[package]] +name = "windows-result" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" +dependencies = [ + "windows-link 0.2.0", +] + +[[package]] +name = "windows-strings" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" +dependencies = [ + "windows-link 0.2.0", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", ] [[package]] @@ -665,7 +1500,7 @@ version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa" dependencies = [ - "windows-link", + "windows-link 0.2.0", ] [[package]] @@ -674,14 +1509,31 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link 0.1.3", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -690,44 +1542,92 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" diff --git a/Cargo.toml b/Cargo.toml index 272a0c63..35a63335 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,5 +2,17 @@ resolver = "2" members = [ - "komorebi", -] \ No newline at end of file + "komorebi", "komorebi-client", + "komorebic", +] + + +[workspace.dependencies] +clap = { version = "4", features = ["derive", "wrap_help"] } +color-eyre = "0.6" +dirs = "6" +lazy_static = "1" +pastey = "0.1" +serde = { version = "1", features = ["derive"] } +serde_json = { package = "serde_json_lenient", version = "0.2" } +thiserror = "2" diff --git a/flake.nix b/flake.nix index 61198d2f..2f621e73 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,7 @@ overlays = [ (import rust-overlay) ]; + pkgs = (import nixpkgs) { inherit system overlays; }; @@ -21,15 +22,12 @@ toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; - - pname = "komorebi"; + src = craneLib.cleanCargoSource ./.; version = "0.1.0"; commonArgs = { - inherit pname version; - nativeBuildInputs = with pkgs; [ -# pkg-config - ]; + inherit src; + nativeBuildInputs = with pkgs; []; doCheck = false; buildInputs = with pkgs; [ gcc @@ -37,23 +35,34 @@ ]; }; - cargoArtifacts = craneLib.buildDepsOnly (commonArgs - // { - src = craneLib.cleanCargoSource (craneLib.path ./.); - }); + cargoArtifacts = craneLib.buildDepsOnly commonArgs; - komorebi = craneLib.buildPackage (commonArgs + komorebi = craneLib.buildPackage ( + commonArgs // { - inherit cargoArtifacts; + inherit version; + pname = "komorebi"; + cargoExtraArgs = "-p komorebi"; src = ./.; - }); + } + ); + + komorebic = craneLib.buildPackage ( + commonArgs + // { + inherit version; + pname = "komorebic"; + cargoExtraArgs = "-p komorebic"; + src = ./.; + } + ); in { devShells = flake-utils.lib.flattenTree { default = import ./shell.nix {inherit pkgs;}; }; packages = flake-utils.lib.flattenTree rec { - inherit komorebi; + inherit komorebi komorebic; default = komorebi; }; } diff --git a/komorebi-client/Cargo.toml b/komorebi-client/Cargo.toml new file mode 100644 index 00000000..6853093c --- /dev/null +++ b/komorebi-client/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "komorebi-client" +version = "0.1.0" +edition = "2024" + +[dependencies] +komorebi = { path = "../komorebi", default-features = false } +serde_json = { workspace = true } diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs new file mode 100644 index 00000000..609bb5d1 --- /dev/null +++ b/komorebi-client/src/lib.rs @@ -0,0 +1,54 @@ +pub use komorebi::DATA_DIR; +pub use komorebi::core::SocketMessage; +pub use komorebi::core::default_layout::DefaultLayout; +pub use komorebi::core::operation_direction::OperationDirection; +pub use komorebi::core::pathext::PathExt; +use std::borrow::Borrow; +use std::io::BufReader; +use std::io::Read; +use std::io::Write; +use std::net::Shutdown; +use std::os::unix::net::UnixStream; +use std::time::Duration; + +const KOMOREBI: &str = "komorebi.sock"; + +pub fn send_message(message: &SocketMessage) -> std::io::Result<()> { + let socket = DATA_DIR.join(KOMOREBI); + let mut stream = UnixStream::connect(socket)?; + stream.set_write_timeout(Some(Duration::from_secs(1)))?; + stream.write_all(serde_json::to_string(message)?.as_bytes()) +} + +pub fn send_batch(messages: impl IntoIterator) -> std::io::Result<()> +where + Q: Borrow, +{ + let socket = DATA_DIR.join(KOMOREBI); + let mut stream = UnixStream::connect(socket)?; + stream.set_write_timeout(Some(Duration::from_secs(1)))?; + let msgs = messages.into_iter().fold(String::new(), |mut s, m| { + if let Ok(m_str) = serde_json::to_string(m.borrow()) { + s.push_str(&m_str); + s.push('\n'); + } + s + }); + stream.write_all(msgs.as_bytes()) +} + +pub fn send_query(message: &SocketMessage) -> std::io::Result { + let socket = DATA_DIR.join(KOMOREBI); + + let mut stream = UnixStream::connect(socket)?; + stream.set_read_timeout(Some(Duration::from_secs(1)))?; + stream.set_write_timeout(Some(Duration::from_secs(1)))?; + stream.write_all(serde_json::to_string(message)?.as_bytes())?; + stream.shutdown(Shutdown::Write)?; + + let mut reader = BufReader::new(stream); + let mut response = String::new(); + reader.read_to_string(&mut response)?; + + Ok(response) +} diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 6e29f99a..41542be9 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -4,15 +4,22 @@ version = "0.1.0" edition = "2024" [dependencies] -color-eyre = { version = "0.6" } +clap = { workspace = true } +color-eyre = { workspace = true } ctrlc = { version = "3", features = ["termination"] } +dirs = { workspace = true } +lazy_static = { workspace = true } objc2 = "0.6" objc2-app-kit = "0.3" objc2-application-services = "0.3" objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } -pastey = "0.1" -serde = { version = "1", features = ["derive"]} -thiserror = "2" +parking_lot = "0.12" +pastey = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_with = "3" +strum = { version = "0.27", features = ["derive"] } +thiserror = { workspace = true } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file diff --git a/komorebi/src/accessibility/mod.rs b/komorebi/src/accessibility/mod.rs index e79db36a..998c2648 100644 --- a/komorebi/src/accessibility/mod.rs +++ b/komorebi/src/accessibility/mod.rs @@ -134,7 +134,7 @@ impl AccessibilityApi { observer: &AXObserver, element: &AXUIElement, notifications: &[&'static str], - run_loop: &CFRetained, + run_loop: &CFRunLoop, ) -> Result<(), AccessibilityError> { AccessibilityApi::add_notifications_to_observer(observer, element, notifications)?; diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index 0da446e0..f76f9684 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -1,3 +1,5 @@ +use crate::AccessibilityObserver; +use crate::AccessibilityUiElement; use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXTitleAttribute; use crate::accessibility::attribute_constants::kAXWindowsAttribute; @@ -36,9 +38,9 @@ const NOTIFICATIONS: &[&str] = &[ #[derive(Debug, Clone)] pub struct Application { - element: CFRetained, + element: AccessibilityUiElement, pub process_id: i32, - pub observer: CFRetained, + pub observer: AccessibilityObserver, } #[instrument(skip_all)] @@ -84,12 +86,12 @@ impl Drop for Application { impl Application { pub fn new(process_id: i32) -> Result { Ok(Self { - element: AccessibilityApi::create_application(process_id), + element: AccessibilityUiElement(AccessibilityApi::create_application(process_id)), process_id, - observer: AccessibilityApi::create_observer( + observer: AccessibilityObserver(AccessibilityApi::create_observer( process_id, Some(application_observer_callback), - )?, + )?), }) } @@ -99,7 +101,7 @@ impl Application { } #[tracing::instrument(skip_all)] - pub fn observe(&self, run_loop: &CFRetained) -> Result<(), AccessibilityError> { + pub fn observe(&self, run_loop: &CFRunLoop) -> Result<(), AccessibilityError> { tracing::info!( "registering observer for process: {}, name: {}", self.process_id, diff --git a/komorebi/src/core/default_layout.rs b/komorebi/src/core/default_layout.rs index 43f208a4..d545a9f3 100644 --- a/komorebi/src/core/default_layout.rs +++ b/komorebi/src/core/default_layout.rs @@ -1,10 +1,11 @@ use crate::core::Sizing; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use clap::ValueEnum; use serde::Deserialize; use serde::Serialize; -#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq, ValueEnum)] pub enum DefaultLayout { BSP, Columns, diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 2daf9079..61da4434 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -1,11 +1,17 @@ +use crate::core::default_layout::DefaultLayout; +use crate::core::operation_direction::OperationDirection; +use color_eyre::eyre; use serde::Deserialize; use serde::Serialize; +use std::str::FromStr; +use strum::Display; pub mod arrangement; pub mod default_layout; pub mod direction; pub mod layout; pub mod operation_direction; +pub mod pathext; pub mod rect; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] @@ -13,3 +19,28 @@ pub enum Sizing { Increase, Decrease, } + +#[serde_with::serde_as] +#[derive(Clone, Debug, Serialize, Deserialize, Display)] +#[serde(tag = "type", content = "content")] +pub enum SocketMessage { + // Window / Container Commands + FocusWindow(OperationDirection), + MoveWindow(OperationDirection), + ChangeLayout(DefaultLayout), + TogglePause, +} + +impl SocketMessage { + pub fn as_bytes(&self) -> eyre::Result> { + Ok(serde_json::to_string(self)?.as_bytes().to_vec()) + } +} + +impl FromStr for SocketMessage { + type Err = serde_json::Error; + + fn from_str(s: &str) -> Result { + serde_json::from_str(s) + } +} diff --git a/komorebi/src/core/operation_direction.rs b/komorebi/src/core/operation_direction.rs index 0c66d6bf..dd526271 100644 --- a/komorebi/src/core/operation_direction.rs +++ b/komorebi/src/core/operation_direction.rs @@ -1,11 +1,11 @@ -use std::num::NonZeroUsize; - use crate::core::arrangement::Axis; use crate::core::direction::Direction; +use clap::ValueEnum; use serde::Deserialize; use serde::Serialize; +use std::num::NonZeroUsize; -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize, ValueEnum)] pub enum OperationDirection { Left, Right, diff --git a/komorebi/src/core/pathext.rs b/komorebi/src/core/pathext.rs new file mode 100644 index 00000000..7110c485 --- /dev/null +++ b/komorebi/src/core/pathext.rs @@ -0,0 +1,196 @@ +use std::collections::HashMap; +use std::env; +use std::ffi::OsStr; +use std::path::Component; +use std::path::Path; +use std::path::PathBuf; + +use serde::Deserialize; +use serde::Serialize; + +/// Path extension trait +pub trait PathExt { + /// Resolve environment variable components in a path. + /// + /// Resolves the following formats: + /// - CMD: `%variable%` + /// - PowerShell: `$Env:variable` + /// - Bash: `$variable`. + fn replace_env(&self) -> PathBuf; +} + +/// Blanket implementation for all types that can be converted to a `Path`. +impl> PathExt for P { + fn replace_env(&self) -> PathBuf { + let mut out = PathBuf::new(); + + for c in self.as_ref().components() { + match c { + Component::Normal(mut c) => { + // Special case for ~ and $HOME, replace with $Env:USERPROFILE + if c == OsStr::new("~") || c.eq_ignore_ascii_case("$HOME") { + c = OsStr::new("$Env:USERPROFILE"); + } + + let bytes = c.as_encoded_bytes(); + + // %LOCALAPPDATA% + let var = if bytes[0] == b'%' && bytes[bytes.len() - 1] == b'%' { + Some(&bytes[1..bytes.len() - 1]) + } else { + // prefix length is 5 for $Env: and 1 for $ + // so we take the minimum of 5 and the length of the bytes + let prefix = &bytes[..5.min(bytes.len())]; + let prefix = unsafe { OsStr::from_encoded_bytes_unchecked(prefix) }; + + // $Env:LOCALAPPDATA + if prefix.eq_ignore_ascii_case("$Env:") { + Some(&bytes[5..]) + } else if bytes[0] == b'$' { + // $LOCALAPPDATA + Some(&bytes[1..]) + } else { + // not a variable + None + } + }; + + // if component is a variable, get the value from the environment + if let Some(var) = var { + let var = unsafe { OsStr::from_encoded_bytes_unchecked(var) }; + if let Some(value) = env::var_os(var) { + out.push(value); + continue; + } + } + + // if not a variable, or a value couldn't be obtained from environemnt + // then push the component as is + out.push(c); + } + + // other components are pushed as is + _ => out.push(c), + } + } + + out + } +} + +/// Replace environment variables in a path. This is a wrapper around +/// [`PathExt::replace_env`] to be used in Clap arguments parsing. +pub fn replace_env_in_path(input: &str) -> Result { + Ok(input.replace_env()) +} + +/// A wrapper around [`PathBuf`] that has a custom [Deserialize] implementation +/// that uses [`PathExt::replace_env`] to resolve environment variables +#[derive(Clone, Debug)] +pub struct ResolvedPathBuf(PathBuf); + +impl ResolvedPathBuf { + /// Create a new [`ResolvedPathBuf`] from a [`PathBuf`] + pub fn new(path: PathBuf) -> Self { + Self(path.replace_env()) + } +} + +impl From for PathBuf { + fn from(path: ResolvedPathBuf) -> Self { + path.0 + } +} + +impl serde_with::SerializeAs for ResolvedPathBuf { + fn serialize_as(path: &PathBuf, serializer: S) -> Result + where + S: serde::Serializer, + { + path.serialize(serializer) + } +} + +impl<'de> serde_with::DeserializeAs<'de, PathBuf> for ResolvedPathBuf { + fn deserialize_as(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let path = PathBuf::deserialize(deserializer)?; + Ok(path.replace_env()) + } +} + +// #[cfg(feature = "schemars")] +// impl serde_with::schemars_0_8::JsonSchemaAs for ResolvedPathBuf { +// fn schema_name() -> String { +// "PathBuf".to_owned() +// } +// +// fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { +// ::json_schema(gen) +// } +// } + +/// Custom deserializer for [`Option>`] that uses +/// [`PathExt::replace_env`] to resolve environment variables in the paths. +/// +/// This is used in `WorkspaceConfig` struct because we can't use +/// #[serde_with::serde_as] as it doesn't handle [`Option>`] +/// quite well and generated compiler errors that can't be fixed because of Rust's orphan rule. +pub fn resolve_option_hashmap_usize_path<'de, D>( + deserializer: D, +) -> Result>, D::Error> +where + D: serde::Deserializer<'de>, +{ + let map = Option::>::deserialize(deserializer)?; + Ok(map.map(|map| map.into_iter().map(|(k, v)| (k, v.replace_env())).collect())) +} + +#[cfg(test)] +mod tests { + use super::*; + + // helper functions + fn expected>(p: P) -> PathBuf { + // Ensure that the path is using the correct path separator for the OS. + p.as_ref().components().collect::() + } + + fn resolve>(p: P) -> PathBuf { + p.replace_env() + } + + #[test] + fn resolves_env_vars() { + // Set a variable for testing + unsafe { + std::env::set_var("VAR", "VALUE"); + } + + // %VAR% format + assert_eq!(resolve("/path/%VAR%/d"), expected("/path/VALUE/d")); + // $env:VAR format + assert_eq!(resolve("/path/$env:VAR/d"), expected("/path/VALUE/d")); + // $VAR format + assert_eq!(resolve("/path/$VAR/d"), expected("/path/VALUE/d")); + + // non-existent variable + assert_eq!(resolve("/path/%ASD%/to/d"), expected("/path/%ASD%/to/d")); + assert_eq!( + resolve("/path/$env:ASD/to/d"), + expected("/path/$env:ASD/to/d") + ); + assert_eq!(resolve("/path/$ASD/to/d"), expected("/path/$ASD/to/d")); + + // Set a $env:USERPROFILE variable for testing + unsafe { + std::env::set_var("USERPROFILE", "C:\\Users\\user"); + } + + // ~ and $HOME should be replaced with $Env:USERPROFILE + assert_eq!(resolve("~"), expected("C:\\Users\\user")); + assert_eq!(resolve("$HOME"), expected("C:\\Users\\user")); + } +} diff --git a/komorebi/src/core_graphics/mod.rs b/komorebi/src/core_graphics/mod.rs index e3d8a8d4..660cd589 100644 --- a/komorebi/src/core_graphics/mod.rs +++ b/komorebi/src/core_graphics/mod.rs @@ -1,10 +1,13 @@ use crate::core_graphics::error::CoreGraphicsError; use objc2_core_foundation::CFArray; use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CGFloat; +use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_graphics::CGDisplayBounds; use objc2_core_graphics::CGGetOnlineDisplayList; use objc2_core_graphics::CGRectIntersectsRect; +use objc2_core_graphics::CGWarpMouseCursorPosition; use objc2_core_graphics::CGWindowListCopyWindowInfo; use objc2_core_graphics::CGWindowListOption; use objc2_core_graphics::kCGNullWindowID; @@ -14,6 +17,18 @@ pub mod error; pub struct CoreGraphicsApi; impl CoreGraphicsApi { + pub fn warp_mouse_cursor_position(x: i32, y: i32) -> Result<(), CoreGraphicsError> { + match unsafe { + CoreGraphicsError::from(CGWarpMouseCursorPosition(CGPoint::new( + x as CGFloat, + y as CGFloat, + ))) + } { + CoreGraphicsError::Success => Ok(()), + error => Err(error), + } + } + pub fn contains_rect(smaller: CGRect, bigger: CGRect) -> bool { unsafe { CGRectIntersectsRect(smaller, bigger) } } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index aaf8e6ea..ac464246 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -2,10 +2,19 @@ use crate::accessibility::error::AccessibilityError; use crate::core_graphics::error::CoreGraphicsError; +use core::pathext::PathExt; +use lazy_static::lazy_static; +use objc2_application_services::AXObserver; +use objc2_application_services::AXUIElement; use objc2_core_foundation::CFArray; use objc2_core_foundation::CFDictionary; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::CFString; +use std::ops::Deref; +use std::path::PathBuf; use std::ptr::NonNull; +use std::sync::atomic::AtomicI32; #[macro_use] pub mod ring; @@ -14,11 +23,72 @@ pub mod accessibility; pub mod application; pub mod core; pub mod core_graphics; +pub mod lockable_sequence; pub mod macos_api; +mod monitor; +pub mod process_command; pub mod window; pub mod window_manager; pub mod workspace; +lazy_static! { + pub static ref HOME_DIR: PathBuf = { + std::env::var("KOMOREBI_CONFIG_HOME").map_or_else(|_| dirs::home_dir().expect("there is no home directory"), |home_path| { + let home = home_path.replace_env(); + + assert!( + home.is_dir(), + "$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory" + ); + + + home + }) + }; + pub static ref DATA_DIR: PathBuf = dirs::data_local_dir() + .expect("there is no local data directory") + .join("komorebi"); +} + +pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); +pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(5); + +#[derive(Debug)] +pub struct CoreFoundationRunLoop(pub CFRetained); +unsafe impl Sync for CoreFoundationRunLoop {} +unsafe impl Send for CoreFoundationRunLoop {} +impl Deref for CoreFoundationRunLoop { + type Target = CFRunLoop; + + fn deref(&self) -> &Self::Target { + self.0.as_ref() + } +} + +#[derive(Debug, Clone)] +pub struct AccessibilityUiElement(pub CFRetained); +unsafe impl Sync for AccessibilityUiElement {} +unsafe impl Send for AccessibilityUiElement {} +impl Deref for AccessibilityUiElement { + type Target = AXUIElement; + + fn deref(&self) -> &Self::Target { + self.0.as_ref() + } +} + +#[derive(Debug, Clone)] +pub struct AccessibilityObserver(pub CFRetained); +unsafe impl Sync for AccessibilityObserver {} +unsafe impl Send for AccessibilityObserver {} +impl Deref for AccessibilityObserver { + type Target = AXObserver; + + fn deref(&self) -> &Self::Target { + self.0.as_ref() + } +} + pub fn cf_array_as(array: &CFArray) -> impl Iterator> + use<'_, T> { let count = CFArray::count(array); (0..count).flat_map(move |idx| { diff --git a/komorebi/src/lockable_sequence.rs b/komorebi/src/lockable_sequence.rs new file mode 100644 index 00000000..e4aed3a3 --- /dev/null +++ b/komorebi/src/lockable_sequence.rs @@ -0,0 +1,363 @@ +use std::collections::VecDeque; + +/// A trait for types that can be marked as locked or unlocked. +pub trait Lockable { + /// Returns `true` if the item is locked. + fn locked(&self) -> bool; + /// Sets the locked state of the item. + fn set_locked(&mut self, locked: bool) -> &mut Self; +} + +/// A sequence supporting insertion, removal, and swapping of elements while preserving the absolute +/// positions of locked items. +pub trait LockableSequence { + /// Inserts a value at `idx`, keeping locked elements at their absolute positions. + fn insert_respecting_locks(&mut self, idx: usize, value: T) -> usize; + /// Removes the element at `idx`, keeping locked elements at their absolute positions. + fn remove_respecting_locks(&mut self, idx: usize) -> Option; + /// Swaps the elements at indices `i` and `j`, keeping locked elements at their absolute positions. + fn swap_respecting_locks(&mut self, i: usize, j: usize); +} + +impl LockableSequence for VecDeque { + /// Insert `value` at logical index `idx`, with trying to keep locked elements + /// (`is_locked()`) anchored at their original positions. + /// + /// Returns the final index of the inserted element. + fn insert_respecting_locks(&mut self, mut idx: usize, value: T) -> usize { + // 1. Bounds check: if index is out of range, simply append. + if idx >= self.len() { + self.push_back(value); + return self.len() - 1; // last index + } + + // 2. Normal VecDeque insertion + self.insert(idx, value); + + // 3. Walk left-to-right once, swapping any misplaced locked element. After + // the VecDeque::insert all items after `idx` have moved right by one. For every locked + // element that is now to the right of an unlocked one, swap it back left exactly once. + for index in (idx + 1)..self.len() { + if self[index].locked() && !self[index - 1].locked() { + self.swap(index - 1, index); + + // If the element we just inserted participated in the swap, + // update `idx` so we can return its final location. + if idx == index - 1 { + idx = index; + } + } + } + idx + } + + /// Remove element at `idx`, with trying to keep locked elements + /// (`is_locked()`) anchored at their original positions. + /// + /// Returns the removed element, or `None` if `idx` is out of bounds. + fn remove_respecting_locks(&mut self, idx: usize) -> Option { + // 1. Bounds check: if index is out of range, do nothing. + if idx >= self.len() { + return None; + } + + // 2. Remove the element at the requested index. + // All elements after idx are now shifted left by 1. + let removed = self.remove(idx)?; + + // 3. If less than 2 elements remain, nothing to shift. + if self.len() < 2 { + return Some(removed); + } + + // 4. Iterate from the element just after the removed spot up to the second-to-last + // element, right-to-left. This loop "fixes" locked elements that were shifted left + // off their anchored positions: If a locked element now has an unlocked element + // to its right, swap them back to restore locked order. + for index in (idx..self.len() - 1).rev() { + // If current is locked and the next one is not locked, swap them. + if self[index].locked() && !self[index + 1].locked() { + self.swap(index, index + 1); + } + } + + // 5. Return the removed value. + Some(removed) + } + + /// Swaps the elements at indices `i` and `j`, along with their `locked` status, ensuring + /// the lock state remains associated with the position rather than the element itself. + fn swap_respecting_locks(&mut self, i: usize, j: usize) { + self.swap(i, j); + let locked_i = self[i].locked(); + let locked_j = self[j].locked(); + self[i].set_locked(locked_j); + self[j].set_locked(locked_i); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[derive(Debug, PartialEq)] + struct TestItem { + val: i32, + locked: bool, + } + + impl Lockable for TestItem { + fn locked(&self) -> bool { + self.locked + } + + fn set_locked(&mut self, locked: bool) -> &mut Self { + self.locked = locked; + self + } + } + + fn vals(v: &VecDeque) -> Vec { + v.iter().map(|x| x.val).collect() + } + + fn test_deque(items: &[(i32, bool)]) -> VecDeque { + items + .iter() + .cloned() + .map(|(val, locked)| TestItem { val, locked }) + .collect() + } + + #[test] + fn test_insert_respecting_locks() { + // Test case 1: Basic insertion with locked index + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, false), (4, false)]); + // Insert at index 0, should shift elements while keeping index 2 locked + ring.insert_respecting_locks( + 0, + TestItem { + val: 99, + locked: false, + }, + ); + // Element '2' remains at index 2, element '1' that was at index 1 is now at index 3 + assert_eq!(vals(&ring), vec![99, 0, 2, 1, 3, 4]); + } + + // Test case 2: Insert at a locked index (should insert after locked) + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, false), (4, false)]); + // Try to insert at locked index 2, should insert at index 3 instead + let actual_index = ring.insert_respecting_locks( + 2, + TestItem { + val: 99, + locked: false, + }, + ); + assert_eq!(actual_index, 3); + assert_eq!(vals(&ring), vec![0, 1, 2, 99, 3, 4]); + } + + // Test case 3: Multiple locked indices + { + // Lock index 1 and 3 + let mut ring = test_deque(&[(0, false), (1, true), (2, false), (3, true), (4, false)]); + // Insert at index 0, should maintain locked indices + ring.insert_respecting_locks( + 0, + TestItem { + val: 99, + locked: false, + }, + ); + // Elements '1' and '3' remain at indices 1 and 3 + assert_eq!(vals(&ring), vec![99, 1, 0, 3, 2, 4]); + } + + // Test case 4: Insert at end + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, false), (4, false)]); + let actual_index = ring.insert_respecting_locks( + 5, + TestItem { + val: 99, + locked: false, + }, + ); + assert_eq!(actual_index, 5); + assert_eq!(vals(&ring), vec![0, 1, 2, 3, 4, 99]); + } + + // Test case 5: Empty ring + { + let mut ring = test_deque(&[]); + // Insert into empty deque + let actual_index = ring.insert_respecting_locks( + 0, + TestItem { + val: 99, + locked: false, + }, + ); + assert_eq!(actual_index, 0); + assert_eq!(vals(&ring), vec![99]); + } + + // Test case 6: All indices locked + { + // Lock all indices + let mut ring = test_deque(&[(0, true), (1, true), (2, true), (3, true), (4, true)]); + // Try to insert at index 2, should insert at the end + let actual_index = ring.insert_respecting_locks( + 2, + TestItem { + val: 99, + locked: false, + }, + ); + assert_eq!(actual_index, 5); + assert_eq!(vals(&ring), vec![0, 1, 2, 3, 4, 99]); + } + + // Test case 7: Consecutive locked indices + { + // Lock index 2 and 3 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, true), (4, false)]); + // Insert at index 1, should maintain consecutive locked indices + ring.insert_respecting_locks( + 1, + TestItem { + val: 99, + locked: false, + }, + ); + // Elements '2' and '3' remain at indices 2 and 3 + assert_eq!(vals(&ring), vec![0, 99, 2, 3, 1, 4]); + } + } + + #[test] + fn test_remove_respecting_locks() { + // Test case 1: Remove a non-locked index before a locked index + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, false), (4, false)]); + let removed = ring.remove_respecting_locks(0); + assert_eq!(removed.map(|x| x.val), Some(0)); + // Elements '2' remain at index 2 + assert_eq!(vals(&ring), vec![1, 3, 2, 4]); + } + + // Test case 2: Remove a locked index + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, false), (4, false)]); + let removed = ring.remove_respecting_locks(2); + assert_eq!(removed.map(|x| x.val), Some(2)); + // Elements should stay at the same places + assert_eq!(vals(&ring), vec![0, 1, 3, 4]); + } + + // Test case 3: Remove an index after a locked index + { + // Lock index 1 + let mut ring = test_deque(&[(0, false), (1, true), (2, false), (3, false), (4, false)]); + let removed = ring.remove_respecting_locks(3); + assert_eq!(removed.map(|x| x.val), Some(3)); + // Elements should stay at the same places + assert_eq!(vals(&ring), vec![0, 1, 2, 4]); + } + + // Test case 4: Multiple locked indices + { + // Lock index 1 and 3 + let mut ring = test_deque(&[(0, false), (1, true), (2, false), (3, true), (4, false)]); + let removed = ring.remove_respecting_locks(0); + assert_eq!(removed.map(|x| x.val), Some(0)); + // Elements '1' and '3' remain at indices '1' and '3' + assert_eq!(vals(&ring), vec![2, 1, 4, 3]); + } + + // Test case 5: Remove the last element + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, false), (4, false)]); + let removed = ring.remove_respecting_locks(4); + assert_eq!(removed.map(|x| x.val), Some(4)); + // Index 2 should still be at the same place + assert_eq!(vals(&ring), vec![0, 1, 2, 3]); + } + + // Test case 6: Invalid index + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true), (3, false), (4, false)]); + let removed = ring.remove_respecting_locks(10); + assert_eq!(removed, None); + // Deque unchanged + assert_eq!(vals(&ring), vec![0, 1, 2, 3, 4]); + } + + // Test case 7: Remove enough elements to make a locked index invalid + { + // Lock index 2 + let mut ring = test_deque(&[(0, false), (1, false), (2, true)]); + ring.remove_respecting_locks(0); + // Index 2 should now be '1' + assert_eq!(vals(&ring), vec![1, 2]); + } + + // Test case 8: Removing an element before multiple locked indices + { + // Lock index 2 and 4 + let mut ring = test_deque(&[ + (0, false), + (1, false), + (2, true), + (3, false), + (4, true), + (5, false), + ]); + let removed = ring.remove_respecting_locks(1); + assert_eq!(removed.map(|x| x.val), Some(1)); + // Both indices should still be at the same place + assert_eq!(vals(&ring), vec![0, 3, 2, 5, 4]); + } + } + + #[test] + fn test_swap_respecting_locks_various_cases() { + // Swap unlocked and locked + let mut ring = test_deque(&[(0, false), (1, true), (2, false), (3, false)]); + ring.swap_respecting_locks(0, 1); + assert_eq!(vals(&ring), vec![1, 0, 2, 3]); + assert!(!ring[0].locked); + assert!(ring[1].locked); + ring.swap_respecting_locks(0, 1); + assert_eq!(vals(&ring), vec![0, 1, 2, 3]); + assert!(!ring[0].locked); + assert!(ring[1].locked); + + // Both locked + let mut ring = test_deque(&[(0, true), (1, false), (2, true)]); + ring.swap_respecting_locks(0, 2); + assert_eq!(vals(&ring), vec![2, 1, 0]); + assert!(ring[0].locked); + assert!(!ring[1].locked); + assert!(ring[2].locked); + + // Both unlocked + let mut ring = test_deque(&[(0, false), (1, true), (2, false)]); + ring.swap_respecting_locks(0, 2); + assert_eq!(vals(&ring), vec![2, 1, 0]); + assert!(!ring[0].locked); + assert!(ring[1].locked); + assert!(!ring[2].locked); + } +} diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 5020e12d..cb5df965 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -1,24 +1,48 @@ use crate::LibraryError; +use crate::accessibility::attribute_constants::kAXPositionAttribute; +use crate::accessibility::attribute_constants::kAXSizeAttribute; use crate::application::Application; use crate::cf_array_as; use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; -use crate::ring::Ring; +use crate::monitor::Monitor; use crate::window::WindowInfo; use crate::window_manager::Container; -use crate::window_manager::Monitor; use crate::window_manager::WindowManager; +use objc2::MainThreadMarker; +use objc2_app_kit::NSScreen; +use objc2_application_services::AXUIElement; use objc2_core_foundation::CFDictionary; +use objc2_core_foundation::CFString; +use objc2_core_foundation::CGPoint; +use objc2_core_foundation::CGSize; use std::collections::HashMap; +use std::ptr::NonNull; pub struct MacosApi; impl MacosApi { pub fn load_monitor_information(wm: &mut WindowManager) -> Result<(), LibraryError> { + let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); + for display_id in CoreGraphicsApi::connected_display_ids()? { - let size = Rect::from(CoreGraphicsApi::display_bounds(display_id)); - let monitor = Monitor::new(display_id, size); - wm.monitors.elements_mut().push_back(monitor); + let display_bounds = CoreGraphicsApi::display_bounds(display_id); + + for screen in &screens { + let menu_bar_height = screen.frame().size.height + - screen.visibleFrame().size.height + - screen.visibleFrame().origin.y; + + if screen.frame() == display_bounds { + let size = Rect::from(display_bounds); + let mut work_area_size = Rect::from(display_bounds); + work_area_size.top += menu_bar_height as i32; + work_area_size.bottom = screen.visibleFrame().size.height as i32; + + let monitor = Monitor::new(display_id, size, work_area_size); + wm.monitors.elements_mut().push_back(monitor); + } + } } Ok(()) @@ -78,9 +102,7 @@ impl MacosApi { for (monitor_idx, windows) in monitor_window_map { for window in windows { - let mut container = Container { - windows: Ring::default(), - }; + let mut container = Container::default(); container.windows_mut().push_back(window); if let Some(Some(workspace)) = monitor_workspace_map.get_mut(monitor_idx) { @@ -91,4 +113,38 @@ impl MacosApi { Ok(()) } + + pub fn center_cursor_in_rect(rect: &Rect) -> Result<(), LibraryError> { + Ok(CoreGraphicsApi::warp_mouse_cursor_position( + rect.left + (rect.right / 2), + rect.top + (rect.bottom / 2), + )?) + } + + pub fn window_rect(element: &AXUIElement) -> Rect { + let mut position_receiver = std::ptr::null(); + let mut size_receiver = std::ptr::null(); + + unsafe { + element.copy_attribute_value( + &CFString::from_static_str(kAXPositionAttribute), + NonNull::from(&mut position_receiver), + ); + + element.copy_attribute_value( + &CFString::from_static_str(kAXSizeAttribute), + NonNull::from(&mut size_receiver), + ); + + let position = *position_receiver.cast::(); + let size = *position_receiver.cast::(); + + Rect { + left: position.x as i32, + top: position.y as i32, + right: size.width as i32, + bottom: size.height as i32, + } + } + } } diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 8c434763..da29eb61 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -2,6 +2,8 @@ use color_eyre::eyre; use color_eyre::eyre::eyre; +use komorebi::DATA_DIR; +use komorebi::process_command::listen_for_commands; use komorebi::window_manager::WindowManager; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; @@ -11,6 +13,7 @@ use objc2_core_graphics::CGDisplayBounds; use objc2_core_graphics::CGMainDisplayID; use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; +use parking_lot::Mutex; use std::sync::Arc; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; @@ -90,19 +93,19 @@ fn main() -> eyre::Result<()> { setup()?; check_permissions()?; + if !DATA_DIR.is_dir() { + std::fs::create_dir_all(&*DATA_DIR)?; + } + let display_size = unsafe { CGDisplayBounds(CGMainDisplayID()) }; tracing::info!("display size for main display is: {:?}", display_size); let run_loop = CFRunLoop::current().ok_or(eyre!("couldn't get CFRunLoop::current"))?; - let mut wm = WindowManager::new(&run_loop); - wm.init()?; + let wm = Arc::new(Mutex::new(WindowManager::new(&run_loop, None)?)); + wm.lock().init()?; + wm.lock().update_focused_workspace(true, true)?; - wm.monitors - .focused_mut() - .unwrap() - .focused_workspace_mut() - .unwrap() - .update()?; + listen_for_commands(wm.clone()); let quit_ctrlc = Arc::new(AtomicBool::new(false)); let quit_thread = quit_ctrlc.clone(); diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs new file mode 100644 index 00000000..17288f5d --- /dev/null +++ b/komorebi/src/monitor.rs @@ -0,0 +1,88 @@ +use crate::DEFAULT_CONTAINER_PADDING; +use crate::DEFAULT_WORKSPACE_PADDING; +use crate::core::rect::Rect; +use crate::ring::Ring; +use crate::workspace::Workspace; +use crate::workspace::WorkspaceGlobals; +use color_eyre::eyre; +use color_eyre::eyre::eyre; +use std::sync::atomic::Ordering; + +impl_ring_elements!(Monitor, Workspace); + +#[derive(Debug)] +pub struct Monitor { + pub id: u32, + pub workspaces: Ring, + pub size: Rect, + pub work_area_offset: Option, + pub work_area_size: Rect, + pub window_based_work_area_offset: Option, + pub window_based_work_area_offset_limit: isize, + pub container_padding: Option, + pub workspace_padding: Option, +} + +impl Monitor { + #[allow(clippy::field_reassign_with_default)] + pub fn new(id: u32, size: Rect, work_area_size: Rect) -> Self { + let mut workspaces = Ring::default(); + workspaces.elements_mut().push_back(Workspace::default()); + + Self { + id, + workspaces, + size, + work_area_offset: None, + work_area_size, + window_based_work_area_offset: None, + window_based_work_area_offset_limit: 0, + container_padding: None, + workspace_padding: None, + } + } + + pub fn update_focused_workspace(&mut self, offset: Option) -> eyre::Result<()> { + let offset = if self.work_area_offset.is_some() { + self.work_area_offset + } else { + offset + }; + + let focused_workspace_idx = self.focused_workspace_idx(); + self.update_workspace_globals(focused_workspace_idx, offset); + self.focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace"))? + .update()?; + + Ok(()) + } + + /// Updates the `globals` field of workspace with index `workspace_idx` + pub fn update_workspace_globals(&mut self, workspace_idx: usize, offset: Option) { + let container_padding = self + .container_padding + .or(Some(DEFAULT_CONTAINER_PADDING.load(Ordering::Relaxed))); + let workspace_padding = self + .workspace_padding + .or(Some(DEFAULT_WORKSPACE_PADDING.load(Ordering::Relaxed))); + let (border_width, border_offset) = (0, 0); + let work_area = self.work_area_size; + let work_area_offset = self.work_area_offset.or(offset); + let window_based_work_area_offset = self.window_based_work_area_offset; + let window_based_work_area_offset_limit = self.window_based_work_area_offset_limit; + + if let Some(workspace) = self.workspaces_mut().get_mut(workspace_idx) { + workspace.globals = WorkspaceGlobals { + container_padding, + workspace_padding, + border_width, + border_offset, + work_area, + work_area_offset, + window_based_work_area_offset, + window_based_work_area_offset_limit, + } + } + } +} diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs new file mode 100644 index 00000000..e5b64d43 --- /dev/null +++ b/komorebi/src/process_command.rs @@ -0,0 +1,122 @@ +use crate::core::SocketMessage; +use crate::window_manager::WindowManager; +use color_eyre::eyre; +use parking_lot::Mutex; +use std::io::BufRead; +use std::io::BufReader; +use std::os::unix::net::UnixStream; +use std::str::FromStr; +use std::sync::Arc; +use std::time::Duration; + +#[tracing::instrument] +pub fn listen_for_commands(wm: Arc>) { + std::thread::spawn(move || { + loop { + let wm = wm.clone(); + + let _ = std::thread::spawn(move || { + let listener = wm + .lock() + .command_listener + .try_clone() + .expect("could not clone unix listener"); + + tracing::info!("listening on komorebi.sock"); + for client in listener.incoming() { + match client { + Ok(stream) => { + let wm_clone = wm.clone(); + std::thread::spawn(move || { + match read_commands_uds(&wm_clone, stream) { + Ok(()) => {} + Err(error) => { + tracing::error!("failed to read command from uds {}", error) + } + } + }); + } + Err(error) => { + tracing::error!("failed to get unix stream {}", error); + break; + } + } + } + }) + .join(); + + tracing::error!("restarting failed thread"); + } + }); +} + +impl WindowManager { + #[tracing::instrument(skip(self, _reply))] + pub fn process_command( + &mut self, + message: SocketMessage, + mut _reply: impl std::io::Write, + ) -> eyre::Result<()> { + match message { + SocketMessage::FocusWindow(direction) => { + self.focus_container_in_direction(direction)?; + } + SocketMessage::MoveWindow(direction) => { + self.move_container_in_direction(direction)?; + } + SocketMessage::ChangeLayout(layout) => self.change_workspace_layout_default(layout)?, + SocketMessage::TogglePause => { + if self.is_paused { + tracing::info!("resuming"); + } else { + tracing::info!("pausing"); + } + + self.is_paused = !self.is_paused; + } + } + + Ok(()) + } +} + +pub fn read_commands_uds( + wm: &Arc>, + mut stream: UnixStream, +) -> eyre::Result<()> { + let reader = BufReader::new(stream.try_clone()?); + // TODO(raggi): while this processes more than one command, if there are + // replies there is no clearly defined protocol for framing yet - it's + // perhaps whole-json objects for now, but termination is signalled by + // socket shutdown. + for line in reader.lines() { + let message = SocketMessage::from_str(&line?)?; + + match wm.try_lock_for(Duration::from_secs(1)) { + None => { + tracing::warn!( + "could not acquire window manager lock, not processing message: {message}" + ); + } + Some(mut wm) => { + if wm.is_paused { + return match message { + SocketMessage::TogglePause + // | SocketMessage::State + // | SocketMessage::GlobalState + // | SocketMessage::Stop + => Ok(wm.process_command(message, &mut stream)?), + _ => { + tracing::trace!("ignoring while paused"); + Ok(()) + } + }; + } + + wm.process_command(message.clone(), &mut stream)?; + } + } + } + + Ok(()) +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index d28fbb43..38dc9c07 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -1,3 +1,6 @@ +use crate::AccessibilityObserver; +use crate::AccessibilityUiElement; +use crate::LibraryError; use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXMainAttribute; use crate::accessibility::attribute_constants::kAXPositionAttribute; @@ -122,9 +125,9 @@ impl WindowInfo { #[derive(Debug)] #[allow(unused)] pub struct Window { - element: CFRetained, + element: AccessibilityUiElement, application: Application, - observer: CFRetained, + observer: AccessibilityObserver, } impl Drop for Window { @@ -150,14 +153,14 @@ impl Window { )?; Ok(Self { - element, + element: AccessibilityUiElement(element), application, - observer, + observer: AccessibilityObserver(observer), }) } #[tracing::instrument(skip_all)] - pub fn observe(&self, run_loop: &CFRetained) -> Result<(), AccessibilityError> { + pub fn observe(&self, run_loop: &CFRunLoop) -> Result<(), AccessibilityError> { tracing::info!( "registering observer for process: {}, title: {}", self.application.process_id, @@ -183,7 +186,7 @@ impl Window { self.set_size(CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat)) } - pub fn focus(&self) -> Result<(), AccessibilityError> { + pub fn focus(&self, focus_follows_mouse: bool) -> Result<(), LibraryError> { unsafe { NSRunningApplication::runningApplicationWithProcessIdentifier( self.application.process_id, @@ -195,8 +198,14 @@ impl Window { let cf_boolean = CFBoolean::new(true); let value = &**cf_boolean; - AccessibilityApi::set_attribute_cf_value(&self.element, kAXMainAttribute, value) + AccessibilityApi::set_attribute_cf_value(&self.element, kAXMainAttribute, value)?; } + + if focus_follows_mouse { + // MacosApi::center_cursor_in_rect(&MacosApi::window_rect(&self.element))? + } + + Ok(()) } pub fn set_point(&self, point: CGPoint) -> Result<(), AccessibilityError> { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 558594a5..4fc5b3aa 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1,28 +1,67 @@ +use crate::CoreFoundationRunLoop; +use crate::DATA_DIR; use crate::LibraryError; use crate::application::Application; +use crate::core::default_layout::DefaultLayout; +use crate::core::layout::Layout; +use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use crate::lockable_sequence::Lockable; use crate::macos_api::MacosApi; +use crate::monitor::Monitor; use crate::ring::Ring; use crate::window::Window; use crate::workspace::Workspace; +use color_eyre::eyre; +use color_eyre::eyre::eyre; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use std::collections::HashMap; +use std::io::ErrorKind; +use std::os::unix::net::UnixListener; +use std::path::PathBuf; #[derive(Debug)] pub struct WindowManager { pub monitors: Ring, pub applications: HashMap, - pub run_loop: CFRetained, + pub run_loop: CoreFoundationRunLoop, + pub command_listener: UnixListener, + pub is_paused: bool, + pub mouse_follows_focus: bool, + pub work_area_offset: Option, } +impl_ring_elements!(WindowManager, Monitor); + impl WindowManager { - pub fn new(run_loop: &CFRetained) -> Self { - Self { + pub fn new( + run_loop: &CFRetained, + custom_socket_path: Option, + ) -> eyre::Result { + let socket = custom_socket_path.unwrap_or_else(|| DATA_DIR.join("komorebi.sock")); + + match std::fs::remove_file(&socket) { + Ok(()) => {} + Err(error) => match error.kind() { + ErrorKind::NotFound => {} + _ => { + return Err(error.into()); + } + }, + }; + + let listener = UnixListener::bind(&socket)?; + + Ok(Self { monitors: Ring::default(), applications: Default::default(), - run_loop: run_loop.clone(), - } + run_loop: CoreFoundationRunLoop(run_loop.clone()), + command_listener: listener, + is_paused: false, + mouse_follows_focus: true, + work_area_offset: None, + }) } #[tracing::instrument(skip(self))] @@ -33,41 +72,191 @@ impl WindowManager { } } -impl_ring_elements!(Monitor, Workspace); -#[derive(Debug)] -pub struct Monitor { - pub id: u32, - pub workspaces: Ring, - pub size: Rect, -} +impl WindowManager { + #[tracing::instrument(skip(self))] + pub fn focus_container_in_direction( + &mut self, + direction: OperationDirection, + ) -> eyre::Result<()> { + let workspace = self.focused_workspace()?; -impl Monitor { - #[allow(clippy::field_reassign_with_default)] - pub fn new(id: u32, size: Rect) -> Self { - let mut workspaces = Ring::default(); - let mut workspace = Workspace::default(); - workspace.work_area = size; - workspace.container_padding = Some(20); - workspace.workspace_padding = Some(20); - workspace.work_area_offset = Some(Rect { - left: 0, - top: 0, - right: 0, - bottom: 40, - }); + tracing::info!("focusing container"); - workspaces.elements_mut().push_back(workspace); - - Self { - id, - workspaces, - size, + match workspace.new_idx_for_direction(direction) { + None => {} + Some(idx) => { + let workspace = self.focused_workspace_mut()?; + workspace.focus_container(idx); + } } + + if let Ok(focused_window) = self.focused_window() { + focused_window.focus(self.mouse_follows_focus)?; + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn move_container_in_direction( + &mut self, + direction: OperationDirection, + ) -> eyre::Result<()> { + let workspace = self.focused_workspace()?; + + tracing::info!("moving container"); + + let origin_container_idx = workspace.focused_container_idx(); + let target_container_idx = workspace.new_idx_for_direction(direction); + + match target_container_idx { + None => {} + Some(new_idx) => { + let workspace = self.focused_workspace_mut()?; + workspace.swap_containers(origin_container_idx, new_idx); + workspace.focus_container(new_idx); + } + } + + self.update_focused_workspace(self.mouse_follows_focus, true)?; + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn update_focused_workspace( + &mut self, + follow_focus: bool, + trigger_focus: bool, + ) -> eyre::Result<()> { + tracing::info!("updating"); + + let offset = self.work_area_offset; + let mouse_follows_focus = self.mouse_follows_focus; + + self.focused_monitor_mut() + .ok_or_else(|| eyre!("there is no monitor"))? + .update_focused_workspace(offset)?; + + if follow_focus + && let Ok(window) = self.focused_window_mut() + && trigger_focus + { + window.focus(mouse_follows_focus)?; + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn change_workspace_layout_default(&mut self, layout: DefaultLayout) -> eyre::Result<()> { + tracing::info!("changing layout"); + + let monitor_count = self.monitors().len(); + let workspace = self.focused_workspace_mut()?; + + if monitor_count > 1 && matches!(layout, DefaultLayout::Scrolling) { + tracing::warn!( + "scrolling layout is only supported for a single monitor; not changing layout" + ); + return Ok(()); + } + + workspace.layout = Layout::Default(layout); + self.update_focused_workspace(self.mouse_follows_focus, false) + } + + pub fn focused_workspace_idx(&self) -> eyre::Result { + Ok(self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))? + .focused_workspace_idx()) + } + + pub fn focused_workspace(&self) -> eyre::Result<&Workspace> { + self.focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))? + .focused_workspace() + .ok_or_else(|| eyre!("there is no workspace")) + } + + pub fn focused_workspace_mut(&mut self) -> eyre::Result<&mut Workspace> { + self.focused_monitor_mut() + .ok_or_else(|| eyre!("there is no monitor"))? + .focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace")) + } + + pub fn focused_workspace_idx_for_monitor_idx(&self, idx: usize) -> eyre::Result { + Ok(self + .monitors() + .get(idx) + .ok_or_else(|| eyre!("there is no monitor at this index"))? + .focused_workspace_idx()) + } + + pub fn focused_workspace_for_monitor_idx(&self, idx: usize) -> eyre::Result<&Workspace> { + self.monitors() + .get(idx) + .ok_or_else(|| eyre!("there is no monitor at this index"))? + .focused_workspace() + .ok_or_else(|| eyre!("there is no workspace")) + } + + pub fn focused_workspace_for_monitor_idx_mut( + &mut self, + idx: usize, + ) -> eyre::Result<&mut Workspace> { + self.monitors_mut() + .get_mut(idx) + .ok_or_else(|| eyre!("there is no monitor at this index"))? + .focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace")) + } + + pub fn focused_container(&self) -> eyre::Result<&Container> { + self.focused_workspace()? + .focused_container() + .ok_or_else(|| eyre!("there is no container")) + } + + pub fn focused_container_idx(&self) -> eyre::Result { + Ok(self.focused_workspace()?.focused_container_idx()) + } + + pub fn focused_container_mut(&mut self) -> eyre::Result<&mut Container> { + self.focused_workspace_mut()? + .focused_container_mut() + .ok_or_else(|| eyre!("there is no container")) + } + + pub fn focused_window(&self) -> eyre::Result<&Window> { + self.focused_container()? + .focused_window() + .ok_or_else(|| eyre!("there is no window")) + } + + fn focused_window_mut(&mut self) -> eyre::Result<&mut Window> { + self.focused_container_mut()? + .focused_window_mut() + .ok_or_else(|| eyre!("there is no window")) } } impl_ring_elements!(Container, Window); -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Container { pub windows: Ring, + pub locked: bool, +} + +impl Lockable for Container { + fn locked(&self) -> bool { + self.locked + } + + fn set_locked(&mut self, locked: bool) -> &mut Self { + self.locked = locked; + self + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 51d6a663..012f8e7f 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -2,7 +2,9 @@ use crate::core::arrangement::Axis; use crate::core::default_layout::DefaultLayout; use crate::core::default_layout::LayoutOptions; use crate::core::layout::Layout; +use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use crate::lockable_sequence::LockableSequence; use crate::ring::Ring; use crate::window_manager::Container; use color_eyre::eyre; @@ -18,7 +20,6 @@ pub struct Workspace { pub container_padding: Option, pub resize_dimensions: Vec>, pub layout: Layout, - pub work_area: Rect, pub work_area_offset: Option, pub latest_layout: Vec, pub layout_flip: Option, @@ -35,7 +36,6 @@ impl Default for Workspace { container_padding: None, resize_dimensions: vec![], layout: Layout::Default(DefaultLayout::UltrawideVerticalStack), - work_area: Default::default(), work_area_offset: None, latest_layout: vec![], layout_flip: None, @@ -81,7 +81,7 @@ impl Workspace { // self.globals.window_based_work_area_offset_limit; let mut adjusted_work_area = work_area_offset.map_or_else( - || self.work_area, + || work_area, |offset| { let mut with_offset = work_area; with_offset.left += offset.left; @@ -130,4 +130,27 @@ impl Workspace { Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn focus_container(&mut self, idx: usize) { + tracing::info!("focusing container"); + + self.containers.focus(idx); + } + + pub fn swap_containers(&mut self, i: usize, j: usize) { + self.containers.elements_mut().swap_respecting_locks(i, j); + self.focus_container(j); + } + + pub fn new_idx_for_direction(&self, direction: OperationDirection) -> Option { + let len = NonZeroUsize::new(self.containers().len())?; + + direction.destination( + self.layout.as_boxed_direction().as_ref(), + self.layout_flip, + self.focused_container_idx(), + len, + ) + } } diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml new file mode 100644 index 00000000..73bb2a8c --- /dev/null +++ b/komorebic/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "komorebic" +version = "0.1.0" +edition = "2024" + +[dependencies] +komorebi-client = { path = "../komorebi-client", default-features = false } + +clap = { workspace = true } +color-eyre = { workspace = true } +dirs = { workspace = true } +lazy_static = { workspace = true } +pastey = { workspace = true } \ No newline at end of file diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs new file mode 100644 index 00000000..0c8c939b --- /dev/null +++ b/komorebic/src/main.rs @@ -0,0 +1,100 @@ +#![warn(clippy::all)] + +use clap::Parser; +use color_eyre::eyre; +use komorebi_client::DefaultLayout; +use komorebi_client::OperationDirection; +use komorebi_client::PathExt; +use komorebi_client::SocketMessage; +use komorebi_client::send_message; +use lazy_static::lazy_static; +use std::path::PathBuf; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; + +lazy_static! { + static ref HAS_CUSTOM_CONFIG_HOME: AtomicBool = AtomicBool::new(false); + static ref HOME_DIR: PathBuf = { + std::env::var("KOMOREBI_CONFIG_HOME").map_or_else( + |_| dirs::home_dir().expect("there is no home directory"), + |home_path| { + let home = home_path.replace_env(); + if home.as_path().is_dir() { + HAS_CUSTOM_CONFIG_HOME.store(true, Ordering::SeqCst); + home + } else { + panic!( + "$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory", + ); + } + }, + ) + }; + static ref DATA_DIR: PathBuf = dirs::data_local_dir() + .expect("there is no local data directory") + .join("komorebi"); +} + +macro_rules! gen_enum_subcommand_args { + // SubCommand Pattern: Enum Type + ( $( $name:ident: $element:ty ),+ $(,)? ) => { + $( + pastey::paste! { + #[derive(clap::Parser)] + pub struct $name { + #[clap(value_enum)] + [<$element:snake>]: $element + } + } + )+ + }; +} + +gen_enum_subcommand_args! { + Focus: OperationDirection, + Move: OperationDirection, + ChangeLayout: DefaultLayout, +} + +#[derive(Parser)] +#[clap(author, about, version)] +struct Opts { + #[clap(subcommand)] + subcmd: SubCommand, +} + +#[derive(Parser)] +enum SubCommand { + /// Change focus to the window in the specified direction + #[clap(arg_required_else_help = true)] + Focus(Focus), + /// Move the focused window in the specified direction + #[clap(arg_required_else_help = true)] + Move(Move), + /// Toggle the paused state for all window tiling + TogglePause, + /// Set the layout on the focused workspace + #[clap(arg_required_else_help = true)] + ChangeLayout(ChangeLayout), +} + +fn main() -> eyre::Result<()> { + let opts: Opts = Opts::parse(); + + match opts.subcmd { + SubCommand::Focus(arg) => { + send_message(&SocketMessage::FocusWindow(arg.operation_direction))?; + } + SubCommand::Move(arg) => { + send_message(&SocketMessage::MoveWindow(arg.operation_direction))?; + } + SubCommand::TogglePause => { + send_message(&SocketMessage::TogglePause)?; + } + SubCommand::ChangeLayout(arg) => { + send_message(&SocketMessage::ChangeLayout(arg.default_layout))?; + } + } + + Ok(()) +} diff --git a/shell.nix b/shell.nix index 1bb344ac..1389867d 100644 --- a/shell.nix +++ b/shell.nix @@ -10,5 +10,6 @@ with pkgs; cargo-deny jq prettier + cargo-udeps ]; - } \ No newline at end of file + } From 4f6267b56edcd9dc0ba01084a929e00b4c50f12b Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 17 Sep 2025 20:56:11 -0700 Subject: [PATCH 006/305] feat(wm): add basic window manager event handling This commit adds a WindowManagerEvent enum and a channel to send and receive variants of it on. The skeleton of process_event has been migrated from komorebi and a few basic implementations of handlers for core events like FocusChange, Show, Destroy, Minimize and Restore have been added. Due to the way the window observers work, in komorebi for Mac we'll need to keep track of minimized Windows so that we don't drop their observers (otherwise we won't receive a notification when they are restored). Most of the code added in this commit around modifying state in response to these events has been migrated from komorebi. --- Cargo.lock | 16 ++ justfile | 2 +- komorebi/Cargo.toml | 1 + komorebi/src/accessibility/mod.rs | 25 +++ .../accessibility/notification_constants.rs | 50 ++++++ komorebi/src/accessibility/private.rs | 10 ++ komorebi/src/application.rs | 66 ++++++-- komorebi/src/ax_event_listener.rs | 19 +++ komorebi/src/container.rs | 83 +++++++++ komorebi/src/lib.rs | 4 + komorebi/src/macos_api.rs | 2 +- komorebi/src/main.rs | 9 +- komorebi/src/process_event.rs | 132 +++++++++++++++ komorebi/src/window.rs | 47 ++++-- komorebi/src/window_manager.rs | 46 +++-- komorebi/src/window_manager_event.rs | 47 ++++++ komorebi/src/workspace.rs | 158 +++++++++++++++++- 17 files changed, 668 insertions(+), 49 deletions(-) create mode 100644 komorebi/src/accessibility/private.rs create mode 100644 komorebi/src/ax_event_listener.rs create mode 100644 komorebi/src/container.rs create mode 100644 komorebi/src/process_event.rs create mode 100644 komorebi/src/window_manager_event.rs diff --git a/Cargo.lock b/Cargo.lock index cd2874b8..a29ca2e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,6 +247,21 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + [[package]] name = "ctrlc" version = "3.5.0" @@ -512,6 +527,7 @@ version = "0.1.0" dependencies = [ "clap", "color-eyre", + "crossbeam-channel", "ctrlc", "dirs", "lazy_static", diff --git a/justfile b/justfile index 6a068793..7af0ca48 100644 --- a/justfile +++ b/justfile @@ -9,7 +9,7 @@ fmt: prettier --write README.md install target: - cargo +stable install --path {{ target }} --locked + cargo +stable install --path {{ target }} --locked --target-dir ~/.cargo/bin build target: cargo +stable build --package {{ target }} --locked --release diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 41542be9..c6c3a98d 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -6,6 +6,7 @@ edition = "2024" [dependencies] clap = { workspace = true } color-eyre = { workspace = true } +crossbeam-channel = "0.5" ctrlc = { version = "3", features = ["termination"] } dirs = { workspace = true } lazy_static = { workspace = true } diff --git a/komorebi/src/accessibility/mod.rs b/komorebi/src/accessibility/mod.rs index 998c2648..fac385d6 100644 --- a/komorebi/src/accessibility/mod.rs +++ b/komorebi/src/accessibility/mod.rs @@ -1,3 +1,4 @@ +use crate::accessibility::private::_AXUIElementGetWindow; use error::AccessibilityApiError; use error::AccessibilityCustomError; use error::AccessibilityError; @@ -6,21 +7,34 @@ use objc2_application_services::AXObserverCallback; use objc2_application_services::AXUIElement; use objc2_application_services::AXValue; use objc2_application_services::AXValueType; +use objc2_core_foundation::CFArray; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::CFRunLoopSource; use objc2_core_foundation::CFString; use objc2_core_foundation::CFType; use objc2_core_foundation::kCFRunLoopDefaultMode; +use objc2_core_graphics::CGWindowID; use std::ptr::NonNull; pub mod attribute_constants; pub mod error; pub mod notification_constants; +pub mod private; pub struct AccessibilityApi; impl AccessibilityApi { + pub fn window_id(element: &AXUIElement) -> Result { + let mut window_id = CGWindowID::default(); + unsafe { + match AccessibilityError::from(_AXUIElementGetWindow(element, &mut window_id)) { + AccessibilityError::Api(AccessibilityApiError::Success) => Ok(window_id), + error => Err(error), + } + } + } + pub fn copy_attribute_value( element: &AXUIElement, attribute: &'static str, @@ -38,6 +52,17 @@ impl AccessibilityApi { } } + pub fn copy_attribute_names(element: &AXUIElement) -> Option> { + let mut receiver = std::ptr::null(); + + unsafe { + element.copy_attribute_names(NonNull::from(&mut receiver)); + + NonNull::new(receiver.cast::().cast_mut()) + .map(|cf_type| CFRetained::from_raw(cf_type)) + } + } + pub fn set_attribute_ax_value( element: &AXUIElement, attribute: &'static str, diff --git a/komorebi/src/accessibility/notification_constants.rs b/komorebi/src/accessibility/notification_constants.rs index 6837505d..8bd11d37 100644 --- a/komorebi/src/accessibility/notification_constants.rs +++ b/komorebi/src/accessibility/notification_constants.rs @@ -1,5 +1,10 @@ #![allow(non_upper_case_globals, unused)] +use serde::Deserialize; +use serde::Serialize; +use strum::Display; +use strum::EnumString; + pub const kAXMainWindowChangedNotification: &str = "AXMainWindowChanged"; pub const kAXFocusedWindowChangedNotification: &str = "AXFocusedWindowChanged"; pub const kAXFocusedUIElementChangedNotification: &str = "AXFocusedUIElementChanged"; @@ -41,3 +46,48 @@ pub const kAXUIElementsKey: &str = "AXUIElementsKey"; pub const kAXPriorityKey: &str = "AXPriorityKey"; pub const kAXAnnouncementKey: &str = "AXAnnouncementKey"; pub const kAXUIElementTitleKey: &str = "AXUIElementTitleKey"; + +#[derive(Debug, Copy, Clone, PartialEq, Eq, EnumString, Display, Serialize, Deserialize)] +pub enum AccessibilityNotification { + AXMainWindowChanged, + AXFocusedWindowChanged, + AXFocusedUIElementChanged, + AXApplicationActivated, + AXApplicationDeactivated, + AXApplicationHidden, + AXApplicationShown, + AXWindowCreated, + AXWindowMoved, + AXWindowResized, + AXWindowMiniaturized, + AXWindowDeminiaturized, + AXDrawerCreated, + AXSheetCreated, + AXHelpTagCreated, + AXValueChanged, + AXUIElementDestroyed, + AXElementBusyChanged, + AXMenuOpened, + AXMenuClosed, + AXMenuItemSelected, + AXRowCountChanged, + AXRowExpanded, + AXRowCollapsed, + AXSelectedCellsChanged, + AXUnitsChanged, + AXSelectedChildrenMoved, + AXSelectedChildrenChanged, + AXResized, + AXMoved, + AXCreated, + AXSelectedRowsChanged, + AXSelectedColumnsChanged, + AXSelectedTextChanged, + AXTitleChanged, + AXLayoutChanged, + AXAnnouncementRequested, + AXUIElementsKey, + AXPriorityKey, + AXAnnouncementKey, + AXUIElementTitleKey, +} diff --git a/komorebi/src/accessibility/private.rs b/komorebi/src/accessibility/private.rs new file mode 100644 index 00000000..5e1eab7c --- /dev/null +++ b/komorebi/src/accessibility/private.rs @@ -0,0 +1,10 @@ +use objc2_application_services::AXError; +use objc2_application_services::AXUIElement; +use objc2_core_graphics::CGWindowID; + +// this is the only private API call Aerospace uses, so I think we're ok to use it too +// https://github.com/nikitabobko/AeroSpace?tab=readme-ov-file#project-values +unsafe extern "C" { + /// Extract `window_id` from an AXUIElement. + pub(crate) fn _AXUIElementGetWindow(elem: &AXUIElement, window_id: *mut CGWindowID) -> AXError; +} diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index f76f9684..377562cb 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -1,9 +1,11 @@ use crate::AccessibilityObserver; use crate::AccessibilityUiElement; use crate::accessibility::AccessibilityApi; +use crate::accessibility::attribute_constants::kAXMainWindowAttribute; use crate::accessibility::attribute_constants::kAXTitleAttribute; use crate::accessibility::attribute_constants::kAXWindowsAttribute; use crate::accessibility::error::AccessibilityError; +use crate::accessibility::notification_constants::AccessibilityNotification; use crate::accessibility::notification_constants::kAXApplicationActivatedNotification; use crate::accessibility::notification_constants::kAXApplicationDeactivatedNotification; use crate::accessibility::notification_constants::kAXApplicationHiddenNotification; @@ -11,7 +13,9 @@ use crate::accessibility::notification_constants::kAXApplicationShownNotificatio use crate::accessibility::notification_constants::kAXMainWindowChangedNotification; use crate::accessibility::notification_constants::kAXUIElementDestroyedNotification; use crate::accessibility::notification_constants::kAXWindowCreatedNotification; +use crate::ax_event_listener::event_tx; use crate::window::Window; +use crate::window_manager_event::WindowManagerEvent; use objc2_application_services::AXObserver; use objc2_application_services::AXUIElement; use objc2_core_foundation::CFArray; @@ -20,6 +24,7 @@ use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::CFString; use std::ffi::c_void; use std::ptr::NonNull; +use std::str::FromStr; use tracing::instrument; const NOTIFICATIONS: &[&str] = &[ @@ -55,31 +60,42 @@ unsafe extern "C-unwind" fn application_observer_callback( AccessibilityApi::copy_attribute_value::(element.as_ref(), kAXTitleAttribute) .map(|s| s.to_string()); - let mut pid = 0; - - element.as_ref().pid(NonNull::from_mut(&mut pid)); - if let Some(name) = name && !name.is_empty() { - tracing::info!( - "notification: {}, process: {pid}, name: \"{name}\"", - notification.as_ref() - ); - } else { - tracing::info!("notification: {}, process: {pid}", notification.as_ref()); + let mut process_id = 0; + element.as_ref().pid(NonNull::from_mut(&mut process_id)); + + if let Ok(notification) = + AccessibilityNotification::from_str(¬ification.as_ref().to_string()) + && let Some(event) = + WindowManagerEvent::from_ax_notification(notification, process_id, None) + { + if let Err(error) = event_tx().send(event) { + tracing::error!("failed to send window manager event: {error}"); + } else { + tracing::debug!( + "notification: {notification}, process: {process_id}, name: \"{name}\"", + ); + } + } } } } impl Drop for Application { fn drop(&mut self) { - tracing::info!( - "invalidating application observer for process id {}", - self.process_id - ); - // make sure the observer gets removed from any run loops - AccessibilityApi::invalidate_observer(&self.observer); + // this gets called when an Application clone on a Window is dropped, so we need + // to make sure it only invalidates the observer if the Application is no longer + // running + if !self.is_valid() { + tracing::info!( + "invalidating application observer for process id {}", + self.process_id + ); + // make sure the observer gets removed from any run loops + AccessibilityApi::invalidate_observer(&self.observer); + } } } @@ -117,13 +133,29 @@ impl Application { ) } - fn window_elements(&self) -> Option>> { + pub fn is_valid(&self) -> bool { + AccessibilityApi::copy_attribute_names(&self.element).is_some() + } + + pub fn window_elements(&self) -> Option>> { AccessibilityApi::copy_attribute_value::>( &self.element, kAXWindowsAttribute, ) } + pub fn main_window(&self) -> Option> { + AccessibilityApi::copy_attribute_value::(&self.element, kAXMainWindowAttribute) + } + + pub fn main_window_id(&self) -> Option { + let window = AccessibilityApi::copy_attribute_value::( + &self.element, + kAXMainWindowAttribute, + )?; + AccessibilityApi::window_id(window.as_ref()).ok() + } + pub fn window_by_title(&self, title: &str) -> Option { let mut target = None; diff --git a/komorebi/src/ax_event_listener.rs b/komorebi/src/ax_event_listener.rs new file mode 100644 index 00000000..2afdd702 --- /dev/null +++ b/komorebi/src/ax_event_listener.rs @@ -0,0 +1,19 @@ +use crate::window_manager_event::WindowManagerEvent; +use crossbeam_channel::Receiver; +use crossbeam_channel::Sender; +use std::sync::OnceLock; + +static CHANNEL: OnceLock<(Sender, Receiver)> = + OnceLock::new(); + +fn channel() -> &'static (Sender, Receiver) { + CHANNEL.get_or_init(|| crossbeam_channel::bounded(20)) +} + +pub fn event_tx() -> Sender { + channel().0.clone() +} + +pub fn event_rx() -> Receiver { + channel().1.clone() +} diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs new file mode 100644 index 00000000..a0b57c6e --- /dev/null +++ b/komorebi/src/container.rs @@ -0,0 +1,83 @@ +use crate::lockable_sequence::Lockable; +use crate::ring::Ring; +use crate::window::Window; + +impl_ring_elements!(Container, Window); + +#[derive(Debug, Default)] +pub struct Container { + pub windows: Ring, + pub locked: bool, +} + +impl Lockable for Container { + fn locked(&self) -> bool { + self.locked + } + + fn set_locked(&mut self, locked: bool) -> &mut Self { + self.locked = locked; + self + } +} + +impl Container { + pub fn contains_window(&self, window_id: u32) -> bool { + for window in self.windows() { + if window.id == window_id { + return true; + } + } + + false + } + + pub fn idx_for_window(&self, window_id: u32) -> Option { + for (i, window) in self.windows().iter().enumerate() { + if window.id == window_id { + return Option::from(i); + } + } + + None + } + + pub fn add_window(&mut self, window: Window) { + self.windows_mut().push_back(window); + self.focus_window(self.windows().len().saturating_sub(1)); + // let focused_window_idx = self.focused_window_idx(); + + // for (i, window) in self.windows().iter().enumerate() { + // if i != focused_window_idx { + // window.hide(); + // } + // } + } + + #[tracing::instrument(skip(self))] + pub fn focus_window(&mut self, idx: usize) { + tracing::info!("focusing window"); + self.windows.focus(idx); + } + + /// Hides the unfocused windows of the container and restores the focused one. This function + /// is used to make sure we update the window that should be shown on a stack. If the container + /// isn't a stack this function won't change anything. + pub fn load_focused_window(&mut self) { + // let focused_idx = self.focused_window_idx(); + + // for (i, window) in self.windows_mut().iter_mut().enumerate() { + // if i == focused_idx { + // window.restore_with_border(false); + // } else { + // window.hide_with_border(false); + // } + // } + } + + pub fn remove_window_by_idx(&mut self, idx: usize) -> Option { + let window = self.windows_mut().remove(idx); + self.focus_window(idx.saturating_sub(1)); + window + } +} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index ac464246..72a7db55 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -21,14 +21,18 @@ pub mod ring; pub mod accessibility; pub mod application; +pub mod ax_event_listener; +mod container; pub mod core; pub mod core_graphics; pub mod lockable_sequence; pub mod macos_api; mod monitor; pub mod process_command; +pub mod process_event; pub mod window; pub mod window_manager; +pub mod window_manager_event; pub mod workspace; lazy_static! { diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index cb5df965..697f449a 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -3,11 +3,11 @@ use crate::accessibility::attribute_constants::kAXPositionAttribute; use crate::accessibility::attribute_constants::kAXSizeAttribute; use crate::application::Application; use crate::cf_array_as; +use crate::container::Container; use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; use crate::monitor::Monitor; use crate::window::WindowInfo; -use crate::window_manager::Container; use crate::window_manager::WindowManager; use objc2::MainThreadMarker; use objc2_app_kit::NSScreen; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index da29eb61..d98df720 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -3,7 +3,9 @@ use color_eyre::eyre; use color_eyre::eyre::eyre; use komorebi::DATA_DIR; +use komorebi::ax_event_listener; use komorebi::process_command::listen_for_commands; +use komorebi::process_event::listen_for_events; use komorebi::window_manager::WindowManager; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; @@ -101,11 +103,16 @@ fn main() -> eyre::Result<()> { tracing::info!("display size for main display is: {:?}", display_size); let run_loop = CFRunLoop::current().ok_or(eyre!("couldn't get CFRunLoop::current"))?; - let wm = Arc::new(Mutex::new(WindowManager::new(&run_loop, None)?)); + let wm = Arc::new(Mutex::new(WindowManager::new( + &run_loop, + ax_event_listener::event_rx(), + None, + )?)); wm.lock().init()?; wm.lock().update_focused_workspace(true, true)?; listen_for_commands(wm.clone()); + listen_for_events(wm.clone()); let quit_ctrlc = Arc::new(AtomicBool::new(false)); let quit_thread = quit_ctrlc.clone(); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs new file mode 100644 index 00000000..7560895f --- /dev/null +++ b/komorebi/src/process_event.rs @@ -0,0 +1,132 @@ +use crate::accessibility::AccessibilityApi; +use crate::accessibility::notification_constants::AccessibilityNotification; +use crate::application::Application; +use crate::window::Window; +use crate::window_manager::WindowManager; +use crate::window_manager_event::WindowManagerEvent; +use color_eyre::eyre; +use parking_lot::Mutex; +use std::sync::Arc; + +#[tracing::instrument] +pub fn listen_for_events(wm: Arc>) { + let receiver = wm.lock().incoming_events.clone(); + + std::thread::spawn(move || { + tracing::info!("listening"); + loop { + if let Ok(event) = receiver.recv() { + let mut guard = wm.lock(); + match guard.process_event(event) { + Ok(()) => {} + Err(error) => { + if cfg!(debug_assertions) { + tracing::error!("{:?}", error) + } else { + tracing::error!("{}", error) + } + } + } + } + } + }); +} + +impl WindowManager { + pub fn process_event(&mut self, event: WindowManagerEvent) -> eyre::Result<()> { + if self.is_paused { + tracing::trace!("ignoring while paused"); + return Ok(()); + } + + tracing::info!("processing event: {event}"); + + match event { + WindowManagerEvent::FocusChange(notification, process_id, _) => { + if let Some(application) = self.applications.get(&process_id) + && let Some(window_id) = application.main_window_id() + { + self.focused_workspace_mut()? + .focus_container_by_window(window_id)?; + } + + if matches!(notification, AccessibilityNotification::AXMainWindowChanged) { + self.reap_invalid_windows_for_application(process_id)?; + self.update_focused_workspace(false, false)?; + } + } + WindowManagerEvent::Show(_, process_id) => { + let mut window_id = None; + let mut create = true; + + { + let application = self.applications.entry(process_id).or_insert_with(|| { + let application = + Application::new(process_id).expect("could not create application"); + application + .observe(&self.run_loop) + .expect("could not observe application"); + application + }); + + if let Some(element) = application.main_window() + && let Ok(wid) = AccessibilityApi::window_id(&element) + { + window_id = Some(wid); + } + } + + if let Some(window_id) = window_id { + let workspace = self.focused_workspace()?; + if workspace.contains_window(window_id) { + // ignore bogus show events + tracing::debug!("ignoring show event for window already on workspace"); + create = false; + } + } + + if create { + let application = self.applications.entry(process_id).or_insert_with(|| { + let application = + Application::new(process_id).expect("could not create application"); + application + .observe(&self.run_loop) + .expect("could not observe application"); + application + }); + + if let Some(element) = application.main_window() + && let Ok(window) = Window::new(element, application.clone()) + { + window.observe(&self.run_loop)?; + + let workspace = self.focused_workspace_mut()?; + workspace.new_container_for_window(window); + + self.update_focused_workspace(false, false)?; + } + } + } + WindowManagerEvent::Destroy(_, process_id) => { + self.reap_invalid_windows_for_application(process_id)?; + self.update_focused_workspace(false, false)?; + } + WindowManagerEvent::Minimize(_, _, window_id) => { + self.extract_minimized_window(window_id)?; + self.update_focused_workspace(false, false)?; + } + WindowManagerEvent::Restore(_, _, window_id) => { + match self.minimized_windows.remove(&window_id) { + None => {} + Some(window) => { + let workspace = self.focused_workspace_mut()?; + workspace.new_container_for_window(window); + self.update_focused_workspace(false, false)?; + } + } + } + } + + Ok(()) + } +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 38dc9c07..6017789b 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -8,14 +8,17 @@ use crate::accessibility::attribute_constants::kAXSizeAttribute; use crate::accessibility::attribute_constants::kAXTitleAttribute; use crate::accessibility::error::AccessibilityCustomError; use crate::accessibility::error::AccessibilityError; +use crate::accessibility::notification_constants::AccessibilityNotification; use crate::accessibility::notification_constants::kAXTitleChangedNotification; use crate::accessibility::notification_constants::kAXWindowDeminiaturizedNotification; use crate::accessibility::notification_constants::kAXWindowMiniaturizedNotification; use crate::accessibility::notification_constants::kAXWindowMovedNotification; use crate::accessibility::notification_constants::kAXWindowResizedNotification; use crate::application::Application; +use crate::ax_event_listener::event_tx; use crate::cf_dictionary_value; use crate::core::rect::Rect; +use crate::window_manager_event::WindowManagerEvent; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; use objc2_application_services::AXObserver; @@ -37,6 +40,7 @@ use objc2_core_graphics::kCGWindowOwnerName; use objc2_core_graphics::kCGWindowOwnerPID; use std::ffi::c_void; use std::ptr::NonNull; +use std::str::FromStr; use tracing::instrument; const NOTIFICATIONS: &[&str] = &[ @@ -55,23 +59,32 @@ unsafe extern "C-unwind" fn window_observer_callback( _context: *mut c_void, ) { unsafe { - let title = + let name = AccessibilityApi::copy_attribute_value::(element.as_ref(), kAXTitleAttribute) .map(|s| s.to_string()); - let mut pid = 0; - - element.as_ref().pid(NonNull::from_mut(&mut pid)); - - if let Some(title) = title - && !title.is_empty() + if let Some(name) = name + && !name.is_empty() { - tracing::info!( - "notification: {}, process: {pid}, title: \"{title}\"", - notification.as_ref() - ); - } else { - tracing::info!("notification: {}, process: {pid}", notification.as_ref()); + let mut process_id = 0; + element.as_ref().pid(NonNull::from_mut(&mut process_id)); + + let window_id = AccessibilityApi::window_id(element.as_ref()).ok(); + + if let Ok(notification) = + AccessibilityNotification::from_str(¬ification.as_ref().to_string()) + && let Some(event) = + WindowManagerEvent::from_ax_notification(notification, process_id, window_id) + { + if let Err(error) = event_tx().send(event) { + tracing::error!("failed to send window manager event: {error}"); + } else { + tracing::debug!( + "notification: {}, process: {process_id}, name: \"{name}\"", + notification, + ); + } + } } } } @@ -125,8 +138,9 @@ impl WindowInfo { #[derive(Debug)] #[allow(unused)] pub struct Window { + pub id: u32, element: AccessibilityUiElement, - application: Application, + pub application: Application, observer: AccessibilityObserver, } @@ -153,12 +167,17 @@ impl Window { )?; Ok(Self { + id: AccessibilityApi::window_id(&element)?, element: AccessibilityUiElement(element), application, observer: AccessibilityObserver(observer), }) } + pub fn is_valid(&self) -> bool { + AccessibilityApi::copy_attribute_names(&self.element).is_some() + } + #[tracing::instrument(skip_all)] pub fn observe(&self, run_loop: &CFRunLoop) -> Result<(), AccessibilityError> { tracing::info!( diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 4fc5b3aa..36bc99bd 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1,19 +1,22 @@ use crate::CoreFoundationRunLoop; use crate::DATA_DIR; use crate::LibraryError; +use crate::accessibility::AccessibilityApi; use crate::application::Application; +use crate::container::Container; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; -use crate::lockable_sequence::Lockable; use crate::macos_api::MacosApi; use crate::monitor::Monitor; use crate::ring::Ring; use crate::window::Window; +use crate::window_manager_event::WindowManagerEvent; use crate::workspace::Workspace; use color_eyre::eyre; use color_eyre::eyre::eyre; +use crossbeam_channel::Receiver; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use std::collections::HashMap; @@ -30,6 +33,8 @@ pub struct WindowManager { pub is_paused: bool, pub mouse_follows_focus: bool, pub work_area_offset: Option, + pub incoming_events: Receiver, + pub minimized_windows: HashMap, } impl_ring_elements!(WindowManager, Monitor); @@ -37,6 +42,7 @@ impl_ring_elements!(WindowManager, Monitor); impl WindowManager { pub fn new( run_loop: &CFRetained, + incoming: Receiver, custom_socket_path: Option, ) -> eyre::Result { let socket = custom_socket_path.unwrap_or_else(|| DATA_DIR.join("komorebi.sock")); @@ -61,6 +67,8 @@ impl WindowManager { is_paused: false, mouse_follows_focus: true, work_area_offset: None, + incoming_events: incoming, + minimized_windows: HashMap::new(), }) } @@ -241,22 +249,32 @@ impl WindowManager { .focused_window_mut() .ok_or_else(|| eyre!("there is no window")) } -} -impl_ring_elements!(Container, Window); -#[derive(Debug, Default)] -pub struct Container { - pub windows: Ring, - pub locked: bool, -} + pub fn extract_minimized_window(&mut self, window_id: u32) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + let window = workspace.remove_window(window_id)?; + self.minimized_windows.insert(window_id, window); -impl Lockable for Container { - fn locked(&self) -> bool { - self.locked + Ok(()) } - fn set_locked(&mut self, locked: bool) -> &mut Self { - self.locked = locked; - self + pub fn reap_invalid_windows_for_application(&mut self, process_id: i32) -> eyre::Result<()> { + if let Some(application) = self.applications.get(&process_id) { + let mut valid_window_ids = vec![]; + if let Some(elements) = application.window_elements() { + for element in elements { + if let Ok(window_id) = AccessibilityApi::window_id(&element) { + valid_window_ids.push(window_id); + } + } + } + + let focused_workspace = self.focused_workspace_mut()?; + focused_workspace + .reap_invalid_windows_for_application(process_id, &valid_window_ids)?; + self.update_focused_workspace(false, false)?; + } + + Ok(()) } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs new file mode 100644 index 00000000..8f11c7ca --- /dev/null +++ b/komorebi/src/window_manager_event.rs @@ -0,0 +1,47 @@ +#![allow(non_upper_case_globals)] + +use crate::accessibility::notification_constants::AccessibilityNotification; +use serde::Deserialize; +use serde::Serialize; +use strum::Display; + +#[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] +#[serde(tag = "type", content = "content")] +pub enum WindowManagerEvent { + FocusChange(AccessibilityNotification, i32, Option), + Show(AccessibilityNotification, i32), + Destroy(AccessibilityNotification, i32), + Minimize(AccessibilityNotification, i32, u32), + Restore(AccessibilityNotification, i32, u32), +} + +impl WindowManagerEvent { + pub fn from_ax_notification( + notification: AccessibilityNotification, + process_id: i32, + window_id: Option, + ) -> Option { + match notification { + AccessibilityNotification::AXMainWindowChanged + | AccessibilityNotification::AXApplicationActivated => Some( + WindowManagerEvent::FocusChange(notification, process_id, window_id), + ), + AccessibilityNotification::AXWindowCreated + | AccessibilityNotification::AXApplicationShown => { + Some(WindowManagerEvent::Show(notification, process_id)) + } + AccessibilityNotification::AXUIElementDestroyed => { + Some(WindowManagerEvent::Destroy(notification, process_id)) + } + AccessibilityNotification::AXWindowMiniaturized => window_id + .map(|window_id| WindowManagerEvent::Minimize(notification, process_id, window_id)), + AccessibilityNotification::AXWindowDeminiaturized => window_id + .map(|window_id| WindowManagerEvent::Restore(notification, process_id, window_id)), + // kAXWindowMovedNotification => {} + // kAXWindowResizedNotification => {} + // kAXTitleChangedNotification => {} + // kAXApplicationDeactivatedNotification => {} + _ => None, + } + } +} diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 012f8e7f..82b9180a 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1,3 +1,4 @@ +use crate::container::Container; use crate::core::arrangement::Axis; use crate::core::default_layout::DefaultLayout; use crate::core::default_layout::LayoutOptions; @@ -6,7 +7,7 @@ use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::lockable_sequence::LockableSequence; use crate::ring::Ring; -use crate::window_manager::Container; +use crate::window::Window; use color_eyre::eyre; use color_eyre::eyre::eyre; use std::num::NonZeroUsize; @@ -153,4 +154,159 @@ impl Workspace { len, ) } + + pub fn container_idx_for_window(&self, window_id: u32) -> Option { + let mut idx = None; + for (i, x) in self.containers().iter().enumerate() { + if x.contains_window(window_id) { + idx = Option::from(i); + } + } + + idx + } + + pub fn focus_container_by_window(&mut self, window_id: u32) -> eyre::Result<()> { + let container_idx = self + .container_idx_for_window(window_id) + .ok_or_else(|| eyre!("there is no container/window"))?; + + let container = self + .containers_mut() + .get_mut(container_idx) + .ok_or_else(|| eyre!("there is no container"))?; + + let window_idx = container + .idx_for_window(window_id) + .ok_or_else(|| eyre!("there is no window"))?; + + let mut should_load = false; + + if container.focused_window_idx() != window_idx { + should_load = true + } + + container.focus_window(window_idx); + + if should_load { + container.load_focused_window(); + } + + self.focus_container(container_idx); + + Ok(()) + } + + pub fn new_container_for_window(&mut self, window: Window) { + let next_idx = if self.containers().is_empty() { + 0 + } else { + self.focused_container_idx() + 1 + }; + + let mut container = Container::default(); + container.add_window(window); + + self.insert_container_at_idx(next_idx, container); + } + + // this fn respects locked container indexes - we should use it for pretty much everything + // except monocle and maximize toggles + pub fn insert_container_at_idx(&mut self, idx: usize, container: Container) -> usize { + let insertion_idx = self + .containers_mut() + .insert_respecting_locks(idx, container); + + if insertion_idx > self.resize_dimensions.len() { + self.resize_dimensions.push(None); + } else { + self.resize_dimensions.insert(insertion_idx, None); + } + + self.focus_container(insertion_idx); + + insertion_idx + } + + pub fn reap_invalid_windows_for_application( + &mut self, + process_id: i32, + valid_window_ids: &[u32], + ) -> eyre::Result<()> { + let mut invalid_window_ids = vec![]; + for container in self.containers() { + if let Some(focused_window) = container.focused_window() + && focused_window.application.process_id == process_id + && !valid_window_ids.contains(&focused_window.id) + { + invalid_window_ids.push(focused_window.id); + } + } + + for window_id in invalid_window_ids { + self.remove_window(window_id)?; + } + + Ok(()) + } + + pub fn remove_window(&mut self, window_id: u32) -> eyre::Result { + let container_idx = self + .container_idx_for_window(window_id) + .ok_or_else(|| eyre!("there is no window"))?; + + let container = self + .containers_mut() + .get_mut(container_idx) + .ok_or_else(|| eyre!("there is no container"))?; + + let window_idx = container + .windows() + .iter() + .position(|window| window.id == window_id) + .ok_or_else(|| eyre!("there is no window"))?; + + let window = container + .remove_window_by_idx(window_idx) + .ok_or_else(|| eyre!("there is no window"))?; + + if container.windows().is_empty() { + self.remove_container_by_idx(container_idx); + self.focus_previous_container(); + } else { + container.load_focused_window(); + if let Some(window) = container.focused_window() { + window.focus(false)?; + } + } + + Ok(window) + } + + // this fn respects locked container indexes - we should use it for pretty much everything + // except monocle and maximize toggles + pub fn remove_container_by_idx(&mut self, idx: usize) -> Option { + let container = self.containers_mut().remove_respecting_locks(idx); + + if idx < self.resize_dimensions.len() { + self.resize_dimensions.remove(idx); + } + + container + } + + pub fn focus_previous_container(&mut self) { + let focused_idx = self.focused_container_idx(); + self.focus_container(focused_idx.saturating_sub(1)); + } + + pub fn contains_window(&self, window_id: u32) -> bool { + for container in self.containers() { + if container.contains_window(window_id) { + return true; + } + } + + false + } } From 92701d902d23a64c4a340729a3c2ff6285117a05 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 18 Sep 2025 15:43:47 -0700 Subject: [PATCH 007/305] feat(wm): add basic stacking support This commit adds support for the StackWindow, UnstackWindow and CycleStack SocketCommands. The code is largely just migrated from komorebi. It looks like there isn't a public API which can be used to hide individual windows, either via AXUIElement or something constructed using the window id. For now I'm just moving the stacked window off the screen and this works well enough. I also added some cleanup which ensures that when the process exits, windows which are off-screen will be restored to their last known position. --- Cargo.lock | 12 +- deny.toml | 15 ++- dependencies.json | 97 +++++++++++++++- komorebi-client/src/lib.rs | 1 + komorebi/src/container.rs | 47 +++++--- komorebi/src/core/cycle_direction.rs | 35 ++++++ komorebi/src/core/mod.rs | 5 + komorebi/src/macos_api.rs | 58 +++++++--- komorebi/src/main.rs | 2 + komorebi/src/process_command.rs | 7 +- komorebi/src/process_event.rs | 35 ++---- komorebi/src/window.rs | 79 +++++++++++-- komorebi/src/window_manager.rs | 167 ++++++++++++++++++++++++--- komorebi/src/window_manager_event.rs | 10 ++ komorebi/src/workspace.rs | 75 +++++++++++- komorebic/src/main.rs | 20 ++++ 16 files changed, 565 insertions(+), 100 deletions(-) create mode 100644 komorebi/src/core/cycle_direction.rs diff --git a/Cargo.lock b/Cargo.lock index a29ca2e9..01c15071 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -424,9 +424,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" [[package]] name = "heck" @@ -489,12 +489,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.11.3" +version = "2.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92119844f513ffa41556430369ab02c295a3578af21cf945caa3e9e0c2481ac3" +checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" dependencies = [ "equivalent", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "serde", "serde_core", ] @@ -1123,7 +1123,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.11.3", + "indexmap 2.11.4", "schemars 0.9.0", "schemars 1.0.4", "serde", diff --git a/deny.toml b/deny.toml index 2b05403b..cb8b0cf2 100644 --- a/deny.toml +++ b/deny.toml @@ -16,9 +16,11 @@ allow = [ "0BSD", "Apache-2.0", "MIT", + "MPL-2.0", "Unicode-3.0", "Zlib", - "LicenseRef-Komorebi-2.0" + + "LicenseRef-Komorebi-2.0", # these are also ok, but not yet used @@ -29,7 +31,6 @@ allow = [ # "CC0-1.0", # "ISC", # "MIT-0", - # "MPL-2.0", # "OFL-1.1", # "Ubuntu-font-1.0", ] @@ -40,6 +41,16 @@ crate = "komorebi" expression = "LicenseRef-Komorebi-2.0" license-files = [] +[[licenses.clarify]] +crate = "komorebi-client" +expression = "LicenseRef-Komorebi-2.0" +license-files = [] + +[[licenses.clarify]] +crate = "komorebic" +expression = "LicenseRef-Komorebi-2.0" +license-files = [] + [bans] multiple-versions = "allow" wildcards = "allow" diff --git a/dependencies.json b/dependencies.json index a7201307..8739a57f 100644 --- a/dependencies.json +++ b/dependencies.json @@ -11,18 +11,39 @@ [ "addr2line 0.24.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", + "anstyle 1.0.11 registry+https://github.com/rust-lang/crates.io-index", + "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", + "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "colorchoice 1.0.4 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", + "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", + "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -37,6 +58,8 @@ "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", @@ -44,15 +67,35 @@ "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "serde 1.0.225 registry+https://github.com/rust-lang/crates.io-index", "serde_core 1.0.225 registry+https://github.com/rust-lang/crates.io-index", "serde_derive 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.14.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.14.0 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", - "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", - "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", + "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index" + "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "Apache-2.0 WITH LLVM-exception", + [ + "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "BSL-1.0", + [ + "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -60,21 +103,45 @@ [ "addr2line 0.24.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", + "anstyle 1.0.11 registry+https://github.com/rust-lang/crates.io-index", + "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", + "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "colorchoice 1.0.4 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "darling 0.20.11 registry+https://github.com/rust-lang/crates.io-index", + "darling_core 0.20.11 registry+https://github.com/rust-lang/crates.io-index", + "darling_macro 0.20.11 registry+https://github.com/rust-lang/crates.io-index", + "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", + "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", + "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index", @@ -97,6 +164,8 @@ "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", "owo-colors 4.2.2 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", @@ -104,14 +173,23 @@ "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "serde 1.0.225 registry+https://github.com/rust-lang/crates.io-index", "serde_core 1.0.225 registry+https://github.com/rust-lang/crates.io-index", "serde_derive 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.14.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.14.0 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", + "strsim 0.11.1 registry+https://github.com/rust-lang/crates.io-index", + "strum 0.27.2 registry+https://github.com/rust-lang/crates.io-index", + "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", - "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", - "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", + "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", "tracing 0.1.41 registry+https://github.com/rust-lang/crates.io-index", "tracing-attributes 0.1.30 registry+https://github.com/rust-lang/crates.io-index", @@ -119,7 +197,14 @@ "tracing-error 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "tracing-log 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index" + "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "MPL-2.0", + [ + "option-ext 0.2.0 registry+https://github.com/rust-lang/crates.io-index" ] ], [ diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 609bb5d1..aae61b29 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,5 +1,6 @@ pub use komorebi::DATA_DIR; pub use komorebi::core::SocketMessage; +pub use komorebi::core::cycle_direction::CycleDirection; pub use komorebi::core::default_layout::DefaultLayout; pub use komorebi::core::operation_direction::OperationDirection; pub use komorebi::core::pathext::PathExt; diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index a0b57c6e..9c7833b9 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -1,6 +1,8 @@ +use crate::accessibility::error::AccessibilityError; use crate::lockable_sequence::Lockable; use crate::ring::Ring; use crate::window::Window; +use color_eyre::eyre; impl_ring_elements!(Container, Window); @@ -42,16 +44,23 @@ impl Container { None } - pub fn add_window(&mut self, window: Window) { - self.windows_mut().push_back(window); - self.focus_window(self.windows().len().saturating_sub(1)); - // let focused_window_idx = self.focused_window_idx(); + pub fn remove_focused_window(&mut self) -> Option { + let focused_idx = self.focused_window_idx(); + self.remove_window_by_idx(focused_idx) + } - // for (i, window) in self.windows().iter().enumerate() { - // if i != focused_window_idx { - // window.hide(); - // } - // } + pub fn add_window(&mut self, window: &Window) -> eyre::Result<()> { + self.windows_mut().push_back(window.clone()); + self.focus_window(self.windows().len().saturating_sub(1)); + let focused_window_idx = self.focused_window_idx(); + + for (i, window) in self.windows_mut().iter_mut().enumerate() { + if i != focused_window_idx { + window.hide()?; + } + } + + Ok(()) } #[tracing::instrument(skip(self))] @@ -63,16 +72,18 @@ impl Container { /// Hides the unfocused windows of the container and restores the focused one. This function /// is used to make sure we update the window that should be shown on a stack. If the container /// isn't a stack this function won't change anything. - pub fn load_focused_window(&mut self) { - // let focused_idx = self.focused_window_idx(); + pub fn load_focused_window(&mut self) -> Result<(), AccessibilityError> { + let focused_idx = self.focused_window_idx(); - // for (i, window) in self.windows_mut().iter_mut().enumerate() { - // if i == focused_idx { - // window.restore_with_border(false); - // } else { - // window.hide_with_border(false); - // } - // } + for (i, window) in self.windows_mut().iter_mut().enumerate() { + if i == focused_idx { + window.restore()?; + } else { + window.hide()?; + } + } + + Ok(()) } pub fn remove_window_by_idx(&mut self, idx: usize) -> Option { diff --git a/komorebi/src/core/cycle_direction.rs b/komorebi/src/core/cycle_direction.rs new file mode 100644 index 00000000..bf820bdb --- /dev/null +++ b/komorebi/src/core/cycle_direction.rs @@ -0,0 +1,35 @@ +use std::num::NonZeroUsize; + +use clap::ValueEnum; +use serde::Deserialize; +use serde::Serialize; +use strum::Display; +use strum::EnumString; + +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] +pub enum CycleDirection { + Previous, + Next, +} + +impl CycleDirection { + #[must_use] + pub const fn next_idx(&self, idx: usize, len: NonZeroUsize) -> usize { + match self { + Self::Previous => { + if idx == 0 { + len.get() - 1 + } else { + idx - 1 + } + } + Self::Next => { + if idx == len.get() - 1 { + 0 + } else { + idx + 1 + } + } + } + } +} diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 61da4434..16fd7a71 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -1,3 +1,4 @@ +use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::operation_direction::OperationDirection; use color_eyre::eyre; @@ -7,6 +8,7 @@ use std::str::FromStr; use strum::Display; pub mod arrangement; +pub mod cycle_direction; pub mod default_layout; pub mod direction; pub mod layout; @@ -27,6 +29,9 @@ pub enum SocketMessage { // Window / Container Commands FocusWindow(OperationDirection), MoveWindow(OperationDirection), + StackWindow(OperationDirection), + CycleStack(CycleDirection), + UnstackWindow, ChangeLayout(DefaultLayout), TogglePause, } diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 697f449a..eaf37dd1 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -1,6 +1,8 @@ use crate::LibraryError; use crate::accessibility::attribute_constants::kAXPositionAttribute; use crate::accessibility::attribute_constants::kAXSizeAttribute; +use crate::accessibility::error::AccessibilityApiError; +use crate::accessibility::error::AccessibilityError; use crate::application::Application; use crate::cf_array_as; use crate::container::Container; @@ -12,11 +14,13 @@ use crate::window_manager::WindowManager; use objc2::MainThreadMarker; use objc2_app_kit::NSScreen; use objc2_application_services::AXUIElement; +use objc2_application_services::AXValue; +use objc2_application_services::AXValueType; use objc2_core_foundation::CFDictionary; use objc2_core_foundation::CFString; -use objc2_core_foundation::CGPoint; -use objc2_core_foundation::CGSize; +use objc2_core_foundation::CGRect; use std::collections::HashMap; +use std::ffi::c_void; use std::ptr::NonNull; pub struct MacosApi; @@ -121,30 +125,50 @@ impl MacosApi { )?) } - pub fn window_rect(element: &AXUIElement) -> Rect { + pub fn window_rect(element: &AXUIElement) -> Result { let mut position_receiver = std::ptr::null(); let mut size_receiver = std::ptr::null(); + // let mut position_receiver = CGPoint::default(); + // let mut size_receiver = CGSize::default(); + unsafe { - element.copy_attribute_value( + match AccessibilityApiError::from(element.copy_attribute_value( &CFString::from_static_str(kAXPositionAttribute), - NonNull::from(&mut position_receiver), - ); + NonNull::from_mut(&mut position_receiver), + )) { + AccessibilityApiError::Success => {} + error => { + tracing::error!("failed to get window position: {error}"); + return Err(error.into()); + } + }; - element.copy_attribute_value( + match AccessibilityApiError::from(element.copy_attribute_value( &CFString::from_static_str(kAXSizeAttribute), - NonNull::from(&mut size_receiver), + NonNull::from_mut(&mut size_receiver), + )) { + AccessibilityApiError::Success => {} + error => { + tracing::error!("failed to get window size: {error}"); + return Err(error.into()); + } + }; + + let mut rect = CGRect::default(); + + AXValue::value( + &*position_receiver.cast::(), + AXValueType::CGPoint, + NonNull::from_mut(&mut rect.origin).cast::(), + ); + AXValue::value( + &*size_receiver.cast::(), + AXValueType::CGSize, + NonNull::from_mut(&mut rect.size).cast::(), ); - let position = *position_receiver.cast::(); - let size = *position_receiver.cast::(); - - Rect { - left: position.x as i32, - top: position.y as i32, - right: size.width as i32, - bottom: size.height as i32, - } + Ok(Rect::from(rect)) } } } diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index d98df720..a0fe28ea 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -146,5 +146,7 @@ fn main() -> eyre::Result<()> { autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) }); } + wm.lock().restore_all_windows(false)?; + Ok(()) } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index e5b64d43..e97294b2 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -31,7 +31,7 @@ pub fn listen_for_commands(wm: Arc>) { match read_commands_uds(&wm_clone, stream) { Ok(()) => {} Err(error) => { - tracing::error!("failed to read command from uds {}", error) + tracing::error!("{error}") } } }); @@ -64,6 +64,11 @@ impl WindowManager { SocketMessage::MoveWindow(direction) => { self.move_container_in_direction(direction)?; } + SocketMessage::StackWindow(direction) => self.add_window_to_container(direction)?, + SocketMessage::UnstackWindow => self.remove_window_from_container()?, + SocketMessage::CycleStack(direction) => { + self.cycle_container_window_in_direction(direction)?; + } SocketMessage::ChangeLayout(layout) => self.change_workspace_layout_default(layout)?, SocketMessage::TogglePause => { if self.is_paused { diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 7560895f..2ad477af 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,6 +1,5 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::notification_constants::AccessibilityNotification; -use crate::application::Application; use crate::window::Window; use crate::window_manager::WindowManager; use crate::window_manager_event::WindowManagerEvent; @@ -43,9 +42,9 @@ impl WindowManager { match event { WindowManagerEvent::FocusChange(notification, process_id, _) => { - if let Some(application) = self.applications.get(&process_id) - && let Some(window_id) = application.main_window_id() - { + let application = self.application(process_id)?; + + if let Some(window_id) = application.main_window_id() { self.focused_workspace_mut()? .focus_container_by_window(window_id)?; } @@ -57,22 +56,16 @@ impl WindowManager { } WindowManagerEvent::Show(_, process_id) => { let mut window_id = None; + let mut window_element = None; let mut create = true; { - let application = self.applications.entry(process_id).or_insert_with(|| { - let application = - Application::new(process_id).expect("could not create application"); - application - .observe(&self.run_loop) - .expect("could not observe application"); - application - }); - + let application = self.application(process_id)?; if let Some(element) = application.main_window() && let Ok(wid) = AccessibilityApi::window_id(&element) { window_id = Some(wid); + window_element = Some(element.clone()); } } @@ -86,22 +79,14 @@ impl WindowManager { } if create { - let application = self.applications.entry(process_id).or_insert_with(|| { - let application = - Application::new(process_id).expect("could not create application"); - application - .observe(&self.run_loop) - .expect("could not observe application"); - application - }); - - if let Some(element) = application.main_window() + let application = self.application(process_id)?; + if let Some(element) = window_element && let Ok(window) = Window::new(element, application.clone()) { window.observe(&self.run_loop)?; let workspace = self.focused_workspace_mut()?; - workspace.new_container_for_window(window); + workspace.new_container_for_window(&window)?; self.update_focused_workspace(false, false)?; } @@ -120,7 +105,7 @@ impl WindowManager { None => {} Some(window) => { let workspace = self.focused_workspace_mut()?; - workspace.new_container_for_window(window); + workspace.new_container_for_window(&window)?; self.update_focused_workspace(false, false)?; } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 6017789b..f6a5a576 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -3,6 +3,7 @@ use crate::AccessibilityUiElement; use crate::LibraryError; use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXMainAttribute; +use crate::accessibility::attribute_constants::kAXMinimizedAttribute; use crate::accessibility::attribute_constants::kAXPositionAttribute; use crate::accessibility::attribute_constants::kAXSizeAttribute; use crate::accessibility::attribute_constants::kAXTitleAttribute; @@ -18,6 +19,7 @@ use crate::application::Application; use crate::ax_event_listener::event_tx; use crate::cf_dictionary_value; use crate::core::rect::Rect; +use crate::macos_api::MacosApi; use crate::window_manager_event::WindowManagerEvent; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; @@ -135,24 +137,30 @@ impl WindowInfo { } } -#[derive(Debug)] +#[derive(Debug, Clone)] #[allow(unused)] pub struct Window { pub id: u32, element: AccessibilityUiElement, pub application: Application, observer: AccessibilityObserver, + pub restore_point: Option<(f32, f32)>, } impl Drop for Window { fn drop(&mut self) { - // make sure the observer gets removed from any run loops - tracing::info!( - "invalidating window observer for {}", - self.title() - .unwrap_or_else(|| String::from("")) - ); - AccessibilityApi::invalidate_observer(&self.observer); + // this gets called when a cloned Window is dropped, so we need to make sure it only + // invalidates the observer if the Window is no longer open + if !self.is_valid() { + tracing::info!( + "invalidating window observer for {}", + self.title() + .unwrap_or_else(|| String::from("")) + ); + + // make sure the observer gets removed from any run loops + AccessibilityApi::invalidate_observer(&self.observer); + } } } @@ -171,6 +179,7 @@ impl Window { element: AccessibilityUiElement(element), application, observer: AccessibilityObserver(observer), + restore_point: None, }) } @@ -195,6 +204,60 @@ impl Window { ) } + #[tracing::instrument(skip_all)] + pub fn hide(&mut self) -> Result<(), AccessibilityError> { + if self.restore_point.is_none() { + let rect = MacosApi::window_rect(&self.element)?; + self.restore_point = Some((rect.left as f32, rect.top as f32)); + + tracing::debug!( + "hiding {} and setting restore point to {},{}", + self.title() + .unwrap_or_else(|| String::from("")), + rect.left, + rect.top, + ); + + // todo: this doesn't really do what I want + self.set_point(CGPoint::new(-5000.0 as CGFloat, rect.top as CGFloat))?; + } + + Ok(()) + } + + pub fn minimize(&mut self) -> Result<(), AccessibilityError> { + let cf_boolean = CFBoolean::new(true); + let value = &**cf_boolean; + AccessibilityApi::set_attribute_cf_value(&self.element, kAXMinimizedAttribute, value) + } + + pub fn unminimize(&mut self) -> Result<(), AccessibilityError> { + let cf_boolean = CFBoolean::new(false); + let value = &**cf_boolean; + AccessibilityApi::set_attribute_cf_value(&self.element, kAXMinimizedAttribute, value) + } + + #[tracing::instrument(skip_all)] + pub fn restore(&mut self) -> Result<(), AccessibilityError> { + let mut should_unset_restore_point = false; + if let Some((x, y)) = self.restore_point { + tracing::debug!( + "restoring {:?} to point {x},{y}", + self.title() + .unwrap_or_else(|| String::from("")) + ); + + self.set_point(CGPoint::new(x as CGFloat, y as CGFloat))?; + should_unset_restore_point = true; + } + + if should_unset_restore_point { + self.restore_point = None; + } + + Ok(()) + } + pub fn title(&self) -> Option { AccessibilityApi::copy_attribute_value::(&self.element, kAXTitleAttribute) .map(|s| s.to_string()) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 36bc99bd..07b7dfbc 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -4,6 +4,7 @@ use crate::LibraryError; use crate::accessibility::AccessibilityApi; use crate::application::Application; use crate::container::Container; +use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; @@ -20,7 +21,9 @@ use crossbeam_channel::Receiver; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use std::collections::HashMap; +use std::collections::hash_map::Entry; use std::io::ErrorKind; +use std::num::NonZeroUsize; use std::os::unix::net::UnixListener; use std::path::PathBuf; @@ -78,9 +81,18 @@ impl WindowManager { MacosApi::load_monitor_information(self)?; MacosApi::load_workspace_information(self) } -} -impl WindowManager { + pub fn application(&mut self, process_id: i32) -> Result<&mut Application, LibraryError> { + match self.applications.entry(process_id) { + Entry::Occupied(entry) => Ok(entry.into_mut()), + Entry::Vacant(vacant) => { + let application = Application::new(process_id)?; + application.observe(&self.run_loop)?; + Ok(vacant.insert(application)) + } + } + } + #[tracing::instrument(skip(self))] pub fn focus_container_in_direction( &mut self, @@ -259,22 +271,151 @@ impl WindowManager { } pub fn reap_invalid_windows_for_application(&mut self, process_id: i32) -> eyre::Result<()> { - if let Some(application) = self.applications.get(&process_id) { - let mut valid_window_ids = vec![]; - if let Some(elements) = application.window_elements() { - for element in elements { - if let Ok(window_id) = AccessibilityApi::window_id(&element) { - valid_window_ids.push(window_id); - } + let application = self.application(process_id)?; + let mut valid_window_ids = vec![]; + if let Some(elements) = application.window_elements() { + for element in elements { + if let Ok(window_id) = AccessibilityApi::window_id(&element) { + valid_window_ids.push(window_id); + } + } + } + + let focused_workspace = self.focused_workspace_mut()?; + focused_workspace.reap_invalid_windows_for_application(process_id, &valid_window_ids)?; + self.update_focused_workspace(false, false) + } + + #[tracing::instrument(skip(self))] + pub fn add_window_to_container(&mut self, direction: OperationDirection) -> eyre::Result<()> { + tracing::info!("adding window to container"); + let mouse_follows_focus = self.mouse_follows_focus; + + let workspace = self.focused_workspace_mut()?; + let len = NonZeroUsize::new(workspace.containers_mut().len()) + .ok_or_else(|| eyre!("there must be at least one container"))?; + let current_container_idx = workspace.focused_container_idx(); + + let is_valid = direction + .destination( + workspace.layout.as_boxed_direction().as_ref(), + workspace.layout_flip, + workspace.focused_container_idx(), + len, + ) + .is_some(); + + if is_valid { + let new_idx = workspace + .new_idx_for_direction(direction) + .ok_or_else(|| eyre!("this is not a valid direction from the current position"))?; + + let mut changed_focus = false; + + let adjusted_new_index = if new_idx > current_container_idx + && !matches!( + workspace.layout, + Layout::Default(DefaultLayout::Grid) + | Layout::Default(DefaultLayout::UltrawideVerticalStack) + ) { + workspace.focus_container(new_idx); + changed_focus = true; + new_idx.saturating_sub(1) + } else { + new_idx + }; + + let mut target_container_is_stack = false; + + if let Some(container) = workspace.containers().get(adjusted_new_index) + && container.windows().len() > 1 + { + target_container_is_stack = true; + } + + if let Some(current) = workspace.focused_container() { + if current.windows().len() > 1 && !target_container_is_stack { + workspace.focus_container(adjusted_new_index); + changed_focus = true; + workspace.move_window_to_container(current_container_idx)?; + } else { + workspace.move_window_to_container(adjusted_new_index)?; } } - let focused_workspace = self.focused_workspace_mut()?; - focused_workspace - .reap_invalid_windows_for_application(process_id, &valid_window_ids)?; - self.update_focused_workspace(false, false)?; + if changed_focus && let Some(container) = workspace.focused_container_mut() { + container.load_focused_window()?; + if let Some(window) = container.focused_window() { + window.focus(mouse_follows_focus)?; + } + } + + self.update_focused_workspace(mouse_follows_focus, false)?; } Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn remove_window_from_container(&mut self) -> eyre::Result<()> { + tracing::info!("removing window"); + + if self.focused_container()?.windows().len() == 1 { + Err(eyre!("a container must have at least one window"))?; + } + + let workspace = self.focused_workspace_mut()?; + + workspace.new_container_for_focused_window()?; + self.update_focused_workspace(self.mouse_follows_focus, false) + } + #[tracing::instrument(skip(self))] + pub fn restore_all_windows(&mut self, ignore_restore: bool) -> eyre::Result<()> { + tracing::info!("restoring all hidden windows"); + + for monitor in self.monitors_mut() { + for workspace in monitor.workspaces_mut() { + for containers in workspace.containers_mut() { + for window in containers.windows_mut() { + if !ignore_restore && let Err(error) = window.restore() { + tracing::error!("failed to restore window: {}", error); + } + } + } + } + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn cycle_container_window_in_direction( + &mut self, + direction: CycleDirection, + ) -> eyre::Result<()> { + tracing::info!("cycling container windows"); + + let mouse_follows_focus = self.mouse_follows_focus; + + let container = self.focused_container_mut()?; + + let len = NonZeroUsize::new(container.windows().len()) + .ok_or_else(|| eyre!("there must be at least one window in a container"))?; + + if len.get() == 1 { + return Err(eyre!("there is only one window in this container")); + } + + let current_idx = container.focused_window_idx(); + let next_idx = direction.next_idx(current_idx, len); + + container.focus_window(next_idx); + container.load_focused_window()?; + + if let Some(window) = container.focused_window() { + window.focus(mouse_follows_focus)?; + } + + self.update_focused_workspace(mouse_follows_focus, true) + } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 8f11c7ca..c06cc7c3 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -44,4 +44,14 @@ impl WindowManagerEvent { _ => None, } } + + pub fn process_id(&self) -> i32 { + match self { + WindowManagerEvent::FocusChange(_, process_id, _) + | WindowManagerEvent::Show(_, process_id) + | WindowManagerEvent::Destroy(_, process_id) + | WindowManagerEvent::Minimize(_, process_id, _) + | WindowManagerEvent::Restore(_, process_id, _) => *process_id, + } + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 82b9180a..cf8d810e 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -189,7 +189,7 @@ impl Workspace { container.focus_window(window_idx); if should_load { - container.load_focused_window(); + container.load_focused_window()?; } self.focus_container(container_idx); @@ -197,7 +197,7 @@ impl Workspace { Ok(()) } - pub fn new_container_for_window(&mut self, window: Window) { + pub fn new_container_for_window(&mut self, window: &Window) -> eyre::Result<()> { let next_idx = if self.containers().is_empty() { 0 } else { @@ -205,9 +205,11 @@ impl Workspace { }; let mut container = Container::default(); - container.add_window(window); + container.add_window(window)?; self.insert_container_at_idx(next_idx, container); + + Ok(()) } // this fn respects locked container indexes - we should use it for pretty much everything @@ -274,7 +276,7 @@ impl Workspace { self.remove_container_by_idx(container_idx); self.focus_previous_container(); } else { - container.load_focused_window(); + container.load_focused_window()?; if let Some(window) = container.focused_window() { window.focus(false)?; } @@ -309,4 +311,69 @@ impl Workspace { false } + + // this is what we use for stacking + pub fn move_window_to_container(&mut self, target_container_idx: usize) -> eyre::Result<()> { + let focused_idx = self.focused_container_idx(); + + let container = self + .focused_container_mut() + .ok_or_else(|| eyre!("there is no container"))?; + + let window = container + .remove_focused_window() + .ok_or_else(|| eyre!("there is no window"))?; + + // This is a little messy + let adjusted_target_container_index = if container.windows().is_empty() { + self.remove_container_by_idx(focused_idx); + + if focused_idx < target_container_idx { + target_container_idx.saturating_sub(1) + } else { + target_container_idx + } + } else { + container.load_focused_window()?; + target_container_idx + }; + + let target_container = self + .containers_mut() + .get_mut(adjusted_target_container_index) + .ok_or_else(|| eyre!("there is no container"))?; + + target_container.add_window(&window)?; + + self.focus_container(adjusted_target_container_index); + self.focused_container_mut() + .ok_or_else(|| eyre!("there is no container"))? + .load_focused_window()?; + + Ok(()) + } + + pub fn new_container_for_focused_window(&mut self) -> eyre::Result<()> { + let focused_container_idx = self.focused_container_idx(); + + let container = self + .focused_container_mut() + .ok_or_else(|| eyre!("there is no container"))?; + + let window = container + .remove_focused_window() + .ok_or_else(|| eyre!("there is no window"))?; + + if container.windows().is_empty() { + self.remove_container_by_idx(focused_container_idx); + } else { + container.load_focused_window()?; + } + + self.new_container_for_window(&window)?; + + let mut container = Container::default(); + container.add_window(&window)?; + Ok(()) + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 0c8c939b..e8c3d2d7 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -2,6 +2,7 @@ use clap::Parser; use color_eyre::eyre; +use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; use komorebi_client::OperationDirection; use komorebi_client::PathExt; @@ -54,6 +55,8 @@ gen_enum_subcommand_args! { Focus: OperationDirection, Move: OperationDirection, ChangeLayout: DefaultLayout, + Stack: OperationDirection, + CycleStack: CycleDirection, } #[derive(Parser)] @@ -71,6 +74,14 @@ enum SubCommand { /// Move the focused window in the specified direction #[clap(arg_required_else_help = true)] Move(Move), + /// Stack the focused window in the specified direction + #[clap(arg_required_else_help = true)] + Stack(Stack), + /// Unstack the focused window + Unstack, + /// Cycle the focused stack in the specified cycle direction + #[clap(arg_required_else_help = true)] + CycleStack(CycleStack), /// Toggle the paused state for all window tiling TogglePause, /// Set the layout on the focused workspace @@ -94,6 +105,15 @@ fn main() -> eyre::Result<()> { SubCommand::ChangeLayout(arg) => { send_message(&SocketMessage::ChangeLayout(arg.default_layout))?; } + SubCommand::Stack(arg) => { + send_message(&SocketMessage::StackWindow(arg.operation_direction))?; + } + SubCommand::Unstack => { + send_message(&SocketMessage::UnstackWindow)?; + } + SubCommand::CycleStack(arg) => { + send_message(&SocketMessage::CycleStack(arg.cycle_direction))?; + } } Ok(()) From 061d7e3e73fffd9dec4a5156f88f79cd84a958f4 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 18 Sep 2025 16:45:41 -0700 Subject: [PATCH 008/305] feat(wm): add basic workspace switching support This commit migrates the code needed from komorebi to implement basic workspace support. The FocusWorkspaceNumber, MoveContainerToWorkspaceNumber and SendContainerToWorkspaceNumber SocketMessage variants have been implemented in process_command, and the commands to emit those SocketMessage variants have been added to komorebic. I took a stab at improving the code for hiding the windows by moving them as off-screen as possible by taking inspiration of Aerospace's approach of trying to leave only 1px of them visible. Right now this always looks to put the hidden windows off-screen on the left side of the screen. --- komorebi/src/container.rs | 29 +++++- komorebi/src/core/mod.rs | 3 + komorebi/src/core_graphics/mod.rs | 27 ++++++ komorebi/src/lib.rs | 11 +++ komorebi/src/macos_api.rs | 4 +- komorebi/src/monitor.rs | 149 ++++++++++++++++++++++++++++++ komorebi/src/process_command.rs | 11 +++ komorebi/src/window.rs | 26 ++++-- komorebi/src/window_manager.rs | 36 ++++++++ komorebi/src/workspace.rs | 63 ++++++++++++- komorebic/src/main.rs | 37 ++++++++ 11 files changed, 382 insertions(+), 14 deletions(-) diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index 9c7833b9..07690891 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -6,7 +6,7 @@ use color_eyre::eyre; impl_ring_elements!(Container, Window); -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct Container { pub windows: Ring, pub locked: bool, @@ -91,4 +91,31 @@ impl Container { self.focus_window(idx.saturating_sub(1)); window } + + pub fn hide(&mut self, omit: Option) -> eyre::Result<()> { + for window in self.windows_mut().iter_mut().rev() { + let mut should_hide = omit.is_none(); + + if !should_hide + && let Some(omit) = omit + && omit != window.id + { + should_hide = true + } + + if should_hide { + window.hide()?; + } + } + + Ok(()) + } + + pub fn restore(&mut self) -> eyre::Result<()> { + if let Some(window) = self.focused_window_mut() { + window.restore()?; + } + + Ok(()) + } } diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 16fd7a71..fbf48322 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -34,6 +34,9 @@ pub enum SocketMessage { UnstackWindow, ChangeLayout(DefaultLayout), TogglePause, + FocusWorkspaceNumber(usize), + MoveContainerToWorkspaceNumber(usize), + SendContainerToWorkspaceNumber(usize), } impl SocketMessage { diff --git a/komorebi/src/core_graphics/mod.rs b/komorebi/src/core_graphics/mod.rs index 660cd589..34503769 100644 --- a/komorebi/src/core_graphics/mod.rs +++ b/komorebi/src/core_graphics/mod.rs @@ -5,6 +5,7 @@ use objc2_core_foundation::CGFloat; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_graphics::CGDisplayBounds; +use objc2_core_graphics::CGGetDisplaysWithPoint; use objc2_core_graphics::CGGetOnlineDisplayList; use objc2_core_graphics::CGRectIntersectsRect; use objc2_core_graphics::CGWarpMouseCursorPosition; @@ -56,6 +57,32 @@ impl CoreGraphicsApi { unsafe { CGDisplayBounds(display_id) } } + pub fn display_bounds_for_window_rect(window_rect: CGRect) -> Option { + let mut displays: Vec = Vec::with_capacity(1); + let mut display_count = 0; + + unsafe { + match CoreGraphicsError::from(CGGetDisplaysWithPoint( + window_rect.origin, + displays.capacity() as u32, + displays.as_mut_ptr(), + &mut display_count, + )) { + CoreGraphicsError::Success => { + displays.set_len(display_count as usize); + } + error => { + tracing::error!("failed to find display for point: {error}"); + return None; + } + } + } + + displays + .first() + .map(|display| CoreGraphicsApi::display_bounds(*display)) + } + pub fn window_list_info() -> Option> { unsafe { CGWindowListCopyWindowInfo( diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 72a7db55..f6903de4 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -11,6 +11,9 @@ use objc2_core_foundation::CFDictionary; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::CFString; +use objc2_core_foundation::CGPoint; +use objc2_core_foundation::CGRect; +use objc2_core_foundation::CGSize; use std::ops::Deref; use std::path::PathBuf; use std::ptr::NonNull; @@ -113,3 +116,11 @@ pub enum LibraryError { #[error(transparent)] CoreGraphics(#[from] CoreGraphicsError), } + +pub fn hidden_frame_bottom_left(screen_frame: CGRect, window_size: CGSize) -> CGRect { + let visible_sliver: f64 = 1.0; + let origin_x = screen_frame.origin.x - (window_size.width - visible_sliver); + let origin_y = screen_frame.origin.y - (window_size.height - visible_sliver); + + CGRect::new(CGPoint::new(origin_x, origin_y), window_size) +} diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index eaf37dd1..2bbba371 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -125,7 +125,7 @@ impl MacosApi { )?) } - pub fn window_rect(element: &AXUIElement) -> Result { + pub fn window_rect(element: &AXUIElement) -> Result { let mut position_receiver = std::ptr::null(); let mut size_receiver = std::ptr::null(); @@ -168,7 +168,7 @@ impl MacosApi { NonNull::from_mut(&mut rect.size).cast::(), ); - Ok(Rect::from(rect)) + Ok(rect) } } } diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 17288f5d..8e742986 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -1,5 +1,9 @@ use crate::DEFAULT_CONTAINER_PADDING; use crate::DEFAULT_WORKSPACE_PADDING; +use crate::container::Container; +use crate::core::default_layout::DefaultLayout; +use crate::core::layout::Layout; +use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::ring::Ring; use crate::workspace::Workspace; @@ -21,6 +25,7 @@ pub struct Monitor { pub window_based_work_area_offset_limit: isize, pub container_padding: Option, pub workspace_padding: Option, + pub last_focused_workspace: Option, } impl Monitor { @@ -39,6 +44,7 @@ impl Monitor { window_based_work_area_offset_limit: 0, container_padding: None, workspace_padding: None, + last_focused_workspace: None, } } @@ -85,4 +91,147 @@ impl Monitor { } } } + + #[tracing::instrument(skip(self))] + pub fn focus_workspace(&mut self, idx: usize) -> eyre::Result<()> { + tracing::info!("focusing workspace"); + + { + let workspaces = self.workspaces_mut(); + + if workspaces.get(idx).is_none() { + workspaces.resize(idx + 1, Workspace::default()); + } + self.last_focused_workspace = Some(self.workspaces.focused_idx()); + self.workspaces.focus(idx); + } + + Ok(()) + } + + pub fn load_focused_workspace(&mut self, mouse_follows_focus: bool) -> eyre::Result<()> { + let focused_idx = self.focused_workspace_idx(); + for (i, workspace) in self.workspaces_mut().iter_mut().enumerate() { + if i == focused_idx { + workspace.restore(mouse_follows_focus)?; + } else { + workspace.hide(None)?; + } + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn move_container_to_workspace( + &mut self, + target_workspace_idx: usize, + follow: bool, + direction: Option, + ) -> eyre::Result<()> { + let workspace = self + .focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace"))?; + + let container = workspace + .remove_focused_container() + .ok_or_else(|| eyre!("there is no container"))?; + + let workspaces = self.workspaces_mut(); + + #[allow(clippy::option_if_let_else)] + let target_workspace = match workspaces.get_mut(target_workspace_idx) { + None => { + workspaces.resize(target_workspace_idx + 1, Workspace::default()); + workspaces.get_mut(target_workspace_idx).unwrap() + } + Some(workspace) => workspace, + }; + + if let Some(direction) = direction { + self.add_container_with_direction(container, Some(target_workspace_idx), direction)?; + } else { + target_workspace.add_container_to_back(container); + } + + if follow { + self.focus_workspace(target_workspace_idx)?; + } + + Ok(()) + } + + /// Adds a container to this `Monitor` using the move direction to calculate if the container + /// should be added in front of all containers, in the back or in place of the focused + /// container, moving the rest along. The move direction should be from the origin monitor + /// towards the target monitor or from the origin workspace towards the target workspace. + pub fn add_container_with_direction( + &mut self, + container: Container, + workspace_idx: Option, + direction: OperationDirection, + ) -> eyre::Result<()> { + let workspace = if let Some(idx) = workspace_idx { + self.workspaces_mut() + .get_mut(idx) + .ok_or_else(|| eyre!("there is no workspace at index {}", idx))? + } else { + self.focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace"))? + }; + + match direction { + OperationDirection::Left => { + // insert the container into the workspace on the monitor at the back (or rightmost position) + // if we are moving across a boundary to the left (back = right side of the target) + match workspace.layout { + Layout::Default(layout) => match layout { + DefaultLayout::RightMainVerticalStack => { + workspace.add_container_to_front(container); + } + DefaultLayout::UltrawideVerticalStack => { + if workspace.containers().len() == 1 { + workspace.insert_container_at_idx(0, container); + } else { + workspace.add_container_to_back(container); + } + } + _ => { + workspace.add_container_to_back(container); + } + }, + } + } + OperationDirection::Right => { + // insert the container into the workspace on the monitor at the front (or leftmost position) + // if we are moving across a boundary to the right (front = left side of the target) + match workspace.layout { + Layout::Default(layout) => { + let target_index = layout.leftmost_index(workspace.containers().len()); + + match layout { + DefaultLayout::RightMainVerticalStack + | DefaultLayout::UltrawideVerticalStack => { + if workspace.containers().len() == 1 { + workspace.add_container_to_back(container); + } else { + workspace.insert_container_at_idx(target_index, container); + } + } + _ => { + workspace.insert_container_at_idx(target_index, container); + } + } + } + } + } + OperationDirection::Up | OperationDirection::Down => { + // insert the container into the workspace on the monitor at the position + // where the currently focused container on that workspace is + workspace.insert_container_at_idx(workspace.focused_container_idx(), container); + } + }; + + Ok(()) + } } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index e97294b2..9c98db1b 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -79,6 +79,17 @@ impl WindowManager { self.is_paused = !self.is_paused; } + SocketMessage::FocusWorkspaceNumber(workspace_idx) => { + if self.focused_workspace_idx().unwrap_or_default() != workspace_idx { + self.focus_workspace(workspace_idx)?; + } + } + SocketMessage::MoveContainerToWorkspaceNumber(workspace_idx) => { + self.move_container_to_workspace(workspace_idx, true, None)?; + } + SocketMessage::SendContainerToWorkspaceNumber(workspace_idx) => { + self.move_container_to_workspace(workspace_idx, false, None)?; + } } Ok(()) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index f6a5a576..f570f9f0 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -19,6 +19,8 @@ use crate::application::Application; use crate::ax_event_listener::event_tx; use crate::cf_dictionary_value; use crate::core::rect::Rect; +use crate::core_graphics::CoreGraphicsApi; +use crate::hidden_frame_bottom_left; use crate::macos_api::MacosApi; use crate::window_manager_event::WindowManagerEvent; use objc2_app_kit::NSApplicationActivationOptions; @@ -206,20 +208,24 @@ impl Window { #[tracing::instrument(skip_all)] pub fn hide(&mut self) -> Result<(), AccessibilityError> { + // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API if self.restore_point.is_none() { let rect = MacosApi::window_rect(&self.element)?; - self.restore_point = Some((rect.left as f32, rect.top as f32)); + if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { + self.restore_point = Some((rect.origin.x as f32, rect.origin.y as f32)); + let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); - tracing::debug!( - "hiding {} and setting restore point to {},{}", - self.title() - .unwrap_or_else(|| String::from("")), - rect.left, - rect.top, - ); + tracing::debug!( + "hiding {} and setting restore point to {},{}", + self.title() + .unwrap_or_else(|| String::from("")), + rect.origin.x, + rect.origin.y, + ); - // todo: this doesn't really do what I want - self.set_point(CGPoint::new(-5000.0 as CGFloat, rect.top as CGFloat))?; + self.set_point(hidden_rect.origin)?; + self.set_size(hidden_rect.size)?; + } } Ok(()) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 07b7dfbc..7bde432c 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -418,4 +418,40 @@ impl WindowManager { self.update_focused_workspace(mouse_follows_focus, true) } + #[tracing::instrument(skip(self))] + pub fn focus_workspace(&mut self, idx: usize) -> eyre::Result<()> { + tracing::info!("focusing workspace"); + + let mouse_follows_focus = self.mouse_follows_focus; + let monitor = self + .focused_monitor_mut() + .ok_or_else(|| eyre!("there is no workspace"))?; + + monitor.focus_workspace(idx)?; + monitor.load_focused_workspace(mouse_follows_focus)?; + + self.update_focused_workspace(false, true) + } + + #[tracing::instrument(skip(self))] + pub fn move_container_to_workspace( + &mut self, + idx: usize, + follow: bool, + direction: Option, + ) -> eyre::Result<()> { + tracing::info!("moving container"); + + let mouse_follows_focus = self.mouse_follows_focus; + let monitor = self + .focused_monitor_mut() + .ok_or_else(|| eyre!("there is no monitor"))?; + + monitor.move_container_to_workspace(idx, follow, direction)?; + monitor.load_focused_workspace(mouse_follows_focus)?; + + self.update_focused_workspace(mouse_follows_focus, true)?; + + Ok(()) + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index cf8d810e..966d5560 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -14,7 +14,7 @@ use std::num::NonZeroUsize; impl_ring_elements!(Workspace, Container); -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Workspace { pub containers: Ring, pub workspace_padding: Option, @@ -376,4 +376,65 @@ impl Workspace { container.add_window(&window)?; Ok(()) } + + pub fn hide(&mut self, omit: Option) -> eyre::Result<()> { + for container in self.containers_mut() { + container.hide(omit)?; + } + + Ok(()) + } + + pub fn restore(&mut self, mouse_follows_focus: bool) -> eyre::Result<()> { + let idx = self.focused_container_idx(); + let mut to_focus = None; + + for (i, container) in self.containers().iter().enumerate() { + if let Some(window) = container.focused_window() + && idx == i + { + to_focus = Option::from(window.clone()); + } + } + + for container in self.containers_mut() { + container.restore()?; + } + + if let Some(container) = self.focused_container_mut() { + container.focus_window(container.focused_window_idx()); + } + + if let Some(window) = to_focus { + window.focus(mouse_follows_focus)?; + } + + Ok(()) + } + + pub fn remove_focused_container(&mut self) -> Option { + let focused_idx = self.focused_container_idx(); + let container = self.remove_container_by_idx(focused_idx); + self.focus_previous_container(); + + container + } + + pub fn add_container_to_back(&mut self, container: Container) { + self.containers_mut().push_back(container); + self.focus_last_container(); + } + + pub fn add_container_to_front(&mut self, container: Container) { + self.containers_mut().push_front(container); + self.focus_first_container(); + } + + fn focus_last_container(&mut self) { + self.focus_container(self.containers().len().saturating_sub(1)); + } + + fn focus_first_container(&mut self) { + self.focus_container(0); + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index e8c3d2d7..288759c7 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -59,6 +59,25 @@ gen_enum_subcommand_args! { CycleStack: CycleDirection, } +macro_rules! gen_target_subcommand_args { + // SubCommand Pattern + ( $( $name:ident ),+ $(,)? ) => { + $( + #[derive(clap::Parser)] + pub struct $name { + /// Target index (zero-indexed) + target: usize, + } + )+ + }; +} + +gen_target_subcommand_args! { + FocusWorkspace, + MoveToWorkspace, + SendToWorkspace +} + #[derive(Parser)] #[clap(author, about, version)] struct Opts { @@ -87,6 +106,15 @@ enum SubCommand { /// Set the layout on the focused workspace #[clap(arg_required_else_help = true)] ChangeLayout(ChangeLayout), + /// Focus the specified workspace on the focused monitor + #[clap(arg_required_else_help = true)] + FocusWorkspace(FocusWorkspace), + /// Move the focused window to the specified workspace + #[clap(arg_required_else_help = true)] + MoveToWorkspace(MoveToWorkspace), + /// Send the focused window to the specified workspace + #[clap(arg_required_else_help = true)] + SendToWorkspace(SendToWorkspace), } fn main() -> eyre::Result<()> { @@ -114,6 +142,15 @@ fn main() -> eyre::Result<()> { SubCommand::CycleStack(arg) => { send_message(&SocketMessage::CycleStack(arg.cycle_direction))?; } + SubCommand::FocusWorkspace(arg) => { + send_message(&SocketMessage::FocusWorkspaceNumber(arg.target))?; + } + SubCommand::MoveToWorkspace(arg) => { + send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target))?; + } + SubCommand::SendToWorkspace(arg) => { + send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target))?; + } } Ok(()) From 558a1578c8f23f544ab6719890b13dccb45bb65e Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 18 Sep 2025 17:14:22 -0700 Subject: [PATCH 009/305] feat(wm): implement monocle containers This commit migrates the code around Monocle containers from komorebi and implements everything needed to handle SocketMessage::ToggleMonocle in the wm and send the SocketMessage from komorebic. I think I should spend time implementing as many Workspace features as I can before I turn my attention to anything else, because hunting for where to re-introduce the monocle code I had previously omitted to get everything compiling was quite tedious and I'm sure I've probably missed things. --- komorebi/src/core/mod.rs | 1 + komorebi/src/monitor.rs | 8 ++ komorebi/src/process_command.rs | 1 + komorebi/src/window.rs | 6 +- komorebi/src/window_manager.rs | 40 ++++++++++ komorebi/src/workspace.rs | 125 +++++++++++++++++++++++++++++++- komorebic/src/main.rs | 5 ++ 7 files changed, 182 insertions(+), 4 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index fbf48322..f3bf201f 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -34,6 +34,7 @@ pub enum SocketMessage { UnstackWindow, ChangeLayout(DefaultLayout), TogglePause, + ToggleMonocle, FocusWorkspaceNumber(usize), MoveContainerToWorkspaceNumber(usize), SendContainerToWorkspaceNumber(usize), diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 8e742986..cbb77f3b 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -148,6 +148,14 @@ impl Monitor { Some(workspace) => workspace, }; + if target_workspace.monocle_container.is_some() { + for container in target_workspace.containers_mut() { + container.restore()?; + } + + target_workspace.reintegrate_monocle_container()?; + } + if let Some(direction) = direction { self.add_container_with_direction(container, Some(target_workspace_idx), direction)?; } else { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 9c98db1b..66031711 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -90,6 +90,7 @@ impl WindowManager { SocketMessage::SendContainerToWorkspaceNumber(workspace_idx) => { self.move_container_to_workspace(workspace_idx, false, None)?; } + SocketMessage::ToggleMonocle => self.toggle_monocle()?, } Ok(()) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index f570f9f0..1e9235a3 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -274,7 +274,7 @@ impl Window { self.set_size(CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat)) } - pub fn focus(&self, focus_follows_mouse: bool) -> Result<(), LibraryError> { + pub fn focus(&self, mouse_follows_focus: bool) -> Result<(), LibraryError> { unsafe { NSRunningApplication::runningApplicationWithProcessIdentifier( self.application.process_id, @@ -289,8 +289,8 @@ impl Window { AccessibilityApi::set_attribute_cf_value(&self.element, kAXMainAttribute, value)?; } - if focus_follows_mouse { - // MacosApi::center_cursor_in_rect(&MacosApi::window_rect(&self.element))? + if mouse_follows_focus { + MacosApi::center_cursor_in_rect(&MacosApi::window_rect(&self.element)?.into())? } Ok(()) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 7bde432c..4dc5f2a6 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -454,4 +454,44 @@ impl WindowManager { Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn toggle_monocle(&mut self) -> eyre::Result<()> { + let workspace = self.focused_workspace()?; + match workspace.monocle_container { + None => self.monocle_on()?, + Some(_) => self.monocle_off()?, + } + + self.update_focused_workspace(true, true)?; + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn monocle_on(&mut self) -> eyre::Result<()> { + tracing::info!("enabling monocle"); + + let workspace = self.focused_workspace_mut()?; + workspace.new_monocle_container()?; + + for container in workspace.containers_mut() { + container.hide(None)?; + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn monocle_off(&mut self) -> eyre::Result<()> { + tracing::info!("disabling monocle"); + + let workspace = self.focused_workspace_mut()?; + + for container in workspace.containers_mut() { + container.restore()?; + } + + workspace.reintegrate_monocle_container() + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 966d5560..01829dc2 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -17,6 +17,8 @@ impl_ring_elements!(Workspace, Container); #[derive(Debug, Clone)] pub struct Workspace { pub containers: Ring, + pub monocle_container: Option, + pub monocle_container_restore_idx: Option, pub workspace_padding: Option, pub container_padding: Option, pub resize_dimensions: Vec>, @@ -33,6 +35,8 @@ impl Default for Workspace { fn default() -> Self { Self { containers: Default::default(), + monocle_container: None, + monocle_container_restore_idx: None, workspace_padding: None, container_padding: None, resize_dimensions: vec![], @@ -98,7 +102,12 @@ impl Workspace { #[allow(clippy::collapsible_if)] if self.tile { - if !self.containers().is_empty() { + if let Some(container) = self.monocle_container.as_mut() { + if let Some(window) = container.focused_window_mut() { + adjusted_work_area.add_padding(container_padding); + window.set_position(&adjusted_work_area)?; + }; + } else if !self.containers().is_empty() { let mut layouts = self.layout.as_boxed_arrangement().calculate( &adjusted_work_area, NonZeroUsize::new(self.containers().len()).ok_or_else(|| { @@ -126,9 +135,26 @@ impl Workspace { } } } + + self.latest_layout = layouts; } } + // Always make sure that the length of the resize dimensions vec is the same as the + // number of layouts / containers. This should never actually truncate as the remove_window + // function takes care of cleaning up resize dimensions when destroying empty containers + let container_count = self.containers().len(); + + // since monocle is a toggle, we never want to truncate the resize dimensions since it will + // almost always be toggled off and the container will be reintegrated into layout + // + // without this check, if there are exactly two containers, when one is toggled to monocle + // the resize dimensions will be truncated to len == 1, and when it is reintegrated, if it + // had a resize adjustment before, that will have been lost + if self.monocle_container.is_none() { + self.resize_dimensions.resize(container_count, None); + } + Ok(()) } @@ -253,6 +279,28 @@ impl Workspace { } pub fn remove_window(&mut self, window_id: u32) -> eyre::Result { + if let Some(container) = self.monocle_container.as_mut() + && let Some(window_idx) = container + .windows() + .iter() + .position(|window| window.id == window_id) + { + let window = container + .remove_window_by_idx(window_idx) + .ok_or_else(|| eyre!("there is no window"))?; + + if container.windows().is_empty() { + self.monocle_container = None; + self.monocle_container_restore_idx = None; + } + + for c in self.containers_mut() { + c.restore()?; + } + + return Ok(window); + } + let container_idx = self .container_idx_for_window(window_id) .ok_or_else(|| eyre!("there is no window"))?; @@ -309,6 +357,12 @@ impl Workspace { } } + if let Some(container) = &self.monocle_container + && container.contains_window(window_id) + { + return true; + } + false } @@ -382,10 +436,21 @@ impl Workspace { container.hide(omit)?; } + if let Some(container) = self.monocle_container.as_mut() { + container.hide(omit)?; + } + Ok(()) } pub fn restore(&mut self, mouse_follows_focus: bool) -> eyre::Result<()> { + if let Some(container) = self.monocle_container.as_mut() { + container.restore()?; + if let Some(window) = container.focused_window() { + window.focus(mouse_follows_focus)?; + } + } + let idx = self.focused_container_idx(); let mut to_focus = None; @@ -437,4 +502,62 @@ impl Workspace { fn focus_first_container(&mut self) { self.focus_container(0); } + + pub fn new_monocle_container(&mut self) -> eyre::Result<()> { + let focused_idx = self.focused_container_idx(); + + // we shouldn't use remove_container_by_idx here because it doesn't make sense for + // monocle and maximized toggles which take over the whole screen before being reinserted + // at the same index to respect locked container indexes + let container = self + .containers_mut() + .remove(focused_idx) + .ok_or_else(|| eyre!("there is no container"))?; + + // We don't remove any resize adjustments for a monocle, because when this container is + // inevitably reintegrated, it would be weird if it doesn't go back to the dimensions + // it had before + + self.monocle_container = Option::from(container); + self.monocle_container_restore_idx = Option::from(focused_idx); + self.focus_previous_container(); + + self.monocle_container + .as_mut() + .ok_or_else(|| eyre!("there is no monocle container"))? + .load_focused_window()?; + + Ok(()) + } + + pub fn reintegrate_monocle_container(&mut self) -> eyre::Result<()> { + let restore_idx = self + .monocle_container_restore_idx + .ok_or_else(|| eyre!("there is no monocle restore index"))?; + + let container = self + .monocle_container + .as_ref() + .ok_or_else(|| eyre!("there is no monocle container"))?; + + let container = container.clone(); + if restore_idx >= self.containers().len() { + self.containers_mut() + .resize(restore_idx, Container::default()); + } + + // we shouldn't use insert_container_at_index here because it doesn't make sense for + // monocle and maximized toggles which take over the whole screen before being reinserted + // at the same index to respect locked container indexes + self.containers_mut().insert(restore_idx, container); + self.focus_container(restore_idx); + self.focused_container_mut() + .ok_or_else(|| eyre!("there is no container"))? + .load_focused_window()?; + + self.monocle_container = None; + self.monocle_container_restore_idx = None; + + Ok(()) + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 288759c7..56edffe8 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -103,6 +103,8 @@ enum SubCommand { CycleStack(CycleStack), /// Toggle the paused state for all window tiling TogglePause, + /// Toggle monocle mode for the focused container + ToggleMonocle, /// Set the layout on the focused workspace #[clap(arg_required_else_help = true)] ChangeLayout(ChangeLayout), @@ -151,6 +153,9 @@ fn main() -> eyre::Result<()> { SubCommand::SendToWorkspace(arg) => { send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target))?; } + SubCommand::ToggleMonocle => { + send_message(&SocketMessage::ToggleMonocle)?; + } } Ok(()) From 5edbd64e65e1d2570be469d7b96a1f09d3a75ebc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 18 Sep 2025 17:27:59 -0700 Subject: [PATCH 010/305] feat(wm): implement window based work area offsets I can't use monocle mode without this feature. Migrated all the relevant code over from komorebi. Values are hardcoded to now for my preferences. After I bring over the rest of the Workspace stuff I should look at bringing in the static config. --- komorebi/src/core/mod.rs | 13 + komorebi/src/monitor.rs | 9 +- komorebi/src/workspace.rs | 522 +++++++++++++++++++++++++++++++------- 3 files changed, 449 insertions(+), 95 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index f3bf201f..fa3b69c5 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -1,11 +1,13 @@ use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::operation_direction::OperationDirection; +use clap::ValueEnum; use color_eyre::eyre; use serde::Deserialize; use serde::Serialize; use std::str::FromStr; use strum::Display; +use strum::EnumString; pub mod arrangement; pub mod cycle_direction; @@ -22,6 +24,17 @@ pub enum Sizing { Decrease, } +#[derive( + Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, +)] +pub enum WindowContainerBehaviour { + /// Create a new container for each new window + #[default] + Create, + /// Append new windows to the focused window container + Append, +} + #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] #[serde(tag = "type", content = "content")] diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index cbb77f3b..c0b1a712 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -40,8 +40,13 @@ impl Monitor { size, work_area_offset: None, work_area_size, - window_based_work_area_offset: None, - window_based_work_area_offset_limit: 0, + window_based_work_area_offset: Some(Rect { + left: 500, + top: 0, + right: 1000, + bottom: 0, + }), + window_based_work_area_offset_limit: 1, container_padding: None, workspace_padding: None, last_focused_workspace: None, diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 01829dc2..8a350691 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1,4 +1,5 @@ use crate::container::Container; +use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; use crate::core::default_layout::DefaultLayout; use crate::core::default_layout::LayoutOptions; @@ -27,8 +28,12 @@ pub struct Workspace { pub latest_layout: Vec, pub layout_flip: Option, pub layout_options: Option, + pub layout_rules: Vec<(usize, Layout)>, pub globals: WorkspaceGlobals, pub tile: bool, + pub apply_window_based_work_area_offset: bool, + pub window_container_behaviour: Option, + pub window_container_behaviour_rules: Option>, } impl Default for Workspace { @@ -45,8 +50,12 @@ impl Default for Workspace { latest_layout: vec![], layout_flip: None, layout_options: None, + layout_rules: vec![], globals: Default::default(), tile: true, + apply_window_based_work_area_offset: true, + window_container_behaviour: None, + window_container_behaviour_rules: None, } } } @@ -65,99 +74,6 @@ pub struct WorkspaceGlobals { } impl Workspace { - pub fn update(&mut self) -> eyre::Result<()> { - // make sure we are never holding on to empty containers - self.containers_mut().retain(|c| !c.windows().is_empty()); - - let container_padding = self - .container_padding - .or(self.globals.container_padding) - .unwrap_or_default(); - let workspace_padding = self - .workspace_padding - .or(self.globals.workspace_padding) - .unwrap_or_default(); - // let border_width = self.globals.border_width; - // let border_offset = self.globals.border_offset; - let work_area = self.globals.work_area; - let work_area_offset = self.work_area_offset.or(self.globals.work_area_offset); - // let window_based_work_area_offset = self.globals.window_based_work_area_offset; - // let window_based_work_area_offset_limit = - // self.globals.window_based_work_area_offset_limit; - - let mut adjusted_work_area = work_area_offset.map_or_else( - || work_area, - |offset| { - let mut with_offset = work_area; - with_offset.left += offset.left; - with_offset.top += offset.top; - with_offset.right -= offset.right; - with_offset.bottom -= offset.bottom; - - with_offset - }, - ); - - adjusted_work_area.add_padding(workspace_padding); - - #[allow(clippy::collapsible_if)] - if self.tile { - if let Some(container) = self.monocle_container.as_mut() { - if let Some(window) = container.focused_window_mut() { - adjusted_work_area.add_padding(container_padding); - window.set_position(&adjusted_work_area)?; - }; - } else if !self.containers().is_empty() { - let mut layouts = self.layout.as_boxed_arrangement().calculate( - &adjusted_work_area, - NonZeroUsize::new(self.containers().len()).ok_or_else(|| { - eyre!( - "there must be at least one container to calculate a workspace layout" - ) - })?, - Some(container_padding), - self.layout_flip, - &self.resize_dimensions, - self.focused_container_idx(), - self.layout_options, - &self.latest_layout, - ); - - let containers = self.containers_mut(); - - for (i, container) in containers.iter_mut().enumerate() { - if let Some(layout) = layouts.get_mut(i) { - layout.add_padding(container_padding); - for window in container.windows() { - if let Err(error) = window.set_position(layout) { - tracing::warn!("failed to set window position: {error}"); - } - } - } - } - - self.latest_layout = layouts; - } - } - - // Always make sure that the length of the resize dimensions vec is the same as the - // number of layouts / containers. This should never actually truncate as the remove_window - // function takes care of cleaning up resize dimensions when destroying empty containers - let container_count = self.containers().len(); - - // since monocle is a toggle, we never want to truncate the resize dimensions since it will - // almost always be toggled off and the container will be reintegrated into layout - // - // without this check, if there are exactly two containers, when one is toggled to monocle - // the resize dimensions will be truncated to len == 1, and when it is reintegrated, if it - // had a resize adjustment before, that will have been lost - if self.monocle_container.is_none() { - self.resize_dimensions.resize(container_count, None); - } - - Ok(()) - } - #[tracing::instrument(skip(self))] pub fn focus_container(&mut self, idx: usize) { tracing::info!("focusing container"); @@ -561,3 +477,423 @@ impl Workspace { Ok(()) } } + +impl Workspace { + pub fn update(&mut self) -> eyre::Result<()> { + // make sure we are never holding on to empty containers + self.containers_mut().retain(|c| !c.windows().is_empty()); + + let container_padding = self + .container_padding + .or(self.globals.container_padding) + .unwrap_or_default(); + let workspace_padding = self + .workspace_padding + .or(self.globals.workspace_padding) + .unwrap_or_default(); + let border_width = self.globals.border_width; + let border_offset = self.globals.border_offset; + let work_area = self.globals.work_area; + let work_area_offset = self.work_area_offset.or(self.globals.work_area_offset); + let window_based_work_area_offset = self.globals.window_based_work_area_offset; + let window_based_work_area_offset_limit = self.globals.window_based_work_area_offset_limit; + + let mut adjusted_work_area = work_area_offset.map_or_else( + || work_area, + |offset| { + let mut with_offset = work_area; + with_offset.left += offset.left; + with_offset.top += offset.top; + with_offset.right -= offset.right; + with_offset.bottom -= offset.bottom; + + with_offset + }, + ); + + if (self.containers().len() <= window_based_work_area_offset_limit as usize + || self.monocle_container.is_some() && window_based_work_area_offset_limit > 0) + && self.apply_window_based_work_area_offset + { + adjusted_work_area = window_based_work_area_offset.map_or_else( + || adjusted_work_area, + |offset| { + let mut with_offset = adjusted_work_area; + with_offset.left += offset.left; + with_offset.top += offset.top; + with_offset.right -= offset.right; + with_offset.bottom -= offset.bottom; + + with_offset + }, + ); + } + + adjusted_work_area.add_padding(workspace_padding); + + self.enforce_resize_constraints(); + + if !self.layout_rules.is_empty() { + let mut updated_layout = None; + + for (threshold, layout) in &self.layout_rules { + if self.containers().len() >= *threshold { + updated_layout = Option::from(layout.clone()); + } + } + + if let Some(updated_layout) = updated_layout { + self.layout = updated_layout; + } + } + + if let Some(window_container_behaviour_rules) = &self.window_container_behaviour_rules { + let mut updated_behaviour = None; + for (threshold, behaviour) in window_container_behaviour_rules { + if self.containers().len() >= *threshold { + updated_behaviour = Option::from(*behaviour); + } + } + + self.window_container_behaviour = updated_behaviour; + } + + if self.tile { + if let Some(container) = self.monocle_container.as_mut() { + if let Some(window) = container.focused_window_mut() { + adjusted_work_area.add_padding(container_padding); + adjusted_work_area.add_padding(border_offset); + adjusted_work_area.add_padding(border_width); + window.set_position(&adjusted_work_area)?; + }; + } else if !self.containers().is_empty() { + let mut layouts = self.layout.as_boxed_arrangement().calculate( + &adjusted_work_area, + NonZeroUsize::new(self.containers().len()).ok_or_else(|| { + eyre!( + "there must be at least one container to calculate a workspace layout" + ) + })?, + Some(container_padding), + self.layout_flip, + &self.resize_dimensions, + self.focused_container_idx(), + self.layout_options, + &self.latest_layout, + ); + + let containers = self.containers_mut(); + + for (i, container) in containers.iter_mut().enumerate() { + if let Some(layout) = layouts.get_mut(i) { + layout.add_padding(border_offset); + layout.add_padding(border_width); + + for window in container.windows() { + window.set_position(layout)?; + } + } + } + + self.latest_layout = layouts; + } + } + + // Always make sure that the length of the resize dimensions vec is the same as the + // number of layouts / containers. This should never actually truncate as the remove_window + // function takes care of cleaning up resize dimensions when destroying empty containers + let container_count = self.containers().len(); + + // since monocle is a toggle, we never want to truncate the resize dimensions since it will + // almost always be toggled off and the container will be reintegrated into layout + // + // without this check, if there are exactly two containers, when one is toggled to monocle + // the resize dimensions will be truncated to len == 1, and when it is reintegrated, if it + // had a resize adjustment before, that will have been lost + if self.monocle_container.is_none() { + self.resize_dimensions.resize(container_count, None); + } + + Ok(()) + } +} + +impl Workspace { + fn enforce_resize_constraints(&mut self) { + match self.layout { + Layout::Default(DefaultLayout::BSP) => self.enforce_resize_constraints_for_bsp(), + Layout::Default(DefaultLayout::Columns) => self.enforce_resize_for_columns(), + Layout::Default(DefaultLayout::Rows) => self.enforce_resize_for_rows(), + Layout::Default(DefaultLayout::VerticalStack) => { + self.enforce_resize_for_vertical_stack(); + } + Layout::Default(DefaultLayout::RightMainVerticalStack) => { + self.enforce_resize_for_right_vertical_stack(); + } + Layout::Default(DefaultLayout::HorizontalStack) => { + self.enforce_resize_for_horizontal_stack(); + } + Layout::Default(DefaultLayout::UltrawideVerticalStack) => { + self.enforce_resize_for_ultrawide(); + } + Layout::Default(DefaultLayout::Scrolling) => { + self.enforce_resize_for_scrolling(); + } + _ => self.enforce_no_resize(), + } + } + + fn enforce_resize_constraints_for_bsp(&mut self) { + for (i, rect) in self.resize_dimensions.iter_mut().enumerate() { + if let Some(rect) = rect { + // Even containers can't be resized to the bottom + if i % 2 == 0 { + rect.bottom = 0; + // Odd containers can't be resized to the right + } else { + rect.right = 0; + } + } + } + + // The first container can never be resized to the left or the top + if let Some(Some(first)) = self.resize_dimensions.first_mut() { + first.top = 0; + first.left = 0; + } + + // The last container can never be resized to the bottom or the right + if let Some(Some(last)) = self.resize_dimensions.last_mut() { + last.bottom = 0; + last.right = 0; + } + } + + fn enforce_resize_for_columns(&mut self) { + let resize_dimensions = &mut self.resize_dimensions; + match resize_dimensions.len() { + 0 | 1 => self.enforce_no_resize(), + _ => { + let len = resize_dimensions.len(); + for (i, rect) in resize_dimensions.iter_mut().enumerate() { + if let Some(rect) = rect { + rect.top = 0; + rect.bottom = 0; + + if i == 0 { + rect.left = 0; + } + if i == len - 1 { + rect.right = 0; + } + } + } + } + } + } + + fn enforce_resize_for_rows(&mut self) { + let resize_dimensions = &mut self.resize_dimensions; + match resize_dimensions.len() { + 0 | 1 => self.enforce_no_resize(), + _ => { + let len = resize_dimensions.len(); + for (i, rect) in resize_dimensions.iter_mut().enumerate() { + if let Some(rect) = rect { + rect.left = 0; + rect.right = 0; + + if i == 0 { + rect.top = 0; + } + if i == len - 1 { + rect.bottom = 0; + } + } + } + } + } + } + + fn enforce_resize_for_vertical_stack(&mut self) { + let resize_dimensions = &mut self.resize_dimensions; + match resize_dimensions.len() { + // Single window can not be resized at all + 0 | 1 => self.enforce_no_resize(), + _ => { + // Zero is actually on the left + if let Some(mut left) = resize_dimensions[0] { + left.top = 0; + left.bottom = 0; + left.left = 0; + } + + // Handle stack on the right + let stack_size = resize_dimensions[1..].len(); + for (i, rect) in resize_dimensions[1..].iter_mut().enumerate() { + if let Some(rect) = rect { + // No containers can resize to the right + rect.right = 0; + + // First container in stack cant resize up + if i == 0 { + rect.top = 0; + } else if i == stack_size - 1 { + // Last cant be resized to the bottom + rect.bottom = 0; + } + } + } + } + } + } + + fn enforce_resize_for_right_vertical_stack(&mut self) { + let resize_dimensions = &mut self.resize_dimensions; + match resize_dimensions.len() { + // Single window can not be resized at all + 0 | 1 => self.enforce_no_resize(), + _ => { + // Zero is actually on the right + if let Some(mut left) = resize_dimensions[1] { + left.top = 0; + left.bottom = 0; + left.right = 0; + } + + // Handle stack on the right + let stack_size = resize_dimensions[1..].len(); + for (i, rect) in resize_dimensions[1..].iter_mut().enumerate() { + if let Some(rect) = rect { + // No containers can resize to the left + rect.left = 0; + + // First container in stack cant resize up + if i == 0 { + rect.top = 0; + } else if i == stack_size - 1 { + // Last cant be resized to the bottom + rect.bottom = 0; + } + } + } + } + } + } + + fn enforce_resize_for_horizontal_stack(&mut self) { + let resize_dimensions = &mut self.resize_dimensions; + match resize_dimensions.len() { + 0 | 1 => self.enforce_no_resize(), + _ => { + if let Some(mut left) = resize_dimensions[0] { + left.top = 0; + left.left = 0; + left.right = 0; + } + + let stack_size = resize_dimensions[1..].len(); + for (i, rect) in resize_dimensions[1..].iter_mut().enumerate() { + if let Some(rect) = rect { + rect.bottom = 0; + + if i == 0 { + rect.left = 0; + } + if i == stack_size - 1 { + rect.right = 0; + } + } + } + } + } + } + + fn enforce_resize_for_ultrawide(&mut self) { + let resize_dimensions = &mut self.resize_dimensions; + match resize_dimensions.len() { + // Single window can not be resized at all + 0 | 1 => self.enforce_no_resize(), + // Two windows can only be resized in the middle + 2 => { + // Zero is actually on the right + if let Some(mut right) = resize_dimensions[0] { + right.top = 0; + right.bottom = 0; + right.right = 0; + } + + // One is on the left + if let Some(mut left) = resize_dimensions[1] { + left.top = 0; + left.bottom = 0; + left.left = 0; + } + } + // Three or more windows means 0 is in center, 1 is at the left, 2.. are a vertical + // stack on the right + _ => { + // Central can be resized left or right + if let Some(mut right) = resize_dimensions[0] { + right.top = 0; + right.bottom = 0; + } + + // Left one can only be resized to the right + if let Some(mut left) = resize_dimensions[1] { + left.top = 0; + left.bottom = 0; + left.left = 0; + } + + // Handle stack on the right + let stack_size = resize_dimensions[2..].len(); + for (i, rect) in resize_dimensions[2..].iter_mut().enumerate() { + if let Some(rect) = rect { + // No containers can resize to the right + rect.right = 0; + + // First container in stack cant resize up + if i == 0 { + rect.top = 0; + } else if i == stack_size - 1 { + // Last cant be resized to the bottom + rect.bottom = 0; + } + } + } + } + } + } + + fn enforce_resize_for_scrolling(&mut self) { + let resize_dimensions = &mut self.resize_dimensions; + match resize_dimensions.len() { + 0 | 1 => self.enforce_no_resize(), + _ => { + let len = resize_dimensions.len(); + + for (i, rect) in resize_dimensions.iter_mut().enumerate() { + if let Some(rect) = rect { + rect.top = 0; + rect.bottom = 0; + + if i == 0 { + rect.left = 0; + } else if i == len - 1 { + rect.right = 0; + } + } + } + } + } + } + fn enforce_no_resize(&mut self) { + for rect in self.resize_dimensions.iter_mut().flatten() { + rect.left = 0; + rect.right = 0; + rect.top = 0; + rect.bottom = 0; + } + } +} From 71adb1c0e05b778d321642d6b775de89e1912a58 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 18 Sep 2025 18:53:21 -0700 Subject: [PATCH 011/305] feat(wm): implement basic workspace layers This commit implements some of the basic plumbing needed to handle SocketMessage::ToggleWorkspaceLayer and SocketMessage::ToggleFloat. I've commented out a bunch of the raise/lower functions for now because I haven't had time to learn about how changing z-ordering on macOS works yet. Even so, this is fairly functional, and it's possible to move floating windows across workspaces, toggle the workspace layer, move floating windows by the resize delta, and change focus between floating windows. I ended up moving the window restore positions to a global map because storing/updating this kind of state on the Window properly will be a pain because hide/restore now require mut self refs and that leads to needing to clone sometimes. --- justfile | 6 +- komorebi/src/core/mod.rs | 76 ++++++ komorebi/src/lib.rs | 10 + komorebi/src/macos_api.rs | 36 ++- komorebi/src/monitor.rs | 87 +++++++ komorebi/src/process_command.rs | 135 +++++++++- komorebi/src/process_event.rs | 61 ++++- komorebi/src/window.rs | 107 +++++++- komorebi/src/window_manager.rs | 426 ++++++++++++++++++++++++++++++++ komorebi/src/workspace.rs | 190 +++++++++++++- komorebic/src/main.rs | 10 + 11 files changed, 1108 insertions(+), 36 deletions(-) diff --git a/justfile b/justfile index 7af0ca48..2ba71c05 100644 --- a/justfile +++ b/justfile @@ -1,13 +1,13 @@ export RUST_BACKTRACE := "full" -clean: - cargo clean - fmt: cargo +nightly fmt cargo +stable clippy prettier --write README.md +clean: + cargo clean + install target: cargo +stable install --path {{ target }} --locked --target-dir ~/.cargo/bin diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index fa3b69c5..6cb01d82 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -24,6 +24,31 @@ pub enum Sizing { Decrease, } +#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)] +pub struct WindowManagementBehaviour { + /// The current WindowContainerBehaviour to be used + pub current_behaviour: WindowContainerBehaviour, + /// Override of `current_behaviour` to open new windows as floating windows + /// that can be later toggled to tiled, when false it will default to + /// `current_behaviour` again. + pub float_override: bool, + /// Determines if a new window should be spawned floating when on the floating layer and the + /// floating layer behaviour is set to float. This value is always calculated when checking for + /// the management behaviour on a specific workspace. + pub floating_layer_override: bool, + /// The floating layer behaviour to be used if the float override is being used + pub floating_layer_behaviour: FloatingLayerBehaviour, + /// The `Placement` to be used when toggling a window to float + pub toggle_float_placement: Placement, + /// The `Placement` to be used when spawning a window on the floating layer with the + /// `FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float` + pub floating_layer_placement: Placement, + /// The `Placement` to be used when spawning a window with float override active + pub float_override_placement: Placement, + /// The `Placement` to be used when spawning a window that matches a 'floating_applications' rule + pub float_rule_placement: Placement, +} + #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )] @@ -35,6 +60,55 @@ pub enum WindowContainerBehaviour { Append, } +#[derive( + Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, +)] +pub enum FloatingLayerBehaviour { + /// Tile new windows (unless they match a float rule or float override is active) + #[default] + Tile, + /// Float new windows + Float, +} + +#[derive( + Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, +)] +pub enum Placement { + /// Does not change the size or position of the window + #[default] + None, + /// Center the window without changing the size + Center, + /// Center the window and resize it according to the `AspectRatio` + CenterAndResize, +} + +impl FloatingLayerBehaviour { + pub fn should_float(&self) -> bool { + match self { + FloatingLayerBehaviour::Tile => false, + FloatingLayerBehaviour::Float => true, + } + } +} + +impl Placement { + pub fn should_center(&self) -> bool { + match self { + Placement::None => false, + Placement::Center | Placement::CenterAndResize => true, + } + } + + pub fn should_resize(&self) -> bool { + match self { + Placement::None | Placement::Center => false, + Placement::CenterAndResize => true, + } + } +} + #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] #[serde(tag = "type", content = "content")] @@ -48,6 +122,8 @@ pub enum SocketMessage { ChangeLayout(DefaultLayout), TogglePause, ToggleMonocle, + ToggleFloat, + ToggleWorkspaceLayer, FocusWorkspaceNumber(usize), MoveContainerToWorkspaceNumber(usize), SendContainerToWorkspaceNumber(usize), diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index f6903de4..3055f20d 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -2,6 +2,8 @@ use crate::accessibility::error::AccessibilityError; use crate::core_graphics::error::CoreGraphicsError; +use crate::window::AspectRatio; +use crate::window::PredefinedAspectRatio; use core::pathext::PathExt; use lazy_static::lazy_static; use objc2_application_services::AXObserver; @@ -14,9 +16,12 @@ use objc2_core_foundation::CFString; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; +use parking_lot::Mutex; +use std::collections::HashMap; use std::ops::Deref; use std::path::PathBuf; use std::ptr::NonNull; +use std::sync::Arc; use std::sync::atomic::AtomicI32; #[macro_use] @@ -55,6 +60,11 @@ lazy_static! { pub static ref DATA_DIR: PathBuf = dirs::data_local_dir() .expect("there is no local data directory") .join("komorebi"); + static ref FLOATING_WINDOW_TOGGLE_ASPECT_RATIO: Arc> = Arc::new(Mutex::new( + AspectRatio::Predefined(PredefinedAspectRatio::Widescreen) + )); + static ref WINDOW_RESTORE_POSITIONS: Arc>> = + Arc::new(Mutex::new(HashMap::new())); } pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 2bbba371..f47604bf 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -1,4 +1,7 @@ use crate::LibraryError; +use crate::accessibility::AccessibilityApi; +use crate::accessibility::attribute_constants::kAXFocusedApplicationAttribute; +use crate::accessibility::attribute_constants::kAXFocusedWindowAttribute; use crate::accessibility::attribute_constants::kAXPositionAttribute; use crate::accessibility::attribute_constants::kAXSizeAttribute; use crate::accessibility::error::AccessibilityApiError; @@ -17,6 +20,7 @@ use objc2_application_services::AXUIElement; use objc2_application_services::AXValue; use objc2_application_services::AXValueType; use objc2_core_foundation::CFDictionary; +use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFString; use objc2_core_foundation::CGRect; use std::collections::HashMap; @@ -129,9 +133,6 @@ impl MacosApi { let mut position_receiver = std::ptr::null(); let mut size_receiver = std::ptr::null(); - // let mut position_receiver = CGPoint::default(); - // let mut size_receiver = CGSize::default(); - unsafe { match AccessibilityApiError::from(element.copy_attribute_value( &CFString::from_static_str(kAXPositionAttribute), @@ -171,4 +172,33 @@ impl MacosApi { Ok(rect) } } + + pub fn foreground_window_id() -> Option { + unsafe { + let syswide = AXUIElement::new_system_wide(); + let app = AccessibilityApi::copy_attribute_value::( + &syswide, + kAXFocusedApplicationAttribute, + )?; + + let window = AccessibilityApi::copy_attribute_value::( + &app, + kAXFocusedWindowAttribute, + )?; + + AccessibilityApi::window_id(&window).ok() + } + } + + pub fn foreground_window() -> Option> { + unsafe { + let syswide = AXUIElement::new_system_wide(); + let app = AccessibilityApi::copy_attribute_value::( + &syswide, + kAXFocusedApplicationAttribute, + )?; + + AccessibilityApi::copy_attribute_value::(&app, kAXFocusedWindowAttribute) + } + } } diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index c0b1a712..2a1c96e2 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -5,9 +5,11 @@ use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use crate::macos_api::MacosApi; use crate::ring::Ring; use crate::workspace::Workspace; use crate::workspace::WorkspaceGlobals; +use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use color_eyre::eyre::eyre; use std::sync::atomic::Ordering; @@ -138,6 +140,91 @@ impl Monitor { .focused_workspace_mut() .ok_or_else(|| eyre!("there is no workspace"))?; + // if workspace.maximized_window().is_some() { + // return Err(eyre!("cannot move native maximized window to another monitor or workspace")); + // } + + let foreground_hwnd = + MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + let floating_window_index = workspace + .floating_windows() + .iter() + .position(|w| w.id == foreground_hwnd); + + if let Some(idx) = floating_window_index { + if let Some(window) = workspace.floating_windows_mut().remove(idx) { + let workspaces = self.workspaces_mut(); + #[allow(clippy::option_if_let_else)] + let target_workspace = match workspaces.get_mut(target_workspace_idx) { + None => { + workspaces.resize(target_workspace_idx + 1, Workspace::default()); + workspaces.get_mut(target_workspace_idx).unwrap() + } + Some(workspace) => workspace, + }; + + target_workspace.floating_windows_mut().push_back(window); + target_workspace.layer = WorkspaceLayer::Floating; + } + } else { + let container = workspace + .remove_focused_container() + .ok_or_else(|| eyre!("there is no container"))?; + + let workspaces = self.workspaces_mut(); + + #[allow(clippy::option_if_let_else)] + let target_workspace = match workspaces.get_mut(target_workspace_idx) { + None => { + workspaces.resize(target_workspace_idx + 1, Workspace::default()); + workspaces.get_mut(target_workspace_idx).unwrap() + } + Some(workspace) => workspace, + }; + + if target_workspace.monocle_container.is_some() { + for container in target_workspace.containers_mut() { + container.restore()?; + } + + for window in target_workspace.floating_windows_mut() { + window.restore()?; + } + + target_workspace.reintegrate_monocle_container()?; + } + + target_workspace.layer = WorkspaceLayer::Tiling; + + if let Some(direction) = direction { + self.add_container_with_direction( + container, + Some(target_workspace_idx), + direction, + )?; + } else { + target_workspace.add_container_to_back(container); + } + } + + if follow { + self.focus_workspace(target_workspace_idx)?; + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn move_container_to_workspace1( + &mut self, + target_workspace_idx: usize, + follow: bool, + direction: Option, + ) -> eyre::Result<()> { + let workspace = self + .focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace"))?; + let container = workspace .remove_focused_container() .ok_or_else(|| eyre!("there is no container"))?; diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 66031711..01f7b26b 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,5 +1,8 @@ use crate::core::SocketMessage; +use crate::core::rect::Rect; +use crate::macos_api::MacosApi; use crate::window_manager::WindowManager; +use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use parking_lot::Mutex; use std::io::BufRead; @@ -57,12 +60,30 @@ impl WindowManager { message: SocketMessage, mut _reply: impl std::io::Write, ) -> eyre::Result<()> { + tracing::info!("processing command: {message}"); + match message { SocketMessage::FocusWindow(direction) => { - self.focus_container_in_direction(direction)?; + let focused_workspace = self.focused_workspace()?; + match focused_workspace.layer { + WorkspaceLayer::Tiling => { + self.focus_container_in_direction(direction)?; + } + WorkspaceLayer::Floating => { + self.focus_floating_window_in_direction(direction)?; + } + } } SocketMessage::MoveWindow(direction) => { - self.move_container_in_direction(direction)?; + let focused_workspace = self.focused_workspace()?; + match focused_workspace.layer { + WorkspaceLayer::Tiling => { + self.move_container_in_direction(direction)?; + } + WorkspaceLayer::Floating => { + self.move_floating_window_in_direction(direction)?; + } + } } SocketMessage::StackWindow(direction) => self.add_window_to_container(direction)?, SocketMessage::UnstackWindow => self.remove_window_from_container()?, @@ -91,6 +112,116 @@ impl WindowManager { self.move_container_to_workspace(workspace_idx, false, None)?; } SocketMessage::ToggleMonocle => self.toggle_monocle()?, + SocketMessage::ToggleFloat => self.toggle_float(false)?, + SocketMessage::ToggleWorkspaceLayer => { + let mouse_follows_focus = self.mouse_follows_focus; + let workspace = self.focused_workspace_mut()?; + + let mut to_focus = None; + match workspace.layer { + WorkspaceLayer::Tiling => { + workspace.layer = WorkspaceLayer::Floating; + tracing::info!("WorkspaceLayer is now Floating"); + + let focused_idx = workspace.focused_floating_window_idx(); + let mut window_idx_pairs = workspace + .floating_windows_mut() + .make_contiguous() + .iter_mut() + .enumerate() + .collect::>(); + + // Sort by window area + window_idx_pairs.sort_by_key(|(_, w)| { + let rect = + Rect::from(MacosApi::window_rect(&w.element).unwrap_or_default()); + rect.right * rect.bottom + }); + window_idx_pairs.reverse(); + + for (i, window) in window_idx_pairs { + if i == focused_idx { + to_focus = Some(window.clone()); + } else { + window.restore()?; + window.raise()?; + } + } + + if let Some(focused_window) = &mut to_focus { + // The focused window should be the last one raised to make sure it is + // on top + focused_window.restore()?; + focused_window.raise()?; + } + + for container in workspace.containers() { + if let Some(_window) = container.focused_window() { + // todo: figure out z order + // window.lower()?; + } + } + + if let Some(monocle) = &workspace.monocle_container + && let Some(_window) = monocle.focused_window() + { + // todo: figure out z order + // window.lower()?; + } + } + WorkspaceLayer::Floating => { + workspace.layer = WorkspaceLayer::Tiling; + tracing::info!("WorkspaceLayer is now Tiling"); + + if let Some(monocle) = &workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + to_focus = Some(window.clone()); + window.raise()?; + } + + for window in workspace.floating_windows_mut() { + window.hide()?; + } + } else { + let focused_container_idx = workspace.focused_container_idx(); + for (i, container) in workspace.containers_mut().iter_mut().enumerate() + { + if let Some(window) = container.focused_window() { + if i == focused_container_idx { + to_focus = Some(window.clone()); + } + + window.raise()?; + } + } + + let mut window_idx_pairs = workspace + .floating_windows_mut() + .make_contiguous() + .iter_mut() + .collect::>(); + + // Sort by window area + window_idx_pairs.sort_by_key(|w| { + let rect = Rect::from( + MacosApi::window_rect(&w.element).unwrap_or_default(), + ); + rect.right * rect.bottom + }); + + for window in window_idx_pairs { + // todo: figure out z order + window.hide()?; + // window.lower()?; + } + } + } + }; + + if let Some(window) = to_focus { + window.focus(mouse_follows_focus)?; + } + } } Ok(()) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 2ad477af..9543f750 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,8 +1,11 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::notification_constants::AccessibilityNotification; +use crate::core::default_layout::DefaultLayout; +use crate::core::layout::Layout; use crate::window::Window; use crate::window_manager::WindowManager; use crate::window_manager_event::WindowManagerEvent; +use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use parking_lot::Mutex; use std::sync::Arc; @@ -38,15 +41,66 @@ impl WindowManager { return Ok(()); } - tracing::info!("processing event: {event}"); + tracing::info!( + "processing event: {event} for process {}", + event.process_id() + ); match event { WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; if let Some(window_id) = application.main_window_id() { - self.focused_workspace_mut()? - .focus_container_by_window(window_id)?; + // todo: figure out if this applies on macOS too + // don't want to trigger the full workspace updates when there are no managed + // containers - this makes floating windows on empty workspaces go into very + // annoying focus change loops which prevents users from interacting with them + if !matches!( + self.focused_workspace()?.layout, + Layout::Default(DefaultLayout::Scrolling) + ) && !self.focused_workspace()?.containers().is_empty() + { + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } + + let workspace = self.focused_workspace_mut()?; + let floating_window_idx = workspace + .floating_windows() + .iter() + .position(|w| w.id == window_id); + + match floating_window_idx { + None => { + // if let Some(w) = workspace.maximized_window() { + // if w.hwnd == window_id { + // return Ok(()); + // } + // } + + if let Some(monocle) = &workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(false)?; + } + } else { + workspace.focus_container_by_window(window_id)?; + } + + workspace.layer = WorkspaceLayer::Tiling; + + if matches!( + self.focused_workspace()?.layout, + Layout::Default(DefaultLayout::Scrolling) + ) && !self.focused_workspace()?.containers().is_empty() + { + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } + } + Some(idx) => { + if let Some(_window) = workspace.floating_windows().get(idx) { + workspace.layer = WorkspaceLayer::Floating; + } + } + } } if matches!(notification, AccessibilityNotification::AXMainWindowChanged) { @@ -54,6 +108,7 @@ impl WindowManager { self.update_focused_workspace(false, false)?; } } + // todo: upate this to work with floating applications / rules WindowManagerEvent::Show(_, process_id) => { let mut window_id = None; let mut window_element = None; diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 1e9235a3..65fd6732 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -1,7 +1,10 @@ use crate::AccessibilityObserver; use crate::AccessibilityUiElement; +use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO; use crate::LibraryError; +use crate::WINDOW_RESTORE_POSITIONS; use crate::accessibility::AccessibilityApi; +use crate::accessibility::attribute_constants::kAXFocusedAttribute; use crate::accessibility::attribute_constants::kAXMainAttribute; use crate::accessibility::attribute_constants::kAXMinimizedAttribute; use crate::accessibility::attribute_constants::kAXPositionAttribute; @@ -42,9 +45,14 @@ use objc2_core_graphics::kCGWindowBounds; use objc2_core_graphics::kCGWindowName; use objc2_core_graphics::kCGWindowOwnerName; use objc2_core_graphics::kCGWindowOwnerPID; +use serde::Deserialize; +use serde::Serialize; +use std::collections::hash_map::Entry; use std::ffi::c_void; use std::ptr::NonNull; use std::str::FromStr; +use strum::Display; +use strum::EnumString; use tracing::instrument; const NOTIFICATIONS: &[&str] = &[ @@ -143,10 +151,9 @@ impl WindowInfo { #[allow(unused)] pub struct Window { pub id: u32, - element: AccessibilityUiElement, + pub element: AccessibilityUiElement, pub application: Application, observer: AccessibilityObserver, - pub restore_point: Option<(f32, f32)>, } impl Drop for Window { @@ -181,7 +188,6 @@ impl Window { element: AccessibilityUiElement(element), application, observer: AccessibilityObserver(observer), - restore_point: None, }) } @@ -208,11 +214,14 @@ impl Window { #[tracing::instrument(skip_all)] pub fn hide(&mut self) -> Result<(), AccessibilityError> { - // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API - if self.restore_point.is_none() { + let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); + if let Entry::Vacant(entry) = window_restore_positions.entry(self.id) { let rect = MacosApi::window_rect(&self.element)?; if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { - self.restore_point = Some((rect.origin.x as f32, rect.origin.y as f32)); + entry.insert(rect); + drop(window_restore_positions); + + // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); tracing::debug!( @@ -245,20 +254,22 @@ impl Window { #[tracing::instrument(skip_all)] pub fn restore(&mut self) -> Result<(), AccessibilityError> { - let mut should_unset_restore_point = false; - if let Some((x, y)) = self.restore_point { + let mut should_remove_restore_position = false; + let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); + if let Some(cg_rect) = window_restore_positions.get(&self.id) { tracing::debug!( - "restoring {:?} to point {x},{y}", + "restoring {:?} to {cg_rect:?}", self.title() .unwrap_or_else(|| String::from("")) ); - self.set_point(CGPoint::new(x as CGFloat, y as CGFloat))?; - should_unset_restore_point = true; + self.set_point(cg_rect.origin)?; + self.set_size(cg_rect.size)?; + should_remove_restore_position = true; } - if should_unset_restore_point { - self.restore_point = None; + if should_remove_restore_position { + window_restore_positions.remove(&self.id); } Ok(()) @@ -296,6 +307,13 @@ impl Window { Ok(()) } + pub fn raise(&self) -> Result<(), AccessibilityError> { + let cf_boolean = CFBoolean::new(true); + let value = &**cf_boolean; + AccessibilityApi::set_attribute_cf_value(&self.element, kAXMainAttribute, value)?; + AccessibilityApi::set_attribute_cf_value(&self.element, kAXFocusedAttribute, value) + } + pub fn set_point(&self, point: CGPoint) -> Result<(), AccessibilityError> { AccessibilityApi::set_attribute_ax_value( &self.element, @@ -313,6 +331,30 @@ impl Window { size, ) } + + pub fn center(&mut self, work_area: &Rect, resize: bool) -> Result<(), AccessibilityError> { + let (target_width, target_height) = if resize { + let (aspect_ratio_width, aspect_ratio_height) = FLOATING_WINDOW_TOGGLE_ASPECT_RATIO + .lock() + .width_and_height(); + let target_height = work_area.bottom / 2; + let target_width = (target_height * aspect_ratio_width) / aspect_ratio_height; + (target_width, target_height) + } else { + let current_rect = Rect::from(MacosApi::window_rect(&self.element)?); + (current_rect.right, current_rect.bottom) + }; + + let x = work_area.left + ((work_area.right - target_width) / 2); + let y = work_area.top + ((work_area.bottom - target_height) / 2); + + self.set_position(&Rect { + left: x, + top: y, + right: target_width, + bottom: target_height, + }) + } } impl From<&CFDictionary> for WindowInfo { @@ -376,3 +418,42 @@ impl From<&CFDictionary> for WindowBounds { } } } + +#[derive(Copy, Clone, Debug, Display, EnumString, Serialize, Deserialize, PartialEq)] +#[serde(untagged)] +pub enum AspectRatio { + /// A predefined aspect ratio + Predefined(PredefinedAspectRatio), + /// A custom W:H aspect ratio + Custom(i32, i32), +} + +impl Default for AspectRatio { + fn default() -> Self { + AspectRatio::Predefined(PredefinedAspectRatio::default()) + } +} + +#[derive(Copy, Clone, Debug, Default, Display, EnumString, Serialize, Deserialize, PartialEq)] +pub enum PredefinedAspectRatio { + /// 21:9 + Ultrawide, + /// 16:9 + Widescreen, + /// 4:3 + #[default] + Standard, +} + +impl AspectRatio { + pub fn width_and_height(self) -> (i32, i32) { + match self { + AspectRatio::Predefined(predefined) => match predefined { + PredefinedAspectRatio::Ultrawide => (21, 9), + PredefinedAspectRatio::Widescreen => (16, 9), + PredefinedAspectRatio::Standard => (4, 3), + }, + AspectRatio::Custom(w, h) => (w, h), + } + } +} diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 4dc5f2a6..2f440fb0 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -4,6 +4,8 @@ use crate::LibraryError; use crate::accessibility::AccessibilityApi; use crate::application::Application; use crate::container::Container; +use crate::core::Placement; +use crate::core::WindowManagementBehaviour; use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; @@ -15,6 +17,7 @@ use crate::ring::Ring; use crate::window::Window; use crate::window_manager_event::WindowManagerEvent; use crate::workspace::Workspace; +use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use color_eyre::eyre::eyre; use crossbeam_channel::Receiver; @@ -34,6 +37,8 @@ pub struct WindowManager { pub run_loop: CoreFoundationRunLoop, pub command_listener: UnixListener, pub is_paused: bool, + pub resize_delta: i32, + pub window_management_behaviour: WindowManagementBehaviour, pub mouse_follows_focus: bool, pub work_area_offset: Option, pub incoming_events: Receiver, @@ -43,6 +48,7 @@ pub struct WindowManager { impl_ring_elements!(WindowManager, Monitor); impl WindowManager { + #[allow(clippy::field_reassign_with_default)] pub fn new( run_loop: &CFRetained, incoming: Receiver, @@ -62,12 +68,18 @@ impl WindowManager { let listener = UnixListener::bind(&socket)?; + // todo: undo this when we get config + let mut behaviour = WindowManagementBehaviour::default(); + behaviour.toggle_float_placement = Placement::CenterAndResize; + Ok(Self { monitors: Ring::default(), applications: Default::default(), run_loop: CoreFoundationRunLoop(run_loop.clone()), command_listener: listener, is_paused: false, + resize_delta: 50, + window_management_behaviour: behaviour, mouse_follows_focus: true, work_area_offset: None, incoming_events: incoming, @@ -93,6 +105,265 @@ impl WindowManager { } } + #[tracing::instrument(skip(self))] + pub fn focus_floating_window_in_direction( + &mut self, + direction: OperationDirection, + ) -> eyre::Result<()> { + let mouse_follows_focus = self.mouse_follows_focus; + let focused_workspace = self.focused_workspace_mut()?; + + let mut target_idx = None; + let len = focused_workspace.floating_windows().len(); + + if len > 1 { + let focused_window_id = + MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + let focused_rect = Rect::from(MacosApi::window_rect( + MacosApi::foreground_window() + .ok_or(eyre!("no foreground window"))? + .as_ref(), + )?); + + match direction { + OperationDirection::Left => { + let mut windows_in_direction = focused_workspace + .floating_windows() + .iter() + .enumerate() + .flat_map(|(idx, w)| { + (w.id != focused_window_id).then_some( + MacosApi::window_rect(&w.element) + .ok() + .map(|r| (idx, Rect::from(r))), + ) + }) + .flatten() + .flat_map(|(idx, r)| { + (r.left < focused_rect.left) + .then_some((idx, i32::abs(r.left - focused_rect.left))) + }) + .collect::>(); + + // Sort by distance to focused + windows_in_direction.sort_by_key(|(_, d)| (*d as f32 * 1000.0).trunc() as i32); + + if let Some((idx, _)) = windows_in_direction.first() { + target_idx = Some(*idx); + } + } + OperationDirection::Right => { + let mut windows_in_direction = focused_workspace + .floating_windows() + .iter() + .enumerate() + .flat_map(|(idx, w)| { + (w.id != focused_window_id).then_some( + MacosApi::window_rect(&w.element) + .ok() + .map(|r| (idx, Rect::from(r))), + ) + }) + .flatten() + .flat_map(|(idx, r)| { + (r.left > focused_rect.left) + .then_some((idx, i32::abs(r.left - focused_rect.left))) + }) + .collect::>(); + + // Sort by distance to focused + windows_in_direction.sort_by_key(|(_, d)| (*d as f32 * 1000.0).trunc() as i32); + + if let Some((idx, _)) = windows_in_direction.first() { + target_idx = Some(*idx); + } + } + OperationDirection::Up => { + let mut windows_in_direction = focused_workspace + .floating_windows() + .iter() + .enumerate() + .flat_map(|(idx, w)| { + (w.id != focused_window_id).then_some( + MacosApi::window_rect(&w.element) + .ok() + .map(|r| (idx, Rect::from(r))), + ) + }) + .flatten() + .flat_map(|(idx, r)| { + (r.top < focused_rect.top) + .then_some((idx, i32::abs(r.top - focused_rect.top))) + }) + .collect::>(); + + // Sort by distance to focused + windows_in_direction.sort_by_key(|(_, d)| (*d as f32 * 1000.0).trunc() as i32); + + if let Some((idx, _)) = windows_in_direction.first() { + target_idx = Some(*idx); + } + } + OperationDirection::Down => { + let mut windows_in_direction = focused_workspace + .floating_windows() + .iter() + .enumerate() + .flat_map(|(idx, w)| { + (w.id != focused_window_id).then_some( + MacosApi::window_rect(&w.element) + .ok() + .map(|r| (idx, Rect::from(r))), + ) + }) + .flatten() + .flat_map(|(idx, r)| { + (r.top > focused_rect.top) + .then_some((idx, i32::abs(r.top - focused_rect.top))) + }) + .collect::>(); + + // Sort by distance to focused + windows_in_direction.sort_by_key(|(_, d)| (*d as f32 * 1000.0).trunc() as i32); + + if let Some((idx, _)) = windows_in_direction.first() { + target_idx = Some(*idx); + } + } + }; + } + + if let Some(idx) = target_idx { + focused_workspace.floating_windows.focus(idx); + if let Some(window) = focused_workspace.floating_windows().get(idx) { + window.focus(mouse_follows_focus)?; + } + return Ok(()); + } + + // let mut cross_monitor_monocle_or_max = false; + + // let workspace_idx = self.focused_workspace_idx()?; + + // this is for when we are scrolling across workspaces like PaperWM + // if matches!( + // self.cross_boundary_behaviour, + // CrossBoundaryBehaviour::Workspace + // ) && matches!( + // direction, + // OperationDirection::Left | OperationDirection::Right + // ) { + // let workspace_count = if let Some(monitor) = self.focused_monitor() { + // monitor.workspaces().len() + // } else { + // 1 + // }; + // + // let next_idx = match direction { + // OperationDirection::Left => match workspace_idx { + // 0 => workspace_count - 1, + // n => n - 1, + // }, + // OperationDirection::Right => match workspace_idx { + // n if n == workspace_count - 1 => 0, + // n => n + 1, + // }, + // _ => workspace_idx, + // }; + // + // self.focus_workspace(next_idx)?; + // + // if let Ok(focused_workspace) = self.focused_workspace_mut() { + // if focused_workspace.monocle_container.is_none() { + // match direction { + // OperationDirection::Left => match focused_workspace.layout { + // Layout::Default(layout) => { + // let target_index = + // layout.rightmost_index(focused_workspace.containers().len()); + // focused_workspace.focus_container(target_index); + // } + // }, + // OperationDirection::Right => match focused_workspace.layout { + // Layout::Default(layout) => { + // let target_index = + // layout.leftmost_index(focused_workspace.containers().len()); + // focused_workspace.focus_container(target_index); + // } + // }, + // _ => {} + // }; + // } + // } + // + // return Ok(()); + // } + + // if there is no floating_window in that direction for this workspace + // let monitor_idx = self + // .monitor_idx_in_direction(direction) + // .ok_or_else(|| eyre!("there is no container or monitor in this direction"))?; + // + // self.focus_monitor(monitor_idx)?; + // let mouse_follows_focus = self.mouse_follows_focus; + // + // if let Ok(focused_workspace) = self.focused_workspace_mut() { + // // if let Some(window) = focused_workspace.maximized_window() { + // // window.focus(mouse_follows_focus)?; + // // cross_monitor_monocle_or_max = true; + // // } else + // if let Some(monocle) = focused_workspace.monocle_container { + // if let Some(window) = monocle.focused_window() { + // window.focus(mouse_follows_focus)?; + // cross_monitor_monocle_or_max = true; + // } + // } else if focused_workspace.layer == WorkspaceLayer::Tiling { + // match direction { + // OperationDirection::Left => match focused_workspace.layout { + // Layout::Default(layout) => { + // let target_index = + // layout.rightmost_index(focused_workspace.containers().len()); + // focused_workspace.focus_container(target_index); + // } + // }, + // OperationDirection::Right => match focused_workspace.layout { + // Layout::Default(layout) => { + // let target_index = + // layout.leftmost_index(focused_workspace.containers().len()); + // focused_workspace.focus_container(target_index); + // } + // }, + // _ => {} + // }; + // } + // } + // + // if !cross_monitor_monocle_or_max { + // let ws = self.focused_workspace_mut()?; + // if ws.is_empty() { + // // This is to remove focus from the previous monitor + // let desktop_window = Window::from(MacosApi::desktop_window()?); + // + // match MacosApi::raise_and_focus_window(desktop_window.id) { + // Ok(()) => {} + // Err(error) => { + // tracing::warn!("{} {}:{}", error, file!(), line!()); + // } + // } + // } else if ws.layer == WorkspaceLayer::Floating && !ws.floating_windows().is_empty() { + // if let Some(window) = ws.focused_floating_window() { + // window.focus(self.mouse_follows_focus)?; + // } + // } else { + // ws.layer = WorkspaceLayer::Tiling; + // if let Ok(focused_window) = self.focused_window() { + // focused_window.focus(self.mouse_follows_focus)?; + // } + // } + // } + + Ok(()) + } + #[tracing::instrument(skip(self))] pub fn focus_container_in_direction( &mut self, @@ -117,6 +388,85 @@ impl WindowManager { Ok(()) } + #[tracing::instrument(skip(self))] + pub fn move_floating_window_in_direction( + &mut self, + direction: OperationDirection, + ) -> eyre::Result<()> { + let mouse_follows_focus = self.mouse_follows_focus; + + let mut focused_monitor_work_area = self.focused_monitor_work_area()?; + let border_offset = 0; + let border_width = 0; + focused_monitor_work_area.left += border_offset; + focused_monitor_work_area.left += border_width; + focused_monitor_work_area.top += border_offset; + focused_monitor_work_area.top += border_width; + focused_monitor_work_area.right -= border_offset * 2; + focused_monitor_work_area.right -= border_width * 2; + focused_monitor_work_area.bottom -= border_offset * 2; + focused_monitor_work_area.bottom -= border_width * 2; + + let focused_workspace = self.focused_workspace()?; + let delta = self.resize_delta; + + let focused_window_id = + MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + for window in focused_workspace.floating_windows().iter() { + if window.id == focused_window_id { + let mut rect = Rect::from(MacosApi::window_rect(&window.element)?); + match direction { + OperationDirection::Left => { + if rect.left - delta < focused_monitor_work_area.left { + rect.left = focused_monitor_work_area.left; + } else { + rect.left -= delta; + } + } + OperationDirection::Right => { + if rect.left + delta + rect.right + > focused_monitor_work_area.left + focused_monitor_work_area.right + { + rect.left = focused_monitor_work_area.left + + focused_monitor_work_area.right + - rect.right; + } else { + rect.left += delta; + } + } + OperationDirection::Up => { + if rect.top - delta < focused_monitor_work_area.top { + rect.top = focused_monitor_work_area.top; + } else { + rect.top -= delta; + } + } + OperationDirection::Down => { + if rect.top + delta + rect.bottom + > focused_monitor_work_area.top + focused_monitor_work_area.bottom + { + rect.top = focused_monitor_work_area.top + + focused_monitor_work_area.bottom + - rect.bottom; + } else { + rect.top += delta; + } + } + } + + window.set_position(&rect)?; + + if mouse_follows_focus { + MacosApi::center_cursor_in_rect(&rect)?; + } + + break; + } + } + + Ok(()) + } + #[tracing::instrument(skip(self))] pub fn move_container_in_direction( &mut self, @@ -262,6 +612,20 @@ impl WindowManager { .ok_or_else(|| eyre!("there is no window")) } + pub fn focused_monitor_size(&self) -> eyre::Result { + Ok(self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))? + .size) + } + + pub fn focused_monitor_work_area(&self) -> eyre::Result { + Ok(self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))? + .work_area_size) + } + pub fn extract_minimized_window(&mut self, window_id: u32) -> eyre::Result<()> { let workspace = self.focused_workspace_mut()?; let window = workspace.remove_window(window_id)?; @@ -494,4 +858,66 @@ impl WindowManager { workspace.reintegrate_monocle_container() } + + #[tracing::instrument(skip(self))] + pub fn toggle_float(&mut self, force_float: bool) -> eyre::Result<()> { + let window_id = MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + + let workspace = self.focused_workspace_mut()?; + if workspace.monocle_container.is_some() { + tracing::warn!("ignoring toggle-float command while workspace has a monocle container"); + return Ok(()); + } + + let mut is_floating_window = false; + + for window in workspace.floating_windows() { + if window.id == window_id { + is_floating_window = true; + } + } + + if is_floating_window && !force_float { + workspace.layer = WorkspaceLayer::Tiling; + self.unfloat_window()?; + } else { + workspace.layer = WorkspaceLayer::Floating; + self.float_window()?; + } + + self.update_focused_workspace(is_floating_window, true) + } + + #[tracing::instrument(skip(self))] + pub fn float_window(&mut self) -> eyre::Result<()> { + tracing::info!("floating window"); + + let mouse_follows_focus = self.mouse_follows_focus; + let work_area = self.focused_monitor_work_area()?; + + let toggle_float_placement = self.window_management_behaviour.toggle_float_placement; + + let workspace = self.focused_workspace_mut()?; + workspace.new_floating_window()?; + + let window = workspace + .floating_windows_mut() + .back_mut() + .ok_or_else(|| eyre!("there is no floating window"))?; + + if toggle_float_placement.should_center() { + window.center(&work_area, toggle_float_placement.should_resize())?; + } + window.focus(mouse_follows_focus)?; + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn unfloat_window(&mut self) -> eyre::Result<()> { + tracing::info!("unfloating window"); + + let workspace = self.focused_workspace_mut()?; + workspace.new_container_for_floating_window() + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 8a350691..df3f733b 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1,4 +1,5 @@ use crate::container::Container; +use crate::core::FloatingLayerBehaviour; use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; use crate::core::default_layout::DefaultLayout; @@ -7,41 +8,71 @@ use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::lockable_sequence::LockableSequence; +use crate::macos_api::MacosApi; use crate::ring::Ring; use crate::window::Window; use color_eyre::eyre; use color_eyre::eyre::eyre; +use serde::Deserialize; +use serde::Serialize; +use std::fmt::Display; +use std::fmt::Formatter; use std::num::NonZeroUsize; -impl_ring_elements!(Workspace, Container); - #[derive(Debug, Clone)] pub struct Workspace { pub containers: Ring, pub monocle_container: Option, pub monocle_container_restore_idx: Option, - pub workspace_padding: Option, - pub container_padding: Option, - pub resize_dimensions: Vec>, + pub maximized_window: Option, + pub maximized_window_restore_idx: Option, + pub floating_windows: Ring, pub layout: Layout, - pub work_area_offset: Option, - pub latest_layout: Vec, - pub layout_flip: Option, pub layout_options: Option, pub layout_rules: Vec<(usize, Layout)>, - pub globals: WorkspaceGlobals, + pub layout_flip: Option, + pub workspace_padding: Option, + pub container_padding: Option, + pub latest_layout: Vec, + pub resize_dimensions: Vec>, pub tile: bool, + pub work_area_offset: Option, pub apply_window_based_work_area_offset: bool, pub window_container_behaviour: Option, pub window_container_behaviour_rules: Option>, + pub float_override: Option, + pub globals: WorkspaceGlobals, + pub layer: WorkspaceLayer, + pub floating_layer_behaviour: Option, } +#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub enum WorkspaceLayer { + #[default] + Tiling, + Floating, +} + +impl Display for WorkspaceLayer { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + WorkspaceLayer::Tiling => write!(f, "Tiling"), + WorkspaceLayer::Floating => write!(f, "Floating"), + } + } +} + +impl_ring_elements!(Workspace, Container); +impl_ring_elements!(Workspace, Window, "floating_window"); + impl Default for Workspace { fn default() -> Self { Self { containers: Default::default(), monocle_container: None, monocle_container_restore_idx: None, + maximized_window: None, + maximized_window_restore_idx: None, workspace_padding: None, container_padding: None, resize_dimensions: vec![], @@ -52,10 +83,14 @@ impl Default for Workspace { layout_options: None, layout_rules: vec![], globals: Default::default(), + layer: Default::default(), tile: true, apply_window_based_work_area_offset: true, window_container_behaviour: None, window_container_behaviour_rules: None, + floating_windows: Default::default(), + float_override: None, + floating_layer_behaviour: None, } } } @@ -348,11 +383,30 @@ impl Workspace { } pub fn hide(&mut self, omit: Option) -> eyre::Result<()> { + for window in self.floating_windows_mut().iter_mut().rev() { + let mut should_hide = omit.is_none(); + + if !should_hide + && let Some(omit) = omit + && omit != window.id + { + should_hide = true + } + + if should_hide { + window.hide()?; + } + } + for container in self.containers_mut() { container.hide(omit)?; } - if let Some(container) = self.monocle_container.as_mut() { + // if let Some(window) = self.maximized_window() { + // window.hide(); + // } + + if let Some(container) = &mut self.monocle_container { container.hide(omit)?; } @@ -360,8 +414,9 @@ impl Workspace { } pub fn restore(&mut self, mouse_follows_focus: bool) -> eyre::Result<()> { - if let Some(container) = self.monocle_container.as_mut() { + if let Some(container) = &mut self.monocle_container { container.restore()?; + if let Some(window) = container.focused_window() { window.focus(mouse_follows_focus)?; } @@ -386,8 +441,28 @@ impl Workspace { container.focus_window(container.focused_window_idx()); } + for window in self.floating_windows_mut() { + window.restore()?; + } + // Do this here to make sure that an error doesn't stop the restoration of other windows + // Maximised windows and floating windows should always be drawn at the top of the Z order + // when switching to a workspace if let Some(window) = to_focus { - window.focus(mouse_follows_focus)?; + if + /* self.maximized_window().is_none() && */ + matches!(self.layer, WorkspaceLayer::Tiling) { + window.focus(mouse_follows_focus)?; + // } else if let Some(maximized_window) = self.maximized_window() { + // maximized_window.restore(); + // maximized_window.focus(mouse_follows_focus)?; + } else if let Some(floating_window) = self.focused_floating_window() { + floating_window.focus(mouse_follows_focus)?; + } + // } else if let Some(maximized_window) = self.maximized_window() { + // maximized_window.restore(); + // maximized_window.focus(mouse_follows_focus)?; + } else if let Some(floating_window) = self.focused_floating_window() { + floating_window.focus(mouse_follows_focus)?; } Ok(()) @@ -476,6 +551,97 @@ impl Workspace { Ok(()) } + + pub fn new_floating_window(&mut self) -> eyre::Result<()> { + let window = if let Some(monocle_container) = &mut self.monocle_container { + let window = monocle_container + .remove_focused_window() + .ok_or_else(|| eyre!("there is no window"))?; + + if monocle_container.windows().is_empty() { + self.monocle_container = None; + self.monocle_container_restore_idx = None; + } else { + monocle_container.load_focused_window()?; + } + + window + } else { + let focused_idx = self.focused_container_idx(); + + let container = self + .focused_container_mut() + .ok_or_else(|| eyre!("there is no container"))?; + + let window = container + .remove_focused_window() + .ok_or_else(|| eyre!("there is no window"))?; + + if container.windows().is_empty() { + self.remove_container_by_idx(focused_idx); + + if focused_idx == self.containers().len() { + self.focus_container(focused_idx.saturating_sub(1)); + } + } else { + container.load_focused_window()?; + } + + window + }; + + self.floating_windows_mut().push_back(window); + + Ok(()) + } + + pub fn new_container_for_floating_window(&mut self) -> eyre::Result<()> { + let focused_idx = self.focused_container_idx(); + let window = self + .remove_focused_floating_window() + .ok_or_else(|| eyre!("there is no floating window"))?; + + let mut container = Container::default(); + container.add_window(&window)?; + + self.insert_container_at_idx(focused_idx, container); + + Ok(()) + } + + pub fn remove_focused_floating_window(&mut self) -> Option { + let window_id = MacosApi::foreground_window_id()?; + + let mut idx = None; + for (i, window) in self.floating_windows().iter().enumerate() { + if window_id == window.id { + idx = Option::from(i); + } + } + + match idx { + None => None, + Some(idx) => { + if self.floating_windows().get(idx).is_some() { + self.focus_previous_floating_window(); + self.floating_windows_mut().remove(idx) + } else { + None + } + } + } + } + + pub fn focus_previous_floating_window(&mut self) { + let focused_idx = self.focused_floating_window_idx(); + self.focus_floating_window(focused_idx.saturating_sub(1)); + } + + pub fn focus_floating_window(&mut self, idx: usize) { + tracing::info!("focusing floating window"); + + self.floating_windows.focus(idx); + } } impl Workspace { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 56edffe8..b789ae4d 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -105,6 +105,10 @@ enum SubCommand { TogglePause, /// Toggle monocle mode for the focused container ToggleMonocle, + /// Toggle floating mode for the focused window + ToggleFloat, + /// Toggle between the Tiling and Floating layers on the focused workspace + ToggleWorkspaceLayer, /// Set the layout on the focused workspace #[clap(arg_required_else_help = true)] ChangeLayout(ChangeLayout), @@ -156,6 +160,12 @@ fn main() -> eyre::Result<()> { SubCommand::ToggleMonocle => { send_message(&SocketMessage::ToggleMonocle)?; } + SubCommand::ToggleFloat => { + send_message(&SocketMessage::ToggleFloat)?; + } + SubCommand::ToggleWorkspaceLayer => { + send_message(&SocketMessage::ToggleWorkspaceLayer)?; + } } Ok(()) From c1cf94b23ffeb80f79207868b8c2807e6d746c41 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 09:33:54 -0700 Subject: [PATCH 012/305] feat(wm): implement resizing and retiling This commit migrates the code from komorebi required to implement the ResizeWindowEdge, ResizeWindowAxis, Retile and RetileWithResizeDimensions SocketMessage variants, as well as the related komorebic commands to emit those SocketMessages. --- komorebi-client/src/lib.rs | 2 + komorebi/src/core/arrangement.rs | 8 +- komorebi/src/core/mod.rs | 8 +- komorebi/src/process_command.rs | 67 ++++++++++ komorebi/src/window_manager.rs | 215 +++++++++++++++++++++++++++++++ komorebic/src/main.rs | 36 ++++++ 6 files changed, 331 insertions(+), 5 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index aae61b29..2a0febd2 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,5 +1,7 @@ pub use komorebi::DATA_DIR; +pub use komorebi::core::Sizing; pub use komorebi::core::SocketMessage; +pub use komorebi::core::arrangement::Axis; pub use komorebi::core::cycle_direction::CycleDirection; pub use komorebi::core::default_layout::DefaultLayout; pub use komorebi::core::operation_direction::OperationDirection; diff --git a/komorebi/src/core/arrangement.rs b/komorebi/src/core/arrangement.rs index c256ec1d..c4915e06 100644 --- a/komorebi/src/core/arrangement.rs +++ b/komorebi/src/core/arrangement.rs @@ -1,10 +1,12 @@ -use std::num::NonZeroUsize; - use crate::core::default_layout::DefaultLayout; use crate::core::default_layout::LayoutOptions; use crate::core::rect::Rect; +use clap::ValueEnum; use serde::Deserialize; use serde::Serialize; +use std::num::NonZeroUsize; +use strum::Display; +use strum::EnumString; pub trait Arrangement { #[allow(clippy::too_many_arguments)] @@ -567,7 +569,7 @@ impl Arrangement for DefaultLayout { } } -#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)] pub enum Axis { Horizontal, Vertical, diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 6cb01d82..c916bd81 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -1,3 +1,4 @@ +use crate::core::arrangement::Axis; use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::operation_direction::OperationDirection; @@ -18,12 +19,11 @@ pub mod operation_direction; pub mod pathext; pub mod rect; -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] pub enum Sizing { Increase, Decrease, } - #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)] pub struct WindowManagementBehaviour { /// The current WindowContainerBehaviour to be used @@ -127,6 +127,10 @@ pub enum SocketMessage { FocusWorkspaceNumber(usize), MoveContainerToWorkspaceNumber(usize), SendContainerToWorkspaceNumber(usize), + ResizeWindowEdge(OperationDirection, Sizing), + ResizeWindowAxis(Axis, Sizing), + Retile, + RetileWithResizeDimensions, } impl SocketMessage { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 01f7b26b..b775eaf6 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,4 +1,6 @@ use crate::core::SocketMessage; +use crate::core::arrangement::Axis; +use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::macos_api::MacosApi; use crate::window_manager::WindowManager; @@ -222,6 +224,71 @@ impl WindowManager { window.focus(mouse_follows_focus)?; } } + SocketMessage::ResizeWindowEdge(direction, sizing) => { + self.resize_window(direction, sizing, self.resize_delta, true)?; + } + SocketMessage::ResizeWindowAxis(axis, sizing) => { + match axis { + Axis::Horizontal => { + self.resize_window( + OperationDirection::Left, + sizing, + self.resize_delta, + false, + )?; + self.resize_window( + OperationDirection::Right, + sizing, + self.resize_delta, + false, + )?; + } + Axis::Vertical => { + self.resize_window( + OperationDirection::Up, + sizing, + self.resize_delta, + false, + )?; + self.resize_window( + OperationDirection::Down, + sizing, + self.resize_delta, + false, + )?; + } + Axis::HorizontalAndVertical => { + self.resize_window( + OperationDirection::Left, + sizing, + self.resize_delta, + false, + )?; + self.resize_window( + OperationDirection::Right, + sizing, + self.resize_delta, + false, + )?; + self.resize_window( + OperationDirection::Up, + sizing, + self.resize_delta, + false, + )?; + self.resize_window( + OperationDirection::Down, + sizing, + self.resize_delta, + false, + )?; + } + } + + self.update_focused_workspace(false, false)?; + } + SocketMessage::Retile => self.retile_all(false)?, + SocketMessage::RetileWithResizeDimensions => self.retile_all(true)?, } Ok(()) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 2f440fb0..5346fedc 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -5,7 +5,10 @@ use crate::accessibility::AccessibilityApi; use crate::application::Application; use crate::container::Container; use crate::core::Placement; +use crate::core::Sizing; use crate::core::WindowManagementBehaviour; +use crate::core::arrangement::Arrangement; +use crate::core::arrangement::Axis; use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; @@ -920,4 +923,216 @@ impl WindowManager { let workspace = self.focused_workspace_mut()?; workspace.new_container_for_floating_window() } + + #[tracing::instrument(skip(self))] + pub fn resize_window( + &mut self, + direction: OperationDirection, + sizing: Sizing, + delta: i32, + update: bool, + ) -> eyre::Result<()> { + let mouse_follows_focus = self.mouse_follows_focus; + let mut focused_monitor_work_area = self.focused_monitor_work_area()?; + let workspace = self.focused_workspace_mut()?; + + match workspace.layer { + WorkspaceLayer::Floating => { + let workspace = self.focused_workspace()?; + let focused_window_id = + MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + + let border_offset = 0; + let border_width = 0; + focused_monitor_work_area.left += border_offset; + focused_monitor_work_area.left += border_width; + focused_monitor_work_area.top += border_offset; + focused_monitor_work_area.top += border_width; + focused_monitor_work_area.right -= border_offset * 2; + focused_monitor_work_area.right -= border_width * 2; + focused_monitor_work_area.bottom -= border_offset * 2; + focused_monitor_work_area.bottom -= border_width * 2; + + for window in workspace.floating_windows().iter() { + if window.id == focused_window_id { + let mut rect = Rect::from(MacosApi::window_rect(&window.element)?); + match (direction, sizing) { + (OperationDirection::Left, Sizing::Increase) => { + if rect.left - delta < focused_monitor_work_area.left { + rect.left = focused_monitor_work_area.left; + } else { + rect.left -= delta; + } + } + (OperationDirection::Left, Sizing::Decrease) => { + rect.left += delta; + } + (OperationDirection::Right, Sizing::Increase) => { + if rect.left + rect.right + delta * 2 + > focused_monitor_work_area.left + + focused_monitor_work_area.right + { + rect.right = focused_monitor_work_area.left + + focused_monitor_work_area.right + - rect.left; + } else { + rect.right += delta * 2; + } + } + (OperationDirection::Right, Sizing::Decrease) => { + rect.right -= delta * 2; + } + (OperationDirection::Up, Sizing::Increase) => { + if rect.top - delta < focused_monitor_work_area.top { + rect.top = focused_monitor_work_area.top; + } else { + rect.top -= delta; + } + } + (OperationDirection::Up, Sizing::Decrease) => { + rect.top += delta; + } + (OperationDirection::Down, Sizing::Increase) => { + if rect.top + rect.bottom + delta * 2 + > focused_monitor_work_area.top + + focused_monitor_work_area.bottom + { + rect.bottom = focused_monitor_work_area.top + + focused_monitor_work_area.bottom + - rect.top; + } else { + rect.bottom += delta * 2; + } + } + (OperationDirection::Down, Sizing::Decrease) => { + rect.bottom -= delta * 2; + } + } + + window.set_position(&rect)?; + + if mouse_follows_focus { + MacosApi::center_cursor_in_rect(&rect)?; + } + + break; + } + } + } + WorkspaceLayer::Tiling => { + match workspace.layout { + Layout::Default(layout) => { + tracing::info!("resizing window"); + let len = NonZeroUsize::new(workspace.containers().len()) + .ok_or_else(|| eyre!("there must be at least one container"))?; + let focused_idx = workspace.focused_container_idx(); + let focused_idx_resize = workspace + .resize_dimensions + .get(focused_idx) + .ok_or_else(|| { + eyre!("there is no resize adjustment for this container") + })?; + + if direction + .destination( + workspace.layout.as_boxed_direction().as_ref(), + workspace.layout_flip, + focused_idx, + len, + ) + .is_some() + { + let unaltered = layout.calculate( + &focused_monitor_work_area, + len, + workspace.container_padding, + workspace.layout_flip, + &[], + workspace.focused_container_idx(), + workspace.layout_options, + &workspace.latest_layout, + ); + + let mut direction = direction; + + // We only ever want to operate on the unflipped Rect positions when resizing, then we + // can flip them however they need to be flipped once the resizing has been done + if let Some(flip) = workspace.layout_flip { + match flip { + Axis::Horizontal => { + if matches!(direction, OperationDirection::Left) + || matches!(direction, OperationDirection::Right) + { + direction = direction.opposite(); + } + } + Axis::Vertical => { + if matches!(direction, OperationDirection::Up) + || matches!(direction, OperationDirection::Down) + { + direction = direction.opposite(); + } + } + Axis::HorizontalAndVertical => direction = direction.opposite(), + } + } + + let resize = layout.resize( + unaltered + .get(focused_idx) + .ok_or_else(|| eyre!("there is no last layout"))?, + focused_idx_resize, + direction, + sizing, + delta, + ); + + workspace.resize_dimensions[focused_idx] = resize; + + return if update { + self.update_focused_workspace(false, false) + } else { + Ok(()) + }; + } + + tracing::warn!("cannot resize container in this direction"); + } + } + } + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn retile_all(&mut self, preserve_resize_dimensions: bool) -> eyre::Result<()> { + let offset = self.work_area_offset; + + for monitor in self.monitors_mut() { + let offset = if monitor.work_area_offset.is_some() { + monitor.work_area_offset + } else { + offset + }; + + let focused_workspace_idx = monitor.focused_workspace_idx(); + monitor.update_workspace_globals(focused_workspace_idx, offset); + + let workspace = monitor + .focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace"))?; + + // Reset any resize adjustments if we want to force a retile + if !preserve_resize_dimensions { + for resize in &mut workspace.resize_dimensions { + *resize = None; + } + } + + workspace.update()?; + } + + Ok(()) + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index b789ae4d..dce01bc8 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -2,10 +2,12 @@ use clap::Parser; use color_eyre::eyre; +use komorebi_client::Axis; use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; use komorebi_client::OperationDirection; use komorebi_client::PathExt; +use komorebi_client::Sizing; use komorebi_client::SocketMessage; use komorebi_client::send_message; use lazy_static::lazy_static; @@ -78,6 +80,22 @@ gen_target_subcommand_args! { SendToWorkspace } +#[derive(Parser)] +struct Resize { + #[clap(value_enum)] + edge: OperationDirection, + #[clap(value_enum)] + sizing: Sizing, +} + +#[derive(Parser)] +struct ResizeAxis { + #[clap(value_enum)] + axis: Axis, + #[clap(value_enum)] + sizing: Sizing, +} + #[derive(Parser)] #[clap(author, about, version)] struct Opts { @@ -101,6 +119,13 @@ enum SubCommand { /// Cycle the focused stack in the specified cycle direction #[clap(arg_required_else_help = true)] CycleStack(CycleStack), + /// Resize the focused window in the specified direction + #[clap(arg_required_else_help = true)] + #[clap(alias = "resize")] + ResizeEdge(Resize), + /// Resize the focused window or primary column along the specified axis + #[clap(arg_required_else_help = true)] + ResizeAxis(ResizeAxis), /// Toggle the paused state for all window tiling TogglePause, /// Toggle monocle mode for the focused container @@ -121,6 +146,8 @@ enum SubCommand { /// Send the focused window to the specified workspace #[clap(arg_required_else_help = true)] SendToWorkspace(SendToWorkspace), + /// Force the retiling of all managed windows + Retile, } fn main() -> eyre::Result<()> { @@ -166,6 +193,15 @@ fn main() -> eyre::Result<()> { SubCommand::ToggleWorkspaceLayer => { send_message(&SocketMessage::ToggleWorkspaceLayer)?; } + SubCommand::ResizeEdge(arg) => { + send_message(&SocketMessage::ResizeWindowEdge(arg.edge, arg.sizing))?; + } + SubCommand::ResizeAxis(arg) => { + send_message(&SocketMessage::ResizeWindowAxis(arg.axis, arg.sizing))?; + } + SubCommand::Retile => { + send_message(&SocketMessage::Retile)?; + } } Ok(()) From c91520c531244a65629801a32ca5de3442ad3965 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 09:41:12 -0700 Subject: [PATCH 013/305] feat(wm): implement container and focus promotion Was going a little crazy without being able to promote a container to the biggest tile. This is pretty much a straight lift and shift from komorebi. --- komorebi/src/core/mod.rs | 3 +++ komorebi/src/process_command.rs | 6 ++++++ komorebi/src/window_manager.rs | 34 +++++++++++++++++++++++++++++++++ komorebi/src/workspace.rs | 17 +++++++++++++++++ komorebic/src/main.rs | 16 ++++++++++++++++ 5 files changed, 76 insertions(+) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index c916bd81..eef2f699 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -131,6 +131,9 @@ pub enum SocketMessage { ResizeWindowAxis(Axis, Sizing), Retile, RetileWithResizeDimensions, + Promote, + PromoteFocus, + PromoteWindow(OperationDirection), } impl SocketMessage { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index b775eaf6..622e6be0 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -65,6 +65,12 @@ impl WindowManager { tracing::info!("processing command: {message}"); match message { + SocketMessage::Promote => self.promote_container_to_front()?, + SocketMessage::PromoteFocus => self.promote_focus_to_front()?, + SocketMessage::PromoteWindow(direction) => { + self.focus_container_in_direction(direction)?; + self.promote_container_to_front()? + } SocketMessage::FocusWindow(direction) => { let focused_workspace = self.focused_workspace()?; match focused_workspace.layer { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 5346fedc..0bb2d113 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1135,4 +1135,38 @@ impl WindowManager { Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn promote_container_to_front(&mut self) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + + if matches!(workspace.layout, Layout::Default(DefaultLayout::Grid)) { + tracing::debug!("ignoring promote command for grid layout"); + return Ok(()); + } + + tracing::info!("promoting container"); + + workspace.promote_container()?; + self.update_focused_workspace(self.mouse_follows_focus, true) + } + + #[tracing::instrument(skip(self))] + pub fn promote_focus_to_front(&mut self) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + + if matches!(workspace.layout, Layout::Default(DefaultLayout::Grid)) { + tracing::info!("ignoring promote focus command for grid layout"); + return Ok(()); + } + + tracing::info!("promoting focus"); + + let target_idx = match workspace.layout { + Layout::Default(_) => 0, + }; + + workspace.focus_container(target_idx); + self.update_focused_workspace(self.mouse_follows_focus, true) + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index df3f733b..0be5b6fb 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -476,6 +476,23 @@ impl Workspace { container } + pub fn promote_container(&mut self) -> eyre::Result<()> { + let resize = self.resize_dimensions.remove(0); + let container = self + .remove_focused_container() + .ok_or_else(|| eyre!("there is no container"))?; + + let primary_idx = match self.layout { + Layout::Default(_) => 0, + }; + + let insertion_idx = self.insert_container_at_idx(primary_idx, container); + self.resize_dimensions[insertion_idx] = resize; + self.focus_container(primary_idx); + + Ok(()) + } + pub fn add_container_to_back(&mut self, container: Container) { self.containers_mut().push_back(container); self.focus_last_container(); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index dce01bc8..96de658e 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -59,6 +59,7 @@ gen_enum_subcommand_args! { ChangeLayout: DefaultLayout, Stack: OperationDirection, CycleStack: CycleDirection, + PromoteWindow: OperationDirection, } macro_rules! gen_target_subcommand_args { @@ -137,6 +138,12 @@ enum SubCommand { /// Set the layout on the focused workspace #[clap(arg_required_else_help = true)] ChangeLayout(ChangeLayout), + /// Promote the focused window to the top of the tree + Promote, + /// Promote the user focus to the top of the tree + PromoteFocus, + /// Promote the window in the specified direction + PromoteWindow(PromoteWindow), /// Focus the specified workspace on the focused monitor #[clap(arg_required_else_help = true)] FocusWorkspace(FocusWorkspace), @@ -202,6 +209,15 @@ fn main() -> eyre::Result<()> { SubCommand::Retile => { send_message(&SocketMessage::Retile)?; } + SubCommand::Promote => { + send_message(&SocketMessage::Promote)?; + } + SubCommand::PromoteFocus => { + send_message(&SocketMessage::PromoteFocus)?; + } + SubCommand::PromoteWindow(arg) => { + send_message(&SocketMessage::PromoteWindow(arg.operation_direction))?; + } } Ok(()) From 4fc401cca80e5dd9555491c35ee106175c3d63a4 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 09:49:25 -0700 Subject: [PATCH 014/305] feat(wm): implement layout cycling and flipping Another lift and shift from komorebi to add support for the CycleLayout and FlipLayout SocketMessage variants. Trying to get through all of the main workspace-related interactive commands. --- komorebi/src/core/default_layout.rs | 6 ++- komorebi/src/core/mod.rs | 2 + komorebi/src/process_command.rs | 2 + komorebi/src/window_manager.rs | 64 +++++++++++++++++++++++++++++ komorebic/src/main.rs | 14 +++++++ 5 files changed, 87 insertions(+), 1 deletion(-) diff --git a/komorebi/src/core/default_layout.rs b/komorebi/src/core/default_layout.rs index d545a9f3..ff85705d 100644 --- a/komorebi/src/core/default_layout.rs +++ b/komorebi/src/core/default_layout.rs @@ -4,8 +4,12 @@ use crate::core::rect::Rect; use clap::ValueEnum; use serde::Deserialize; use serde::Serialize; +use strum::Display; +use strum::EnumString; -#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq, ValueEnum)] +#[derive( + Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq, Display, EnumString, ValueEnum, +)] pub enum DefaultLayout { BSP, Columns, diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index eef2f699..35890123 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -120,6 +120,8 @@ pub enum SocketMessage { CycleStack(CycleDirection), UnstackWindow, ChangeLayout(DefaultLayout), + CycleLayout(CycleDirection), + FlipLayout(Axis), TogglePause, ToggleMonocle, ToggleFloat, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 622e6be0..0c9e69e3 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -98,7 +98,9 @@ impl WindowManager { SocketMessage::CycleStack(direction) => { self.cycle_container_window_in_direction(direction)?; } + SocketMessage::FlipLayout(layout_flip) => self.flip_layout(layout_flip)?, SocketMessage::ChangeLayout(layout) => self.change_workspace_layout_default(layout)?, + SocketMessage::CycleLayout(direction) => self.cycle_layout(direction)?, SocketMessage::TogglePause => { if self.is_paused { tracing::info!("resuming"); diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 0bb2d113..3c9bac4e 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1169,4 +1169,68 @@ impl WindowManager { workspace.focus_container(target_idx); self.update_focused_workspace(self.mouse_follows_focus, true) } + + #[tracing::instrument(skip(self))] + pub fn flip_layout(&mut self, layout_flip: Axis) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + + tracing::info!("flipping layout"); + + #[allow(clippy::match_same_arms)] + match workspace.layout_flip { + None => { + workspace.layout_flip = Option::from(layout_flip); + } + Some(current_layout_flip) => { + match current_layout_flip { + Axis::Horizontal => match layout_flip { + Axis::Horizontal => workspace.layout_flip = None, + Axis::Vertical => { + workspace.layout_flip = Option::from(Axis::HorizontalAndVertical) + } + Axis::HorizontalAndVertical => { + workspace.layout_flip = Option::from(Axis::HorizontalAndVertical) + } + }, + Axis::Vertical => match layout_flip { + Axis::Horizontal => { + workspace.layout_flip = Option::from(Axis::HorizontalAndVertical) + } + Axis::Vertical => workspace.layout_flip = None, + Axis::HorizontalAndVertical => { + workspace.layout_flip = Option::from(Axis::HorizontalAndVertical) + } + }, + Axis::HorizontalAndVertical => match layout_flip { + Axis::Horizontal => workspace.layout_flip = Option::from(Axis::Vertical), + Axis::Vertical => workspace.layout_flip = Option::from(Axis::Horizontal), + Axis::HorizontalAndVertical => workspace.layout_flip = None, + }, + }; + } + } + + self.update_focused_workspace(false, false) + } + + #[tracing::instrument(skip(self))] + pub fn cycle_layout(&mut self, direction: CycleDirection) -> eyre::Result<()> { + tracing::info!("cycling layout"); + + let workspace = self.focused_workspace_mut()?; + + match workspace.layout { + Layout::Default(current) => { + let new_layout = match direction { + CycleDirection::Previous => current.cycle_previous(), + CycleDirection::Next => current.cycle_next(), + }; + + tracing::info!("next layout: {new_layout}"); + workspace.layout = Layout::Default(new_layout); + } + } + + self.update_focused_workspace(self.mouse_follows_focus, false) + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 96de658e..cc5d8a4e 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -56,7 +56,9 @@ macro_rules! gen_enum_subcommand_args { gen_enum_subcommand_args! { Focus: OperationDirection, Move: OperationDirection, + FlipLayout: Axis, ChangeLayout: DefaultLayout, + CycleLayout: CycleDirection, Stack: OperationDirection, CycleStack: CycleDirection, PromoteWindow: OperationDirection, @@ -138,6 +140,12 @@ enum SubCommand { /// Set the layout on the focused workspace #[clap(arg_required_else_help = true)] ChangeLayout(ChangeLayout), + /// Cycle between available layouts + #[clap(arg_required_else_help = true)] + CycleLayout(CycleLayout), + /// Flip the layout on the focused workspace + #[clap(arg_required_else_help = true)] + FlipLayout(FlipLayout), /// Promote the focused window to the top of the tree Promote, /// Promote the user focus to the top of the tree @@ -173,6 +181,12 @@ fn main() -> eyre::Result<()> { SubCommand::ChangeLayout(arg) => { send_message(&SocketMessage::ChangeLayout(arg.default_layout))?; } + SubCommand::CycleLayout(arg) => { + send_message(&SocketMessage::CycleLayout(arg.cycle_direction))?; + } + SubCommand::FlipLayout(arg) => { + send_message(&SocketMessage::FlipLayout(arg.axis))?; + } SubCommand::Stack(arg) => { send_message(&SocketMessage::StackWindow(arg.operation_direction))?; } From e01fc551340058631860f8defafdebb8750491ef Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 10:22:35 -0700 Subject: [PATCH 015/305] feat(wm): implement various ws config toggle cmds This commit implements the ToggleWorkspaceWindowContainerBehaviour, ToggleWorkspaceFloatOverride, ToggleLock, ToggleFloat, ToggleMonocle, ToggleWindowContainerBehaviour, ToggleFloatOverride, ToggleCrossMonitorMoveBehaviour, ToggleTiling and ToggleWindowBasedWorkAreaOffset SocketMessage variants. Again mostly a lift-and-shift from komorebi. ToggleMaximizeWindow can be implemented later once I figure out how maximized windows are handled in macOS. --- komorebi/src/core/mod.rs | 38 +++- komorebi/src/process_command.rs | 75 +++++++- komorebi/src/process_event.rs | 4 +- komorebi/src/window_manager.rs | 300 ++++++++++++++++++++------------ komorebi/src/workspace.rs | 7 + komorebic/src/main.rs | 44 +++++ 6 files changed, 346 insertions(+), 122 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 35890123..023be973 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -109,6 +109,30 @@ impl Placement { } } +#[derive( + Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, +)] +pub enum MoveBehaviour { + /// Swap the window container with the window container at the edge of the adjacent monitor + #[default] + Swap, + /// Insert the window container into the focused workspace on the adjacent monitor + Insert, + /// Do nothing if trying to move a window container in the direction of an adjacent monitor + NoOp, +} + +#[derive( + Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, +)] +pub enum CrossBoundaryBehaviour { + /// Attempt to perform actions across a workspace boundary + Workspace, + /// Attempt to perform actions across a monitor boundary + #[default] + Monitor, +} + #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] #[serde(tag = "type", content = "content")] @@ -122,10 +146,20 @@ pub enum SocketMessage { ChangeLayout(DefaultLayout), CycleLayout(CycleDirection), FlipLayout(Axis), - TogglePause, - ToggleMonocle, + ToggleWorkspaceWindowContainerBehaviour, + ToggleWorkspaceFloatOverride, + ToggleLock, ToggleFloat, + ToggleMonocle, + ToggleWindowContainerBehaviour, + ToggleFloatOverride, + ToggleCrossMonitorMoveBehaviour, + ToggleTiling, + ToggleWindowBasedWorkAreaOffset, + TogglePause, ToggleWorkspaceLayer, + // TODO: look into maximized windows + // ToggleMaximize, FocusWorkspaceNumber(usize), MoveContainerToWorkspaceNumber(usize), SendContainerToWorkspaceNumber(usize), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 0c9e69e3..c9edaf9f 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,4 +1,6 @@ +use crate::core::MoveBehaviour; use crate::core::SocketMessage; +use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; @@ -167,7 +169,7 @@ impl WindowManager { for container in workspace.containers() { if let Some(_window) = container.focused_window() { - // todo: figure out z order + // TODO: figure out z order // window.lower()?; } } @@ -175,7 +177,7 @@ impl WindowManager { if let Some(monocle) = &workspace.monocle_container && let Some(_window) = monocle.focused_window() { - // todo: figure out z order + // TODO: figure out z order // window.lower()?; } } @@ -220,7 +222,7 @@ impl WindowManager { }); for window in window_idx_pairs { - // todo: figure out z order + // TODO: figure out z order window.hide()?; // window.lower()?; } @@ -297,6 +299,73 @@ impl WindowManager { } SocketMessage::Retile => self.retile_all(false)?, SocketMessage::RetileWithResizeDimensions => self.retile_all(true)?, + SocketMessage::ToggleWorkspaceWindowContainerBehaviour => { + let current_global_behaviour = self.window_management_behaviour.current_behaviour; + if let Some(behaviour) = + &mut self.focused_workspace_mut()?.window_container_behaviour + { + match behaviour { + WindowContainerBehaviour::Create => { + *behaviour = WindowContainerBehaviour::Append + } + WindowContainerBehaviour::Append => { + *behaviour = WindowContainerBehaviour::Create + } + } + } else { + self.focused_workspace_mut()?.window_container_behaviour = + Some(match current_global_behaviour { + WindowContainerBehaviour::Create => WindowContainerBehaviour::Append, + WindowContainerBehaviour::Append => WindowContainerBehaviour::Create, + }); + }; + } + SocketMessage::ToggleWorkspaceFloatOverride => { + let current_global_override = self.window_management_behaviour.float_override; + if let Some(float_override) = &mut self.focused_workspace_mut()?.float_override { + *float_override = !*float_override; + } else { + self.focused_workspace_mut()?.float_override = Some(!current_global_override); + }; + } + SocketMessage::ToggleLock => self.toggle_lock()?, + SocketMessage::ToggleWindowContainerBehaviour => { + match self.window_management_behaviour.current_behaviour { + WindowContainerBehaviour::Create => { + self.window_management_behaviour.current_behaviour = + WindowContainerBehaviour::Append; + } + WindowContainerBehaviour::Append => { + self.window_management_behaviour.current_behaviour = + WindowContainerBehaviour::Create; + } + } + } + SocketMessage::ToggleFloatOverride => { + self.window_management_behaviour.float_override = + !self.window_management_behaviour.float_override; + } + SocketMessage::ToggleWindowBasedWorkAreaOffset => { + let workspace = self.focused_workspace_mut()?; + workspace.apply_window_based_work_area_offset = + !workspace.apply_window_based_work_area_offset; + + self.retile_all(true)?; + } + SocketMessage::ToggleCrossMonitorMoveBehaviour => { + match self.cross_monitor_move_behaviour { + MoveBehaviour::Swap => { + self.cross_monitor_move_behaviour = MoveBehaviour::Insert; + } + MoveBehaviour::Insert => { + self.cross_monitor_move_behaviour = MoveBehaviour::Swap; + } + _ => {} + } + } + SocketMessage::ToggleTiling => { + self.toggle_tiling()?; + } } Ok(()) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 9543f750..61e615dd 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -51,7 +51,7 @@ impl WindowManager { let application = self.application(process_id)?; if let Some(window_id) = application.main_window_id() { - // todo: figure out if this applies on macOS too + // TODO: figure out if this applies on macOS too // don't want to trigger the full workspace updates when there are no managed // containers - this makes floating windows on empty workspaces go into very // annoying focus change loops which prevents users from interacting with them @@ -108,7 +108,7 @@ impl WindowManager { self.update_focused_workspace(false, false)?; } } - // todo: upate this to work with floating applications / rules + // TODO: upate this to work with floating applications / rules WindowManagerEvent::Show(_, process_id) => { let mut window_id = None; let mut window_element = None; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 3c9bac4e..7e7981ed 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -4,6 +4,8 @@ use crate::LibraryError; use crate::accessibility::AccessibilityApi; use crate::application::Application; use crate::container::Container; +use crate::core::CrossBoundaryBehaviour; +use crate::core::MoveBehaviour; use crate::core::Placement; use crate::core::Sizing; use crate::core::WindowManagementBehaviour; @@ -14,6 +16,7 @@ use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use crate::lockable_sequence::Lockable; use crate::macos_api::MacosApi; use crate::monitor::Monitor; use crate::ring::Ring; @@ -42,6 +45,8 @@ pub struct WindowManager { pub is_paused: bool, pub resize_delta: i32, pub window_management_behaviour: WindowManagementBehaviour, + pub cross_monitor_move_behaviour: MoveBehaviour, + pub cross_boundary_behaviour: CrossBoundaryBehaviour, pub mouse_follows_focus: bool, pub work_area_offset: Option, pub incoming_events: Receiver, @@ -71,7 +76,7 @@ impl WindowManager { let listener = UnixListener::bind(&socket)?; - // todo: undo this when we get config + // TODO: undo this when we get config let mut behaviour = WindowManagementBehaviour::default(); behaviour.toggle_float_placement = Placement::CenterAndResize; @@ -83,6 +88,8 @@ impl WindowManager { is_paused: false, resize_delta: 50, window_management_behaviour: behaviour, + cross_monitor_move_behaviour: Default::default(), + cross_boundary_behaviour: Default::default(), mouse_follows_focus: true, work_area_offset: None, incoming_events: incoming, @@ -244,125 +251,126 @@ impl WindowManager { return Ok(()); } - // let mut cross_monitor_monocle_or_max = false; + let mut cross_monitor_monocle_or_max = false; - // let workspace_idx = self.focused_workspace_idx()?; + let workspace_idx = self.focused_workspace_idx()?; // this is for when we are scrolling across workspaces like PaperWM - // if matches!( - // self.cross_boundary_behaviour, - // CrossBoundaryBehaviour::Workspace - // ) && matches!( - // direction, - // OperationDirection::Left | OperationDirection::Right - // ) { - // let workspace_count = if let Some(monitor) = self.focused_monitor() { - // monitor.workspaces().len() - // } else { - // 1 - // }; - // - // let next_idx = match direction { - // OperationDirection::Left => match workspace_idx { - // 0 => workspace_count - 1, - // n => n - 1, - // }, - // OperationDirection::Right => match workspace_idx { - // n if n == workspace_count - 1 => 0, - // n => n + 1, - // }, - // _ => workspace_idx, - // }; - // - // self.focus_workspace(next_idx)?; - // - // if let Ok(focused_workspace) = self.focused_workspace_mut() { - // if focused_workspace.monocle_container.is_none() { - // match direction { - // OperationDirection::Left => match focused_workspace.layout { - // Layout::Default(layout) => { - // let target_index = - // layout.rightmost_index(focused_workspace.containers().len()); - // focused_workspace.focus_container(target_index); - // } - // }, - // OperationDirection::Right => match focused_workspace.layout { - // Layout::Default(layout) => { - // let target_index = - // layout.leftmost_index(focused_workspace.containers().len()); - // focused_workspace.focus_container(target_index); - // } - // }, - // _ => {} - // }; - // } - // } - // - // return Ok(()); - // } + if matches!( + self.cross_boundary_behaviour, + CrossBoundaryBehaviour::Workspace + ) && matches!( + direction, + OperationDirection::Left | OperationDirection::Right + ) { + let workspace_count = if let Some(monitor) = self.focused_monitor() { + monitor.workspaces().len() + } else { + 1 + }; + + let next_idx = match direction { + OperationDirection::Left => match workspace_idx { + 0 => workspace_count - 1, + n => n - 1, + }, + OperationDirection::Right => match workspace_idx { + n if n == workspace_count - 1 => 0, + n => n + 1, + }, + _ => workspace_idx, + }; + + self.focus_workspace(next_idx)?; + + if let Ok(focused_workspace) = self.focused_workspace_mut() + && focused_workspace.monocle_container.is_none() + { + match direction { + OperationDirection::Left => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = + layout.rightmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + OperationDirection::Right => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = + layout.leftmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + _ => {} + }; + } + + return Ok(()); + } // if there is no floating_window in that direction for this workspace - // let monitor_idx = self - // .monitor_idx_in_direction(direction) - // .ok_or_else(|| eyre!("there is no container or monitor in this direction"))?; - // - // self.focus_monitor(monitor_idx)?; - // let mouse_follows_focus = self.mouse_follows_focus; - // - // if let Ok(focused_workspace) = self.focused_workspace_mut() { - // // if let Some(window) = focused_workspace.maximized_window() { - // // window.focus(mouse_follows_focus)?; - // // cross_monitor_monocle_or_max = true; - // // } else - // if let Some(monocle) = focused_workspace.monocle_container { - // if let Some(window) = monocle.focused_window() { - // window.focus(mouse_follows_focus)?; - // cross_monitor_monocle_or_max = true; - // } - // } else if focused_workspace.layer == WorkspaceLayer::Tiling { - // match direction { - // OperationDirection::Left => match focused_workspace.layout { - // Layout::Default(layout) => { - // let target_index = - // layout.rightmost_index(focused_workspace.containers().len()); - // focused_workspace.focus_container(target_index); - // } - // }, - // OperationDirection::Right => match focused_workspace.layout { - // Layout::Default(layout) => { - // let target_index = - // layout.leftmost_index(focused_workspace.containers().len()); - // focused_workspace.focus_container(target_index); - // } - // }, - // _ => {} - // }; - // } - // } - // - // if !cross_monitor_monocle_or_max { - // let ws = self.focused_workspace_mut()?; - // if ws.is_empty() { - // // This is to remove focus from the previous monitor - // let desktop_window = Window::from(MacosApi::desktop_window()?); - // - // match MacosApi::raise_and_focus_window(desktop_window.id) { - // Ok(()) => {} - // Err(error) => { - // tracing::warn!("{} {}:{}", error, file!(), line!()); - // } - // } - // } else if ws.layer == WorkspaceLayer::Floating && !ws.floating_windows().is_empty() { - // if let Some(window) = ws.focused_floating_window() { - // window.focus(self.mouse_follows_focus)?; - // } - // } else { - // ws.layer = WorkspaceLayer::Tiling; - // if let Ok(focused_window) = self.focused_window() { - // focused_window.focus(self.mouse_follows_focus)?; - // } - // } - // } + let monitor_idx = self + .monitor_idx_in_direction(direction) + .ok_or_else(|| eyre!("there is no container or monitor in this direction"))?; + + self.focus_monitor(monitor_idx)?; + let mouse_follows_focus = self.mouse_follows_focus; + + if let Ok(focused_workspace) = self.focused_workspace_mut() { + // if let Some(window) = focused_workspace.maximized_window() { + // window.focus(mouse_follows_focus)?; + // cross_monitor_monocle_or_max = true; + // } else + if let Some(monocle) = &focused_workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(mouse_follows_focus)?; + cross_monitor_monocle_or_max = true; + } + } else if focused_workspace.layer == WorkspaceLayer::Tiling { + match direction { + OperationDirection::Left => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = + layout.rightmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + OperationDirection::Right => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = + layout.leftmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + _ => {} + }; + } + } + + if !cross_monitor_monocle_or_max { + let ws = self.focused_workspace_mut()?; + if ws.is_empty() { + // TODO: figure out if we need to do this on macos + // This is to remove focus from the previous monitor + // let desktop_window = Window::from(MacosApi::desktop_window()?); + // + // match MacosApi::raise_and_focus_window(desktop_window.id) { + // Ok(()) => {} + // Err(error) => { + // tracing::warn!("{} {}:{}", error, file!(), line!()); + // } + // } + } else if ws.layer == WorkspaceLayer::Floating && !ws.floating_windows().is_empty() { + if let Some(window) = ws.focused_floating_window() { + window.focus(mouse_follows_focus)?; + } + } else { + ws.layer = WorkspaceLayer::Tiling; + if let Ok(focused_window) = self.focused_window() { + focused_window.focus(mouse_follows_focus)?; + } + } + } Ok(()) } @@ -1233,4 +1241,66 @@ impl WindowManager { self.update_focused_workspace(self.mouse_follows_focus, false) } + + #[tracing::instrument(skip(self))] + pub fn toggle_lock(&mut self) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + if let Some(container) = workspace.focused_container_mut() { + // Toggle the locked flag + container.set_locked(!container.locked()); + } + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn toggle_tiling(&mut self) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + workspace.tile = !workspace.tile; + self.update_focused_workspace(false, false) + } + + #[tracing::instrument(skip(self))] + pub fn focus_monitor(&mut self, idx: usize) -> eyre::Result<()> { + tracing::info!("focusing monitor"); + + if self.monitors().get(idx).is_some() { + self.monitors.focus(idx); + } else { + return Err(eyre!("this is not a valid monitor index")); + } + + Ok(()) + } + + // TODO: see if this logic is the same in macos when I have more than one monitor + pub fn monitor_idx_in_direction(&self, direction: OperationDirection) -> Option { + let current_monitor_size = self.focused_monitor_size().ok()?; + + for (idx, monitor) in self.monitors.elements().iter().enumerate() { + match direction { + OperationDirection::Left => { + if monitor.size.left + monitor.size.right == current_monitor_size.left { + return Option::from(idx); + } + } + OperationDirection::Right => { + if current_monitor_size.right + current_monitor_size.left == monitor.size.left { + return Option::from(idx); + } + } + OperationDirection::Up => { + if monitor.size.top + monitor.size.bottom == current_monitor_size.top { + return Option::from(idx); + } + } + OperationDirection::Down => { + if current_monitor_size.top + current_monitor_size.bottom == monitor.size.top { + return Option::from(idx); + } + } + } + } + + None + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 0be5b6fb..099eecd8 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -301,6 +301,13 @@ impl Workspace { self.focus_container(focused_idx.saturating_sub(1)); } + pub fn is_empty(&self) -> bool { + self.containers().is_empty() + && self.maximized_window.is_none() + && self.monocle_container.is_none() + && self.floating_windows().is_empty() + } + pub fn contains_window(&self, window_id: u32) -> bool { for container in self.containers() { if container.contains_window(window_id) { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index cc5d8a4e..5dc65108 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -163,6 +163,26 @@ enum SubCommand { SendToWorkspace(SendToWorkspace), /// Force the retiling of all managed windows Retile, + /// Toggle application of the window-based work area offset for the focused workspace + ToggleWindowBasedWorkAreaOffset, + /// Toggle the behaviour for new windows (stacking or dynamic tiling) + ToggleWindowContainerBehaviour, + /// Enable or disable float override, which makes it so every new window opens in floating mode + ToggleFloatOverride, + /// Toggle the behaviour for new windows (stacking or dynamic tiling) for currently focused + /// workspace. If there was no behaviour set for the workspace previously it takes the opposite + /// of the global value. + ToggleWorkspaceWindowContainerBehaviour, + /// Enable or disable float override, which makes it so every new window opens in floating + /// mode, for the currently focused workspace. If there was no override value set for the + /// workspace previously it takes the opposite of the global value. + ToggleWorkspaceFloatOverride, + /// Toggle window tiling on the focused workspace + ToggleTiling, + /// Toggle a lock for the focused container, ensuring it will not be displaced by any new windows + ToggleLock, + /// Toggle the behaviour when moving windows across monitor boundaries + ToggleCrossMonitorMoveBehaviour, } fn main() -> eyre::Result<()> { @@ -232,6 +252,30 @@ fn main() -> eyre::Result<()> { SubCommand::PromoteWindow(arg) => { send_message(&SocketMessage::PromoteWindow(arg.operation_direction))?; } + SubCommand::ToggleWindowBasedWorkAreaOffset => { + send_message(&SocketMessage::ToggleWindowBasedWorkAreaOffset)?; + } + SubCommand::ToggleWindowContainerBehaviour => { + send_message(&SocketMessage::ToggleWindowContainerBehaviour)?; + } + SubCommand::ToggleFloatOverride => { + send_message(&SocketMessage::ToggleFloatOverride)?; + } + SubCommand::ToggleWorkspaceWindowContainerBehaviour => { + send_message(&SocketMessage::ToggleWorkspaceWindowContainerBehaviour)?; + } + SubCommand::ToggleWorkspaceFloatOverride => { + send_message(&SocketMessage::ToggleWorkspaceFloatOverride)?; + } + SubCommand::ToggleTiling => { + send_message(&SocketMessage::ToggleTiling)?; + } + SubCommand::ToggleLock => { + send_message(&SocketMessage::ToggleLock)?; + } + SubCommand::ToggleCrossMonitorMoveBehaviour => { + send_message(&SocketMessage::ToggleCrossMonitorMoveBehaviour)?; + } } Ok(()) From e883f4a1611dd38a3dec13ae2d3585e387d9382d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 11:03:27 -0700 Subject: [PATCH 016/305] feat(wm): implement various monitor & ws focus cmds This commit implements the CycleFocusMonitor, CycleFocusWorkspace, CycleFocusEmptyWorkspace, FocusMonitorNumber, FocusMonitorAtCursor, FocusLastWorkspace, CloseWorkspace, FocusWorkspaceNumbers, FocusMonitorWorkspaceNumber and FocusNamedWorkspace SocketMessage variants. Largely a lift-and-shift from komorebi. Had to implement some utility functions in MacosApi to retrieve a monitor ID from the current cursor position. None of the monitor-related system code has been tested on macOS since I only have a single monitor to work with right now. --- komorebi/src/core/mod.rs | 10 ++ komorebi/src/core_graphics/mod.rs | 24 ++++ komorebi/src/macos_api.rs | 13 ++ komorebi/src/process_command.rs | 223 ++++++++++++++++++++++++++++++ komorebi/src/window_manager.rs | 41 ++++++ komorebi/src/workspace.rs | 2 + komorebic/src/main.rs | 98 ++++++++++++- 7 files changed, 409 insertions(+), 2 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 023be973..f0446091 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -160,7 +160,17 @@ pub enum SocketMessage { ToggleWorkspaceLayer, // TODO: look into maximized windows // ToggleMaximize, + CycleFocusMonitor(CycleDirection), + CycleFocusWorkspace(CycleDirection), + CycleFocusEmptyWorkspace(CycleDirection), + FocusMonitorNumber(usize), + FocusMonitorAtCursor, + FocusLastWorkspace, + CloseWorkspace, FocusWorkspaceNumber(usize), + FocusWorkspaceNumbers(usize), + FocusMonitorWorkspaceNumber(usize, usize), + FocusNamedWorkspace(String), MoveContainerToWorkspaceNumber(usize), SendContainerToWorkspaceNumber(usize), ResizeWindowEdge(OperationDirection, Sizing), diff --git a/komorebi/src/core_graphics/mod.rs b/komorebi/src/core_graphics/mod.rs index 34503769..b7758e4c 100644 --- a/komorebi/src/core_graphics/mod.rs +++ b/komorebi/src/core_graphics/mod.rs @@ -83,6 +83,30 @@ impl CoreGraphicsApi { .map(|display| CoreGraphicsApi::display_bounds(*display)) } + pub fn display_with_point(point: CGPoint) -> Option { + let mut displays: Vec = Vec::with_capacity(1); + let mut display_count = 0; + + unsafe { + match CoreGraphicsError::from(CGGetDisplaysWithPoint( + point, + displays.capacity() as u32, + displays.as_mut_ptr(), + &mut display_count, + )) { + CoreGraphicsError::Success => { + displays.set_len(display_count as usize); + } + error => { + tracing::error!("failed to find display for point: {error}"); + return None; + } + } + } + + displays.first().copied() + } + pub fn window_list_info() -> Option> { unsafe { CGWindowListCopyWindowInfo( diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index f47604bf..f6e70e79 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -15,6 +15,7 @@ use crate::monitor::Monitor; use crate::window::WindowInfo; use crate::window_manager::WindowManager; use objc2::MainThreadMarker; +use objc2_app_kit::NSEvent; use objc2_app_kit::NSScreen; use objc2_application_services::AXUIElement; use objc2_application_services::AXValue; @@ -22,6 +23,7 @@ use objc2_application_services::AXValueType; use objc2_core_foundation::CFDictionary; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFString; +use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use std::collections::HashMap; use std::ffi::c_void; @@ -201,4 +203,15 @@ impl MacosApi { AccessibilityApi::copy_attribute_value::(&app, kAXFocusedWindowAttribute) } } + + pub fn cursor_pos() -> CGPoint { + unsafe { + let point = NSEvent::mouseLocation(); + CGPoint::new(point.x, point.y) + } + } + + pub fn monitor_from_point(point: CGPoint) -> Option { + CoreGraphicsApi::display_with_point(point) + } } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index c9edaf9f..4b9bf8ca 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -8,9 +8,11 @@ use crate::macos_api::MacosApi; use crate::window_manager::WindowManager; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; +use color_eyre::eyre::eyre; use parking_lot::Mutex; use std::io::BufRead; use std::io::BufReader; +use std::num::NonZeroUsize; use std::os::unix::net::UnixStream; use std::str::FromStr; use std::sync::Arc; @@ -112,11 +114,232 @@ impl WindowManager { self.is_paused = !self.is_paused; } + SocketMessage::CycleFocusMonitor(direction) => { + let monitor_idx = direction.next_idx( + self.focused_monitor_idx(), + NonZeroUsize::new(self.monitors().len()) + .ok_or_else(|| eyre!("there must be at least one monitor"))?, + ); + + self.focus_monitor(monitor_idx)?; + self.update_focused_workspace(self.mouse_follows_focus, true)?; + } + SocketMessage::CycleFocusWorkspace(direction) => { + // This is to ensure that even on an empty workspace on a secondary monitor, the + // secondary monitor where the cursor is focused will be used as the target for + // the workspace switch op + if let Some(monitor_idx) = self.monitor_idx_from_current_pos() + && monitor_idx != self.focused_monitor_idx() + && let Some(monitor) = self.monitors().get(monitor_idx) + && let Some(workspace) = monitor.focused_workspace() + && workspace.is_empty() + { + self.focus_monitor(monitor_idx)?; + } + + let focused_monitor = self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))?; + + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + let workspaces = focused_monitor.workspaces().len(); + + let workspace_idx = direction.next_idx( + focused_workspace_idx, + NonZeroUsize::new(workspaces) + .ok_or_else(|| eyre!("there must be at least one workspace"))?, + ); + + self.focus_workspace(workspace_idx)?; + } + SocketMessage::CycleFocusEmptyWorkspace(direction) => { + // TODO: figure out if we need to do this on macOS + // // This is to ensure that even on an empty workspace on a secondary monitor, the + // // secondary monitor where the cursor is focused will be used as the target for + // // the workspace switch op + // if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + // if monitor_idx != self.focused_monitor_idx() { + // if let Some(monitor) = self.monitors().get(monitor_idx) { + // if let Some(workspace) = monitor.focused_workspace() { + // if workspace.is_empty() { + // self.focus_monitor(monitor_idx)?; + // } + // } + // } + // } + // } + + let focused_monitor = self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))?; + + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + let workspaces = focused_monitor.workspaces().len(); + + let mut empty_workspaces = vec![]; + + for (idx, w) in focused_monitor.workspaces().iter().enumerate() { + if w.is_empty() { + empty_workspaces.push(idx); + } + } + + if !empty_workspaces.is_empty() { + let mut workspace_idx = direction.next_idx( + focused_workspace_idx, + NonZeroUsize::new(workspaces) + .ok_or_else(|| eyre!("there must be at least one workspace"))?, + ); + + while !empty_workspaces.contains(&workspace_idx) { + workspace_idx = direction.next_idx( + workspace_idx, + NonZeroUsize::new(workspaces) + .ok_or_else(|| eyre!("there must be at least one workspace"))?, + ); + } + + self.focus_workspace(workspace_idx)?; + } + } + SocketMessage::FocusMonitorNumber(monitor_idx) => { + self.focus_monitor(monitor_idx)?; + self.update_focused_workspace(self.mouse_follows_focus, true)?; + } + SocketMessage::FocusMonitorAtCursor => { + if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + self.focus_monitor(monitor_idx)?; + } + } + SocketMessage::FocusLastWorkspace => { + // TODO: figure out if we need to do this on macOS + // // This is to ensure that even on an empty workspace on a secondary monitor, the + // // secondary monitor where the cursor is focused will be used as the target for + // // the workspace switch op + // if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + // if monitor_idx != self.focused_monitor_idx() { + // if let Some(monitor) = self.monitors().get(monitor_idx) { + // if let Some(workspace) = monitor.focused_workspace() { + // if workspace.is_empty() { + // self.focus_monitor(monitor_idx)?; + // } + // } + // } + // } + // } + + let idx = self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))? + .focused_workspace_idx(); + + if let Some(monitor) = self.focused_monitor_mut() + && let Some(last_focused_workspace) = monitor.last_focused_workspace + { + self.focus_workspace(last_focused_workspace)?; + } + + self.focused_monitor_mut() + .ok_or_else(|| eyre!("there is no monitor"))? + .last_focused_workspace = Option::from(idx); + } SocketMessage::FocusWorkspaceNumber(workspace_idx) => { if self.focused_workspace_idx().unwrap_or_default() != workspace_idx { self.focus_workspace(workspace_idx)?; } } + SocketMessage::FocusWorkspaceNumbers(workspace_idx) => { + // TODO: figure out if we need to do this on macOS + // // This is to ensure that even on an empty workspace on a secondary monitor, the + // // secondary monitor where the cursor is focused will be used as the target for + // // the workspace switch op + // if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + // if monitor_idx != self.focused_monitor_idx() { + // if let Some(monitor) = self.monitors().get(monitor_idx) { + // if let Some(workspace) = monitor.focused_workspace() { + // if workspace.is_empty() { + // self.focus_monitor(monitor_idx)?; + // } + // } + // } + // } + // } + + let focused_monitor_idx = self.focused_monitor_idx(); + + for (i, monitor) in self.monitors_mut().iter_mut().enumerate() { + if i != focused_monitor_idx { + monitor.focus_workspace(workspace_idx)?; + monitor.load_focused_workspace(false)?; + } + } + + self.focus_workspace(workspace_idx)?; + } + SocketMessage::FocusMonitorWorkspaceNumber(monitor_idx, workspace_idx) => { + let focused_monitor_idx = self.focused_monitor_idx(); + let focused_workspace_idx = self.focused_workspace_idx().unwrap_or_default(); + + let focused_pair = (focused_monitor_idx, focused_workspace_idx); + + if focused_pair != (monitor_idx, workspace_idx) { + self.focus_monitor(monitor_idx)?; + self.focus_workspace(workspace_idx)?; + } + } + SocketMessage::FocusNamedWorkspace(ref name) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(name) + { + self.focus_monitor(monitor_idx)?; + self.focus_workspace(workspace_idx)?; + } + } + SocketMessage::CloseWorkspace => { + // TODO: figure out if we need to do this on macOS + // // This is to ensure that even on an empty workspace on a secondary monitor, the + // // secondary monitor where the cursor is focused will be used as the target for + // // the workspace switch op + // if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + // if monitor_idx != self.focused_monitor_idx() { + // if let Some(monitor) = self.monitors().get(monitor_idx) { + // if let Some(workspace) = monitor.focused_workspace() { + // if workspace.is_empty() { + // self.focus_monitor(monitor_idx)?; + // } + // } + // } + // } + // } + + let mut can_close = false; + + if let Some(monitor) = self.focused_monitor_mut() { + let focused_workspace_idx = monitor.focused_workspace_idx(); + let next_focused_workspace_idx = focused_workspace_idx.saturating_sub(1); + + if let Some(workspace) = monitor.focused_workspace() + && monitor.workspaces().len() > 1 + && workspace.containers().is_empty() + && workspace.floating_windows().is_empty() + && workspace.monocle_container.is_none() + && workspace.maximized_window.is_none() + && workspace.name.is_none() + { + can_close = true; + } + + if can_close + && monitor + .workspaces_mut() + .remove(focused_workspace_idx) + .is_some() + { + self.focus_workspace(next_focused_workspace_idx)?; + } + } + } + SocketMessage::MoveContainerToWorkspaceNumber(workspace_idx) => { self.move_container_to_workspace(workspace_idx, true, None)?; } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 7e7981ed..6fb77722 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1303,4 +1303,45 @@ impl WindowManager { None } + + pub fn monitor_idx_from_current_pos(&mut self) -> Option { + let monitor_id = MacosApi::monitor_from_point(MacosApi::cursor_pos())?; + + for (i, monitor) in self.monitors().iter().enumerate() { + if monitor.id == monitor_id { + return Option::from(i); + } + } + + // TODO: figure out if we need this on macOS + // // our hmonitor might be stale, so if we didn't return above, try querying via the latest + // // info taken from win32_display_data and update our hmonitor while we're at it + // if let Ok(latest) = MacosApi::monitor(monitor_id) { + // for (i, monitor) in self.monitors_mut().iter_mut().enumerate() { + // if monitor.device_id() == latest.device_id() { + // monitor.set_id(latest.id()); + // return Option::from(i); + // } + // } + // } + + None + } + + #[tracing::instrument(skip(self))] + pub fn monitor_workspace_index_by_name(&mut self, name: &str) -> Option<(usize, usize)> { + tracing::info!("looking up workspace by name"); + + for (monitor_idx, monitor) in self.monitors().iter().enumerate() { + for (workspace_idx, workspace) in monitor.workspaces().iter().enumerate() { + if let Some(workspace_name) = &workspace.name + && workspace_name == name + { + return Option::from((monitor_idx, workspace_idx)); + } + } + } + + None + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 099eecd8..9138b880 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -21,6 +21,7 @@ use std::num::NonZeroUsize; #[derive(Debug, Clone)] pub struct Workspace { + pub name: Option, pub containers: Ring, pub monocle_container: Option, pub monocle_container_restore_idx: Option, @@ -68,6 +69,7 @@ impl_ring_elements!(Workspace, Window, "floating_window"); impl Default for Workspace { fn default() -> Self { Self { + name: None, containers: Default::default(), monocle_container: None, monocle_container_restore_idx: None, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 5dc65108..ca37b104 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -62,6 +62,9 @@ gen_enum_subcommand_args! { Stack: OperationDirection, CycleStack: CycleDirection, PromoteWindow: OperationDirection, + CycleMonitor: CycleDirection, + CycleWorkspace: CycleDirection, + CycleEmptyWorkspace: CycleDirection, } macro_rules! gen_target_subcommand_args { @@ -78,9 +81,30 @@ macro_rules! gen_target_subcommand_args { } gen_target_subcommand_args! { - FocusWorkspace, + MoveToMonitor, MoveToWorkspace, - SendToWorkspace + SendToMonitor, + SendToWorkspace, + FocusMonitor, + FocusWorkspace, + FocusWorkspaces, +} + +macro_rules! gen_named_target_subcommand_args { + // SubCommand Pattern + ( $( $name:ident ),+ $(,)? ) => { + $( + #[derive(clap::Parser)] + pub struct $name { + /// Target workspace name + workspace: String, + } + )+ + }; +} + +gen_named_target_subcommand_args! { + FocusNamedWorkspace, } #[derive(Parser)] @@ -99,6 +123,14 @@ struct ResizeAxis { sizing: Sizing, } +#[derive(Parser)] +struct FocusMonitorWorkspace { + /// Target monitor index (zero-indexed) + target_monitor: usize, + /// Workspace index on the target monitor (zero-indexed) + target_workspace: usize, +} + #[derive(Parser)] #[clap(author, about, version)] struct Opts { @@ -152,9 +184,36 @@ enum SubCommand { PromoteFocus, /// Promote the window in the specified direction PromoteWindow(PromoteWindow), + /// Focus the specified monitor + #[clap(arg_required_else_help = true)] + FocusMonitor(FocusMonitor), + /// Focus the monitor at the current cursor location + FocusMonitorAtCursor, + /// Focus the last focused workspace on the focused monitor + FocusLastWorkspace, /// Focus the specified workspace on the focused monitor #[clap(arg_required_else_help = true)] FocusWorkspace(FocusWorkspace), + /// Focus the specified workspace on all monitors + #[clap(arg_required_else_help = true)] + FocusWorkspaces(FocusWorkspaces), + /// Focus the specified workspace on the target monitor + #[clap(arg_required_else_help = true)] + FocusMonitorWorkspace(FocusMonitorWorkspace), + /// Focus the specified workspace + #[clap(arg_required_else_help = true)] + FocusNamedWorkspace(FocusNamedWorkspace), + /// Close the focused workspace (must be empty and unnamed) + CloseWorkspace, + /// Focus the monitor in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleMonitor(CycleMonitor), + /// Focus the workspace in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleWorkspace(CycleWorkspace), + /// Focus the next empty workspace in the given cycle direction (if one exists) + #[clap(arg_required_else_help = true)] + CycleEmptyWorkspace(CycleEmptyWorkspace), /// Move the focused window to the specified workspace #[clap(arg_required_else_help = true)] MoveToWorkspace(MoveToWorkspace), @@ -276,6 +335,41 @@ fn main() -> eyre::Result<()> { SubCommand::ToggleCrossMonitorMoveBehaviour => { send_message(&SocketMessage::ToggleCrossMonitorMoveBehaviour)?; } + SubCommand::FocusMonitor(arg) => { + send_message(&SocketMessage::FocusMonitorNumber(arg.target))?; + } + SubCommand::FocusMonitorAtCursor => { + send_message(&SocketMessage::FocusMonitorAtCursor)?; + } + SubCommand::FocusLastWorkspace => { + send_message(&SocketMessage::FocusLastWorkspace)?; + } + SubCommand::FocusWorkspaces(arg) => { + send_message(&SocketMessage::FocusWorkspaceNumbers(arg.target))?; + } + SubCommand::FocusMonitorWorkspace(arg) => { + send_message(&SocketMessage::FocusMonitorWorkspaceNumber( + arg.target_monitor, + arg.target_workspace, + ))?; + } + SubCommand::FocusNamedWorkspace(arg) => { + send_message(&SocketMessage::FocusNamedWorkspace(arg.workspace))?; + } + SubCommand::CloseWorkspace => { + send_message(&SocketMessage::CloseWorkspace)?; + } + SubCommand::CycleMonitor(arg) => { + send_message(&SocketMessage::CycleFocusMonitor(arg.cycle_direction))?; + } + SubCommand::CycleWorkspace(arg) => { + send_message(&SocketMessage::CycleFocusWorkspace(arg.cycle_direction))?; + } + SubCommand::CycleEmptyWorkspace(arg) => { + send_message(&SocketMessage::CycleFocusEmptyWorkspace( + arg.cycle_direction, + ))?; + } } Ok(()) From 19686d9778159bea10e3dddae20a7daff8c63198 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 11:37:07 -0700 Subject: [PATCH 017/305] feat(wm): implement various focus and move cmds This commit implements the MoveContainerToLastWorkspace, SendContainerToLastWorkspace, MoveContainerToMonitorNumber, CycleMoveContainerToMonitor, MoveContainerToWorkspaceNumber, MoveContainerToNamedWorkspace, CycleMoveContainerToWorkspace, SendContainerToMonitorNumber, CycleSendContainerToMonitor, SendContainerToWorkspaceNumber, CycleSendContainerToWorkspace, SendContainerToMonitorWorkspaceNumber, MoveContainerToMonitorWorkspaceNumber, SendContainerToNamedWorkspace, CycleMoveWorkspaceToMonitor, MoveWorkspaceToMonitorNumber, and SwapWorkspacesToMonitorNumber SocketMessage variants. This is primarily a lift-and-shift from komorebi. I still have no idea if the monitor-related stuff works as expected. I need to figure out how to construct a light Window from a window_id to be able to call move_to_area() when moving a container to another monitor. --- komorebi/src/core/mod.rs | 23 ++- komorebi/src/monitor.rs | 72 +++++++++ komorebi/src/process_command.rs | 216 +++++++++++++++++++++++++++ komorebi/src/window.rs | 72 +++++++++ komorebi/src/window_manager.rs | 256 ++++++++++++++++++++++++++++++++ komorebi/src/workspace.rs | 1 + komorebic/src/main.rs | 177 +++++++++++++++++++--- 7 files changed, 795 insertions(+), 22 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index f0446091..d5db0cfe 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -143,6 +143,25 @@ pub enum SocketMessage { StackWindow(OperationDirection), CycleStack(CycleDirection), UnstackWindow, + ResizeWindowEdge(OperationDirection, Sizing), + ResizeWindowAxis(Axis, Sizing), + MoveContainerToLastWorkspace, + SendContainerToLastWorkspace, + MoveContainerToMonitorNumber(usize), + CycleMoveContainerToMonitor(CycleDirection), + MoveContainerToWorkspaceNumber(usize), + MoveContainerToNamedWorkspace(String), + CycleMoveContainerToWorkspace(CycleDirection), + SendContainerToMonitorNumber(usize), + CycleSendContainerToMonitor(CycleDirection), + SendContainerToWorkspaceNumber(usize), + CycleSendContainerToWorkspace(CycleDirection), + SendContainerToMonitorWorkspaceNumber(usize, usize), + MoveContainerToMonitorWorkspaceNumber(usize, usize), + SendContainerToNamedWorkspace(String), + CycleMoveWorkspaceToMonitor(CycleDirection), + MoveWorkspaceToMonitorNumber(usize), + SwapWorkspacesToMonitorNumber(usize), ChangeLayout(DefaultLayout), CycleLayout(CycleDirection), FlipLayout(Axis), @@ -171,10 +190,6 @@ pub enum SocketMessage { FocusWorkspaceNumbers(usize), FocusMonitorWorkspaceNumber(usize, usize), FocusNamedWorkspace(String), - MoveContainerToWorkspaceNumber(usize), - SendContainerToWorkspaceNumber(usize), - ResizeWindowEdge(OperationDirection, Sizing), - ResizeWindowAxis(Axis, Sizing), Retile, RetileWithResizeDimensions, Promote, diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 2a1c96e2..8b825673 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -1,6 +1,7 @@ use crate::DEFAULT_CONTAINER_PADDING; use crate::DEFAULT_WORKSPACE_PADDING; use crate::container::Container; +use crate::core::FloatingLayerBehaviour; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; @@ -12,6 +13,7 @@ use crate::workspace::WorkspaceGlobals; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use color_eyre::eyre::eyre; +use std::collections::VecDeque; use std::sync::atomic::Ordering; impl_ring_elements!(Monitor, Workspace); @@ -28,6 +30,7 @@ pub struct Monitor { pub container_padding: Option, pub workspace_padding: Option, pub last_focused_workspace: Option, + pub floating_layer_behaviour: Option, } impl Monitor { @@ -52,6 +55,7 @@ impl Monitor { container_padding: None, workspace_padding: None, last_focused_workspace: None, + floating_layer_behaviour: None, } } @@ -84,6 +88,7 @@ impl Monitor { let work_area_offset = self.work_area_offset.or(offset); let window_based_work_area_offset = self.window_based_work_area_offset; let window_based_work_area_offset_limit = self.window_based_work_area_offset_limit; + let floating_layer_behaviour = self.floating_layer_behaviour; if let Some(workspace) = self.workspaces_mut().get_mut(workspace_idx) { workspace.globals = WorkspaceGlobals { @@ -95,6 +100,7 @@ impl Monitor { work_area_offset, window_based_work_area_offset, window_based_work_area_offset_limit, + floating_layer_behaviour, } } } @@ -334,4 +340,70 @@ impl Monitor { Ok(()) } + + pub fn update_workspaces_globals(&mut self, offset: Option) { + let container_padding = self + .container_padding + .or(Some(DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst))); + let workspace_padding = self + .workspace_padding + .or(Some(DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst))); + let (border_width, border_offset) = (0, 0); + let work_area = self.work_area_size; + let work_area_offset = self.work_area_offset.or(offset); + let window_based_work_area_offset = self.window_based_work_area_offset; + let window_based_work_area_offset_limit = self.window_based_work_area_offset_limit; + let floating_layer_behaviour = self.floating_layer_behaviour; + + for workspace in self.workspaces_mut() { + workspace.globals = WorkspaceGlobals { + container_padding, + workspace_padding, + border_width, + border_offset, + work_area, + work_area_offset, + window_based_work_area_offset, + window_based_work_area_offset_limit, + floating_layer_behaviour, + } + } + } + + pub fn remove_workspace_by_idx(&mut self, idx: usize) -> Option { + if idx < self.workspaces().len() { + return self.workspaces_mut().remove(idx); + } + + if idx == 0 { + self.workspaces_mut().push_back(Workspace::default()); + } else { + self.focus_workspace(idx.saturating_sub(1)).ok()?; + }; + + None + } + + pub fn add_container( + &mut self, + container: Container, + workspace_idx: Option, + ) -> eyre::Result<()> { + let workspace = if let Some(idx) = workspace_idx { + self.workspaces_mut() + .get_mut(idx) + .ok_or_else(|| eyre!("there is no workspace at index {}", idx))? + } else { + self.focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace"))? + }; + + workspace.add_container_to_back(container); + + Ok(()) + } + + pub fn remove_workspaces(&mut self) -> VecDeque { + self.workspaces_mut().drain(..).collect() + } } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 4b9bf8ca..c11e625a 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -5,7 +5,9 @@ use crate::core::arrangement::Axis; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::macos_api::MacosApi; +use crate::monitor::Monitor; use crate::window_manager::WindowManager; +use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use color_eyre::eyre::eyre; @@ -589,10 +591,224 @@ impl WindowManager { SocketMessage::ToggleTiling => { self.toggle_tiling()?; } + SocketMessage::MoveContainerToLastWorkspace => { + // This is to ensure that even on an empty workspace on a secondary monitor, the + // secondary monitor where the cursor is focused will be used as the target for + // the workspace switch op + if let Some(monitor_idx) = self.monitor_idx_from_current_pos() + && monitor_idx != self.focused_monitor_idx() + && let Some(monitor) = self.monitors().get(monitor_idx) + && let Some(workspace) = monitor.focused_workspace() + && workspace.is_empty() + { + self.focus_monitor(monitor_idx)?; + } + + let idx = self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))? + .focused_workspace_idx(); + + if let Some(monitor) = self.focused_monitor_mut() + && let Some(last_focused_workspace) = monitor.last_focused_workspace + { + self.move_container_to_workspace(last_focused_workspace, true, None)?; + } + + self.focused_monitor_mut() + .ok_or_else(|| eyre!("there is no monitor"))? + .last_focused_workspace = Option::from(idx); + } + SocketMessage::SendContainerToLastWorkspace => { + // This is to ensure that even on an empty workspace on a secondary monitor, the + // secondary monitor where the cursor is focused will be used as the target for + // the workspace switch op + if let Some(monitor_idx) = self.monitor_idx_from_current_pos() + && monitor_idx != self.focused_monitor_idx() + && let Some(monitor) = self.monitors().get(monitor_idx) + && let Some(workspace) = monitor.focused_workspace() + && workspace.is_empty() + { + self.focus_monitor(monitor_idx)?; + } + + let idx = self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))? + .focused_workspace_idx(); + + if let Some(monitor) = self.focused_monitor_mut() + && let Some(last_focused_workspace) = monitor.last_focused_workspace + { + self.move_container_to_workspace(last_focused_workspace, false, None)?; + } + self.focused_monitor_mut() + .ok_or_else(|| eyre!("there is no monitor"))? + .last_focused_workspace = Option::from(idx); + } + SocketMessage::CycleMoveContainerToWorkspace(direction) => { + let focused_monitor = self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))?; + + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + let workspaces = focused_monitor.workspaces().len(); + + let workspace_idx = direction.next_idx( + focused_workspace_idx, + NonZeroUsize::new(workspaces) + .ok_or_else(|| eyre!("there must be at least one workspace"))?, + ); + + self.move_container_to_workspace(workspace_idx, true, None)?; + } + SocketMessage::MoveContainerToMonitorNumber(monitor_idx) => { + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor(monitor_idx, None, true, direction)?; + } + SocketMessage::SwapWorkspacesToMonitorNumber(monitor_idx) => { + self.swap_focused_monitor(monitor_idx)?; + } + SocketMessage::CycleMoveContainerToMonitor(direction) => { + let monitor_idx = direction.next_idx( + self.focused_monitor_idx(), + NonZeroUsize::new(self.monitors().len()) + .ok_or_else(|| eyre!("there must be at least one monitor"))?, + ); + + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor(monitor_idx, None, true, direction)?; + } + SocketMessage::CycleSendContainerToWorkspace(direction) => { + let focused_monitor = self + .focused_monitor() + .ok_or_else(|| eyre!("there is no monitor"))?; + + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + let workspaces = focused_monitor.workspaces().len(); + + let workspace_idx = direction.next_idx( + focused_workspace_idx, + NonZeroUsize::new(workspaces) + .ok_or_else(|| eyre!("there must be at least one workspace"))?, + ); + + self.move_container_to_workspace(workspace_idx, false, None)?; + } + SocketMessage::SendContainerToMonitorNumber(monitor_idx) => { + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor(monitor_idx, None, false, direction)?; + } + SocketMessage::CycleSendContainerToMonitor(direction) => { + let monitor_idx = direction.next_idx( + self.focused_monitor_idx(), + NonZeroUsize::new(self.monitors().len()) + .ok_or_else(|| eyre!("there must be at least one monitor"))?, + ); + + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor(monitor_idx, None, false, direction)?; + } + SocketMessage::SendContainerToMonitorWorkspaceNumber(monitor_idx, workspace_idx) => { + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor( + monitor_idx, + Option::from(workspace_idx), + false, + direction, + )?; + } + SocketMessage::MoveContainerToMonitorWorkspaceNumber(monitor_idx, workspace_idx) => { + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor( + monitor_idx, + Option::from(workspace_idx), + true, + direction, + )?; + } + SocketMessage::SendContainerToNamedWorkspace(ref workspace) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor( + monitor_idx, + Option::from(workspace_idx), + false, + direction, + )?; + } + } + SocketMessage::MoveContainerToNamedWorkspace(ref workspace) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + let direction = self.direction_from_monitor_idx(monitor_idx); + self.move_container_to_monitor( + monitor_idx, + Option::from(workspace_idx), + true, + direction, + )?; + } + } + + SocketMessage::MoveWorkspaceToMonitorNumber(monitor_idx) => { + self.move_workspace_to_monitor(monitor_idx)?; + } + SocketMessage::CycleMoveWorkspaceToMonitor(direction) => { + let monitor_idx = direction.next_idx( + self.focused_monitor_idx(), + NonZeroUsize::new(self.monitors().len()) + .ok_or_else(|| eyre!("there must be at least one monitor"))?, + ); + + self.move_workspace_to_monitor(monitor_idx)?; + } } Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn move_workspace_to_monitor(&mut self, idx: usize) -> eyre::Result<()> { + tracing::info!("moving workspace"); + let mouse_follows_focus = self.mouse_follows_focus; + let offset = self.work_area_offset; + let workspace = self + .remove_focused_workspace() + .ok_or_else(|| eyre!("there is no workspace"))?; + + { + let target_monitor: &mut Monitor = self + .monitors_mut() + .get_mut(idx) + .ok_or_else(|| eyre!("there is no monitor"))?; + + target_monitor.workspaces_mut().push_back(workspace); + target_monitor.update_workspaces_globals(offset); + target_monitor.focus_workspace(target_monitor.workspaces().len().saturating_sub(1))?; + target_monitor.load_focused_workspace(mouse_follows_focus)?; + } + + self.focus_monitor(idx)?; + self.update_focused_workspace(mouse_follows_focus, true) + } + + pub fn remove_focused_workspace(&mut self) -> Option { + let focused_monitor: &mut Monitor = self.focused_monitor_mut()?; + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + let workspace = focused_monitor.remove_workspace_by_idx(focused_workspace_idx); + if let Err(error) = focused_monitor.focus_workspace(focused_workspace_idx.saturating_sub(1)) + { + tracing::error!( + "Error focusing previous workspace while removing the focused workspace: {}", + error + ); + } + workspace + } } pub fn read_commands_uds( diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 65fd6732..fb67b849 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -355,6 +355,78 @@ impl Window { bottom: target_height, }) } + + pub fn move_to_area( + &self, + current_area: &Rect, + target_area: &Rect, + ) -> Result<(), AccessibilityError> { + let current_rect = Rect::from(MacosApi::window_rect(&self.element)?); + let x_diff = target_area.left - current_area.left; + let y_diff = target_area.top - current_area.top; + let x_ratio = f32::abs((target_area.right as f32) / (current_area.right as f32)); + let y_ratio = f32::abs((target_area.bottom as f32) / (current_area.bottom as f32)); + let window_relative_x = current_rect.left - current_area.left; + let window_relative_y = current_rect.top - current_area.top; + let corrected_relative_x = (window_relative_x as f32 * x_ratio) as i32; + let corrected_relative_y = (window_relative_y as f32 * y_ratio) as i32; + let window_x = current_area.left + corrected_relative_x; + let window_y = current_area.top + corrected_relative_y; + let left = x_diff + window_x; + let top = y_diff + window_y; + + let corrected_width = (current_rect.right as f32 * x_ratio) as i32; + let corrected_height = (current_rect.bottom as f32 * y_ratio) as i32; + + let new_rect = Rect { + left, + top, + right: corrected_width, + bottom: corrected_height, + }; + + // TODO: figure out what to do about maximized windows on macOS + // let is_maximized = &new_rect == target_area; + // if is_maximized { + // windows_api::WindowsApi::unmaximize_window(self.hwnd); + // let animation_enabled = ANIMATION_ENABLED_PER_ANIMATION.lock(); + // let move_enabled = animation_enabled + // .get(&MovementRenderDispatcher::PREFIX) + // .is_some_and(|v| *v); + // drop(animation_enabled); + // + // if move_enabled || ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst) { + // let anim_count = ANIMATION_MANAGER + // .lock() + // .count_in_progress(MovementRenderDispatcher::PREFIX); + // self.set_position(&new_rect, true)?; + // let hwnd = self.hwnd; + // // Wait for the animation to finish before maximizing the window again, otherwise + // // we would be maximizing the window on the current monitor anyway + // thread::spawn(move || { + // let mut new_anim_count = ANIMATION_MANAGER + // .lock() + // .count_in_progress(MovementRenderDispatcher::PREFIX); + // let mut max_wait = 2000; // Max waiting time. No one will be using an animation longer than 2s, right? RIGHT??? WHY? + // while new_anim_count > anim_count && max_wait > 0 { + // thread::sleep(Duration::from_millis(10)); + // new_anim_count = ANIMATION_MANAGER + // .lock() + // .count_in_progress(MovementRenderDispatcher::PREFIX); + // max_wait -= 1; + // } + // windows_api::WindowsApi::maximize_window(hwnd); + // }); + // } else { + // self.set_position(&new_rect, true)?; + // windows_api::WindowsApi::maximize_window(self.hwnd); + // } + // } else { + self.set_position(&new_rect)?; + // } + + Ok(()) + } } impl From<&CFDictionary> for WindowInfo { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 6fb77722..a80b2dd9 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1344,4 +1344,260 @@ impl WindowManager { None } + + /// Calculates the direction of a move across monitors given a specific monitor index + pub fn direction_from_monitor_idx( + &self, + target_monitor_idx: usize, + ) -> Option { + let current_monitor_idx = self.focused_monitor_idx(); + if current_monitor_idx == target_monitor_idx { + return None; + } + + let current_monitor_size = self.focused_monitor_size().ok()?; + let target_monitor_size = self.monitors().get(target_monitor_idx)?.size; + + if target_monitor_size.left + target_monitor_size.right == current_monitor_size.left { + return Some(OperationDirection::Left); + } + if current_monitor_size.right + current_monitor_size.left == target_monitor_size.left { + return Some(OperationDirection::Right); + } + if target_monitor_size.top + target_monitor_size.bottom == current_monitor_size.top { + return Some(OperationDirection::Up); + } + if current_monitor_size.top + current_monitor_size.bottom == target_monitor_size.top { + return Some(OperationDirection::Down); + } + + None + } + + #[tracing::instrument(skip(self))] + pub fn move_container_to_monitor( + &mut self, + monitor_idx: usize, + workspace_idx: Option, + follow: bool, + move_direction: Option, + ) -> eyre::Result<()> { + tracing::info!("moving container"); + + let focused_monitor_idx = self.focused_monitor_idx(); + + if focused_monitor_idx == monitor_idx + && let Some(workspace_idx) = workspace_idx + { + return self.move_container_to_workspace(workspace_idx, follow, None); + } + + let offset = self.work_area_offset; + let mouse_follows_focus = self.mouse_follows_focus; + + let monitor = self + .focused_monitor_mut() + .ok_or_else(|| eyre!("there is no monitor"))?; + + let current_area = monitor.work_area_size; + + let workspace = monitor + .focused_workspace_mut() + .ok_or_else(|| eyre!("there is no workspace"))?; + + if workspace.maximized_window.is_some() { + return Err(eyre!( + "cannot move native maximized window to another monitor or workspace" + )); + } + + let foreground_window_id = + MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + let floating_window_index = workspace + .floating_windows() + .iter() + .position(|w| w.id == foreground_window_id); + + let floating_window = + floating_window_index.and_then(|idx| workspace.floating_windows_mut().remove(idx)); + let container = if floating_window_index.is_none() { + Some( + workspace + .remove_focused_container() + .ok_or_else(|| eyre!("there is no container"))?, + ) + } else { + None + }; + monitor.update_focused_workspace(offset)?; + + let target_monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_else(|| eyre!("there is no monitor"))?; + + let target_monitor_work_area_size = target_monitor.work_area_size; + + let mut should_load_workspace = false; + if let Some(workspace_idx) = workspace_idx + && workspace_idx != target_monitor.focused_workspace_idx() + { + target_monitor.focus_workspace(workspace_idx)?; + should_load_workspace = true; + } + let target_workspace = target_monitor + .focused_workspace_mut() + .ok_or_else(|| eyre!("there is no focused workspace on target monitor"))?; + + if target_workspace.monocle_container.is_some() { + for container in target_workspace.containers_mut() { + container.restore()?; + } + + for window in target_workspace.floating_windows_mut() { + window.restore()?; + } + + target_workspace.reintegrate_monocle_container()?; + } + + if let Some(window) = floating_window { + window.move_to_area(¤t_area, &target_monitor_work_area_size)?; + target_workspace.floating_windows_mut().push_back(window); + target_workspace.layer = WorkspaceLayer::Floating; + } else if let Some(container) = container { + let _container_window_ids = + container.windows().iter().map(|w| w.id).collect::>(); + + target_workspace.layer = WorkspaceLayer::Tiling; + + if let Some(direction) = move_direction { + target_monitor.add_container_with_direction(container, workspace_idx, direction)?; + } else { + target_monitor.add_container(container, workspace_idx)?; + } + + if let Some(workspace) = target_monitor.focused_workspace() + && !workspace.tile + { + // TODO: figure out how to construct a Window from just an id here + // for window_id in container_window_ids { + // Window::from(window_id) + // .move_to_area(¤t_area, &target_monitor.work_area_size)?; + // } + } + } else { + return Err(eyre!("failed to find a window to move")); + } + + if should_load_workspace { + target_monitor.load_focused_workspace(mouse_follows_focus)?; + } + target_monitor.update_focused_workspace(offset)?; + + // this second one is for DPI changes when the target is another monitor + // if we don't do this the layout on the other monitor could look funny + // until it is interacted with again + target_monitor.update_focused_workspace(offset)?; + + if follow { + self.focus_monitor(monitor_idx)?; + } + + self.update_focused_workspace(self.mouse_follows_focus, true)?; + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn swap_focused_monitor(&mut self, idx: usize) -> eyre::Result<()> { + tracing::info!("swapping focused monitor"); + + let focused_monitor_idx = self.focused_monitor_idx(); + let mouse_follows_focus = self.mouse_follows_focus; + + self.swap_monitor_workspaces(focused_monitor_idx, idx)?; + + self.update_focused_workspace(mouse_follows_focus, true) + } + + #[tracing::instrument(skip(self))] + pub fn swap_monitor_workspaces( + &mut self, + first_idx: usize, + second_idx: usize, + ) -> eyre::Result<()> { + tracing::info!("swaping monitors"); + if first_idx == second_idx { + return Ok(()); + } + let mouse_follows_focus = self.mouse_follows_focus; + let offset = self.work_area_offset; + let first_focused_workspace = { + let first_monitor = self + .monitors() + .get(first_idx) + .ok_or_else(|| eyre!("There is no monitor"))?; + first_monitor.focused_workspace_idx() + }; + + let second_focused_workspace = { + let second_monitor = self + .monitors() + .get(second_idx) + .ok_or_else(|| eyre!("There is no monitor"))?; + second_monitor.focused_workspace_idx() + }; + + // Swap workspaces between the first and second monitors + + let first_workspaces = self + .monitors_mut() + .get_mut(first_idx) + .ok_or_else(|| eyre!("There is no monitor"))? + .remove_workspaces(); + + let second_workspaces = self + .monitors_mut() + .get_mut(second_idx) + .ok_or_else(|| eyre!("There is no monitor"))? + .remove_workspaces(); + + self.monitors_mut() + .get_mut(first_idx) + .ok_or_else(|| eyre!("There is no monitor"))? + .workspaces_mut() + .extend(second_workspaces); + + self.monitors_mut() + .get_mut(second_idx) + .ok_or_else(|| eyre!("There is no monitor"))? + .workspaces_mut() + .extend(first_workspaces); + + // Set the focused workspaces for the first and second monitors + if let Some(first_monitor) = self.monitors_mut().get_mut(first_idx) { + first_monitor.update_workspaces_globals(offset); + first_monitor.focus_workspace(second_focused_workspace)?; + first_monitor.load_focused_workspace(mouse_follows_focus)?; + } + + if let Some(second_monitor) = self.monitors_mut().get_mut(second_idx) { + second_monitor.update_workspaces_globals(offset); + second_monitor.focus_workspace(first_focused_workspace)?; + second_monitor.load_focused_workspace(mouse_follows_focus)?; + } + + self.update_focused_workspace_by_monitor_idx(second_idx)?; + self.update_focused_workspace_by_monitor_idx(first_idx) + } + + pub fn update_focused_workspace_by_monitor_idx(&mut self, idx: usize) -> eyre::Result<()> { + let offset = self.work_area_offset; + + self.monitors_mut() + .get_mut(idx) + .ok_or_else(|| eyre!("there is no monitor"))? + .update_focused_workspace(offset) + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 9138b880..14a1ace0 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -108,6 +108,7 @@ pub struct WorkspaceGlobals { pub work_area_offset: Option, pub window_based_work_area_offset: Option, pub window_based_work_area_offset_limit: isize, + pub floating_layer_behaviour: Option, } impl Workspace { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index ca37b104..0ec69b77 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -56,15 +56,29 @@ macro_rules! gen_enum_subcommand_args { gen_enum_subcommand_args! { Focus: OperationDirection, Move: OperationDirection, - FlipLayout: Axis, - ChangeLayout: DefaultLayout, - CycleLayout: CycleDirection, - Stack: OperationDirection, - CycleStack: CycleDirection, - PromoteWindow: OperationDirection, + CycleFocus: CycleDirection, + CycleMove: CycleDirection, + CycleMoveToWorkspace: CycleDirection, + CycleSendToWorkspace: CycleDirection, + CycleSendToMonitor: CycleDirection, + CycleMoveToMonitor: CycleDirection, CycleMonitor: CycleDirection, CycleWorkspace: CycleDirection, CycleEmptyWorkspace: CycleDirection, + CycleMoveWorkspaceToMonitor: CycleDirection, + Stack: OperationDirection, + CycleStack: CycleDirection, + CycleStackIndex: CycleDirection, + FlipLayout: Axis, + ChangeLayout: DefaultLayout, + CycleLayout: CycleDirection, + // WatchConfiguration: BooleanState, + // MouseFollowsFocus: BooleanState, + // Query: StateQuery, + // WindowHidingBehaviour: HidingBehaviour, + // CrossMonitorMoveBehaviour: MoveBehaviour, + // UnmanagedWindowOperationBehaviour: OperationBehaviour, + PromoteWindow: OperationDirection, } macro_rules! gen_target_subcommand_args { @@ -88,6 +102,9 @@ gen_target_subcommand_args! { FocusMonitor, FocusWorkspace, FocusWorkspaces, + MoveWorkspaceToMonitor, + SwapWorkspacesWithMonitor, + FocusStackWindow, } macro_rules! gen_named_target_subcommand_args { @@ -104,7 +121,10 @@ macro_rules! gen_named_target_subcommand_args { } gen_named_target_subcommand_args! { + MoveToNamedWorkspace, + SendToNamedWorkspace, FocusNamedWorkspace, + ClearNamedWorkspaceLayoutRules } #[derive(Parser)] @@ -131,6 +151,22 @@ struct FocusMonitorWorkspace { target_workspace: usize, } +#[derive(Parser)] +pub struct SendToMonitorWorkspace { + /// Target monitor index (zero-indexed) + target_monitor: usize, + /// Workspace index on the target monitor (zero-indexed) + target_workspace: usize, +} + +#[derive(Parser)] +pub struct MoveToMonitorWorkspace { + /// Target monitor index (zero-indexed) + target_monitor: usize, + /// Workspace index on the target monitor (zero-indexed) + target_workspace: usize, +} + #[derive(Parser)] #[clap(author, about, version)] struct Opts { @@ -184,6 +220,56 @@ enum SubCommand { PromoteFocus, /// Promote the window in the specified direction PromoteWindow(PromoteWindow), + + /// Move the focused window to the specified monitor + #[clap(arg_required_else_help = true)] + MoveToMonitor(MoveToMonitor), + /// Move the focused window to the monitor in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleMoveToMonitor(CycleMoveToMonitor), + /// Move the focused window to the specified workspace + #[clap(arg_required_else_help = true)] + MoveToWorkspace(MoveToWorkspace), + /// Move the focused window to the specified workspace + #[clap(arg_required_else_help = true)] + MoveToNamedWorkspace(MoveToNamedWorkspace), + /// Move the focused window to the workspace in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleMoveToWorkspace(CycleMoveToWorkspace), + /// Send the focused window to the specified monitor + #[clap(arg_required_else_help = true)] + SendToMonitor(SendToMonitor), + /// Send the focused window to the monitor in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleSendToMonitor(CycleSendToMonitor), + /// Send the focused window to the specified workspace + #[clap(arg_required_else_help = true)] + SendToWorkspace(SendToWorkspace), + /// Send the focused window to the specified workspace + #[clap(arg_required_else_help = true)] + SendToNamedWorkspace(SendToNamedWorkspace), + /// Send the focused window to the workspace in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleSendToWorkspace(CycleSendToWorkspace), + /// Send the focused window to the specified monitor workspace + #[clap(arg_required_else_help = true)] + SendToMonitorWorkspace(SendToMonitorWorkspace), + /// Move the focused window to the specified monitor workspace + #[clap(arg_required_else_help = true)] + MoveToMonitorWorkspace(MoveToMonitorWorkspace), + /// Send the focused window to the last focused monitor workspace + SendToLastWorkspace, + /// Move the focused window to the last focused monitor workspace + MoveToLastWorkspace, + /// Move the focused workspace to the specified monitor + #[clap(arg_required_else_help = true)] + MoveWorkspaceToMonitor(MoveWorkspaceToMonitor), + /// Move the focused workspace monitor in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleMoveWorkspaceToMonitor(CycleMoveWorkspaceToMonitor), + /// Swap focused monitor workspaces with specified monitor + #[clap(arg_required_else_help = true)] + SwapWorkspacesWithMonitor(SwapWorkspacesWithMonitor), /// Focus the specified monitor #[clap(arg_required_else_help = true)] FocusMonitor(FocusMonitor), @@ -214,12 +300,6 @@ enum SubCommand { /// Focus the next empty workspace in the given cycle direction (if one exists) #[clap(arg_required_else_help = true)] CycleEmptyWorkspace(CycleEmptyWorkspace), - /// Move the focused window to the specified workspace - #[clap(arg_required_else_help = true)] - MoveToWorkspace(MoveToWorkspace), - /// Send the focused window to the specified workspace - #[clap(arg_required_else_help = true)] - SendToWorkspace(SendToWorkspace), /// Force the retiling of all managed windows Retile, /// Toggle application of the window-based work area offset for the focused workspace @@ -278,12 +358,6 @@ fn main() -> eyre::Result<()> { SubCommand::FocusWorkspace(arg) => { send_message(&SocketMessage::FocusWorkspaceNumber(arg.target))?; } - SubCommand::MoveToWorkspace(arg) => { - send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target))?; - } - SubCommand::SendToWorkspace(arg) => { - send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target))?; - } SubCommand::ToggleMonocle => { send_message(&SocketMessage::ToggleMonocle)?; } @@ -370,6 +444,73 @@ fn main() -> eyre::Result<()> { arg.cycle_direction, ))?; } + SubCommand::MoveToMonitor(arg) => { + send_message(&SocketMessage::MoveContainerToMonitorNumber(arg.target))?; + } + SubCommand::CycleMoveToMonitor(arg) => { + send_message(&SocketMessage::CycleMoveContainerToMonitor( + arg.cycle_direction, + ))?; + } + SubCommand::MoveToWorkspace(arg) => { + send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target))?; + } + SubCommand::MoveToNamedWorkspace(arg) => { + send_message(&SocketMessage::MoveContainerToNamedWorkspace(arg.workspace))?; + } + SubCommand::CycleMoveToWorkspace(arg) => { + send_message(&SocketMessage::CycleMoveContainerToWorkspace( + arg.cycle_direction, + ))?; + } + SubCommand::SendToMonitor(arg) => { + send_message(&SocketMessage::SendContainerToMonitorNumber(arg.target))?; + } + SubCommand::CycleSendToMonitor(arg) => { + send_message(&SocketMessage::CycleSendContainerToMonitor( + arg.cycle_direction, + ))?; + } + SubCommand::SendToWorkspace(arg) => { + send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target))?; + } + SubCommand::SendToNamedWorkspace(arg) => { + send_message(&SocketMessage::SendContainerToNamedWorkspace(arg.workspace))?; + } + SubCommand::CycleSendToWorkspace(arg) => { + send_message(&SocketMessage::CycleSendContainerToWorkspace( + arg.cycle_direction, + ))?; + } + SubCommand::SendToMonitorWorkspace(arg) => { + send_message(&SocketMessage::SendContainerToMonitorWorkspaceNumber( + arg.target_monitor, + arg.target_workspace, + ))?; + } + SubCommand::MoveToMonitorWorkspace(arg) => { + send_message(&SocketMessage::MoveContainerToMonitorWorkspaceNumber( + arg.target_monitor, + arg.target_workspace, + ))?; + } + SubCommand::MoveWorkspaceToMonitor(arg) => { + send_message(&SocketMessage::MoveWorkspaceToMonitorNumber(arg.target))?; + } + SubCommand::CycleMoveWorkspaceToMonitor(arg) => { + send_message(&SocketMessage::CycleMoveWorkspaceToMonitor( + arg.cycle_direction, + ))?; + } + SubCommand::MoveToLastWorkspace => { + send_message(&SocketMessage::MoveContainerToLastWorkspace)?; + } + SubCommand::SendToLastWorkspace => { + send_message(&SocketMessage::SendContainerToLastWorkspace)?; + } + SubCommand::SwapWorkspacesWithMonitor(arg) => { + send_message(&SocketMessage::SwapWorkspacesToMonitorNumber(arg.target))?; + } } Ok(()) From 565c6cd6f88b0bbe06edbee0db67b3f95acbd939 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 11:55:37 -0700 Subject: [PATCH 018/305] feat(wm): implement remaining cycle and stack cmds This commit implements the CycleFocusWindow, CycleMoveWindow, StackAll, UnstackAll, FocusStackWindow and CycleStackIndex SocketMessage variants. Largely a code migration from komorebi. --- komorebi/src/core/mod.rs | 8 +- komorebi/src/process_command.rs | 31 ++++ komorebi/src/window_manager.rs | 251 ++++++++++++++++++++++++++++++++ komorebi/src/workspace.rs | 25 ++++ komorebic/src/main.rs | 34 +++++ 5 files changed, 348 insertions(+), 1 deletion(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index d5db0cfe..74e32962 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -140,9 +140,15 @@ pub enum SocketMessage { // Window / Container Commands FocusWindow(OperationDirection), MoveWindow(OperationDirection), + CycleFocusWindow(CycleDirection), + CycleMoveWindow(CycleDirection), StackWindow(OperationDirection), - CycleStack(CycleDirection), UnstackWindow, + CycleStack(CycleDirection), + CycleStackIndex(CycleDirection), + FocusStackWindow(usize), + StackAll, + UnstackAll, ResizeWindowEdge(OperationDirection, Sizing), ResizeWindowAxis(Axis, Sizing), MoveContainerToLastWorkspace, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index c11e625a..aae233ca 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -99,11 +99,42 @@ impl WindowManager { } } } + SocketMessage::CycleFocusWindow(direction) => { + let focused_workspace = self.focused_workspace()?; + match focused_workspace.layer { + WorkspaceLayer::Tiling => { + self.focus_container_in_cycle_direction(direction)?; + } + WorkspaceLayer::Floating => { + self.focus_floating_window_in_cycle_direction(direction)?; + } + } + } + SocketMessage::CycleMoveWindow(direction) => { + self.move_container_in_cycle_direction(direction)?; + } + SocketMessage::StackWindow(direction) => self.add_window_to_container(direction)?, SocketMessage::UnstackWindow => self.remove_window_from_container()?, + SocketMessage::StackAll => self.stack_all()?, + SocketMessage::UnstackAll => self.unstack_all(true)?, SocketMessage::CycleStack(direction) => { self.cycle_container_window_in_direction(direction)?; } + SocketMessage::CycleStackIndex(direction) => { + self.cycle_container_window_index_in_direction(direction)?; + } + SocketMessage::FocusStackWindow(idx) => { + // In case you are using this command on a bar on a monitor + // different from the currently focused one, you'd want that + // monitor to be focused so that the FocusStackWindow happens + // on the monitor with the bar you just pressed. + if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + self.focus_monitor(monitor_idx)?; + } + self.focus_container_window(idx)?; + } + SocketMessage::FlipLayout(layout_flip) => self.flip_layout(layout_flip)?, SocketMessage::ChangeLayout(layout) => self.change_workspace_layout_default(layout)?, SocketMessage::CycleLayout(direction) => self.cycle_layout(direction)?, diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index a80b2dd9..696d4554 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1600,4 +1600,255 @@ impl WindowManager { .ok_or_else(|| eyre!("there is no monitor"))? .update_focused_workspace(offset) } + + #[tracing::instrument(skip(self))] + pub fn focus_container_in_cycle_direction( + &mut self, + direction: CycleDirection, + ) -> eyre::Result<()> { + tracing::info!("focusing container"); + // let mut maximize_next = false; + let mut monocle_next = false; + + let mouse_follows_focus = self.mouse_follows_focus; + + if self.focused_workspace_mut()?.maximized_window.is_some() { + // TODO: maximized window stuff + // maximize_next = true; + // self.unmaximize_window()?; + } + + if self.focused_workspace_mut()?.monocle_container.is_some() { + monocle_next = true; + self.monocle_off()?; + } + + let workspace = self.focused_workspace_mut()?; + + let new_idx = workspace + .new_idx_for_cycle_direction(direction) + .ok_or_else(|| eyre!("this is not a valid direction from the current position"))?; + + workspace.focus_container(new_idx); + + // if maximize_next { + // self.toggle_maximize()?; + // } else + if monocle_next { + self.toggle_monocle()?; + } else { + self.focused_window_mut()?.focus(mouse_follows_focus)?; + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn move_container_in_cycle_direction( + &mut self, + direction: CycleDirection, + ) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + if workspace.is_focused_window_monocle_or_maximized()? { + return Err(eyre!( + "ignoring command while active window is in monocle mode or maximized" + )); + } + + tracing::info!("moving container"); + + let current_idx = workspace.focused_container_idx(); + let new_idx = workspace + .new_idx_for_cycle_direction(direction) + .ok_or_else(|| eyre!("this is not a valid direction from the current position"))?; + + workspace.swap_containers(current_idx, new_idx); + workspace.focus_container(new_idx); + self.update_focused_workspace(self.mouse_follows_focus, true) + } + + #[tracing::instrument(skip(self))] + pub fn focus_floating_window_in_cycle_direction( + &mut self, + direction: CycleDirection, + ) -> eyre::Result<()> { + let mouse_follows_focus = self.mouse_follows_focus; + let focused_workspace = self.focused_workspace()?; + + let mut target_idx = None; + let len = focused_workspace.floating_windows().len(); + + if len > 1 { + let focused_window_id = + MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + for (idx, window) in focused_workspace.floating_windows().iter().enumerate() { + if window.id == focused_window_id { + match direction { + CycleDirection::Previous => { + if idx == 0 { + target_idx = Some(len - 1) + } else { + target_idx = Some(idx - 1) + } + } + CycleDirection::Next => { + if idx == len - 1 { + target_idx = Some(0) + } else { + target_idx = Some(idx - 1) + } + } + } + } + } + + if target_idx.is_none() { + target_idx = Some(0); + } + } + + if let Some(idx) = target_idx + && let Some(window) = focused_workspace.floating_windows().get(idx) + { + window.focus(mouse_follows_focus)?; + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn cycle_container_window_index_in_direction( + &mut self, + direction: CycleDirection, + ) -> eyre::Result<()> { + tracing::info!("cycling container window index"); + + let mouse_follows_focus = self.mouse_follows_focus; + + let container = + if let Some(container) = &mut self.focused_workspace_mut()?.monocle_container { + container + } else { + self.focused_container_mut()? + }; + + let len = NonZeroUsize::new(container.windows().len()) + .ok_or_else(|| eyre!("there must be at least one window in a container"))?; + + if len.get() == 1 { + return Err(eyre!("there is only one window in this container")); + } + + let current_idx = container.focused_window_idx(); + let next_idx = direction.next_idx(current_idx, len); + container.windows_mut().swap(current_idx, next_idx); + + container.focus_window(next_idx); + container.load_focused_window()?; + + if let Some(window) = container.focused_window() { + window.focus(mouse_follows_focus)?; + } + + self.update_focused_workspace(mouse_follows_focus, true) + } + + #[tracing::instrument(skip(self))] + pub fn focus_container_window(&mut self, idx: usize) -> eyre::Result<()> { + tracing::info!("focusing container window at index {idx}"); + + let mouse_follows_focus = self.mouse_follows_focus; + + let container = + if let Some(container) = &mut self.focused_workspace_mut()?.monocle_container { + container + } else { + self.focused_container_mut()? + }; + + let len = NonZeroUsize::new(container.windows().len()) + .ok_or_else(|| eyre!("there must be at least one window in a container"))?; + + if len.get() == 1 && idx != 0 { + return Err(eyre!("there is only one window in this container")); + } + + if container.windows().get(idx).is_none() { + return Err(eyre!("there is no window in this container at index {idx}")); + } + + container.focus_window(idx); + container.load_focused_window()?; + + if let Some(window) = container.focused_window() { + window.focus(mouse_follows_focus)?; + } + + self.update_focused_workspace(mouse_follows_focus, true) + } + + #[tracing::instrument(skip(self))] + pub fn stack_all(&mut self) -> eyre::Result<()> { + self.unstack_all(false)?; + + tracing::info!("stacking all windows on workspace"); + + let workspace = self.focused_workspace_mut()?; + + let mut focused_window_id = None; + if let Some(container) = workspace.focused_container() + && let Some(window) = container.focused_window() + { + focused_window_id = Some(window.id); + } + + workspace.focus_container(workspace.containers().len().saturating_sub(1)); + while workspace.focused_container_idx() > 0 { + workspace.move_window_to_container(0)?; + workspace.focus_container(workspace.containers().len().saturating_sub(1)); + } + + if let Some(window_id) = focused_window_id { + workspace.focus_container_by_window(window_id)?; + } + + self.update_focused_workspace(self.mouse_follows_focus, true) + } + + #[tracing::instrument(skip(self))] + pub fn unstack_all(&mut self, update_workspace: bool) -> eyre::Result<()> { + tracing::info!("unstacking all windows in container"); + + let workspace = self.focused_workspace_mut()?; + + let mut focused_window_id = None; + if let Some(container) = workspace.focused_container() + && let Some(window) = container.focused_window() + { + focused_window_id = Some(window.id); + } + + let initial_focused_container_index = workspace.focused_container_idx(); + let mut focused_container = workspace.focused_container().cloned(); + + while let Some(focused) = &focused_container { + if focused.windows().len() > 1 { + workspace.new_container_for_focused_window()?; + workspace.focus_container(initial_focused_container_index); + focused_container = workspace.focused_container().cloned(); + } else { + focused_container = None; + } + } + + if let Some(window_id) = focused_window_id { + workspace.focus_container_by_window(window_id)?; + } + + if update_workspace { + self.update_focused_workspace(self.mouse_follows_focus, true)?; + } + + Ok(()) + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 14a1ace0..89f31601 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -2,6 +2,7 @@ use crate::container::Container; use crate::core::FloatingLayerBehaviour; use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; +use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::default_layout::LayoutOptions; use crate::core::layout::Layout; @@ -135,6 +136,13 @@ impl Workspace { ) } + pub fn new_idx_for_cycle_direction(&self, direction: CycleDirection) -> Option { + Option::from(direction.next_idx( + self.focused_container_idx(), + NonZeroUsize::new(self.containers().len())?, + )) + } + pub fn container_idx_for_window(&self, window_id: u32) -> Option { let mut idx = None; for (i, x) in self.containers().iter().enumerate() { @@ -304,6 +312,23 @@ impl Workspace { self.focus_container(focused_idx.saturating_sub(1)); } + pub fn is_focused_window_monocle_or_maximized(&self) -> eyre::Result { + let window_id = MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + if let Some(window) = &self.maximized_window + && window_id == window.id + { + return Ok(true); + } + + if let Some(container) = &self.monocle_container + && container.contains_window(window_id) + { + return Ok(true); + } + + Ok(false) + } + pub fn is_empty(&self) -> bool { self.containers().is_empty() && self.maximized_window.is_none() diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 0ec69b77..22ea0408 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -185,11 +185,27 @@ enum SubCommand { /// Stack the focused window in the specified direction #[clap(arg_required_else_help = true)] Stack(Stack), + /// Change focus to the window in the specified cycle direction + #[clap(arg_required_else_help = true)] + CycleFocus(CycleFocus), + /// Move the focused window in the specified cycle direction + #[clap(arg_required_else_help = true)] + CycleMove(CycleMove), /// Unstack the focused window Unstack, /// Cycle the focused stack in the specified cycle direction #[clap(arg_required_else_help = true)] CycleStack(CycleStack), + /// Cycle the index of the focused window in the focused stack in the specified cycle direction + #[clap(arg_required_else_help = true)] + CycleStackIndex(CycleStackIndex), + /// Focus the specified window index in the focused stack + #[clap(arg_required_else_help = true)] + FocusStackWindow(FocusStackWindow), + /// Stack all windows on the focused workspace + StackAll, + /// Unstack all windows in the focused container + UnstackAll, /// Resize the focused window in the specified direction #[clap(arg_required_else_help = true)] #[clap(alias = "resize")] @@ -334,6 +350,12 @@ fn main() -> eyre::Result<()> { SubCommand::Move(arg) => { send_message(&SocketMessage::MoveWindow(arg.operation_direction))?; } + SubCommand::CycleFocus(arg) => { + send_message(&SocketMessage::CycleFocusWindow(arg.cycle_direction))?; + } + SubCommand::CycleMove(arg) => { + send_message(&SocketMessage::CycleMoveWindow(arg.cycle_direction))?; + } SubCommand::TogglePause => { send_message(&SocketMessage::TogglePause)?; } @@ -349,12 +371,24 @@ fn main() -> eyre::Result<()> { SubCommand::Stack(arg) => { send_message(&SocketMessage::StackWindow(arg.operation_direction))?; } + SubCommand::StackAll => { + send_message(&SocketMessage::StackAll)?; + } SubCommand::Unstack => { send_message(&SocketMessage::UnstackWindow)?; } + SubCommand::UnstackAll => { + send_message(&SocketMessage::UnstackAll)?; + } + SubCommand::FocusStackWindow(arg) => { + send_message(&SocketMessage::FocusStackWindow(arg.target))?; + } SubCommand::CycleStack(arg) => { send_message(&SocketMessage::CycleStack(arg.cycle_direction))?; } + SubCommand::CycleStackIndex(arg) => { + send_message(&SocketMessage::CycleStackIndex(arg.cycle_direction))?; + } SubCommand::FocusWorkspace(arg) => { send_message(&SocketMessage::FocusWorkspaceNumber(arg.target))?; } From 8eb01713f2c246a811f75785b26766b855cac15c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 14:02:46 -0700 Subject: [PATCH 019/305] feat(wm): handle non-observable applications OBS Studio is not observable when starting komorebi, so this changes Application.observe to set a new field is_observable to false if registering the observer fails instead of erroring out. This allows the wm initialization to continue instead of crashing. --- komorebi/src/application.rs | 22 ++++++++++++++++++---- komorebi/src/macos_api.rs | 24 ++++++++++-------------- komorebi/src/window_manager.rs | 4 ++-- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index 377562cb..85224b83 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -46,6 +46,7 @@ pub struct Application { element: AccessibilityUiElement, pub process_id: i32, pub observer: AccessibilityObserver, + pub is_observable: bool, } #[instrument(skip_all)] @@ -88,7 +89,7 @@ impl Drop for Application { // this gets called when an Application clone on a Window is dropped, so we need // to make sure it only invalidates the observer if the Application is no longer // running - if !self.is_valid() { + if self.is_observable && !self.is_valid() { tracing::info!( "invalidating application observer for process id {}", self.process_id @@ -108,6 +109,7 @@ impl Application { process_id, Some(application_observer_callback), )?), + is_observable: true, }) } @@ -117,7 +119,7 @@ impl Application { } #[tracing::instrument(skip_all)] - pub fn observe(&self, run_loop: &CFRunLoop) -> Result<(), AccessibilityError> { + pub fn observe(&mut self, run_loop: &CFRunLoop) { tracing::info!( "registering observer for process: {}, name: {}", self.process_id, @@ -125,12 +127,24 @@ impl Application { .unwrap_or_else(|| String::from("")) ); - AccessibilityApi::add_observer_to_run_loop( + match AccessibilityApi::add_observer_to_run_loop( &self.observer, &self.element, NOTIFICATIONS, run_loop, - ) + ) { + Ok(_) => { + self.is_observable = true; + } + Err(error) => { + tracing::warn!( + "failed to register observer for process {} ({}): {error}", + self.process_id, + self.name() + .unwrap_or_else(|| String::from("")) + ); + } + } } pub fn is_valid(&self) -> bool { diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index f6e70e79..51f584ea 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -26,6 +26,7 @@ use objc2_core_foundation::CFString; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use std::collections::HashMap; +use std::collections::hash_map::Entry; use std::ffi::c_void; use std::ptr::NonNull; @@ -82,20 +83,15 @@ impl MacosApi { .entry(monitor_idx) .or_insert_with(Vec::new); - let application = - wm.applications.entry(info.owner_pid).or_insert_with(|| { - let application = Application::new(info.owner_pid) - .unwrap_or_else(|_| { - panic!( - "failed to create application from pid {}", - info.owner_pid - ) - }); - application - .observe(&wm.run_loop) - .expect("application must be observable"); - application - }); + let application = match wm.applications.entry(info.owner_pid) { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(vacant) => { + let mut application = Application::new(info.owner_pid)?; + // TODO: this ain't great, fix this OBS workaround + application.observe(&wm.run_loop); + vacant.insert(application) + } + }; if let Some(window) = application.window_by_title(&info.name) { window.observe(&wm.run_loop)?; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 696d4554..f30eec0d 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -108,8 +108,8 @@ impl WindowManager { match self.applications.entry(process_id) { Entry::Occupied(entry) => Ok(entry.into_mut()), Entry::Vacant(vacant) => { - let application = Application::new(process_id)?; - application.observe(&self.run_loop)?; + let mut application = Application::new(process_id)?; + application.observe(&self.run_loop); Ok(vacant.insert(application)) } } From 63d3b4e33aa486dcfc3c4385ae83b0951dfe30f9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 19 Sep 2025 14:58:10 -0700 Subject: [PATCH 020/305] 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. --- komorebi/src/window_manager.rs | 10 +++++++++- komorebi/src/workspace.rs | 12 +++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index f30eec0d..23bf6229 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -656,8 +656,16 @@ impl WindowManager { } } + let mut reaped_count = 0; + let focused_workspace = self.focused_workspace_mut()?; - focused_workspace.reap_invalid_windows_for_application(process_id, &valid_window_ids)?; + reaped_count += focused_workspace + .reap_invalid_windows_for_application(process_id, &valid_window_ids)?; + + if reaped_count > 0 { + tracing::debug!("reaped {reaped_count} invalid window(s)"); + } + self.update_focused_workspace(false, false) } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 89f31601..8bbb29e6 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -222,7 +222,7 @@ impl Workspace { &mut self, process_id: i32, valid_window_ids: &[u32], - ) -> eyre::Result<()> { + ) -> eyre::Result { let mut invalid_window_ids = vec![]; for container in self.containers() { if let Some(focused_window) = container.focused_window() @@ -233,11 +233,11 @@ impl Workspace { } } - for window_id in invalid_window_ids { - self.remove_window(window_id)?; + for window_id in &invalid_window_ids { + self.remove_window(*window_id)?; } - Ok(()) + Ok(invalid_window_ids.len()) } pub fn remove_window(&mut self, window_id: u32) -> eyre::Result { @@ -808,7 +808,9 @@ impl Workspace { layout.add_padding(border_width); for window in container.windows() { - window.set_position(layout)?; + if let Err(error) = window.set_position(layout) { + tracing::warn!("failed to set window position: {error}") + } } } } From b7ce8c03b5b1948ed3a493efef40402de0886e3d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 20 Sep 2025 10:23:14 -0700 Subject: [PATCH 021/305] 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. --- justfile | 1 + komorebi/src/main.rs | 4 +- komorebi/src/monitor.rs | 24 +++--- komorebi/src/process_command.rs | 52 ++++++------- komorebi/src/window_manager.rs | 128 +++++++++++++++----------------- komorebi/src/workspace.rs | 60 ++++++++------- 6 files changed, 127 insertions(+), 142 deletions(-) diff --git a/justfile b/justfile index 2ba71c05..35a89b32 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,7 @@ export RUST_BACKTRACE := "full" fmt: + test -z "$(rg 'eyre!' --type rust)" || (echo "eyre! macro not allowed"; false) cargo +nightly fmt cargo +stable clippy prettier --write README.md diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index a0fe28ea..24d41cee 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -1,7 +1,7 @@ #![warn(clippy::all)] use color_eyre::eyre; -use color_eyre::eyre::eyre; +use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; use komorebi::ax_event_listener; use komorebi::process_command::listen_for_commands; @@ -102,7 +102,7 @@ fn main() -> eyre::Result<()> { let display_size = unsafe { CGDisplayBounds(CGMainDisplayID()) }; tracing::info!("display size for main display is: {:?}", display_size); - let run_loop = CFRunLoop::current().ok_or(eyre!("couldn't get CFRunLoop::current"))?; + let run_loop = CFRunLoop::current().ok_or_eyre("couldn't get CFRunLoop::current")?; let wm = Arc::new(Mutex::new(WindowManager::new( &run_loop, ax_event_listener::event_rx(), diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 8b825673..0b1afcc5 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -12,7 +12,7 @@ use crate::workspace::Workspace; use crate::workspace::WorkspaceGlobals; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; -use color_eyre::eyre::eyre; +use color_eyre::eyre::OptionExt; use std::collections::VecDeque; use std::sync::atomic::Ordering; @@ -69,7 +69,7 @@ impl Monitor { let focused_workspace_idx = self.focused_workspace_idx(); self.update_workspace_globals(focused_workspace_idx, offset); self.focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace"))? + .ok_or_eyre("there is no workspace")? .update()?; Ok(()) @@ -144,14 +144,14 @@ impl Monitor { ) -> eyre::Result<()> { let workspace = self .focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace"))?; + .ok_or_eyre("there is no workspace")?; // if workspace.maximized_window().is_some() { - // return Err(eyre!("cannot move native maximized window to another monitor or workspace")); + // eyre::bail!("cannot move native maximized window to another monitor or workspace"); // } let foreground_hwnd = - MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; let floating_window_index = workspace .floating_windows() .iter() @@ -175,7 +175,7 @@ impl Monitor { } else { let container = workspace .remove_focused_container() - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let workspaces = self.workspaces_mut(); @@ -229,11 +229,11 @@ impl Monitor { ) -> eyre::Result<()> { let workspace = self .focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace"))?; + .ok_or_eyre("there is no workspace")?; let container = workspace .remove_focused_container() - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let workspaces = self.workspaces_mut(); @@ -280,10 +280,10 @@ impl Monitor { let workspace = if let Some(idx) = workspace_idx { self.workspaces_mut() .get_mut(idx) - .ok_or_else(|| eyre!("there is no workspace at index {}", idx))? + .ok_or_eyre(format!("there is no workspace at index {}", idx))? } else { self.focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace"))? + .ok_or_eyre("there is no workspace")? }; match direction { @@ -392,10 +392,10 @@ impl Monitor { let workspace = if let Some(idx) = workspace_idx { self.workspaces_mut() .get_mut(idx) - .ok_or_else(|| eyre!("there is no workspace at index {}", idx))? + .ok_or_eyre(format!("there is no workspace at index {}", idx))? } else { self.focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace"))? + .ok_or_eyre("there is no workspace")? }; workspace.add_container_to_back(container); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index aae233ca..c83c87c8 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -10,7 +10,7 @@ use crate::window_manager::WindowManager; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; -use color_eyre::eyre::eyre; +use color_eyre::eyre::OptionExt; use parking_lot::Mutex; use std::io::BufRead; use std::io::BufReader; @@ -151,7 +151,7 @@ impl WindowManager { let monitor_idx = direction.next_idx( self.focused_monitor_idx(), NonZeroUsize::new(self.monitors().len()) - .ok_or_else(|| eyre!("there must be at least one monitor"))?, + .ok_or_eyre("there must be at least one monitor")?, ); self.focus_monitor(monitor_idx)?; @@ -170,9 +170,7 @@ impl WindowManager { self.focus_monitor(monitor_idx)?; } - let focused_monitor = self - .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))?; + let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?; let focused_workspace_idx = focused_monitor.focused_workspace_idx(); let workspaces = focused_monitor.workspaces().len(); @@ -180,7 +178,7 @@ impl WindowManager { let workspace_idx = direction.next_idx( focused_workspace_idx, NonZeroUsize::new(workspaces) - .ok_or_else(|| eyre!("there must be at least one workspace"))?, + .ok_or_eyre("there must be at least one workspace")?, ); self.focus_workspace(workspace_idx)?; @@ -202,9 +200,7 @@ impl WindowManager { // } // } - let focused_monitor = self - .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))?; + let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?; let focused_workspace_idx = focused_monitor.focused_workspace_idx(); let workspaces = focused_monitor.workspaces().len(); @@ -221,14 +217,14 @@ impl WindowManager { let mut workspace_idx = direction.next_idx( focused_workspace_idx, NonZeroUsize::new(workspaces) - .ok_or_else(|| eyre!("there must be at least one workspace"))?, + .ok_or_eyre("there must be at least one workspace")?, ); while !empty_workspaces.contains(&workspace_idx) { workspace_idx = direction.next_idx( workspace_idx, NonZeroUsize::new(workspaces) - .ok_or_else(|| eyre!("there must be at least one workspace"))?, + .ok_or_eyre("there must be at least one workspace")?, ); } @@ -263,7 +259,7 @@ impl WindowManager { let idx = self .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .focused_workspace_idx(); if let Some(monitor) = self.focused_monitor_mut() @@ -273,7 +269,7 @@ impl WindowManager { } self.focused_monitor_mut() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .last_focused_workspace = Option::from(idx); } SocketMessage::FocusWorkspaceNumber(workspace_idx) => { @@ -637,7 +633,7 @@ impl WindowManager { let idx = self .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .focused_workspace_idx(); if let Some(monitor) = self.focused_monitor_mut() @@ -647,7 +643,7 @@ impl WindowManager { } self.focused_monitor_mut() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .last_focused_workspace = Option::from(idx); } SocketMessage::SendContainerToLastWorkspace => { @@ -665,7 +661,7 @@ impl WindowManager { let idx = self .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .focused_workspace_idx(); if let Some(monitor) = self.focused_monitor_mut() @@ -674,13 +670,11 @@ impl WindowManager { self.move_container_to_workspace(last_focused_workspace, false, None)?; } self.focused_monitor_mut() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .last_focused_workspace = Option::from(idx); } SocketMessage::CycleMoveContainerToWorkspace(direction) => { - let focused_monitor = self - .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))?; + let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?; let focused_workspace_idx = focused_monitor.focused_workspace_idx(); let workspaces = focused_monitor.workspaces().len(); @@ -688,7 +682,7 @@ impl WindowManager { let workspace_idx = direction.next_idx( focused_workspace_idx, NonZeroUsize::new(workspaces) - .ok_or_else(|| eyre!("there must be at least one workspace"))?, + .ok_or_eyre("there must be at least one workspace")?, ); self.move_container_to_workspace(workspace_idx, true, None)?; @@ -704,16 +698,14 @@ impl WindowManager { let monitor_idx = direction.next_idx( self.focused_monitor_idx(), NonZeroUsize::new(self.monitors().len()) - .ok_or_else(|| eyre!("there must be at least one monitor"))?, + .ok_or_eyre("there must be at least one monitor")?, ); let direction = self.direction_from_monitor_idx(monitor_idx); self.move_container_to_monitor(monitor_idx, None, true, direction)?; } SocketMessage::CycleSendContainerToWorkspace(direction) => { - let focused_monitor = self - .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))?; + let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?; let focused_workspace_idx = focused_monitor.focused_workspace_idx(); let workspaces = focused_monitor.workspaces().len(); @@ -721,7 +713,7 @@ impl WindowManager { let workspace_idx = direction.next_idx( focused_workspace_idx, NonZeroUsize::new(workspaces) - .ok_or_else(|| eyre!("there must be at least one workspace"))?, + .ok_or_eyre("there must be at least one workspace")?, ); self.move_container_to_workspace(workspace_idx, false, None)?; @@ -734,7 +726,7 @@ impl WindowManager { let monitor_idx = direction.next_idx( self.focused_monitor_idx(), NonZeroUsize::new(self.monitors().len()) - .ok_or_else(|| eyre!("there must be at least one monitor"))?, + .ok_or_eyre("there must be at least one monitor")?, ); let direction = self.direction_from_monitor_idx(monitor_idx); @@ -792,7 +784,7 @@ impl WindowManager { let monitor_idx = direction.next_idx( self.focused_monitor_idx(), NonZeroUsize::new(self.monitors().len()) - .ok_or_else(|| eyre!("there must be at least one monitor"))?, + .ok_or_eyre("there must be at least one monitor")?, ); self.move_workspace_to_monitor(monitor_idx)?; @@ -809,13 +801,13 @@ impl WindowManager { let offset = self.work_area_offset; let workspace = self .remove_focused_workspace() - .ok_or_else(|| eyre!("there is no workspace"))?; + .ok_or_eyre("there is no workspace")?; { let target_monitor: &mut Monitor = self .monitors_mut() .get_mut(idx) - .ok_or_else(|| eyre!("there is no monitor"))?; + .ok_or_eyre("there is no monitor")?; target_monitor.workspaces_mut().push_back(workspace); target_monitor.update_workspaces_globals(offset); diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 23bf6229..15fe829b 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -25,7 +25,7 @@ use crate::window_manager_event::WindowManagerEvent; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; -use color_eyre::eyre::eyre; +use color_eyre::eyre::OptionExt; use crossbeam_channel::Receiver; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; @@ -128,10 +128,10 @@ impl WindowManager { if len > 1 { let focused_window_id = - MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; let focused_rect = Rect::from(MacosApi::window_rect( MacosApi::foreground_window() - .ok_or(eyre!("no foreground window"))? + .ok_or_eyre("no foreground window")? .as_ref(), )?); @@ -311,7 +311,7 @@ impl WindowManager { // if there is no floating_window in that direction for this workspace let monitor_idx = self .monitor_idx_in_direction(direction) - .ok_or_else(|| eyre!("there is no container or monitor in this direction"))?; + .ok_or_eyre("there is no container or monitor in this direction")?; self.focus_monitor(monitor_idx)?; let mouse_follows_focus = self.mouse_follows_focus; @@ -422,7 +422,7 @@ impl WindowManager { let delta = self.resize_delta; let focused_window_id = - MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; for window in focused_workspace.floating_windows().iter() { if window.id == focused_window_id { let mut rect = Rect::from(MacosApi::window_rect(&window.element)?); @@ -516,7 +516,7 @@ impl WindowManager { let mouse_follows_focus = self.mouse_follows_focus; self.focused_monitor_mut() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .update_focused_workspace(offset)?; if follow_focus @@ -550,38 +550,38 @@ impl WindowManager { pub fn focused_workspace_idx(&self) -> eyre::Result { Ok(self .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .focused_workspace_idx()) } pub fn focused_workspace(&self) -> eyre::Result<&Workspace> { self.focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .focused_workspace() - .ok_or_else(|| eyre!("there is no workspace")) + .ok_or_eyre("there is no workspace") } pub fn focused_workspace_mut(&mut self) -> eyre::Result<&mut Workspace> { self.focused_monitor_mut() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace")) + .ok_or_eyre("there is no workspace") } pub fn focused_workspace_idx_for_monitor_idx(&self, idx: usize) -> eyre::Result { Ok(self .monitors() .get(idx) - .ok_or_else(|| eyre!("there is no monitor at this index"))? + .ok_or_eyre("there is no monitor at this index")? .focused_workspace_idx()) } pub fn focused_workspace_for_monitor_idx(&self, idx: usize) -> eyre::Result<&Workspace> { self.monitors() .get(idx) - .ok_or_else(|| eyre!("there is no monitor at this index"))? + .ok_or_eyre("there is no monitor at this index")? .focused_workspace() - .ok_or_else(|| eyre!("there is no workspace")) + .ok_or_eyre("there is no workspace") } pub fn focused_workspace_for_monitor_idx_mut( @@ -590,15 +590,15 @@ impl WindowManager { ) -> eyre::Result<&mut Workspace> { self.monitors_mut() .get_mut(idx) - .ok_or_else(|| eyre!("there is no monitor at this index"))? + .ok_or_eyre("there is no monitor at this index")? .focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace")) + .ok_or_eyre("there is no workspace") } pub fn focused_container(&self) -> eyre::Result<&Container> { self.focused_workspace()? .focused_container() - .ok_or_else(|| eyre!("there is no container")) + .ok_or_eyre("there is no container") } pub fn focused_container_idx(&self) -> eyre::Result { @@ -608,32 +608,32 @@ impl WindowManager { pub fn focused_container_mut(&mut self) -> eyre::Result<&mut Container> { self.focused_workspace_mut()? .focused_container_mut() - .ok_or_else(|| eyre!("there is no container")) + .ok_or_eyre("there is no container") } pub fn focused_window(&self) -> eyre::Result<&Window> { self.focused_container()? .focused_window() - .ok_or_else(|| eyre!("there is no window")) + .ok_or_eyre("there is no window") } fn focused_window_mut(&mut self) -> eyre::Result<&mut Window> { self.focused_container_mut()? .focused_window_mut() - .ok_or_else(|| eyre!("there is no window")) + .ok_or_eyre("there is no window") } pub fn focused_monitor_size(&self) -> eyre::Result { Ok(self .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .size) } pub fn focused_monitor_work_area(&self) -> eyre::Result { Ok(self .focused_monitor() - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .work_area_size) } @@ -676,7 +676,7 @@ impl WindowManager { let workspace = self.focused_workspace_mut()?; let len = NonZeroUsize::new(workspace.containers_mut().len()) - .ok_or_else(|| eyre!("there must be at least one container"))?; + .ok_or_eyre("there must be at least one container")?; let current_container_idx = workspace.focused_container_idx(); let is_valid = direction @@ -691,7 +691,7 @@ impl WindowManager { if is_valid { let new_idx = workspace .new_idx_for_direction(direction) - .ok_or_else(|| eyre!("this is not a valid direction from the current position"))?; + .ok_or_eyre("this is not a valid direction from the current position")?; let mut changed_focus = false; @@ -744,7 +744,7 @@ impl WindowManager { tracing::info!("removing window"); if self.focused_container()?.windows().len() == 1 { - Err(eyre!("a container must have at least one window"))?; + eyre::bail!("a container must have at least one window"); } let workspace = self.focused_workspace_mut()?; @@ -783,10 +783,10 @@ impl WindowManager { let container = self.focused_container_mut()?; let len = NonZeroUsize::new(container.windows().len()) - .ok_or_else(|| eyre!("there must be at least one window in a container"))?; + .ok_or_eyre("there must be at least one window in a container")?; if len.get() == 1 { - return Err(eyre!("there is only one window in this container")); + eyre::bail!("there is only one window in this container"); } let current_idx = container.focused_window_idx(); @@ -808,7 +808,7 @@ impl WindowManager { let mouse_follows_focus = self.mouse_follows_focus; let monitor = self .focused_monitor_mut() - .ok_or_else(|| eyre!("there is no workspace"))?; + .ok_or_eyre("there is no workspace")?; monitor.focus_workspace(idx)?; monitor.load_focused_workspace(mouse_follows_focus)?; @@ -828,7 +828,7 @@ impl WindowManager { let mouse_follows_focus = self.mouse_follows_focus; let monitor = self .focused_monitor_mut() - .ok_or_else(|| eyre!("there is no monitor"))?; + .ok_or_eyre("there is no monitor")?; monitor.move_container_to_workspace(idx, follow, direction)?; monitor.load_focused_workspace(mouse_follows_focus)?; @@ -880,7 +880,7 @@ impl WindowManager { #[tracing::instrument(skip(self))] pub fn toggle_float(&mut self, force_float: bool) -> eyre::Result<()> { - let window_id = MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + let window_id = MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; let workspace = self.focused_workspace_mut()?; if workspace.monocle_container.is_some() { @@ -922,7 +922,7 @@ impl WindowManager { let window = workspace .floating_windows_mut() .back_mut() - .ok_or_else(|| eyre!("there is no floating window"))?; + .ok_or_eyre("there is no floating window")?; if toggle_float_placement.should_center() { window.center(&work_area, toggle_float_placement.should_resize())?; @@ -956,7 +956,7 @@ impl WindowManager { WorkspaceLayer::Floating => { let workspace = self.focused_workspace()?; let focused_window_id = - MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; let border_offset = 0; let border_width = 0; @@ -1040,14 +1040,12 @@ impl WindowManager { Layout::Default(layout) => { tracing::info!("resizing window"); let len = NonZeroUsize::new(workspace.containers().len()) - .ok_or_else(|| eyre!("there must be at least one container"))?; + .ok_or_eyre("there must be at least one container")?; let focused_idx = workspace.focused_container_idx(); let focused_idx_resize = workspace .resize_dimensions .get(focused_idx) - .ok_or_else(|| { - eyre!("there is no resize adjustment for this container") - })?; + .ok_or_eyre("there is no resize adjustment for this container")?; if direction .destination( @@ -1096,7 +1094,7 @@ impl WindowManager { let resize = layout.resize( unaltered .get(focused_idx) - .ok_or_else(|| eyre!("there is no last layout"))?, + .ok_or_eyre("there is no last layout")?, focused_idx_resize, direction, sizing, @@ -1137,7 +1135,7 @@ impl WindowManager { let workspace = monitor .focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace"))?; + .ok_or_eyre("there is no workspace")?; // Reset any resize adjustments if we want to force a retile if !preserve_resize_dimensions { @@ -1274,7 +1272,7 @@ impl WindowManager { if self.monitors().get(idx).is_some() { self.monitors.focus(idx); } else { - return Err(eyre!("this is not a valid monitor index")); + eyre::bail!("this is not a valid monitor index"); } Ok(()) @@ -1405,22 +1403,20 @@ impl WindowManager { let monitor = self .focused_monitor_mut() - .ok_or_else(|| eyre!("there is no monitor"))?; + .ok_or_eyre("there is no monitor")?; let current_area = monitor.work_area_size; let workspace = monitor .focused_workspace_mut() - .ok_or_else(|| eyre!("there is no workspace"))?; + .ok_or_eyre("there is no workspace")?; if workspace.maximized_window.is_some() { - return Err(eyre!( - "cannot move native maximized window to another monitor or workspace" - )); + eyre::bail!("cannot move native maximized window to another monitor or workspace"); } let foreground_window_id = - MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; let floating_window_index = workspace .floating_windows() .iter() @@ -1432,7 +1428,7 @@ impl WindowManager { Some( workspace .remove_focused_container() - .ok_or_else(|| eyre!("there is no container"))?, + .ok_or_eyre("there is no container")?, ) } else { None @@ -1442,7 +1438,7 @@ impl WindowManager { let target_monitor = self .monitors_mut() .get_mut(monitor_idx) - .ok_or_else(|| eyre!("there is no monitor"))?; + .ok_or_eyre("there is no monitor")?; let target_monitor_work_area_size = target_monitor.work_area_size; @@ -1455,7 +1451,7 @@ impl WindowManager { } let target_workspace = target_monitor .focused_workspace_mut() - .ok_or_else(|| eyre!("there is no focused workspace on target monitor"))?; + .ok_or_eyre("there is no focused workspace on target monitor")?; if target_workspace.monocle_container.is_some() { for container in target_workspace.containers_mut() { @@ -1495,7 +1491,7 @@ impl WindowManager { // } } } else { - return Err(eyre!("failed to find a window to move")); + eyre::bail!("failed to find a window to move"); } if should_load_workspace { @@ -1545,7 +1541,7 @@ impl WindowManager { let first_monitor = self .monitors() .get(first_idx) - .ok_or_else(|| eyre!("There is no monitor"))?; + .ok_or_eyre("There is no monitor")?; first_monitor.focused_workspace_idx() }; @@ -1553,7 +1549,7 @@ impl WindowManager { let second_monitor = self .monitors() .get(second_idx) - .ok_or_else(|| eyre!("There is no monitor"))?; + .ok_or_eyre("There is no monitor")?; second_monitor.focused_workspace_idx() }; @@ -1562,24 +1558,24 @@ impl WindowManager { let first_workspaces = self .monitors_mut() .get_mut(first_idx) - .ok_or_else(|| eyre!("There is no monitor"))? + .ok_or_eyre("There is no monitor")? .remove_workspaces(); let second_workspaces = self .monitors_mut() .get_mut(second_idx) - .ok_or_else(|| eyre!("There is no monitor"))? + .ok_or_eyre("There is no monitor")? .remove_workspaces(); self.monitors_mut() .get_mut(first_idx) - .ok_or_else(|| eyre!("There is no monitor"))? + .ok_or_eyre("There is no monitor")? .workspaces_mut() .extend(second_workspaces); self.monitors_mut() .get_mut(second_idx) - .ok_or_else(|| eyre!("There is no monitor"))? + .ok_or_eyre("There is no monitor")? .workspaces_mut() .extend(first_workspaces); @@ -1605,7 +1601,7 @@ impl WindowManager { self.monitors_mut() .get_mut(idx) - .ok_or_else(|| eyre!("there is no monitor"))? + .ok_or_eyre("there is no monitor")? .update_focused_workspace(offset) } @@ -1635,7 +1631,7 @@ impl WindowManager { let new_idx = workspace .new_idx_for_cycle_direction(direction) - .ok_or_else(|| eyre!("this is not a valid direction from the current position"))?; + .ok_or_eyre("this is not a valid direction from the current position")?; workspace.focus_container(new_idx); @@ -1658,9 +1654,7 @@ impl WindowManager { ) -> eyre::Result<()> { let workspace = self.focused_workspace_mut()?; if workspace.is_focused_window_monocle_or_maximized()? { - return Err(eyre!( - "ignoring command while active window is in monocle mode or maximized" - )); + eyre::bail!("ignoring command while active window is in monocle mode or maximized"); } tracing::info!("moving container"); @@ -1668,7 +1662,7 @@ impl WindowManager { let current_idx = workspace.focused_container_idx(); let new_idx = workspace .new_idx_for_cycle_direction(direction) - .ok_or_else(|| eyre!("this is not a valid direction from the current position"))?; + .ok_or_eyre("this is not a valid direction from the current position")?; workspace.swap_containers(current_idx, new_idx); workspace.focus_container(new_idx); @@ -1688,7 +1682,7 @@ impl WindowManager { if len > 1 { let focused_window_id = - MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; for (idx, window) in focused_workspace.floating_windows().iter().enumerate() { if window.id == focused_window_id { match direction { @@ -1741,10 +1735,10 @@ impl WindowManager { }; let len = NonZeroUsize::new(container.windows().len()) - .ok_or_else(|| eyre!("there must be at least one window in a container"))?; + .ok_or_eyre("there must be at least one window in a container")?; if len.get() == 1 { - return Err(eyre!("there is only one window in this container")); + eyre::bail!("there is only one window in this container"); } let current_idx = container.focused_window_idx(); @@ -1775,14 +1769,14 @@ impl WindowManager { }; let len = NonZeroUsize::new(container.windows().len()) - .ok_or_else(|| eyre!("there must be at least one window in a container"))?; + .ok_or_eyre("there must be at least one window in a container")?; if len.get() == 1 && idx != 0 { - return Err(eyre!("there is only one window in this container")); + eyre::bail!("there is only one window in this container"); } if container.windows().get(idx).is_none() { - return Err(eyre!("there is no window in this container at index {idx}")); + eyre::bail!("there is no window in this container at index {idx}"); } container.focus_window(idx); diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 8bbb29e6..4408040e 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -13,7 +13,7 @@ use crate::macos_api::MacosApi; use crate::ring::Ring; use crate::window::Window; use color_eyre::eyre; -use color_eyre::eyre::eyre; +use color_eyre::eyre::OptionExt; use serde::Deserialize; use serde::Serialize; use std::fmt::Display; @@ -157,16 +157,16 @@ impl Workspace { pub fn focus_container_by_window(&mut self, window_id: u32) -> eyre::Result<()> { let container_idx = self .container_idx_for_window(window_id) - .ok_or_else(|| eyre!("there is no container/window"))?; + .ok_or_eyre("there is no container/window")?; let container = self .containers_mut() .get_mut(container_idx) - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let window_idx = container .idx_for_window(window_id) - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; let mut should_load = false; @@ -249,7 +249,7 @@ impl Workspace { { let window = container .remove_window_by_idx(window_idx) - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; if container.windows().is_empty() { self.monocle_container = None; @@ -265,22 +265,22 @@ impl Workspace { let container_idx = self .container_idx_for_window(window_id) - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; let container = self .containers_mut() .get_mut(container_idx) - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let window_idx = container .windows() .iter() .position(|window| window.id == window_id) - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; let window = container .remove_window_by_idx(window_idx) - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; if container.windows().is_empty() { self.remove_container_by_idx(container_idx); @@ -313,7 +313,7 @@ impl Workspace { } pub fn is_focused_window_monocle_or_maximized(&self) -> eyre::Result { - let window_id = MacosApi::foreground_window_id().ok_or(eyre!("no foreground window"))?; + let window_id = MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; if let Some(window) = &self.maximized_window && window_id == window.id { @@ -358,11 +358,11 @@ impl Workspace { let container = self .focused_container_mut() - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let window = container .remove_focused_window() - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; // This is a little messy let adjusted_target_container_index = if container.windows().is_empty() { @@ -381,13 +381,13 @@ impl Workspace { let target_container = self .containers_mut() .get_mut(adjusted_target_container_index) - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; target_container.add_window(&window)?; self.focus_container(adjusted_target_container_index); self.focused_container_mut() - .ok_or_else(|| eyre!("there is no container"))? + .ok_or_eyre("there is no container")? .load_focused_window()?; Ok(()) @@ -398,11 +398,11 @@ impl Workspace { let container = self .focused_container_mut() - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let window = container .remove_focused_window() - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; if container.windows().is_empty() { self.remove_container_by_idx(focused_container_idx); @@ -515,7 +515,7 @@ impl Workspace { let resize = self.resize_dimensions.remove(0); let container = self .remove_focused_container() - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let primary_idx = match self.layout { Layout::Default(_) => 0, @@ -555,7 +555,7 @@ impl Workspace { let container = self .containers_mut() .remove(focused_idx) - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; // We don't remove any resize adjustments for a monocle, because when this container is // inevitably reintegrated, it would be weird if it doesn't go back to the dimensions @@ -567,7 +567,7 @@ impl Workspace { self.monocle_container .as_mut() - .ok_or_else(|| eyre!("there is no monocle container"))? + .ok_or_eyre("there is no monocle container")? .load_focused_window()?; Ok(()) @@ -576,12 +576,12 @@ impl Workspace { pub fn reintegrate_monocle_container(&mut self) -> eyre::Result<()> { let restore_idx = self .monocle_container_restore_idx - .ok_or_else(|| eyre!("there is no monocle restore index"))?; + .ok_or_eyre("there is no monocle restore index")?; let container = self .monocle_container .as_ref() - .ok_or_else(|| eyre!("there is no monocle container"))?; + .ok_or_eyre("there is no monocle container")?; let container = container.clone(); if restore_idx >= self.containers().len() { @@ -595,7 +595,7 @@ impl Workspace { self.containers_mut().insert(restore_idx, container); self.focus_container(restore_idx); self.focused_container_mut() - .ok_or_else(|| eyre!("there is no container"))? + .ok_or_eyre("there is no container")? .load_focused_window()?; self.monocle_container = None; @@ -608,7 +608,7 @@ impl Workspace { let window = if let Some(monocle_container) = &mut self.monocle_container { let window = monocle_container .remove_focused_window() - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; if monocle_container.windows().is_empty() { self.monocle_container = None; @@ -623,11 +623,11 @@ impl Workspace { let container = self .focused_container_mut() - .ok_or_else(|| eyre!("there is no container"))?; + .ok_or_eyre("there is no container")?; let window = container .remove_focused_window() - .ok_or_else(|| eyre!("there is no window"))?; + .ok_or_eyre("there is no window")?; if container.windows().is_empty() { self.remove_container_by_idx(focused_idx); @@ -651,7 +651,7 @@ impl Workspace { let focused_idx = self.focused_container_idx(); let window = self .remove_focused_floating_window() - .ok_or_else(|| eyre!("there is no floating window"))?; + .ok_or_eyre("there is no floating window")?; let mut container = Container::default(); container.add_window(&window)?; @@ -787,11 +787,9 @@ impl Workspace { } else if !self.containers().is_empty() { let mut layouts = self.layout.as_boxed_arrangement().calculate( &adjusted_work_area, - NonZeroUsize::new(self.containers().len()).ok_or_else(|| { - eyre!( - "there must be at least one container to calculate a workspace layout" - ) - })?, + NonZeroUsize::new(self.containers().len()).ok_or_eyre( + "there must be at least one container to calculate a workspace layout", + )?, Some(container_padding), self.layout_flip, &self.resize_dimensions, From a4bc40aa5e7e6b922946f910e8c60661929f506c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 20 Sep 2025 22:07:47 -0700 Subject: [PATCH 022/305] 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. --- Cargo.lock | 3 + justfile | 2 + komorebi/Cargo.toml | 1 + .../src/app_kit_notification_constants.rs | 75 ++++++++ komorebi/src/application.rs | 8 +- komorebi/src/lib.rs | 4 +- komorebi/src/main.rs | 3 + komorebi/src/notification_center_listener.rs | 172 ++++++++++++++++++ komorebi/src/process_event.rs | 8 +- komorebi/src/window.rs | 10 +- komorebi/src/window_manager_event.rs | 61 +++++-- komorebi/src/workspace.rs | 11 +- 12 files changed, 328 insertions(+), 30 deletions(-) create mode 100644 komorebi/src/app_kit_notification_constants.rs create mode 100644 komorebi/src/notification_center_listener.rs diff --git a/Cargo.lock b/Cargo.lock index 01c15071..6c66057a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -536,6 +536,7 @@ dependencies = [ "objc2-application-services", "objc2-core-foundation", "objc2-core-graphics", + "objc2-foundation", "parking_lot", "pastey", "serde", @@ -800,6 +801,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c" dependencies = [ "bitflags", + "block2", + "libc", "objc2", "objc2-core-foundation", ] diff --git a/justfile b/justfile index 35a89b32..0beb52cf 100644 --- a/justfile +++ b/justfile @@ -2,6 +2,8 @@ export RUST_BACKTRACE := "full" fmt: test -z "$(rg 'eyre!' --type rust)" || (echo "eyre! macro not allowed"; false) + test -z "$(rg 'dbg!' --type rust)" || (echo "dbg! macro not allowed"; false) + test -z "$(rg 'println!' --type rust)" || (echo "println! macro not allowed"; false) cargo +nightly fmt cargo +stable clippy prettier --write README.md diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index c6c3a98d..ff957cc5 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -13,6 +13,7 @@ lazy_static = { workspace = true } objc2 = "0.6" objc2-app-kit = "0.3" objc2-application-services = "0.3" +objc2-foundation = "0.3" objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } parking_lot = "0.12" diff --git a/komorebi/src/app_kit_notification_constants.rs b/komorebi/src/app_kit_notification_constants.rs new file mode 100644 index 00000000..d77c328e --- /dev/null +++ b/komorebi/src/app_kit_notification_constants.rs @@ -0,0 +1,75 @@ +#![allow(clippy::enum_variant_names)] + +use objc2::rc::Retained; +use objc2_foundation::NSNotification; +use objc2_foundation::NSNotificationName; +use serde::Deserialize; +use serde::Serialize; +use std::str::FromStr; +use strum::Display; +use strum::EnumString; + +#[derive(Debug, Copy, Clone, Serialize, Deserialize, Display, EnumString)] +pub enum AppKitWorkspaceNotification { + // A notification that the workspace posts when any of the accessibility display options change. + NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification, + // A notification that the workspace posts when a Spaces change occurs. + NSWorkspaceActiveSpaceDidChangeNotification, + // A notification that the workspace posts when the Finder is about to activate an app. + NSWorkspaceDidActivateApplicationNotification, + // A notification that the workspace posts when the Finder file labels or colors change. + NSWorkspaceDidChangeFileLabelsNotification, + // A notification that the workspace posts when the Finder deactivates an app. + NSWorkspaceDidDeactivateApplicationNotification, + // A notification that the workspace posts when the Finder hides an app. + NSWorkspaceDidHideApplicationNotification, + // A notification that the workspace posts when a new app starts up. + NSWorkspaceDidLaunchApplicationNotification, + // A notification that the workspace posts when a new device mounts. + NSWorkspaceDidMountNotification, + // Posted when a file operation has been performed in the receiving app. + // #[deprecated] + // NSWorkspaceDidPerformFileOperationNotification, + // A notification that the workspace posts when a volume changes its name or mount path. + NSWorkspaceDidRenameVolumeNotification, + // A notification that the workspace posts when an app finishes executing. + NSWorkspaceDidTerminateApplicationNotification, + // A notification that the workspace posts when the Finder unhides an app. + NSWorkspaceDidUnhideApplicationNotification, + // A notification that the workspace posts when the Finder unmounts a device. + NSWorkspaceDidUnmountNotification, + // A notification that the workspace posts when the device wakes from sleep. + NSWorkspaceDidWakeNotification, + // A notification that the workspace posts when the device’s screen goes to sleep. + NSWorkspaceScreensDidSleepNotification, + // A notification that the workspace posts when the device’s screens wake. + NSWorkspaceScreensDidWakeNotification, + // A notification that the workspace posts after a user session switches in. + NSWorkspaceSessionDidBecomeActiveNotification, + // A notification that the workspace posts before a user session switches out. + NSWorkspaceSessionDidResignActiveNotification, + // A notification that the workspace posts when the Finder is about to launch an app. + NSWorkspaceWillLaunchApplicationNotification, + // A notification that the workspace posts when the user requests a logout or powers off the device. + NSWorkspaceWillPowerOffNotification, + // A notification that the workspace posts before the device goes to sleep. + NSWorkspaceWillSleepNotification, + // A notification that the workspace posts when the Finder is about to unmount a device. + NSWorkspaceWillUnmountNotification, +} + +impl From for Retained { + fn from(value: AppKitWorkspaceNotification) -> Self { + NSNotificationName::from_str(&value.to_string()) + } +} + +impl TryFrom for AppKitWorkspaceNotification { + type Error = strum::ParseError; + + fn try_from(value: NSNotification) -> Result { + let name = unsafe { value.name().to_string() }; + + AppKitWorkspaceNotification::from_str(&name) + } +} diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index 85224b83..ec8e51d7 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -15,6 +15,7 @@ use crate::accessibility::notification_constants::kAXUIElementDestroyedNotificat use crate::accessibility::notification_constants::kAXWindowCreatedNotification; use crate::ax_event_listener::event_tx; use crate::window::Window; +use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use objc2_application_services::AXObserver; use objc2_application_services::AXUIElement; @@ -69,8 +70,11 @@ unsafe extern "C-unwind" fn application_observer_callback( if let Ok(notification) = AccessibilityNotification::from_str(¬ification.as_ref().to_string()) - && let Some(event) = - WindowManagerEvent::from_ax_notification(notification, process_id, None) + && let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::Accessibility(notification), + process_id, + None, + ) { if let Err(error) = event_tx().send(event) { tracing::error!("failed to send window manager event: {error}"); diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 3055f20d..ea511ff5 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -28,6 +28,7 @@ use std::sync::atomic::AtomicI32; pub mod ring; pub mod accessibility; +mod app_kit_notification_constants; pub mod application; pub mod ax_event_listener; mod container; @@ -35,7 +36,8 @@ pub mod core; pub mod core_graphics; pub mod lockable_sequence; pub mod macos_api; -mod monitor; +pub mod monitor; +pub mod notification_center_listener; pub mod process_command; pub mod process_event; pub mod window; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 24d41cee..d8907b5b 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -4,6 +4,7 @@ use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; use komorebi::ax_event_listener; +use komorebi::notification_center_listener::NotificationCenterListener; use komorebi::process_command::listen_for_commands; use komorebi::process_event::listen_for_events; use komorebi::window_manager::WindowManager; @@ -99,6 +100,8 @@ fn main() -> eyre::Result<()> { std::fs::create_dir_all(&*DATA_DIR)?; } + let _notification_center_listener = NotificationCenterListener::init(); + let display_size = unsafe { CGDisplayBounds(CGMainDisplayID()) }; tracing::info!("display size for main display is: {:?}", display_size); diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs new file mode 100644 index 00000000..f97c94fe --- /dev/null +++ b/komorebi/src/notification_center_listener.rs @@ -0,0 +1,172 @@ +use crate::app_kit_notification_constants::AppKitWorkspaceNotification; +use crate::ax_event_listener::event_tx; +use crate::window_manager_event::SystemNotification; +use crate::window_manager_event::WindowManagerEvent; +use objc2::AnyThread; +use objc2::define_class; +use objc2::msg_send; +use objc2::rc::Retained; +use objc2::runtime::NSObject; +use objc2::sel; +use objc2_app_kit::NSApplication; +use objc2_app_kit::NSRunningApplication; +use objc2_app_kit::NSWorkspace; +use objc2_foundation::NSDistributedNotificationCenter; +use objc2_foundation::NSNotification; +use objc2_foundation::NSNotificationCenter; +use objc2_foundation::NSNotificationName; +use objc2_foundation::NSString; +use std::str::FromStr; + +#[derive(Debug, Clone)] +pub struct Ivars {} + +// this is gross, auto formatting doesn't work inside here +define_class! { + #[unsafe(super(NSObject))] + #[ivars = Ivars] + #[derive(Debug)] + pub struct NotificationCenterListenerNsObject; + + impl NotificationCenterListenerNsObject { + #[unsafe(method(handleNotification:))] + fn handle_notification(&self, notif: &NSNotification) { + unsafe { + let mut process_id = None; + let mut valid_keys = vec![]; + + if let Some(user_info) = notif.userInfo() { + let all_keys = user_info.allKeys(); + for k in all_keys { + if let Some(key) = k.downcast_ref::() { + valid_keys.push(key.to_string()); + } + } + + if let Some(application_key) = + user_info.valueForKey(&NSString::from_str("NSWorkspaceApplicationKey")) + && let Some(application) = application_key.downcast_ref::() + { + process_id = Some(application.processIdentifier()); + // TODO: maybe get the window IDs here too? + } + } + + tracing::trace!("received {} with keys {}", notif.name(), valid_keys.join(", ")); + + match process_id { + None => { + tracing::debug!( + "notification: {}, skipping as there is no associated process id", + notif.name() + ); + } + Some(process_id) => { + tracing::debug!("notification: {}, process: {process_id}", notif.name()); + if let Ok(notification) = + AppKitWorkspaceNotification::from_str(¬if.name().to_string()) + && let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::AppKitWorkspace(notification), + process_id, + None, + ) + && let Err(error) = event_tx().send(event) + { + tracing::error!("failed to send window manager event: {error}"); + }; + } + } + } + } + } +} + +#[derive(Debug)] +pub struct NotificationCenterListener { + pub inner: Retained, +} + +impl Drop for NotificationCenterListener { + fn drop(&mut self) { + tracing::info!("removing notification center observer"); + unsafe { + NSWorkspace::sharedWorkspace() + .notificationCenter() + .removeObserver(&self.inner); + NSNotificationCenter::defaultCenter().removeObserver(&self.inner); + NSDistributedNotificationCenter::defaultCenter().removeObserver(&self.inner); + } + } +} + +impl NotificationCenterListenerNsObject { + fn new() -> Retained { + // if we don't set ivars here this fails to compile + let this = Self::alloc().set_ivars(Ivars {}); + unsafe { msg_send![super(this), init] } + } +} + +impl NotificationCenterListener { + pub fn init() -> Self { + let observer = NotificationCenterListener { + inner: NotificationCenterListenerNsObject::new(), + }; + + unsafe { + // this is needed to get the spice flowing?? + if !NSApplication::load() { + panic!("NSApplicationLoad failed"); + } + + let shared_workspace = NSWorkspace::sharedWorkspace(); + let notification_center = shared_workspace.notificationCenter(); + + // https://developer.apple.com/documentation/appkit/nsworkspace/willlaunchapplicationnotification?language=objc + for notification in [ + // A notification that the workspace posts when a new app starts up. + AppKitWorkspaceNotification::NSWorkspaceDidLaunchApplicationNotification, + // A notification that the workspace posts when an app finishes executing. + AppKitWorkspaceNotification::NSWorkspaceDidTerminateApplicationNotification, + // A notification that the workspace posts after a user session switches in. + AppKitWorkspaceNotification::NSWorkspaceSessionDidBecomeActiveNotification, + // A notification that the workspace posts before a user session switches out. + AppKitWorkspaceNotification::NSWorkspaceSessionDidResignActiveNotification, + // A notification that the workspace posts when the Finder hides an app. + AppKitWorkspaceNotification::NSWorkspaceDidHideApplicationNotification, + // A notification that the workspace posts when the Finder unhides an app. + AppKitWorkspaceNotification::NSWorkspaceDidUnhideApplicationNotification, + // A notification that the workspace posts when the Finder is about to activate an app. + AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification, + // A notification that the workspace posts when the Finder deactivates an app. + AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification, + // A notification that the workspace posts when a volume changes its name or mount path. + AppKitWorkspaceNotification::NSWorkspaceDidRenameVolumeNotification, + // A notification that the workspace posts when a new device mounts. + AppKitWorkspaceNotification::NSWorkspaceDidMountNotification, + // A notification that the workspace posts when the Finder is about to unmount a device. + AppKitWorkspaceNotification::NSWorkspaceWillUnmountNotification, + // A notification that the workspace posts when the Finder unmounts a device. + AppKitWorkspaceNotification::NSWorkspaceDidUnmountNotification, + // A notification that the workspace posts when the Finder file labels or colors change. + AppKitWorkspaceNotification::NSWorkspaceDidChangeFileLabelsNotification, + // A notification that the workspace posts when a Spaces change occurs. + AppKitWorkspaceNotification::NSWorkspaceActiveSpaceDidChangeNotification, + // A notification that the workspace posts when the device wakes from sleep. + AppKitWorkspaceNotification::NSWorkspaceDidWakeNotification, + ] { + let notification_name: Retained = notification.into(); + + // thanks, I hate it + notification_center.addObserver_selector_name_object( + &observer.inner, + sel!(handleNotification:), + Some(¬ification_name), + None, + ); + } + } + + observer + } +} diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 61e615dd..86532d93 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -4,6 +4,7 @@ use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::window::Window; use crate::window_manager::WindowManager; +use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; @@ -103,7 +104,12 @@ impl WindowManager { } } - if matches!(notification, AccessibilityNotification::AXMainWindowChanged) { + if matches!( + notification, + SystemNotification::Accessibility( + AccessibilityNotification::AXMainWindowChanged + ) + ) { self.reap_invalid_windows_for_application(process_id)?; self.update_focused_workspace(false, false)?; } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index fb67b849..709bb4c0 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -25,6 +25,7 @@ use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; use crate::hidden_frame_bottom_left; use crate::macos_api::MacosApi; +use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; @@ -85,8 +86,11 @@ unsafe extern "C-unwind" fn window_observer_callback( if let Ok(notification) = AccessibilityNotification::from_str(¬ification.as_ref().to_string()) - && let Some(event) = - WindowManagerEvent::from_ax_notification(notification, process_id, window_id) + && let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::Accessibility(notification), + process_id, + window_id, + ) { if let Err(error) = event_tx().send(event) { tracing::error!("failed to send window manager event: {error}"); @@ -148,7 +152,6 @@ impl WindowInfo { } #[derive(Debug, Clone)] -#[allow(unused)] pub struct Window { pub id: u32, pub element: AccessibilityUiElement, @@ -459,7 +462,6 @@ impl From<&CFDictionary> for WindowInfo { } #[derive(Default, Debug, Copy, Clone)] -#[allow(unused)] pub struct WindowBounds { pub height: f32, pub width: f32, diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index c06cc7c3..8cd9b1cd 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -1,41 +1,62 @@ #![allow(non_upper_case_globals)] use crate::accessibility::notification_constants::AccessibilityNotification; +use crate::app_kit_notification_constants::AppKitWorkspaceNotification; use serde::Deserialize; use serde::Serialize; use strum::Display; +#[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] +#[serde(tag = "type", content = "content")] +pub enum SystemNotification { + Accessibility(AccessibilityNotification), + AppKitWorkspace(AppKitWorkspaceNotification), +} + #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] #[serde(tag = "type", content = "content")] pub enum WindowManagerEvent { - FocusChange(AccessibilityNotification, i32, Option), - Show(AccessibilityNotification, i32), - Destroy(AccessibilityNotification, i32), - Minimize(AccessibilityNotification, i32, u32), - Restore(AccessibilityNotification, i32, u32), + FocusChange(SystemNotification, i32, Option), + Show(SystemNotification, i32), + Destroy(SystemNotification, i32), + Minimize(SystemNotification, i32, u32), + Restore(SystemNotification, i32, u32), } impl WindowManagerEvent { - pub fn from_ax_notification( - notification: AccessibilityNotification, + pub fn from_system_notification( + notification: SystemNotification, process_id: i32, window_id: Option, ) -> Option { match notification { - AccessibilityNotification::AXMainWindowChanged - | AccessibilityNotification::AXApplicationActivated => Some( - WindowManagerEvent::FocusChange(notification, process_id, window_id), - ), - AccessibilityNotification::AXWindowCreated - | AccessibilityNotification::AXApplicationShown => { - Some(WindowManagerEvent::Show(notification, process_id)) + SystemNotification::Accessibility(AccessibilityNotification::AXMainWindowChanged) + | SystemNotification::Accessibility( + AccessibilityNotification::AXApplicationActivated, + ) => Some(WindowManagerEvent::FocusChange( + notification, + process_id, + window_id, + )), + SystemNotification::Accessibility(AccessibilityNotification::AXWindowCreated) + | SystemNotification::Accessibility(AccessibilityNotification::AXApplicationShown) + | SystemNotification::AppKitWorkspace( + AppKitWorkspaceNotification::NSWorkspaceDidLaunchApplicationNotification, + ) => Some(WindowManagerEvent::Show(notification, process_id)), + SystemNotification::Accessibility(AccessibilityNotification::AXUIElementDestroyed) + | SystemNotification::AppKitWorkspace( + AppKitWorkspaceNotification::NSWorkspaceDidTerminateApplicationNotification, + ) => Some(WindowManagerEvent::Destroy(notification, process_id)), + // TODO: figure out if we wanna handle the hide/unhide notifications separately + // TODO: maybe turn window id into a vec of window IDs for hidden apps + SystemNotification::Accessibility(AccessibilityNotification::AXWindowMiniaturized) => { + window_id.map(|window_id| { + WindowManagerEvent::Minimize(notification, process_id, window_id) + }) } - AccessibilityNotification::AXUIElementDestroyed => { - Some(WindowManagerEvent::Destroy(notification, process_id)) - } - AccessibilityNotification::AXWindowMiniaturized => window_id - .map(|window_id| WindowManagerEvent::Minimize(notification, process_id, window_id)), - AccessibilityNotification::AXWindowDeminiaturized => window_id + SystemNotification::Accessibility( + AccessibilityNotification::AXWindowDeminiaturized, + ) => window_id .map(|window_id| WindowManagerEvent::Restore(notification, process_id, window_id)), // kAXWindowMovedNotification => {} // kAXWindowResizedNotification => {} diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 4408040e..1b413c08 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -227,9 +227,16 @@ impl Workspace { for container in self.containers() { if let Some(focused_window) = container.focused_window() && focused_window.application.process_id == process_id - && !valid_window_ids.contains(&focused_window.id) { - invalid_window_ids.push(focused_window.id); + if !valid_window_ids.contains(&focused_window.id) { + invalid_window_ids.push(focused_window.id); + } + + // if accessibility API calls fail on AXError::InvalidUIElement + // let's try and nuke these early + if !focused_window.is_valid() { + invalid_window_ids.push(focused_window.id); + } } } From 98616c428849da97570dbeeef7ea43a01d811b84 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 21 Sep 2025 10:05:42 -0700 Subject: [PATCH 023/305] 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. --- .../src/display_reconfiguration_listener.rs | 91 +++++++++++++ komorebi/src/lib.rs | 2 + komorebi/src/main.rs | 4 + komorebi/src/monitor_reconciliator.rs | 123 ++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 komorebi/src/display_reconfiguration_listener.rs create mode 100644 komorebi/src/monitor_reconciliator.rs diff --git a/komorebi/src/display_reconfiguration_listener.rs b/komorebi/src/display_reconfiguration_listener.rs new file mode 100644 index 00000000..0683f2d3 --- /dev/null +++ b/komorebi/src/display_reconfiguration_listener.rs @@ -0,0 +1,91 @@ +use crate::core_graphics::error::CoreGraphicsError; +use crate::monitor_reconciliator; +use crate::monitor_reconciliator::MonitorNotification; +use objc2_core_graphics::CGDirectDisplayID; +use objc2_core_graphics::CGDisplayChangeSummaryFlags; +use objc2_core_graphics::CGDisplayRegisterReconfigurationCallback; +use objc2_core_graphics::CGDisplayRemoveReconfigurationCallback; +use std::ffi::c_void; + +pub struct DisplayReconfigurationListener {} + +unsafe extern "C-unwind" fn callback( + display_id: CGDirectDisplayID, + flags: CGDisplayChangeSummaryFlags, + _user_info: *mut c_void, +) { + if flags.contains(CGDisplayChangeSummaryFlags::DesktopShapeChangedFlag) { + tracing::debug!("display: {display_id} resized"); + monitor_reconciliator::send_notification(MonitorNotification::Resize(display_id)); + } + + // if flags.contains(CGDisplayChangeSummaryFlags::BeginConfigurationFlag) { + // tracing::debug!("display: {display_id} configured"); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::AddFlag) { + // tracing::debug!("display: {display_id} added"); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::RemoveFlag) { + // tracing::debug!("display: {display_id} removed"); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::MirrorFlag) { + // tracing::debug!("display: {display_id} mirrored"); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::UnMirrorFlag) { + // tracing::debug!("display: {display_id} unmirrored"); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::EnabledFlag) { + // tracing::debug!("display: {display_id} enabled"); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::DisabledFlag) { + // tracing::debug!("display: {display_id} disabled"); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::DisabledFlag) { + // tracing::debug!("display: {display_id} disabled"); + // } + // + // tracing::trace!("display: {display_id}, flags: {flags:?}"); +} + +impl DisplayReconfigurationListener { + pub fn init() -> Result<(), CoreGraphicsError> { + tracing::info!("registering display reconfiguration listener callback"); + + unsafe { + match CoreGraphicsError::from(CGDisplayRegisterReconfigurationCallback( + Some(callback), + std::ptr::null_mut(), + )) { + CoreGraphicsError::Success => Ok(()), + err => Err(err), + } + } + } +} + +impl Drop for DisplayReconfigurationListener { + fn drop(&mut self) { + tracing::info!("removing display reconfiguration listener callback"); + + unsafe { + match CoreGraphicsError::from(CGDisplayRemoveReconfigurationCallback( + Some(callback), + std::ptr::null_mut(), + )) { + CoreGraphicsError::Success => {} + error => { + tracing::error!( + "failed to remove display reconfiguration listener callback {error}" + ) + } + } + } + } +} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index ea511ff5..1fcd7823 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -34,9 +34,11 @@ pub mod ax_event_listener; mod container; pub mod core; pub mod core_graphics; +pub mod display_reconfiguration_listener; pub mod lockable_sequence; pub mod macos_api; pub mod monitor; +pub mod monitor_reconciliator; pub mod notification_center_listener; pub mod process_command; pub mod process_event; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index d8907b5b..323280d2 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -4,6 +4,8 @@ use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; use komorebi::ax_event_listener; +use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; +use komorebi::monitor_reconciliator; use komorebi::notification_center_listener::NotificationCenterListener; use komorebi::process_command::listen_for_commands; use komorebi::process_event::listen_for_events; @@ -101,6 +103,7 @@ fn main() -> eyre::Result<()> { } let _notification_center_listener = NotificationCenterListener::init(); + let _display_reconfiguration_listener = DisplayReconfigurationListener::init(); let display_size = unsafe { CGDisplayBounds(CGMainDisplayID()) }; tracing::info!("display size for main display is: {:?}", display_size); @@ -116,6 +119,7 @@ fn main() -> eyre::Result<()> { listen_for_commands(wm.clone()); listen_for_events(wm.clone()); + monitor_reconciliator::listen_for_notifications(wm.clone())?; let quit_ctrlc = Arc::new(AtomicBool::new(false)); let quit_thread = quit_ctrlc.clone(); diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs new file mode 100644 index 00000000..f0c2be23 --- /dev/null +++ b/komorebi/src/monitor_reconciliator.rs @@ -0,0 +1,123 @@ +use crate::core::rect::Rect; +use crate::core_graphics::CoreGraphicsApi; +use crate::window_manager::WindowManager; +use crossbeam_channel::Receiver; +use crossbeam_channel::Sender; +use objc2_core_graphics::CGDirectDisplayID; +use parking_lot::Mutex; +use serde::Deserialize; +use serde::Serialize; +use std::sync::Arc; +use std::sync::OnceLock; +use strum::Display; + +#[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] + +pub enum MonitorNotification { + Resize(CGDirectDisplayID), +} + +static CHANNEL: OnceLock<(Sender, Receiver)> = + OnceLock::new(); +pub fn channel() -> &'static (Sender, Receiver) { + CHANNEL.get_or_init(|| crossbeam_channel::bounded(20)) +} + +fn event_tx() -> Sender { + channel().0.clone() +} + +fn event_rx() -> Receiver { + channel().1.clone() +} + +pub fn send_notification(notification: MonitorNotification) { + if event_tx().try_send(notification).is_err() { + tracing::warn!("channel is full; dropping notification") + } +} + +pub fn listen_for_notifications(wm: Arc>) -> color_eyre::Result<()> { + std::thread::spawn(move || { + loop { + match handle_notifications(wm.clone()) { + Ok(()) => { + tracing::warn!("restarting finished thread"); + } + Err(error) => { + if cfg!(debug_assertions) { + tracing::error!("restarting failed thread: {:?}", error) + } else { + tracing::error!("restarting failed thread: {}", error) + } + } + } + } + }); + + Ok(()) +} + +pub fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> { + tracing::info!("listening"); + + let receiver = event_rx(); + + for notification in receiver { + let mut wm = wm.lock(); + + match notification { + MonitorNotification::Resize(display_id) => { + tracing::debug!("handling resize notification"); + let new_size = CoreGraphicsApi::display_bounds(display_id); + for monitor in wm.monitors_mut() { + let mut should_update = false; + + if Rect::from(new_size) != monitor.size { + // need to do this because we can't call NSScreen from a background thread + monitor.work_area_size = calculate_scaled_work_area( + &Rect::from(new_size), + &monitor.size, + &monitor.work_area_size, + ); + monitor.size = Rect::from(new_size); + should_update = true; + } + + if should_update { + tracing::info!("updated size and work area for monitor: {}", monitor.id); + monitor.update_focused_workspace(None)?; + } + } + } + } + } + + Ok(()) +} + +fn calculate_scaled_work_area( + new_size: &Rect, + monitor_size: &Rect, + monitor_work_area_size: &Rect, +) -> Rect { + let scale_x = new_size.right as f64 / monitor_size.right as f64; + let scale_y = new_size.bottom as f64 / monitor_size.bottom as f64; + + let top_offset = monitor_work_area_size.top - monitor_size.top; + let bottom_offset = monitor_size.bottom - monitor_work_area_size.bottom; + let left_offset = monitor_work_area_size.left - monitor_size.left; + let right_offset = monitor_size.right - monitor_work_area_size.right; + + let scaled_top_offset = (top_offset as f64 * scale_y).round() as i32; + let scaled_bottom_offset = (bottom_offset as f64 * scale_y).round() as i32; + let scaled_left_offset = (left_offset as f64 * scale_x).round() as i32; + let scaled_right_offset = (right_offset as f64 * scale_x).round() as i32; + + Rect { + left: new_size.left + scaled_left_offset, + top: new_size.top + scaled_top_offset, + right: new_size.right - scaled_right_offset, + bottom: new_size.bottom - scaled_bottom_offset, + } +} From c45090c5c55aa70aeb3a0f20cefd3675173b46a1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 21 Sep 2025 10:59:00 -0700 Subject: [PATCH 024/305] 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. --- komorebi/src/lib.rs | 2 + komorebi/src/macos_api.rs | 42 ++++++++++++++++++++ komorebi/src/main.rs | 11 ++++++ komorebi/src/monitor_reconciliator.rs | 57 +++------------------------ 4 files changed, 60 insertions(+), 52 deletions(-) diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 1fcd7823..bdc42f49 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -22,6 +22,7 @@ use std::ops::Deref; use std::path::PathBuf; use std::ptr::NonNull; use std::sync::Arc; +use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicI32; #[macro_use] @@ -69,6 +70,7 @@ lazy_static! { )); static ref WINDOW_RESTORE_POSITIONS: Arc>> = Arc::new(Mutex::new(HashMap::new())); + pub static ref UPDATE_MONITOR_WORK_AREAS: Arc = Arc::new(AtomicBool::new(false)); } pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 51f584ea..d33e86fa 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -14,6 +14,7 @@ use crate::core_graphics::CoreGraphicsApi; use crate::monitor::Monitor; use crate::window::WindowInfo; use crate::window_manager::WindowManager; +use color_eyre::eyre; use objc2::MainThreadMarker; use objc2_app_kit::NSEvent; use objc2_app_kit::NSScreen; @@ -25,10 +26,12 @@ use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFString; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; +use parking_lot::Mutex; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::ffi::c_void; use std::ptr::NonNull; +use std::sync::Arc; pub struct MacosApi; @@ -59,6 +62,45 @@ impl MacosApi { Ok(()) } + pub fn update_monitor_work_areas(wm: Arc>) -> eyre::Result<()> { + let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); + + for display_id in CoreGraphicsApi::connected_display_ids()? { + let display_bounds = CoreGraphicsApi::display_bounds(display_id); + + let mut wm = wm.lock(); + + for screen in &screens { + let menu_bar_height = screen.frame().size.height + - screen.visibleFrame().size.height + - screen.visibleFrame().origin.y; + + if screen.frame() == display_bounds { + let size = Rect::from(display_bounds); + let mut work_area_size = Rect::from(display_bounds); + work_area_size.top += menu_bar_height as i32; + work_area_size.bottom = screen.visibleFrame().size.height as i32; + + for monitor in wm.monitors_mut() { + if monitor.id == display_id { + monitor.size = size; + monitor.work_area_size = work_area_size; + } + + tracing::info!( + "updated monitor size and work area for monitor {display_id}" + ) + } + } + } + + let focus_follows_mouse = wm.mouse_follows_focus; + wm.update_focused_workspace(focus_follows_mouse, true)?; + } + + Ok(()) + } + pub fn load_workspace_information(wm: &mut WindowManager) -> Result<(), LibraryError> { let mut monitor_size_map = HashMap::new(); let mut monitor_workspace_map = HashMap::new(); diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 323280d2..9cf0f0c9 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -3,8 +3,10 @@ use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; +use komorebi::UPDATE_MONITOR_WORK_AREAS; use komorebi::ax_event_listener; use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; +use komorebi::macos_api::MacosApi; use komorebi::monitor_reconciliator; use komorebi::notification_center_listener::NotificationCenterListener; use komorebi::process_command::listen_for_commands; @@ -149,6 +151,15 @@ fn main() -> eyre::Result<()> { break; } + if UPDATE_MONITOR_WORK_AREAS.load(Ordering::Relaxed) { + // this can only be called on the main thread + if let Err(error) = MacosApi::update_monitor_work_areas(wm.clone()) { + tracing::error!("failed to update montior work areas: {error}"); + } + + UPDATE_MONITOR_WORK_AREAS.store(false, Ordering::Relaxed); + } + // this gets our observer notification callbacks firing autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) }); } diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index f0c2be23..d88b8114 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -1,5 +1,4 @@ -use crate::core::rect::Rect; -use crate::core_graphics::CoreGraphicsApi; +use crate::UPDATE_MONITOR_WORK_AREAS; use crate::window_manager::WindowManager; use crossbeam_channel::Receiver; use crossbeam_channel::Sender; @@ -9,6 +8,7 @@ use serde::Deserialize; use serde::Serialize; use std::sync::Arc; use std::sync::OnceLock; +use std::sync::atomic::Ordering; use strum::Display; #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] @@ -58,66 +58,19 @@ pub fn listen_for_notifications(wm: Arc>) -> color_eyre::Re Ok(()) } -pub fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> { +pub fn handle_notifications(_wm: Arc>) -> color_eyre::Result<()> { tracing::info!("listening"); let receiver = event_rx(); for notification in receiver { - let mut wm = wm.lock(); - match notification { - MonitorNotification::Resize(display_id) => { + MonitorNotification::Resize(_display_id) => { tracing::debug!("handling resize notification"); - let new_size = CoreGraphicsApi::display_bounds(display_id); - for monitor in wm.monitors_mut() { - let mut should_update = false; - - if Rect::from(new_size) != monitor.size { - // need to do this because we can't call NSScreen from a background thread - monitor.work_area_size = calculate_scaled_work_area( - &Rect::from(new_size), - &monitor.size, - &monitor.work_area_size, - ); - monitor.size = Rect::from(new_size); - should_update = true; - } - - if should_update { - tracing::info!("updated size and work area for monitor: {}", monitor.id); - monitor.update_focused_workspace(None)?; - } - } + UPDATE_MONITOR_WORK_AREAS.store(true, Ordering::Relaxed); } } } Ok(()) } - -fn calculate_scaled_work_area( - new_size: &Rect, - monitor_size: &Rect, - monitor_work_area_size: &Rect, -) -> Rect { - let scale_x = new_size.right as f64 / monitor_size.right as f64; - let scale_y = new_size.bottom as f64 / monitor_size.bottom as f64; - - let top_offset = monitor_work_area_size.top - monitor_size.top; - let bottom_offset = monitor_size.bottom - monitor_work_area_size.bottom; - let left_offset = monitor_work_area_size.left - monitor_size.left; - let right_offset = monitor_size.right - monitor_work_area_size.right; - - let scaled_top_offset = (top_offset as f64 * scale_y).round() as i32; - let scaled_bottom_offset = (bottom_offset as f64 * scale_y).round() as i32; - let scaled_left_offset = (left_offset as f64 * scale_x).round() as i32; - let scaled_right_offset = (right_offset as f64 * scale_x).round() as i32; - - Rect { - left: new_size.left + scaled_left_offset, - top: new_size.top + scaled_top_offset, - right: new_size.right - scaled_right_offset, - bottom: new_size.bottom - scaled_bottom_offset, - } -} From d5919112d9cf21c4652b23382bfe7d2a82c9bbc9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 21 Sep 2025 14:45:05 -0700 Subject: [PATCH 025/305] 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. --- komorebi/src/application.rs | 40 +++++---- komorebi/src/input_event_listener.rs | 67 +++++++++++++++ komorebi/src/lib.rs | 2 + komorebi/src/main.rs | 6 ++ komorebi/src/notification_center_listener.rs | 4 +- komorebi/src/process_event.rs | 11 ++- komorebi/src/reaper.rs | 89 ++++++++++++++++++++ komorebi/src/window.rs | 19 ++++- komorebi/src/window_manager.rs | 2 - komorebi/src/window_manager_event.rs | 3 + 10 files changed, 220 insertions(+), 23 deletions(-) create mode 100644 komorebi/src/input_event_listener.rs create mode 100644 komorebi/src/reaper.rs diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index ec8e51d7..38fa4bfc 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -131,22 +131,30 @@ impl Application { .unwrap_or_else(|| String::from("")) ); - match AccessibilityApi::add_observer_to_run_loop( - &self.observer, - &self.element, - NOTIFICATIONS, - run_loop, - ) { - Ok(_) => { - self.is_observable = true; - } - Err(error) => { - tracing::warn!( - "failed to register observer for process {} ({}): {error}", - self.process_id, - self.name() - .unwrap_or_else(|| String::from("")) - ); + let mut retries = 5; + + while retries > 0 { + match AccessibilityApi::add_observer_to_run_loop( + &self.observer, + &self.element, + NOTIFICATIONS, + run_loop, + ) { + Ok(_) => { + self.is_observable = true; + break; + } + Err(error) => { + // Chromium apps are still gross on macOS too + retries -= 1; + std::thread::sleep(std::time::Duration::from_millis(100)); + tracing::warn!( + "failed to register observer for process {} ({}): {error}, {retries} retries left", + self.process_id, + self.name() + .unwrap_or_else(|| String::from("")) + ); + } } } } diff --git a/komorebi/src/input_event_listener.rs b/komorebi/src/input_event_listener.rs new file mode 100644 index 00000000..f6f466a1 --- /dev/null +++ b/komorebi/src/input_event_listener.rs @@ -0,0 +1,67 @@ +use crate::reaper; +use crate::reaper::ReaperNotification; +use objc2_core_foundation::CFMachPort; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; +use objc2_core_foundation::kCFRunLoopDefaultMode; +use objc2_core_graphics::CGEvent; +use objc2_core_graphics::CGEventTapLocation; +use objc2_core_graphics::CGEventTapOptions; +use objc2_core_graphics::CGEventTapPlacement; +use objc2_core_graphics::CGEventTapProxy; +use objc2_core_graphics::CGEventType; +use std::ffi::c_void; +use std::ptr::NonNull; + +pub struct InputEventListener { + port: CFRetained, +} + +extern "C-unwind" fn callback( + _: CGEventTapProxy, + _event_type: CGEventType, + mut event_ref: NonNull, + _listener: *mut c_void, +) -> *mut CGEvent { + reaper::send_notification(ReaperNotification::MouseUpKeyUp); + unsafe { event_ref.as_mut() } +} +impl InputEventListener { + pub fn init(run_loop: &CFRunLoop) -> Option { + let mouse_event_mask = (1 << CGEventType::LeftMouseUp.0) | (1 << CGEventType::KeyUp.0); + let mut port = None; + + unsafe { + let tap_port = CGEvent::tap_create( + CGEventTapLocation::HIDEventTap, + CGEventTapPlacement::HeadInsertEventTap, + CGEventTapOptions::Default, + mouse_event_mask, + Some(callback), + std::ptr::null_mut(), + ); + + if let Some(tap_port) = &tap_port { + port = Some(tap_port.clone()); + } + + match CFMachPort::new_run_loop_source(None, tap_port.as_deref(), 0) { + None => {} + Some(source) => { + CFRunLoop::add_source(run_loop, Some(&source), kCFRunLoopDefaultMode); + } + } + } + + port.map(|port| Self { port }) + } +} + +impl Drop for InputEventListener { + fn drop(&mut self) { + CFMachPort::invalidate(&self.port); + unsafe { + CGEvent::tap_enable(&self.port, false); + } + } +} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index bdc42f49..2e31192d 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -36,6 +36,7 @@ mod container; pub mod core; pub mod core_graphics; pub mod display_reconfiguration_listener; +pub mod input_event_listener; pub mod lockable_sequence; pub mod macos_api; pub mod monitor; @@ -43,6 +44,7 @@ pub mod monitor_reconciliator; pub mod notification_center_listener; pub mod process_command; pub mod process_event; +pub mod reaper; pub mod window; pub mod window_manager; pub mod window_manager_event; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 9cf0f0c9..910dc0b1 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -6,11 +6,13 @@ use komorebi::DATA_DIR; use komorebi::UPDATE_MONITOR_WORK_AREAS; use komorebi::ax_event_listener; use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; +use komorebi::input_event_listener::InputEventListener; use komorebi::macos_api::MacosApi; use komorebi::monitor_reconciliator; use komorebi::notification_center_listener::NotificationCenterListener; use komorebi::process_command::listen_for_commands; use komorebi::process_event::listen_for_events; +use komorebi::reaper; use komorebi::window_manager::WindowManager; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; @@ -111,17 +113,21 @@ fn main() -> eyre::Result<()> { tracing::info!("display size for main display is: {:?}", display_size); let run_loop = CFRunLoop::current().ok_or_eyre("couldn't get CFRunLoop::current")?; + let _input_listener = InputEventListener::init(&run_loop); + let wm = Arc::new(Mutex::new(WindowManager::new( &run_loop, ax_event_listener::event_rx(), None, )?)); + wm.lock().init()?; wm.lock().update_focused_workspace(true, true)?; listen_for_commands(wm.clone()); listen_for_events(wm.clone()); monitor_reconciliator::listen_for_notifications(wm.clone())?; + reaper::listen_for_notifications(wm.clone()); let quit_ctrlc = Arc::new(AtomicBool::new(false)); let quit_thread = quit_ctrlc.clone(); diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs index f97c94fe..22bf5d3f 100644 --- a/komorebi/src/notification_center_listener.rs +++ b/komorebi/src/notification_center_listener.rs @@ -165,8 +165,8 @@ impl NotificationCenterListener { None, ); } - } - observer + observer + } } } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 86532d93..9f95b888 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,5 +1,6 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::notification_constants::AccessibilityNotification; +use crate::ax_event_listener::event_tx; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::window::Window; @@ -83,7 +84,15 @@ impl WindowManager { window.focus(false)?; } } else { - workspace.focus_container_by_window(window_id)?; + // if this fails, the app was probably open but windowless when komorebi + // launched, so the window hasn't been registered - we should treat it + // as a "Show" event + if workspace.focus_container_by_window(window_id).is_err() { + event_tx().send(WindowManagerEvent::Show( + notification, + event.process_id(), + ))? + } } workspace.layer = WorkspaceLayer::Tiling; diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs new file mode 100644 index 00000000..2dfb62b5 --- /dev/null +++ b/komorebi/src/reaper.rs @@ -0,0 +1,89 @@ +use crate::window_manager::WindowManager; +use crossbeam_channel::Receiver; +use crossbeam_channel::Sender; +use parking_lot::Mutex; +use std::sync::Arc; +use std::sync::OnceLock; + +pub enum ReaperNotification { + InvalidWindow(u32), + MouseUpKeyUp, +} + +static CHANNEL: OnceLock<(Sender, Receiver)> = + OnceLock::new(); + +pub fn channel() -> &'static (Sender, Receiver) { + CHANNEL.get_or_init(|| crossbeam_channel::bounded(50)) +} + +fn event_tx() -> Sender { + channel().0.clone() +} + +fn event_rx() -> Receiver { + channel().1.clone() +} + +pub fn send_notification(notification: ReaperNotification) { + if event_tx().try_send(notification).is_err() { + tracing::warn!("channel is full; dropping notification") + } +} + +pub fn listen_for_notifications(wm: Arc>) { + std::thread::spawn(move || { + loop { + match handle_notifications(wm.clone()) { + Ok(()) => { + tracing::warn!("restarting finished thread"); + } + Err(error) => { + tracing::warn!("restarting failed thread: {}", error); + } + } + } + }); +} + +fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> { + tracing::info!("listening"); + + let receiver = event_rx(); + + for notification in receiver { + let mut wm = wm.lock(); + + match notification { + ReaperNotification::InvalidWindow(window_id) => { + let mut should_update = false; + for monitor in wm.monitors_mut() { + for workspace in monitor.workspaces_mut() { + for container in workspace.containers_mut() { + container.windows_mut().retain(|w| { + if w.id == window_id { + should_update = true; + tracing::info!("reaping window: {window_id}"); + } + + w.id != window_id + }); + } + } + } + + // If an invalid window was cleaned up, we update the workspace + wm.update_focused_workspace(false, false)?; + } + ReaperNotification::MouseUpKeyUp => { + // this first one will do a "nothing" update to check if any windows failed + // to have their positions set - the failures will trigger an InvalidWindow + // notification + // TODO: maybe replace this with something a bit more lightweight + wm.update_focused_workspace(false, false)?; + } + } + } + + Ok(()) +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 709bb4c0..77f4763e 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -25,6 +25,8 @@ use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; use crate::hidden_frame_bottom_left; use crate::macos_api::MacosApi; +use crate::reaper; +use crate::reaper::ReaperNotification; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use objc2_app_kit::NSApplicationActivationOptions; @@ -284,8 +286,21 @@ impl Window { } pub fn set_position(&self, rect: &Rect) -> Result<(), AccessibilityError> { - self.set_point(CGPoint::new(rect.left as CGFloat, rect.top as CGFloat))?; - self.set_size(CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat)) + match self.set_point(CGPoint::new(rect.left as CGFloat, rect.top as CGFloat)) { + Ok(_) => {} + Err(error) => { + reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + return Err(error); + } + } + + match self.set_size(CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat)) { + Ok(_) => Ok(()), + Err(error) => { + reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + Err(error) + } + } } pub fn focus(&self, mouse_follows_focus: bool) -> Result<(), LibraryError> { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 15fe829b..4791901c 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -510,8 +510,6 @@ impl WindowManager { follow_focus: bool, trigger_focus: bool, ) -> eyre::Result<()> { - tracing::info!("updating"); - let offset = self.work_area_offset; let mouse_follows_focus = self.mouse_follows_focus; diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 8cd9b1cd..e9c4d764 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -33,6 +33,9 @@ impl WindowManagerEvent { SystemNotification::Accessibility(AccessibilityNotification::AXMainWindowChanged) | SystemNotification::Accessibility( AccessibilityNotification::AXApplicationActivated, + ) + | SystemNotification::AppKitWorkspace( + AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification, ) => Some(WindowManagerEvent::FocusChange( notification, process_id, From 8b9b5782171520c051800d13d8e86bbe6f3ff509 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 21 Sep 2025 16:04:09 -0700 Subject: [PATCH 026/305] 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. --- komorebi/src/window.rs | 87 +++++++++++++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 13 deletions(-) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 77f4763e..0739696a 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -8,7 +8,9 @@ use crate::accessibility::attribute_constants::kAXFocusedAttribute; use crate::accessibility::attribute_constants::kAXMainAttribute; use crate::accessibility::attribute_constants::kAXMinimizedAttribute; use crate::accessibility::attribute_constants::kAXPositionAttribute; +use crate::accessibility::attribute_constants::kAXRoleAttribute; use crate::accessibility::attribute_constants::kAXSizeAttribute; +use crate::accessibility::attribute_constants::kAXSubroleAttribute; use crate::accessibility::attribute_constants::kAXTitleAttribute; use crate::accessibility::error::AccessibilityCustomError; use crate::accessibility::error::AccessibilityError; @@ -29,6 +31,7 @@ use crate::reaper; use crate::reaper::ReaperNotification; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; +use objc2::__framework_prelude::Retained; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; use objc2_application_services::AXObserver; @@ -52,6 +55,9 @@ use serde::Deserialize; use serde::Serialize; use std::collections::hash_map::Entry; use std::ffi::c_void; +use std::fmt::Display; +use std::fmt::Formatter; +use std::fmt::Write; use std::ptr::NonNull; use std::str::FromStr; use strum::Display; @@ -178,6 +184,35 @@ impl Drop for Window { } } +impl Display for Window { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let mut display = format!( + "(window_id: {}, process_id: {}", + self.id, self.application.process_id + ); + + if let Some(title) = self.title() { + write!(display, ", title: {title}")?; + } + + if let Some(exe) = self.exe() { + write!(display, ", exe: {exe}")?; + } + + if let Some(role) = self.role() { + write!(display, ", role: {role}")?; + } + + if let Some(subrole) = self.subrole() { + write!(display, ", subrole: {subrole}")?; + } + + write!(display, ")")?; + + write!(f, "{display}") + } +} + impl Window { pub fn new( element: CFRetained, @@ -202,12 +237,7 @@ impl Window { #[tracing::instrument(skip_all)] pub fn observe(&self, run_loop: &CFRunLoop) -> Result<(), AccessibilityError> { - tracing::info!( - "registering observer for process: {}, title: {}", - self.application.process_id, - self.title() - .unwrap_or_else(|| String::from("")) - ); + tracing::info!("registering observer for {self}"); AccessibilityApi::add_observer_to_run_loop( &self.observer, @@ -285,6 +315,42 @@ impl Window { .map(|s| s.to_string()) } + pub fn exe(&self) -> Option { + self.application.name() + } + + pub fn bundle_identifier(&self) -> Option { + if let Ok(Some(identifier)) = self + .running_application() + .map(|app| unsafe { app.bundleIdentifier() }) + { + Some(identifier.to_string()) + } else { + None + } + } + + pub fn role(&self) -> Option { + AccessibilityApi::copy_attribute_value::(&self.element, kAXRoleAttribute) + .map(|s| s.to_string()) + } + + pub fn subrole(&self) -> Option { + AccessibilityApi::copy_attribute_value::(&self.element, kAXSubroleAttribute) + .map(|s| s.to_string()) + } + + fn running_application(&self) -> Result, AccessibilityError> { + unsafe { + NSRunningApplication::runningApplicationWithProcessIdentifier( + self.application.process_id, + ) + .ok_or(AccessibilityError::Custom( + AccessibilityCustomError::NSRunningApplication(self.application.process_id), + )) + } + } + pub fn set_position(&self, rect: &Rect) -> Result<(), AccessibilityError> { match self.set_point(CGPoint::new(rect.left as CGFloat, rect.top as CGFloat)) { Ok(_) => {} @@ -305,13 +371,8 @@ impl Window { pub fn focus(&self, mouse_follows_focus: bool) -> Result<(), LibraryError> { unsafe { - NSRunningApplication::runningApplicationWithProcessIdentifier( - self.application.process_id, - ) - .ok_or(AccessibilityError::Custom( - AccessibilityCustomError::NSRunningApplication(self.application.process_id), - ))? - .activateWithOptions(NSApplicationActivationOptions::empty()); + self.running_application()? + .activateWithOptions(NSApplicationActivationOptions::empty()); let cf_boolean = CFBoolean::new(true); let value = &**cf_boolean; From 34beecdb22c407f51461c911a730209e88d176f5 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 21 Sep 2025 17:28:33 -0700 Subject: [PATCH 027/305] feat(wm): migrate asc and config generation primitives --- Cargo.lock | 13 +++ dependencies.json | 4 + komorebi/Cargo.toml | 3 +- komorebi/src/core/asc.rs | 134 +++++++++++++++++++++++++ komorebi/src/core/config_generation.rs | 99 ++++++++++++++++++ komorebi/src/core/mod.rs | 16 +++ komorebi/src/lib.rs | 39 ++++++- 7 files changed, 305 insertions(+), 3 deletions(-) create mode 100644 komorebi/src/core/asc.rs create mode 100644 komorebi/src/core/config_generation.rs diff --git a/Cargo.lock b/Cargo.lock index 6c66057a..e2a6c09d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,6 +539,7 @@ dependencies = [ "objc2-foundation", "parking_lot", "pastey", + "regex", "serde", "serde_json_lenient", "serde_with", @@ -983,6 +984,18 @@ dependencies = [ "syn", ] +[[package]] +name = "regex" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + [[package]] name = "regex-automata" version = "0.4.10" diff --git a/dependencies.json b/dependencies.json index 8739a57f..6ce3c607 100644 --- a/dependencies.json +++ b/dependencies.json @@ -64,6 +64,7 @@ "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", @@ -103,6 +104,7 @@ [ "addr2line 0.24.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", "anstyle 1.0.11 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", @@ -170,6 +172,7 @@ "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", @@ -216,6 +219,7 @@ [ "Unlicense", [ + "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index" ] ], diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index ff957cc5..31005369 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -13,11 +13,12 @@ lazy_static = { workspace = true } objc2 = "0.6" objc2-app-kit = "0.3" objc2-application-services = "0.3" -objc2-foundation = "0.3" objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } +objc2-foundation = "0.3" parking_lot = "0.12" pastey = { workspace = true } +regex = "1" serde = { workspace = true } serde_json = { workspace = true } serde_with = "3" diff --git a/komorebi/src/core/asc.rs b/komorebi/src/core/asc.rs new file mode 100644 index 00000000..dd4e1414 --- /dev/null +++ b/komorebi/src/core/asc.rs @@ -0,0 +1,134 @@ +use crate::core::config_generation::ApplicationConfiguration; +use crate::core::config_generation::ApplicationOptions; +use crate::core::config_generation::MatchingRule; +use color_eyre::Result; +use serde::Deserialize; +use serde::Serialize; +use std::collections::BTreeMap; +use std::ops::Deref; +use std::ops::DerefMut; +use std::path::PathBuf; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ApplicationSpecificConfiguration(pub BTreeMap); + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AscApplicationRulesOrSchema { + AscApplicationRules(AscApplicationRules), + Schema(String), +} + +impl Deref for ApplicationSpecificConfiguration { + type Target = BTreeMap; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for ApplicationSpecificConfiguration { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl ApplicationSpecificConfiguration { + pub fn load(pathbuf: &PathBuf) -> Result { + let content = std::fs::read_to_string(pathbuf)?; + Ok(serde_json::from_str(&content)?) + } + + pub fn format(pathbuf: &PathBuf) -> Result { + Ok(serde_json::to_string_pretty(&Self::load(pathbuf)?)?) + } +} + +/// Rules that determine how an application is handled +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct AscApplicationRules { + /// Rules to ignore specific windows + #[serde(skip_serializing_if = "Option::is_none")] + pub ignore: Option>, + /// Rules to forcibly manage specific windows + #[serde(skip_serializing_if = "Option::is_none")] + pub manage: Option>, + /// Rules to manage specific windows as floating windows + #[serde(skip_serializing_if = "Option::is_none")] + pub floating: Option>, + /// Rules to ignore specific windows from the transparency feature + #[serde(skip_serializing_if = "Option::is_none")] + pub transparency_ignore: Option>, + /// Rules to identify applications which minimize to the tray or have multiple windows + #[serde(skip_serializing_if = "Option::is_none")] + pub tray_and_multi_window: Option>, + /// Rules to identify applications which have the `WS_EX_LAYERED` Extended Window Style + #[serde(skip_serializing_if = "Option::is_none")] + pub layered: Option>, + /// Rules to identify applications which send the `EVENT_OBJECT_NAMECHANGE` event on launch + #[serde(skip_serializing_if = "Option::is_none")] + pub object_name_change: Option>, + /// Rules to identify applications which are slow to send initial event notifications + #[serde(skip_serializing_if = "Option::is_none")] + pub slow_application: Option>, +} + +impl From> for ApplicationSpecificConfiguration { + fn from(value: Vec) -> Self { + let mut map = BTreeMap::new(); + + for entry in &value { + let key = entry.name.clone(); + let mut rules = AscApplicationRules { + ignore: None, + manage: None, + floating: None, + transparency_ignore: None, + tray_and_multi_window: None, + layered: None, + object_name_change: None, + slow_application: None, + }; + + rules.ignore = entry.ignore_identifiers.clone(); + + if let Some(options) = &entry.options { + for opt in options { + match opt { + ApplicationOptions::ObjectNameChange => { + rules.object_name_change = + Some(vec![MatchingRule::Simple(entry.identifier.clone())]); + } + ApplicationOptions::Layered => { + rules.layered = + Some(vec![MatchingRule::Simple(entry.identifier.clone())]); + } + ApplicationOptions::TrayAndMultiWindow => { + rules.tray_and_multi_window = + Some(vec![MatchingRule::Simple(entry.identifier.clone())]); + } + ApplicationOptions::Force => { + rules.manage = + Some(vec![MatchingRule::Simple(entry.identifier.clone())]); + } + ApplicationOptions::BorderOverflow => {} + } + } + } + + if rules.ignore.is_some() + || rules.manage.is_some() + || rules.floating.is_some() + || rules.transparency_ignore.is_some() + || rules.tray_and_multi_window.is_some() + || rules.layered.is_some() + || rules.object_name_change.is_some() + || rules.slow_application.is_some() + { + map.insert(key, AscApplicationRulesOrSchema::AscApplicationRules(rules)); + } + } + + Self(map) + } +} diff --git a/komorebi/src/core/config_generation.rs b/komorebi/src/core/config_generation.rs new file mode 100644 index 00000000..3dfbe2fd --- /dev/null +++ b/komorebi/src/core/config_generation.rs @@ -0,0 +1,99 @@ +use clap::ValueEnum; +use serde::Deserialize; +use serde::Serialize; +use strum::Display; +use strum::EnumString; + +use super::ApplicationIdentifier; + +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] +#[strum(serialize_all = "snake_case")] +#[serde(rename_all = "snake_case")] +pub enum ApplicationOptions { + ObjectNameChange, + Layered, + TrayAndMultiWindow, + Force, + BorderOverflow, +} + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum MatchingRule { + Simple(IdWithIdentifier), + Composite(Vec), +} + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +pub struct WorkspaceMatchingRule { + pub monitor_index: usize, + pub workspace_index: usize, + pub matching_rule: MatchingRule, + pub initial_only: bool, +} + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +pub struct IdWithIdentifier { + pub kind: ApplicationIdentifier, + pub id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub matching_strategy: Option, +} + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display)] +pub enum MatchingStrategy { + Legacy, + Equals, + StartsWith, + EndsWith, + Contains, + Regex, + DoesNotEndWith, + DoesNotStartWith, + DoesNotEqual, + DoesNotContain, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct IdWithIdentifierAndComment { + pub kind: ApplicationIdentifier, + pub id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub matching_strategy: Option, +} + +impl From for IdWithIdentifier { + fn from(value: IdWithIdentifierAndComment) -> Self { + Self { + kind: value.kind, + id: value.id.clone(), + matching_strategy: value.matching_strategy, + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ApplicationConfiguration { + pub name: String, + pub identifier: IdWithIdentifier, + #[serde(skip_serializing_if = "Option::is_none")] + pub options: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(alias = "float_identifiers")] + pub ignore_identifiers: Option>, +} + +impl ApplicationConfiguration { + pub fn populate_default_matching_strategies(&mut self) { + if self.identifier.matching_strategy.is_none() { + match self.identifier.kind { + ApplicationIdentifier::Exe | ApplicationIdentifier::Path => { + self.identifier.matching_strategy = Option::from(MatchingStrategy::Equals); + } + ApplicationIdentifier::Class | ApplicationIdentifier::Title => {} + } + } + } +} diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 74e32962..aea9818e 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -11,6 +11,8 @@ use strum::Display; use strum::EnumString; pub mod arrangement; +pub mod asc; +pub mod config_generation; pub mod cycle_direction; pub mod default_layout; pub mod direction; @@ -133,6 +135,20 @@ pub enum CrossBoundaryBehaviour { Monitor, } +#[derive( + Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, +)] +pub enum ApplicationIdentifier { + #[serde(alias = "exe")] + Exe, + #[serde(alias = "class")] + Class, + #[serde(alias = "title")] + Title, + #[serde(alias = "path")] + Path, +} + #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] #[serde(tag = "type", content = "content")] diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 2e31192d..e0dd07d6 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -1,6 +1,10 @@ #![warn(clippy::all)] use crate::accessibility::error::AccessibilityError; +use crate::core::ApplicationIdentifier; +use crate::core::config_generation::IdWithIdentifier; +use crate::core::config_generation::MatchingRule; +use crate::core::config_generation::MatchingStrategy; use crate::core_graphics::error::CoreGraphicsError; use crate::window::AspectRatio; use crate::window::PredefinedAspectRatio; @@ -17,6 +21,7 @@ use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; use parking_lot::Mutex; +use regex::Regex; use std::collections::HashMap; use std::ops::Deref; use std::path::PathBuf; @@ -29,10 +34,10 @@ use std::sync::atomic::AtomicI32; pub mod ring; pub mod accessibility; -mod app_kit_notification_constants; +pub mod app_kit_notification_constants; pub mod application; pub mod ax_event_listener; -mod container; +pub mod container; pub mod core; pub mod core_graphics; pub mod display_reconfiguration_listener; @@ -73,6 +78,36 @@ lazy_static! { static ref WINDOW_RESTORE_POSITIONS: Arc>> = Arc::new(Mutex::new(HashMap::new())); pub static ref UPDATE_MONITOR_WORK_AREAS: Arc = Arc::new(AtomicBool::new(false)); + static ref REGEX_IDENTIFIERS: Arc>> = + Arc::new(Mutex::new(HashMap::new())); + static ref MANAGE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![])); + static ref IGNORE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![ + MatchingRule::Simple(IdWithIdentifier { + kind: ApplicationIdentifier::Class, + id: String::from("OPContainerClass"), + matching_strategy: Option::from(MatchingStrategy::Equals), + }), + MatchingRule::Simple(IdWithIdentifier { + kind: ApplicationIdentifier::Class, + id: String::from("IHWindowClass"), + matching_strategy: Option::from(MatchingStrategy::Equals), + }), + MatchingRule::Simple(IdWithIdentifier { + kind: ApplicationIdentifier::Exe, + id: String::from("komorebi-bar.exe"), + matching_strategy: Option::from(MatchingStrategy::Equals), + }) + ])); + static ref SESSION_FLOATING_APPLICATIONS: Arc>> = + Arc::new(Mutex::new(Vec::new())); + static ref FLOATING_APPLICATIONS: Arc>> = + Arc::new(Mutex::new(vec![MatchingRule::Simple(IdWithIdentifier { + kind: ApplicationIdentifier::Exe, + id: String::from("komorebi-shortcuts.exe"), + matching_strategy: Option::from(MatchingStrategy::Equals), + })])); + static ref PERMAIGNORE_CLASSES: Arc>> = + Arc::new(Mutex::new(vec!["Chrome_RenderWidgetHostHWND".to_string(),])); } pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); From d9a8634559c112ce0630abedc4583eb686d3422d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 21 Sep 2025 19:33:46 -0700 Subject: [PATCH 028/305] 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. --- Cargo.lock | 259 ++++- deny.toml | 4 +- dependencies.json | 28 +- komorebi/Cargo.toml | 1 + komorebi/src/core/mod.rs | 15 + komorebi/src/core/rect.rs | 4 +- komorebi/src/lib.rs | 4 + komorebi/src/main.rs | 62 +- komorebi/src/monitor.rs | 7 + komorebi/src/process_command.rs | 4 + komorebi/src/process_event.rs | 23 + komorebi/src/static_config.rs | 1683 +++++++++++++++++++++++++++++++ komorebi/src/window.rs | 580 +++++++++++ komorebi/src/window_manager.rs | 305 ++++++ komorebi/src/workspace.rs | 118 +++ 15 files changed, 3071 insertions(+), 26 deletions(-) create mode 100644 komorebi/src/static_config.rs diff --git a/Cargo.lock b/Cargo.lock index e2a6c09d..8a867a2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,6 +112,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.9.4" @@ -351,7 +357,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" dependencies = [ - "bitflags", + "bitflags 2.9.4", "objc2", ] @@ -387,6 +393,27 @@ dependencies = [ "once_cell", ] +[[package]] +name = "file-id" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13be71e6ca82e91bc0cb862bebaac0b2d1924a5a1d970c822b2f98b63fda8c3" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "filetime" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.60.2", +] + [[package]] name = "find-msvc-tools" version = "0.1.1" @@ -399,6 +426,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + [[package]] name = "getrandom" version = "0.2.16" @@ -440,6 +476,17 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hotwatch" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9140219159163c92eb58c37955a0cc57c5814c3c44521955aae376064c668756" +dependencies = [ + "log", + "notify", + "notify-debouncer-full", +] + [[package]] name = "iana-time-zone" version = "0.1.64" @@ -499,6 +546,26 @@ dependencies = [ "serde_core", ] +[[package]] +name = "inotify" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +dependencies = [ + "bitflags 1.3.2", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -530,6 +597,7 @@ dependencies = [ "crossbeam-channel", "ctrlc", "dirs", + "hotwatch", "lazy_static", "objc2", "objc2-app-kit", @@ -569,6 +637,26 @@ dependencies = [ "pastey", ] +[[package]] +name = "kqueue" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -587,8 +675,9 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ - "bitflags", + "bitflags 2.9.4", "libc", + "redox_syscall", ] [[package]] @@ -637,18 +726,62 @@ dependencies = [ "adler2", ] +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "nix" version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ - "bitflags", + "bitflags 2.9.4", "cfg-if", "cfg_aliases", "libc", ] +[[package]] +name = "notify" +version = "6.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" +dependencies = [ + "bitflags 2.9.4", + "crossbeam-channel", + "filetime", + "fsevent-sys", + "inotify", + "kqueue", + "libc", + "log", + "mio", + "walkdir", + "windows-sys 0.48.0", +] + +[[package]] +name = "notify-debouncer-full" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4812c1eb49be776fb8df4961623bdc01ec9dfdc1abe8211ceb09150a2e64219" +dependencies = [ + "crossbeam-channel", + "file-id", + "notify", + "parking_lot", + "walkdir", +] + [[package]] name = "nu-ansi-term" version = "0.50.1" @@ -688,7 +821,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc" dependencies = [ - "bitflags", + "bitflags 2.9.4", "block2", "libc", "objc2", @@ -707,7 +840,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9abc05b1f757ebfbd72f4f3f9a515662c67dfe66b26e71b37d818f56a1c2f17" dependencies = [ - "bitflags", + "bitflags 2.9.4", "libc", "objc2", "objc2-core-foundation", @@ -722,7 +855,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17614fdcd9b411e6ff1117dfb1d0150f908ba83a7df81b1f118005fe0a8ea15d" dependencies = [ - "bitflags", + "bitflags 2.9.4", "objc2", "objc2-foundation", ] @@ -733,7 +866,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291fbbf7d29287518e8686417cf7239c74700fd4b607623140a7d4a3c834329d" dependencies = [ - "bitflags", + "bitflags 2.9.4", "objc2", "objc2-foundation", ] @@ -744,7 +877,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166" dependencies = [ - "bitflags", + "bitflags 2.9.4", "block2", "dispatch2", "libc", @@ -757,7 +890,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4" dependencies = [ - "bitflags", + "bitflags 2.9.4", "block2", "dispatch2", "libc", @@ -801,7 +934,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c" dependencies = [ - "bitflags", + "bitflags 2.9.4", "block2", "libc", "objc2", @@ -814,7 +947,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c" dependencies = [ - "bitflags", + "bitflags 2.9.4", "objc2", "objc2-core-foundation", ] @@ -825,7 +958,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f246c183239540aab1782457b35ab2040d4259175bd1d0c58e46ada7b47a874" dependencies = [ - "bitflags", + "bitflags 2.9.4", "objc2", "objc2-foundation", ] @@ -836,7 +969,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ffb6a0cd5f182dc964334388560b12a57f7b74b3e2dec5e2722aa2dfb2ccd5" dependencies = [ - "bitflags", + "bitflags 2.9.4", "objc2", "objc2-foundation", ] @@ -847,7 +980,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1f8e0ef3ab66b08c42644dcb34dba6ec0a574bbd8adbb8bdbdc7a2779731a44" dependencies = [ - "bitflags", + "bitflags 2.9.4", "objc2", "objc2-core-foundation", ] @@ -950,7 +1083,7 @@ version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ - "bitflags", + "bitflags 2.9.4", ] [[package]] @@ -1025,7 +1158,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags", + "bitflags 2.9.4", "errno", "libc", "linux-raw-sys", @@ -1044,6 +1177,15 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schemars" version = "0.9.0" @@ -1378,6 +1520,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -1443,6 +1595,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.0", +] + [[package]] name = "windows-core" version = "0.62.0" @@ -1508,6 +1669,15 @@ dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -1535,6 +1705,21 @@ dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + [[package]] name = "windows-targets" version = "0.52.6" @@ -1568,6 +1753,12 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -1580,6 +1771,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -1592,6 +1789,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1616,6 +1819,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -1628,6 +1837,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -1640,6 +1855,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -1652,6 +1873,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/deny.toml b/deny.toml index cb8b0cf2..4bcaa988 100644 --- a/deny.toml +++ b/deny.toml @@ -15,6 +15,8 @@ ignore = [] allow = [ "0BSD", "Apache-2.0", + "Artistic-2.0", + "CC0-1.0", "MIT", "MPL-2.0", "Unicode-3.0", @@ -24,11 +26,9 @@ allow = [ # these are also ok, but not yet used - # "Artistic-2.0", # "BSD-2-Clause", # "BSD-3-Clause", # "BSL-1.0", - # "CC0-1.0", # "ISC", # "MIT-0", # "OFL-1.1", diff --git a/dependencies.json b/dependencies.json index 6ce3c607..cfe2f739 100644 --- a/dependencies.json +++ b/dependencies.json @@ -34,9 +34,11 @@ "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", @@ -93,12 +95,27 @@ "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index" ] ], + [ + "Artistic-2.0", + [ + "file-id 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "notify-debouncer-full 0.1.0 registry+https://github.com/rust-lang/crates.io-index" + ] + ], [ "BSL-1.0", [ "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index" ] ], + [ + "CC0-1.0", + [ + "file-id 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "notify 6.1.1 registry+https://github.com/rust-lang/crates.io-index", + "notify-debouncer-full 0.1.0 registry+https://github.com/rust-lang/crates.io-index" + ] + ], [ "MIT", [ @@ -134,9 +151,12 @@ "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "fsevent-sys 4.1.0 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", @@ -177,6 +197,7 @@ "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "serde 1.0.225 registry+https://github.com/rust-lang/crates.io-index", "serde_core 1.0.225 registry+https://github.com/rust-lang/crates.io-index", @@ -201,7 +222,8 @@ "tracing-log 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", - "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index" + "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -220,7 +242,9 @@ "Unlicense", [ "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", - "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index" + "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index", + "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", + "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index" ] ], [ diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 31005369..324e797f 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -9,6 +9,7 @@ color-eyre = { workspace = true } crossbeam-channel = "0.5" ctrlc = { version = "3", features = ["termination"] } dirs = { workspace = true } +hotwatch = "0.5" lazy_static = { workspace = true } objc2 = "0.6" objc2-app-kit = "0.3" diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index aea9818e..1c81fef0 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -2,10 +2,12 @@ use crate::core::arrangement::Axis; use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::operation_direction::OperationDirection; +use crate::core::pathext::ResolvedPathBuf; use clap::ValueEnum; use color_eyre::eyre; use serde::Deserialize; use serde::Serialize; +use std::path::PathBuf; use std::str::FromStr; use strum::Display; use strum::EnumString; @@ -21,11 +23,23 @@ pub mod operation_direction; pub mod pathext; pub mod rect; +#[derive( + Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, +)] +pub enum OperationBehaviour { + /// Process komorebic commands on temporarily unmanaged/floated windows + #[default] + Op, + /// Ignore komorebic commands on temporarily unmanaged/floated windows + NoOp, +} + #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] pub enum Sizing { Increase, Decrease, } + #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)] pub struct WindowManagementBehaviour { /// The current WindowContainerBehaviour to be used @@ -217,6 +231,7 @@ pub enum SocketMessage { Promote, PromoteFocus, PromoteWindow(OperationDirection), + ReloadStaticConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), } impl SocketMessage { diff --git a/komorebi/src/core/rect.rs b/komorebi/src/core/rect.rs index a125effd..f46fbfba 100644 --- a/komorebi/src/core/rect.rs +++ b/komorebi/src/core/rect.rs @@ -4,8 +4,10 @@ use objc2_core_foundation::CGFloat; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; +use serde::Deserialize; +use serde::Serialize; -#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq)] pub struct Rect { pub left: i32, pub top: i32, diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index e0dd07d6..f7893fc9 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -5,6 +5,7 @@ use crate::core::ApplicationIdentifier; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; +use crate::core::config_generation::WorkspaceMatchingRule; use crate::core_graphics::error::CoreGraphicsError; use crate::window::AspectRatio; use crate::window::PredefinedAspectRatio; @@ -50,6 +51,7 @@ pub mod notification_center_listener; pub mod process_command; pub mod process_event; pub mod reaper; +pub mod static_config; pub mod window; pub mod window_manager; pub mod window_manager_event; @@ -78,6 +80,8 @@ lazy_static! { static ref WINDOW_RESTORE_POSITIONS: Arc>> = Arc::new(Mutex::new(HashMap::new())); pub static ref UPDATE_MONITOR_WORK_AREAS: Arc = Arc::new(AtomicBool::new(false)); + static ref WORKSPACE_MATCHING_RULES: Arc>> = + Arc::new(Mutex::new(Vec::new())); static ref REGEX_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(HashMap::new())); static ref MANAGE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![])); diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 910dc0b1..ce2eb93b 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -1,10 +1,13 @@ #![warn(clippy::all)] +use clap::Parser; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; +use komorebi::HOME_DIR; use komorebi::UPDATE_MONITOR_WORK_AREAS; use komorebi::ax_event_listener; +use komorebi::core::pathext::replace_env_in_path; use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; use komorebi::input_event_listener::InputEventListener; use komorebi::macos_api::MacosApi; @@ -13,6 +16,7 @@ use komorebi::notification_center_listener::NotificationCenterListener; use komorebi::process_command::listen_for_commands; use komorebi::process_event::listen_for_events; use komorebi::reaper; +use komorebi::static_config::StaticConfig; use komorebi::window_manager::WindowManager; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; @@ -23,6 +27,7 @@ use objc2_core_graphics::CGMainDisplayID; use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; use parking_lot::Mutex; +use std::path::PathBuf; use std::sync::Arc; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; @@ -98,7 +103,23 @@ pub fn setup() -> eyre::Result<()> { Ok(()) } +#[derive(Parser)] +#[clap(author, about, version)] +struct Opts { + /// Path to a static configuration JSON file + #[clap(short, long)] + #[clap(value_parser = replace_env_in_path)] + config: Option, + // /// Do not attempt to auto-apply a dumped state temp file from a previously running instance of komorebi + // #[clap(long)] + // clean_state: bool, + // /// Level of log output verbosity + // #[clap(long, value_enum, default_value_t=LogLevel::Info)] + // log_level: LogLevel, +} + fn main() -> eyre::Result<()> { + let opts: Opts = Opts::parse(); setup()?; check_permissions()?; @@ -115,13 +136,44 @@ fn main() -> eyre::Result<()> { let run_loop = CFRunLoop::current().ok_or_eyre("couldn't get CFRunLoop::current")?; let _input_listener = InputEventListener::init(&run_loop); - let wm = Arc::new(Mutex::new(WindowManager::new( - &run_loop, - ax_event_listener::event_rx(), - None, - )?)); + let static_config = opts.config.map_or_else( + || { + let komorebi_json = HOME_DIR.join("komorebi.json"); + if komorebi_json.is_file() { + Option::from(komorebi_json) + } else { + None + } + }, + Option::from, + ); + + let wm = if let Some(config) = &static_config { + tracing::info!( + "creating window manager from static configuration file: {}", + config.display() + ); + + Arc::new(Mutex::new(StaticConfig::preload( + config, + ax_event_listener::event_rx(), + None, + &run_loop, + )?)) + } else { + Arc::new(Mutex::new(WindowManager::new( + &run_loop, + ax_event_listener::event_rx(), + None, + )?)) + }; wm.lock().init()?; + + if let Some(config) = &static_config { + StaticConfig::postload(config, &wm)?; + } + wm.lock().update_focused_workspace(true, true)?; listen_for_commands(wm.clone()); diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 0b1afcc5..111c3c53 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -406,4 +406,11 @@ impl Monitor { pub fn remove_workspaces(&mut self) -> VecDeque { self.workspaces_mut().drain(..).collect() } + + pub fn ensure_workspace_count(&mut self, ensure_count: usize) { + if self.workspaces().len() < ensure_count { + self.workspaces_mut() + .resize(ensure_count, Workspace::default()); + } + } } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index c83c87c8..888fcde0 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -69,6 +69,7 @@ impl WindowManager { mut _reply: impl std::io::Write, ) -> eyre::Result<()> { tracing::info!("processing command: {message}"); + self.handle_unmanaged_window_behaviour()?; match message { SocketMessage::Promote => self.promote_container_to_front()?, @@ -789,6 +790,9 @@ impl WindowManager { self.move_workspace_to_monitor(monitor_idx)?; } + SocketMessage::ReloadStaticConfiguration(ref pathbuf) => { + self.reload_static_configuration(pathbuf)?; + } } Ok(()) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 9f95b888..10b5cce0 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -43,11 +43,34 @@ impl WindowManager { return Ok(()); } + let mut should_manage = true; + { + let application = self.application(event.process_id())?; + if let Some(window_element) = application.main_window() + && let Ok(window) = Window::new(window_element, application.clone()) + { + let print_window = window.clone(); + should_manage = window.should_manage(Some(event))?; + + if !should_manage { + tracing::debug!( + "ignoring event as window should not be managed: {print_window}" + ); + } + } + } + + if !should_manage { + return Ok(()); + } + tracing::info!( "processing event: {event} for process {}", event.process_id() ); + self.enforce_workspace_rules()?; + match event { WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs new file mode 100644 index 00000000..20e9a95e --- /dev/null +++ b/komorebi/src/static_config.rs @@ -0,0 +1,1683 @@ +use crate::CoreFoundationRunLoop; +use crate::DATA_DIR; +use crate::DEFAULT_CONTAINER_PADDING; +use crate::DEFAULT_WORKSPACE_PADDING; +use crate::FLOATING_APPLICATIONS; +use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO; +use crate::IGNORE_IDENTIFIERS; +use crate::MANAGE_IDENTIFIERS; +use crate::REGEX_IDENTIFIERS; +use crate::WORKSPACE_MATCHING_RULES; +use crate::core::CrossBoundaryBehaviour; +use crate::core::FloatingLayerBehaviour; +use crate::core::MoveBehaviour; +use crate::core::OperationBehaviour; +use crate::core::Placement; +use crate::core::SocketMessage; +use crate::core::WindowContainerBehaviour; +use crate::core::WindowManagementBehaviour; +use crate::core::arrangement::Axis; +use crate::core::asc::ApplicationSpecificConfiguration; +use crate::core::asc::AscApplicationRulesOrSchema; +use crate::core::config_generation::MatchingRule; +use crate::core::config_generation::MatchingStrategy; +use crate::core::config_generation::WorkspaceMatchingRule; +use crate::core::default_layout::DefaultLayout; +use crate::core::default_layout::LayoutOptions; +use crate::core::layout::Layout; +use crate::core::pathext::ResolvedPathBuf; +use crate::core::rect::Rect; +use crate::monitor::Monitor; +use crate::ring::Ring; +use crate::window::AspectRatio; +use crate::window::PredefinedAspectRatio; +use crate::window_manager::WindowManager; +use crate::window_manager_event::WindowManagerEvent; +use crate::workspace::Workspace; +use color_eyre::eyre; +use crossbeam_channel::Receiver; +use hotwatch::EventKind; +use hotwatch::Hotwatch; +use objc2_core_foundation::CFRetained; +use objc2_core_foundation::CFRunLoop; +use parking_lot::Mutex; +use regex::Regex; +use serde::Deserialize; +use serde::Serialize; +use std::collections::HashMap; +use std::io::ErrorKind; +use std::io::Write; +use std::os::unix::net::UnixListener; +use std::os::unix::net::UnixStream; +use std::path::PathBuf; +use std::sync::Arc; +use std::sync::atomic::Ordering; + +// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct BorderColours { +// /// Border colour when the container contains a single window +// #[serde(skip_serializing_if = "Option::is_none")] +// pub single: Option, +// /// Border colour when the container contains multiple windows +// #[serde(skip_serializing_if = "Option::is_none")] +// pub stack: Option, +// /// Border colour when the container is in monocle mode +// #[serde(skip_serializing_if = "Option::is_none")] +// pub monocle: Option, +// /// Border colour when the container is in floating mode +// #[serde(skip_serializing_if = "Option::is_none")] +// pub floating: Option, +// /// Border colour when the container is unfocused +// #[serde(skip_serializing_if = "Option::is_none")] +// pub unfocused: Option, +// /// Border colour when the container is unfocused and locked +// #[serde(skip_serializing_if = "Option::is_none")] +// pub unfocused_locked: Option, +// } + +// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct ThemeOptions { +// /// Specify Light or Dark variant for theme generation (default: Dark) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub theme_variant: Option, +// /// Border colour when the container contains a single window (default: Base0D) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub single_border: Option, +// /// Border colour when the container contains multiple windows (default: Base0B) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub stack_border: Option, +// /// Border colour when the container is in monocle mode (default: Base0F) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub monocle_border: Option, +// /// Border colour when the window is floating (default: Base09) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub floating_border: Option, +// /// Border colour when the container is unfocused (default: Base01) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub unfocused_border: Option, +// /// Border colour when the container is unfocused and locked (default: Base08) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub unfocused_locked_border: Option, +// /// Stackbar focused tab text colour (default: Base0B) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub stackbar_focused_text: Option, +// /// Stackbar unfocused tab text colour (default: Base05) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub stackbar_unfocused_text: Option, +// /// Stackbar tab background colour (default: Base01) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub stackbar_background: Option, +// /// Komorebi status bar accent (default: Base0D) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub bar_accent: Option, +// } + +// #[serde_with::serde_as] +// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct Wallpaper { +// /// Path to the wallpaper image file +// #[serde_as(as = "ResolvedPathBuf")] +// pub path: PathBuf, +// /// Generate and apply Base16 theme for this wallpaper (default: true) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub generate_theme: Option, +// /// Specify Light or Dark variant for theme generation (default: Dark) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub theme_options: Option, +// } + +// serde_as must be before derive +#[serde_with::serde_as] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct WorkspaceConfig { + /// Name + pub name: String, + /// Layout (default: BSP) + #[serde(skip_serializing_if = "Option::is_none")] + pub layout: Option, + /// Layout-specific options (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub layout_options: Option, + /// END OF LIFE FEATURE: Custom Layout (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + #[serde_as(as = "Option")] + pub custom_layout: Option, + /// Layout rules in the format of threshold => layout (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub layout_rules: Option>, + /// Container padding (default: global) + #[serde(skip_serializing_if = "Option::is_none")] + pub container_padding: Option, + /// Workspace padding (default: global) + #[serde(skip_serializing_if = "Option::is_none")] + pub workspace_padding: Option, + /// Initial workspace application rules + #[serde(skip_serializing_if = "Option::is_none")] + pub initial_workspace_rules: Option>, + /// Permanent workspace application rules + #[serde(skip_serializing_if = "Option::is_none")] + pub workspace_rules: Option>, + /// Workspace specific work area offset (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub work_area_offset: Option, + /// Apply this monitor's window-based work area offset (default: true) + #[serde(skip_serializing_if = "Option::is_none")] + pub apply_window_based_work_area_offset: Option, + /// Determine what happens when a new window is opened (default: Create) + #[serde(skip_serializing_if = "Option::is_none")] + pub window_container_behaviour: Option, + /// Window container behaviour rules in the format of threshold => behaviour (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub window_container_behaviour_rules: Option>, + /// Enable or disable float override, which makes it so every new window opens in floating mode (default: false) + #[serde(skip_serializing_if = "Option::is_none")] + pub float_override: Option, + /// Enable or disable tiling for the workspace (default: true) + #[serde(skip_serializing_if = "Option::is_none")] + pub tile: Option, + /// Specify an axis on which to flip the selected layout (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub layout_flip: Option, + /// Determine what happens to a new window when the Floating workspace layer is active (default: Tile) + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_layer_behaviour: Option, + // /// Specify a wallpaper for this workspace + // #[serde(skip_serializing_if = "Option::is_none")] + // pub wallpaper: Option, +} + +impl From<&Workspace> for WorkspaceConfig { + fn from(value: &Workspace) -> Self { + let mut layout_rules = HashMap::new(); + for (threshold, layout) in &value.layout_rules { + match layout { + Layout::Default(value) => { + layout_rules.insert(*threshold, *value); + } + } + } + let layout_rules = (!layout_rules.is_empty()).then_some(layout_rules); + + let mut window_container_behaviour_rules = HashMap::new(); + for (threshold, behaviour) in value.window_container_behaviour_rules.iter().flatten() { + window_container_behaviour_rules.insert(*threshold, *behaviour); + } + + let default_container_padding = DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst); + let default_workspace_padding = DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst); + + let container_padding = value.container_padding.and_then(|container_padding| { + if container_padding == default_container_padding { + None + } else { + Option::from(container_padding) + } + }); + + let workspace_padding = value.workspace_padding.and_then(|workspace_padding| { + if workspace_padding == default_workspace_padding { + None + } else { + Option::from(workspace_padding) + } + }); + + let tile = if value.tile { None } else { Some(false) }; + + Self { + name: value + .name + .clone() + .unwrap_or_else(|| String::from("unnamed")), + layout: value + .tile + .then_some(match value.layout { + Layout::Default(layout) => Option::from(layout), + }) + .flatten(), + layout_options: value.layout_options, + custom_layout: value + .workspace_config + .as_ref() + .and_then(|c| c.custom_layout.clone()), + layout_rules, + container_padding, + workspace_padding, + initial_workspace_rules: value + .workspace_config + .as_ref() + .and_then(|c| c.initial_workspace_rules.clone()), + workspace_rules: value + .workspace_config + .as_ref() + .and_then(|c| c.workspace_rules.clone()), + work_area_offset: value.work_area_offset, + apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset), + window_container_behaviour: value.window_container_behaviour, + window_container_behaviour_rules: Option::from(window_container_behaviour_rules), + float_override: value.float_override, + tile, + layout_flip: value.layout_flip, + floating_layer_behaviour: value.floating_layer_behaviour, + // wallpaper: None, + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct MonitorConfig { + /// Workspace configurations + pub workspaces: Vec, + /// Monitor-specific work area offset (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub work_area_offset: Option, + /// Window based work area offset (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub window_based_work_area_offset: Option, + /// Open window limit after which the window based work area offset will no longer be applied (default: 1) + #[serde(skip_serializing_if = "Option::is_none")] + pub window_based_work_area_offset_limit: Option, + /// Container padding (default: global) + #[serde(skip_serializing_if = "Option::is_none")] + pub container_padding: Option, + /// Workspace padding (default: global) + #[serde(skip_serializing_if = "Option::is_none")] + pub workspace_padding: Option, + // /// Specify a wallpaper for this monitor + // #[serde(skip_serializing_if = "Option::is_none")] + // pub wallpaper: Option, + /// Determine what happens to a new window when the Floating workspace layer is active (default: Tile) + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_layer_behaviour: Option, +} + +impl From<&Monitor> for MonitorConfig { + fn from(value: &Monitor) -> Self { + let mut workspaces = vec![]; + for w in value.workspaces() { + workspaces.push(WorkspaceConfig::from(w)); + } + + let default_container_padding = DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst); + let default_workspace_padding = DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst); + + let container_padding = value.container_padding.and_then(|container_padding| { + if container_padding == default_container_padding { + None + } else { + Option::from(container_padding) + } + }); + + let workspace_padding = value.workspace_padding.and_then(|workspace_padding| { + if workspace_padding == default_workspace_padding { + None + } else { + Option::from(workspace_padding) + } + }); + + Self { + workspaces, + work_area_offset: value.work_area_offset, + window_based_work_area_offset: value.window_based_work_area_offset, + window_based_work_area_offset_limit: Some(value.window_based_work_area_offset_limit), + container_padding, + workspace_padding, + // wallpaper: value.wallpaper.clone(), + floating_layer_behaviour: value.floating_layer_behaviour, + } + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[serde(untagged)] +pub enum AppSpecificConfigurationPath { + /// A single applications.json file + Single(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + /// Multiple applications.json files + Multiple(#[serde_as(as = "Vec")] Vec), +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] +/// The `komorebi.json` static configuration file reference for `v0.1.39` +pub struct StaticConfig { + // /// DISCOURAGED: Minimum width for a window to be eligible for tiling + // #[serde(skip_serializing_if = "Option::is_none")] + // pub minimum_window_width: Option, + // /// DISCOURAGED: Minimum height for a window to be eligible for tiling + // #[serde(skip_serializing_if = "Option::is_none")] + // pub minimum_window_height: Option, + /// Delta to resize windows by (default 50) + #[serde(skip_serializing_if = "Option::is_none")] + pub resize_delta: Option, + /// Determine what happens when a new window is opened (default: Create) + #[serde(skip_serializing_if = "Option::is_none")] + pub window_container_behaviour: Option, + /// Enable or disable float override, which makes it so every new window opens in floating mode + /// (default: false) + #[serde(skip_serializing_if = "Option::is_none")] + pub float_override: Option, + /// Determines what happens on a new window when on the `FloatingLayer` + /// (default: Tile) + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_layer_behaviour: Option, + /// Determines the placement of a new window when toggling to float (default: CenterAndResize) + #[serde(skip_serializing_if = "Option::is_none")] + pub toggle_float_placement: Option, + /// Determines the `Placement` to be used when spawning a window on the floating layer with the + /// `FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float` (default: Center) + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_layer_placement: Option, + /// Determines the `Placement` to be used when spawning a window with float override active + /// (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub float_override_placement: Option, + /// Determines the `Placement` to be used when spawning a window that matches a + /// 'floating_applications' rule (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub float_rule_placement: Option, + /// Determine what happens when a window is moved across a monitor boundary (default: Swap) + #[serde(skip_serializing_if = "Option::is_none")] + pub cross_monitor_move_behaviour: Option, + /// Determine what happens when an action is called on a window at a monitor boundary (default: Monitor) + #[serde(skip_serializing_if = "Option::is_none")] + pub cross_boundary_behaviour: Option, + /// Determine what happens when commands are sent while an unmanaged window is in the foreground (default: Op) + #[serde(skip_serializing_if = "Option::is_none")] + pub unmanaged_window_operation_behaviour: Option, + /// Enable or disable mouse follows focus (default: true) + #[serde(skip_serializing_if = "Option::is_none")] + pub mouse_follows_focus: Option, + /// Path to applications.json from komorebi-application-specific-configurations (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub app_specific_configuration_path: Option, + // /// Width of the window border (default: 8) + // #[serde(skip_serializing_if = "Option::is_none")] + // #[serde(alias = "active_window_border_width")] + // pub border_width: Option, + // /// Offset of the window border (default: -1) + // #[serde(skip_serializing_if = "Option::is_none")] + // #[serde(alias = "active_window_border_offset")] + // pub border_offset: Option, + // /// Display an active window border (default: true) + // #[serde(skip_serializing_if = "Option::is_none")] + // #[serde(alias = "active_window_border")] + // pub border: Option, + // /// Active window border colours for different container types + // #[serde(skip_serializing_if = "Option::is_none")] + // #[serde(alias = "active_window_border_colours")] + // pub border_colours: Option, + // /// Active window border style (default: System) + // #[serde(skip_serializing_if = "Option::is_none")] + // #[serde(alias = "active_window_border_style")] + // pub border_style: Option, + // /// Active window border implementation (default: Komorebi) + // #[serde(skip_serializing_if = "Option::is_none")] + // pub border_implementation: Option, + /// Add transparency to unfocused windows (default: false) + // #[serde(skip_serializing_if = "Option::is_none")] + // pub transparency: Option, + // /// Alpha value for unfocused window transparency [[0-255]] (default: 200) + // #[serde(skip_serializing_if = "Option::is_none")] + // pub transparency_alpha: Option, + // /// Individual window transparency ignore rules + // #[serde(skip_serializing_if = "Option::is_none")] + // pub transparency_ignore_rules: Option>, + /// Global default workspace padding (default: 10) + #[serde(skip_serializing_if = "Option::is_none")] + pub default_workspace_padding: Option, + /// Global default container padding (default: 10) + #[serde(skip_serializing_if = "Option::is_none")] + pub default_container_padding: Option, + /// Monitor and workspace configurations + #[serde(skip_serializing_if = "Option::is_none")] + pub monitors: Option>, + // /// Which Windows signal to use when hiding windows (default: Cloak) + // #[serde(skip_serializing_if = "Option::is_none")] + // pub window_hiding_behaviour: Option, + /// Global work area (space used for tiling) offset (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub global_work_area_offset: Option, + /// Individual window floating rules + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(alias = "float_rules")] + pub ignore_rules: Option>, + /// Individual window force-manage rules + #[serde(skip_serializing_if = "Option::is_none")] + pub manage_rules: Option>, + /// Identify applications which should be managed as floating windows + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_applications: Option>, + /// Identify border overflow applications + #[serde(skip_serializing_if = "Option::is_none")] + pub border_overflow_applications: Option>, + /// Identify tray and multi-window applications + #[serde(skip_serializing_if = "Option::is_none")] + pub tray_and_multi_window_applications: Option>, + /// Identify applications that have the WS_EX_LAYERED extended window style + #[serde(skip_serializing_if = "Option::is_none")] + pub layered_applications: Option>, + /// Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare) + #[serde(skip_serializing_if = "Option::is_none")] + pub object_name_change_applications: Option>, + /// Do not process EVENT_OBJECT_NAMECHANGE events as Show events for identified applications matching these title regexes + #[serde(skip_serializing_if = "Option::is_none")] + pub object_name_change_title_ignore_list: Option>, + // /// Set monitor index preferences + // #[serde(skip_serializing_if = "Option::is_none")] + // pub monitor_index_preferences: Option>, + // /// Set display index preferences + // #[serde(skip_serializing_if = "Option::is_none")] + // pub display_index_preferences: Option>, + // /// Stackbar configuration options + // #[serde(skip_serializing_if = "Option::is_none")] + // pub stackbar: Option, + // /// Animations configuration options + // #[serde(skip_serializing_if = "Option::is_none")] + // pub animation: Option, + // /// Theme configuration options + // #[serde(skip_serializing_if = "Option::is_none")] + // pub theme: Option, + /// Identify applications which are slow to send initial event notifications + // #[serde(skip_serializing_if = "Option::is_none")] + // pub slow_application_identifiers: Option>, + // /// How long to wait when compensating for slow applications, in milliseconds (default: 20) + // #[serde(skip_serializing_if = "Option::is_none")] + // pub slow_application_compensation_time: Option, + // /// Komorebi status bar configuration files for multiple instances on different monitors + // // this option is a little special because it is only consumed by komorebic + // #[serde(skip_serializing_if = "Option::is_none")] + // #[serde_as(as = "Option>")] + // pub bar_configurations: Option>, + // /// HEAVILY DISCOURAGED: Identify applications for which komorebi should forcibly remove title bars + // #[serde(skip_serializing_if = "Option::is_none")] + // pub remove_titlebar_applications: Option>, + /// Aspect ratio to resize with when toggling floating mode for a window + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_window_aspect_ratio: Option, + // /// Which Windows API behaviour to use when manipulating windows (default: Sync) + // #[serde(skip_serializing_if = "Option::is_none")] + // pub window_handling_behaviour: Option, +} + +// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct AnimationsConfig { +// /// Enable or disable animations (default: false) +// pub enabled: PerAnimationPrefixConfig, +// /// Set the animation duration in ms (default: 250) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub duration: Option>, +// /// Set the animation style (default: Linear) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub style: Option>, +// /// Set the animation FPS (default: 60) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub fps: Option, +// } + +// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// #[serde(tag = "palette")] +// pub enum KomorebiTheme { +// /// A theme from catppuccin-egui +// Catppuccin { +// /// Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin) +// name: komorebi_themes::Catppuccin, +// /// Border colour when the container contains a single window (default: Blue) +// #[serde(skip_serializing_if = "Option::is_none")] +// single_border: Option, +// /// Border colour when the container contains multiple windows (default: Green) +// #[serde(skip_serializing_if = "Option::is_none")] +// stack_border: Option, +// /// Border colour when the container is in monocle mode (default: Pink) +// #[serde(skip_serializing_if = "Option::is_none")] +// monocle_border: Option, +// /// Border colour when the window is floating (default: Yellow) +// #[serde(skip_serializing_if = "Option::is_none")] +// floating_border: Option, +// /// Border colour when the container is unfocused (default: Base) +// #[serde(skip_serializing_if = "Option::is_none")] +// unfocused_border: Option, +// /// Border colour when the container is unfocused and locked (default: Red) +// #[serde(skip_serializing_if = "Option::is_none")] +// unfocused_locked_border: Option, +// /// Stackbar focused tab text colour (default: Green) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_focused_text: Option, +// /// Stackbar unfocused tab text colour (default: Text) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_unfocused_text: Option, +// /// Stackbar tab background colour (default: Base) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_background: Option, +// /// Komorebi status bar accent (default: Blue) +// #[serde(skip_serializing_if = "Option::is_none")] +// bar_accent: Option, +// }, +// /// A theme from base16-egui-themes +// Base16 { +// /// Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/) +// name: komorebi_themes::Base16, +// /// Border colour when the container contains a single window (default: Base0D) +// #[serde(skip_serializing_if = "Option::is_none")] +// single_border: Option, +// /// Border colour when the container contains multiple windows (default: Base0B) +// #[serde(skip_serializing_if = "Option::is_none")] +// stack_border: Option, +// /// Border colour when the container is in monocle mode (default: Base0F) +// #[serde(skip_serializing_if = "Option::is_none")] +// monocle_border: Option, +// /// Border colour when the window is floating (default: Base09) +// #[serde(skip_serializing_if = "Option::is_none")] +// floating_border: Option, +// /// Border colour when the container is unfocused (default: Base01) +// #[serde(skip_serializing_if = "Option::is_none")] +// unfocused_border: Option, +// /// Border colour when the container is unfocused and locked (default: Base08) +// #[serde(skip_serializing_if = "Option::is_none")] +// unfocused_locked_border: Option, +// /// Stackbar focused tab text colour (default: Base0B) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_focused_text: Option, +// /// Stackbar unfocused tab text colour (default: Base05) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_unfocused_text: Option, +// /// Stackbar tab background colour (default: Base01) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_background: Option, +// /// Komorebi status bar accent (default: Base0D) +// #[serde(skip_serializing_if = "Option::is_none")] +// bar_accent: Option, +// }, +// /// A custom Base16 theme +// Custom { +// /// Colours of the custom Base16 theme palette +// colours: Box, +// /// Border colour when the container contains a single window (default: Base0D) +// #[serde(skip_serializing_if = "Option::is_none")] +// single_border: Option, +// /// Border colour when the container contains multiple windows (default: Base0B) +// #[serde(skip_serializing_if = "Option::is_none")] +// stack_border: Option, +// /// Border colour when the container is in monocle mode (default: Base0F) +// #[serde(skip_serializing_if = "Option::is_none")] +// monocle_border: Option, +// /// Border colour when the window is floating (default: Base09) +// #[serde(skip_serializing_if = "Option::is_none")] +// floating_border: Option, +// /// Border colour when the container is unfocused (default: Base01) +// #[serde(skip_serializing_if = "Option::is_none")] +// unfocused_border: Option, +// /// Border colour when the container is unfocused and locked (default: Base08) +// #[serde(skip_serializing_if = "Option::is_none")] +// unfocused_locked_border: Option, +// /// Stackbar focused tab text colour (default: Base0B) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_focused_text: Option, +// /// Stackbar unfocused tab text colour (default: Base05) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_unfocused_text: Option, +// /// Stackbar tab background colour (default: Base01) +// #[serde(skip_serializing_if = "Option::is_none")] +// stackbar_background: Option, +// /// Komorebi status bar accent (default: Base0D) +// #[serde(skip_serializing_if = "Option::is_none")] +// bar_accent: Option, +// }, +// } + +// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct TabsConfig { +// /// Width of a stackbar tab +// #[serde(skip_serializing_if = "Option::is_none")] +// pub width: Option, +// /// Focused tab text colour +// #[serde(skip_serializing_if = "Option::is_none")] +// pub focused_text: Option, +// /// Unfocused tab text colour +// #[serde(skip_serializing_if = "Option::is_none")] +// pub unfocused_text: Option, +// /// Tab background colour +// #[serde(skip_serializing_if = "Option::is_none")] +// pub background: Option, +// /// Font family +// #[serde(skip_serializing_if = "Option::is_none")] +// pub font_family: Option, +// /// Font size +// #[serde(skip_serializing_if = "Option::is_none")] +// pub font_size: Option, +// } + +// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct StackbarConfig { +// /// Stackbar height +// #[serde(skip_serializing_if = "Option::is_none")] +// pub height: Option, +// /// Stackbar label +// #[serde(skip_serializing_if = "Option::is_none")] +// pub label: Option, +// /// Stackbar mode (default: Never) +// #[serde(skip_serializing_if = "Option::is_none")] +// pub mode: Option, +// /// Stackbar tab configuration options +// #[serde(skip_serializing_if = "Option::is_none")] +// pub tabs: Option, +// } + +impl From<&WindowManager> for StaticConfig { + #[allow(clippy::too_many_lines)] + fn from(value: &WindowManager) -> Self { + let mut monitors = vec![]; + for m in value.monitors() { + monitors.push(MonitorConfig::from(m)); + } + + // let border_colours = if border_manager::FOCUSED.load(Ordering::SeqCst) == 0 { + // None + // } else { + // Option::from(BorderColours { + // single: Option::from(Colour::from(border_manager::FOCUSED.load(Ordering::SeqCst))), + // stack: Option::from(Colour::from(border_manager::STACK.load(Ordering::SeqCst))), + // monocle: Option::from(Colour::from(border_manager::MONOCLE.load(Ordering::SeqCst))), + // floating: Option::from(Colour::from( + // border_manager::FLOATING.load(Ordering::SeqCst), + // )), + // unfocused: Option::from(Colour::from( + // border_manager::UNFOCUSED.load(Ordering::SeqCst), + // )), + // unfocused_locked: Option::from(Colour::from( + // border_manager::UNFOCUSED_LOCKED.load(Ordering::SeqCst), + // )), + // }) + // }; + + Self { + // invisible_borders: None, + resize_delta: Option::from(value.resize_delta), + window_container_behaviour: Option::from( + value.window_management_behaviour.current_behaviour, + ), + float_override: Option::from(value.window_management_behaviour.float_override), + floating_layer_behaviour: Option::from( + value.window_management_behaviour.floating_layer_behaviour, + ), + toggle_float_placement: Option::from( + value.window_management_behaviour.toggle_float_placement, + ), + floating_layer_placement: Option::from( + value.window_management_behaviour.floating_layer_placement, + ), + float_override_placement: Option::from( + value.window_management_behaviour.float_override_placement, + ), + float_rule_placement: Option::from( + value.window_management_behaviour.float_rule_placement, + ), + cross_monitor_move_behaviour: Option::from(value.cross_monitor_move_behaviour), + cross_boundary_behaviour: Option::from(value.cross_boundary_behaviour), + unmanaged_window_operation_behaviour: Option::from( + value.unmanaged_window_operation_behaviour, + ), + // minimum_window_height: Some(window::MINIMUM_HEIGHT.load(Ordering::SeqCst)), + // minimum_window_width: Some(window::MINIMUM_WIDTH.load(Ordering::SeqCst)), + // focus_follows_mouse: value.focus_follows_mouse, + mouse_follows_focus: Option::from(value.mouse_follows_focus), + app_specific_configuration_path: None, + // border_width: Option::from(border_manager::BORDER_WIDTH.load(Ordering::SeqCst)), + // border_offset: Option::from(border_manager::BORDER_OFFSET.load(Ordering::SeqCst)), + // border: Option::from(border_manager::BORDER_ENABLED.load(Ordering::SeqCst)), + // border_colours, + // transparency: Option::from( + // transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst), + // ), + // transparency_alpha: Option::from( + // transparency_manager::TRANSPARENCY_ALPHA.load(Ordering::SeqCst), + // ), + // transparency_ignore_rules: None, + // border_style: Option::from(STYLE.load()), + // border_z_order: None, + // border_implementation: Option::from(IMPLEMENTATION.load()), + default_workspace_padding: Option::from( + DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst), + ), + default_container_padding: Option::from( + DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst), + ), + monitors: Option::from(monitors), + // window_hiding_behaviour: Option::from(*HIDING_BEHAVIOUR.lock()), + global_work_area_offset: value.work_area_offset, + ignore_rules: None, + floating_applications: None, + manage_rules: None, + border_overflow_applications: None, + tray_and_multi_window_applications: None, + layered_applications: None, + object_name_change_applications: None, + object_name_change_title_ignore_list: None, + // monitor_index_preferences: Option::from(MONITOR_INDEX_PREFERENCES.lock().clone()), + // display_index_preferences: Option::from(DISPLAY_INDEX_PREFERENCES.read().clone()), + // stackbar: None, + // animation: None, + // theme: None, + // slow_application_compensation_time: Option::from( + // SLOW_APPLICATION_COMPENSATION_TIME.load(Ordering::SeqCst), + // ), + // slow_application_identifiers: Option::from(SLOW_APPLICATION_IDENTIFIERS.lock().clone()), + // bar_configurations: None, + // remove_titlebar_applications: Option::from(NO_TITLEBAR.lock().clone()), + floating_window_aspect_ratio: Option::from(*FLOATING_WINDOW_TOGGLE_ASPECT_RATIO.lock()), + // window_handling_behaviour: Option::from(WINDOW_HANDLING_BEHAVIOUR.load()), + } + } +} + +impl StaticConfig { + #[allow(clippy::cognitive_complexity, clippy::too_many_lines)] + fn apply_globals(&mut self) -> eyre::Result<()> { + *FLOATING_WINDOW_TOGGLE_ASPECT_RATIO.lock() = self + .floating_window_aspect_ratio + .unwrap_or(AspectRatio::Predefined(PredefinedAspectRatio::Standard)); + + // if let Some(monitor_index_preferences) = &self.monitor_index_preferences { + // let mut preferences = MONITOR_INDEX_PREFERENCES.lock(); + // preferences.clone_from(monitor_index_preferences); + // } + // + // if let Some(display_index_preferences) = &self.display_index_preferences { + // let mut preferences = DISPLAY_INDEX_PREFERENCES.write(); + // preferences.clone_from(display_index_preferences); + // } + + // if let Some(behaviour) = self.window_hiding_behaviour { + // let mut window_hiding_behaviour = HIDING_BEHAVIOUR.lock(); + // *window_hiding_behaviour = behaviour; + // } + + // if let Some(height) = self.minimum_window_height { + // window::MINIMUM_HEIGHT.store(height, Ordering::SeqCst); + // } + // + // if let Some(width) = self.minimum_window_width { + // window::MINIMUM_WIDTH.store(width, Ordering::SeqCst); + // } + + // if let Some(animations) = &self.animation { + // match &animations.enabled { + // PerAnimationPrefixConfig::Prefix(enabled) => { + // ANIMATION_ENABLED_PER_ANIMATION.lock().clone_from(enabled); + // } + // PerAnimationPrefixConfig::Global(enabled) => { + // ANIMATION_ENABLED_GLOBAL.store(*enabled, Ordering::SeqCst); + // ANIMATION_ENABLED_PER_ANIMATION.lock().clear(); + // } + // } + // + // match &animations.style { + // Some(PerAnimationPrefixConfig::Prefix(style)) => { + // ANIMATION_STYLE_PER_ANIMATION.lock().clone_from(style); + // } + // Some(PerAnimationPrefixConfig::Global(style)) => { + // let mut animation_style = ANIMATION_STYLE_GLOBAL.lock(); + // *animation_style = *style; + // ANIMATION_STYLE_PER_ANIMATION.lock().clear(); + // } + // None => {} + // } + // + // match &animations.duration { + // Some(PerAnimationPrefixConfig::Prefix(duration)) => { + // ANIMATION_DURATION_PER_ANIMATION.lock().clone_from(duration); + // } + // Some(PerAnimationPrefixConfig::Global(duration)) => { + // ANIMATION_DURATION_GLOBAL.store(*duration, Ordering::SeqCst); + // ANIMATION_DURATION_PER_ANIMATION.lock().clear(); + // } + // None => {} + // } + // + // ANIMATION_FPS.store( + // animations.fps.unwrap_or(DEFAULT_ANIMATION_FPS), + // Ordering::SeqCst, + // ); + // } + + if let Some(container) = self.default_container_padding { + DEFAULT_CONTAINER_PADDING.store(container, Ordering::SeqCst); + } + + if let Some(workspace) = self.default_workspace_padding { + DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst); + } + + // border_manager::BORDER_WIDTH.store(self.border_width.unwrap_or(8), Ordering::SeqCst); + // border_manager::BORDER_OFFSET.store(self.border_offset.unwrap_or(-1), Ordering::SeqCst); + // border_manager::BORDER_ENABLED.store(self.border.unwrap_or(true), Ordering::SeqCst); + // + // if let Some(colours) = &self.border_colours { + // if let Some(single) = colours.single { + // border_manager::FOCUSED.store(u32::from(single), Ordering::SeqCst); + // } + // + // if let Some(stack) = colours.stack { + // border_manager::STACK.store(u32::from(stack), Ordering::SeqCst); + // } + // + // if let Some(monocle) = colours.monocle { + // border_manager::MONOCLE.store(u32::from(monocle), Ordering::SeqCst); + // } + // + // if let Some(floating) = colours.floating { + // border_manager::FLOATING.store(u32::from(floating), Ordering::SeqCst); + // } + // + // if let Some(unfocused) = colours.unfocused { + // border_manager::UNFOCUSED.store(u32::from(unfocused), Ordering::SeqCst); + // } + // + // if let Some(unfocused_locked) = colours.unfocused_locked { + // border_manager::UNFOCUSED_LOCKED + // .store(u32::from(unfocused_locked), Ordering::SeqCst); + // } + // } + // + // STYLE.store(self.border_style.unwrap_or_default()); + // + // if !*WINDOWS_11 + // && matches!( + // self.border_implementation.unwrap_or_default(), + // BorderImplementation::Windows + // ) + // { + // tracing::error!( + // "BorderImplementation::Windows is only supported on Windows 11 and above" + // ); + // } else { + // IMPLEMENTATION.store(self.border_implementation.unwrap_or_default()); + // match IMPLEMENTATION.load() { + // BorderImplementation::Komorebi => { + // border_manager::destroy_all_borders()?; + // } + // BorderImplementation::Windows => { + // // TODO: figure out how to call wm.remove_all_accents here + // } + // } + // + // border_manager::send_notification(None); + // } + // + // transparency_manager::TRANSPARENCY_ENABLED + // .store(self.transparency.unwrap_or(false), Ordering::SeqCst); + // transparency_manager::TRANSPARENCY_ALPHA + // .store(self.transparency_alpha.unwrap_or(200), Ordering::SeqCst); + + let mut ignore_identifiers = IGNORE_IDENTIFIERS.lock(); + let mut regex_identifiers = REGEX_IDENTIFIERS.lock(); + let mut manage_identifiers = MANAGE_IDENTIFIERS.lock(); + // let mut tray_and_multi_window_identifiers = TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock(); + // let mut object_name_change_identifiers = OBJECT_NAME_CHANGE_ON_LAUNCH.lock(); + // let mut object_name_change_title_ignore_list = OBJECT_NAME_CHANGE_TITLE_IGNORE_LIST.lock(); + // let mut layered_identifiers = LAYERED_WHITELIST.lock(); + // let mut transparency_blacklist = TRANSPARENCY_BLACKLIST.lock(); + // let mut slow_application_identifiers = SLOW_APPLICATION_IDENTIFIERS.lock(); + let mut floating_applications = FLOATING_APPLICATIONS.lock(); + // let mut no_titlebar_applications = NO_TITLEBAR.lock(); + + if let Some(rules) = &mut self.ignore_rules { + populate_rules(rules, &mut ignore_identifiers, &mut regex_identifiers)?; + } + + if let Some(rules) = &mut self.floating_applications { + populate_rules(rules, &mut floating_applications, &mut regex_identifiers)?; + } + + if let Some(rules) = &mut self.manage_rules { + populate_rules(rules, &mut manage_identifiers, &mut regex_identifiers)?; + } + + // if let Some(rules) = &mut self.object_name_change_applications { + // populate_rules( + // rules, + // &mut object_name_change_identifiers, + // &mut regex_identifiers, + // )?; + // } + // + // if let Some(regexes) = &mut self.object_name_change_title_ignore_list { + // let mut updated = vec![]; + // for r in regexes { + // if let Ok(regex) = Regex::new(r) { + // updated.push(regex); + // } + // } + // + // *object_name_change_title_ignore_list = updated; + // } + // + // if let Some(rules) = &mut self.layered_applications { + // populate_rules(rules, &mut layered_identifiers, &mut regex_identifiers)?; + // } + // + // if let Some(rules) = &mut self.tray_and_multi_window_applications { + // populate_rules( + // rules, + // &mut tray_and_multi_window_identifiers, + // &mut regex_identifiers, + // )?; + // } + // + // if let Some(rules) = &mut self.transparency_ignore_rules { + // populate_rules(rules, &mut transparency_blacklist, &mut regex_identifiers)?; + // } + // + // if let Some(rules) = &mut self.slow_application_identifiers { + // populate_rules( + // rules, + // &mut slow_application_identifiers, + // &mut regex_identifiers, + // )?; + // } + // + // if let Some(rules) = &mut self.remove_titlebar_applications { + // populate_rules(rules, &mut no_titlebar_applications, &mut regex_identifiers)?; + // } + // + // if let Some(stackbar) = &self.stackbar { + // if let Some(height) = &stackbar.height { + // STACKBAR_TAB_HEIGHT.store(*height, Ordering::SeqCst); + // } + // + // if let Some(label) = &stackbar.label { + // STACKBAR_LABEL.store(*label); + // } + // + // if let Some(mode) = &stackbar.mode { + // STACKBAR_MODE.store(*mode); + // } + // + // #[allow(clippy::assigning_clones)] + // if let Some(tabs) = &stackbar.tabs { + // if let Some(background) = &tabs.background { + // STACKBAR_TAB_BACKGROUND_COLOUR.store((*background).into(), Ordering::SeqCst); + // } + // + // if let Some(colour) = &tabs.focused_text { + // STACKBAR_FOCUSED_TEXT_COLOUR.store((*colour).into(), Ordering::SeqCst); + // } + // + // if let Some(colour) = &tabs.unfocused_text { + // STACKBAR_UNFOCUSED_TEXT_COLOUR.store((*colour).into(), Ordering::SeqCst); + // } + // + // if let Some(width) = &tabs.width { + // STACKBAR_TAB_WIDTH.store(*width, Ordering::SeqCst); + // } + // + // STACKBAR_FONT_SIZE.store(tabs.font_size.unwrap_or(0), Ordering::SeqCst); + // *STACKBAR_FONT_FAMILY.lock() = tabs.font_family.clone(); + // } + // } + // + // if let Some(theme) = &self.theme { + // theme_manager::send_notification(theme.clone()); + // } + + if let Some(path) = &self.app_specific_configuration_path { + match path { + AppSpecificConfigurationPath::Single(path) => handle_asc_file( + path, + &mut ignore_identifiers, + &mut vec![], + &mut vec![], + &mut vec![], + &mut manage_identifiers, + &mut floating_applications, + &mut vec![], + &mut vec![], + &mut regex_identifiers, + )?, + AppSpecificConfigurationPath::Multiple(paths) => { + for path in paths { + handle_asc_file( + path, + &mut ignore_identifiers, + &mut vec![], + &mut vec![], + &mut vec![], + &mut manage_identifiers, + &mut floating_applications, + &mut vec![], + &mut vec![], + &mut regex_identifiers, + )? + } + } + } + } + + // if let Some(behaviour) = self.window_handling_behaviour { + // WINDOW_HANDLING_BEHAVIOUR.store(behaviour); + // } + + Ok(()) + } + + pub fn read_raw(raw: &str) -> eyre::Result { + Ok(serde_json::from_str(raw)?) + } + + pub fn read(path: &PathBuf) -> eyre::Result { + let content = std::fs::read_to_string(path)?; + serde_json::from_str(&content).map_err(Into::into) + } + + #[allow(clippy::too_many_lines)] + pub fn preload( + path: &PathBuf, + incoming: Receiver, + unix_listener: Option, + run_loop: &CFRetained, + ) -> eyre::Result { + let mut value = Self::read(path)?; + value.apply_globals()?; + + let listener = match unix_listener { + Some(listener) => listener, + None => { + let socket = DATA_DIR.join("komorebi.sock"); + + match std::fs::remove_file(&socket) { + Ok(()) => {} + Err(error) => match error.kind() { + // Doing this because ::exists() doesn't work reliably on Windows via IntelliJ + ErrorKind::NotFound => {} + _ => { + return Err(error.into()); + } + }, + }; + + UnixListener::bind(&socket)? + } + }; + + let mut wm = WindowManager { + monitors: Ring::default(), + // monitor_usr_idx_map: HashMap::new(), + applications: Default::default(), + incoming_events: incoming, + command_listener: listener, + is_paused: false, + // virtual_desktop_id: current_virtual_desktop(), + work_area_offset: value.global_work_area_offset, + window_management_behaviour: WindowManagementBehaviour { + current_behaviour: value + .window_container_behaviour + .unwrap_or(WindowContainerBehaviour::Create), + float_override: value.float_override.unwrap_or_default(), + floating_layer_override: false, // this value is always automatically calculated + floating_layer_behaviour: FloatingLayerBehaviour::default(), + toggle_float_placement: value + .toggle_float_placement + .unwrap_or(Placement::CenterAndResize), + floating_layer_placement: value + .floating_layer_placement + .unwrap_or(Placement::Center), + float_override_placement: value.float_override_placement.unwrap_or(Placement::None), + float_rule_placement: value.float_rule_placement.unwrap_or(Placement::None), + }, + cross_monitor_move_behaviour: value + .cross_monitor_move_behaviour + .unwrap_or(MoveBehaviour::Swap), + cross_boundary_behaviour: value + .cross_boundary_behaviour + .unwrap_or(CrossBoundaryBehaviour::Monitor), + unmanaged_window_operation_behaviour: value + .unmanaged_window_operation_behaviour + .unwrap_or(OperationBehaviour::Op), + resize_delta: value.resize_delta.unwrap_or(50), + // focus_follows_mouse: value.focus_follows_mouse, + mouse_follows_focus: value.mouse_follows_focus.unwrap_or(true), + hotwatch: Hotwatch::new()?, + // has_pending_raise_op: false, + // pending_move_op: Arc::new(None), + // already_moved_window_handles: Arc::new(Mutex::new(HashSet::new())), + // uncloack_to_ignore: 0, + // known_hwnds: HashMap::new(), + run_loop: CoreFoundationRunLoop(run_loop.clone()), + minimized_windows: Default::default(), + already_moved_window_handles: Default::default(), + }; + + // match value.focus_follows_mouse { + // None => WindowsApi::disable_focus_follows_mouse()?, + // Some(FocusFollowsMouseImplementation::Windows) => { + // WindowsApi::enable_focus_follows_mouse()?; + // } + // Some(FocusFollowsMouseImplementation::Komorebi) => {} + // }; + + let bytes = SocketMessage::ReloadStaticConfiguration(path.clone()).as_bytes()?; + + wm.hotwatch.watch(path, move |event| match event.kind { + // Editing in Notepad sends a NoticeWrite while editing in (Neo)Vim sends + // a NoticeRemove, presumably because of the use of swap files? + EventKind::Modify(_) | EventKind::Remove(_) => { + let socket = DATA_DIR.join("komorebi.sock"); + let mut stream = + UnixStream::connect(socket).expect("could not connect to komorebi.sock"); + stream + .write_all(&bytes) + .expect("could not write to komorebi.sock"); + } + _ => {} + })?; + + Ok(wm) + } + + pub fn postload(path: &PathBuf, wm: &Arc>) -> eyre::Result<()> { + let mut value = Self::read(path)?; + let mut wm = wm.lock(); + + // let configs_with_preference: Vec<_> = + // DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect(); + let configs_with_preference = []; + let mut configs_used = Vec::new(); + + let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); + workspace_matching_rules.clear(); + drop(workspace_matching_rules); + + let monitor_count = wm.monitors().len(); + + let offset = wm.work_area_offset; + for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() { + let preferred_config_idx = None; + // let preferred_config_idx = { + // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + // let c_idx = display_index_preferences.iter().find_map(|(c_idx, id)| { + // (monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id) + // || monitor.device_id.eq(id)) + // .then_some(*c_idx) + // }); + // c_idx + // }; + + let idx = preferred_config_idx.or({ + // Monitor without preferred config idx. + // Get index of first config that is not a preferred config of some other monitor + // and that has not been used yet. This might return `None` as well, in that case + // this monitor won't have a config tied to it and will use the default values. + let m_config_count = value + .monitors + .as_ref() + .map(|ms| ms.len()) + .unwrap_or_default(); + (0..m_config_count) + .find(|i| !configs_with_preference.contains(i) && !configs_used.contains(i)) + }); + + if let Some(monitor_config) = value + .monitors + .as_mut() + .and_then(|ms| idx.and_then(|i| ms.get_mut(i))) + { + if let Some(used_config_idx) = idx { + configs_used.push(used_config_idx); + } + + monitor.ensure_workspace_count(monitor_config.workspaces.len()); + monitor.work_area_offset = monitor_config.work_area_offset; + monitor.window_based_work_area_offset = + monitor_config.window_based_work_area_offset; + monitor.window_based_work_area_offset_limit = monitor_config + .window_based_work_area_offset_limit + .unwrap_or(1); + monitor.container_padding = monitor_config.container_padding; + monitor.workspace_padding = monitor_config.workspace_padding; + // monitor.wallpaper = monitor_config.wallpaper.clone(); + monitor.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + + monitor.update_workspaces_globals(offset); + for (j, ws) in monitor.workspaces_mut().iter_mut().enumerate() { + if let Some(workspace_config) = monitor_config.workspaces.get_mut(j) { + if monitor_count > 1 + && matches!(workspace_config.layout, Some(DefaultLayout::Scrolling)) + { + tracing::warn!( + "scrolling layout is only supported for a single monitor; falling back to columns layout" + ); + workspace_config.layout = Some(DefaultLayout::Columns); + } + + ws.load_static_config(workspace_config)?; + } + } + + // Check if this monitor config is the preferred config for this monitor and store + // a copy of the monitor itself on the monitor cache if it is. + // if idx == preferred_config_idx { + // let id = monitor + // .serial_number_id + // .as_ref() + // .map_or(&monitor.device_id, |sn| sn); + // monitor_reconciliator::insert_in_monitor_cache(id, monitor.clone()); + // } + + let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); + for (j, ws) in monitor_config.workspaces.iter().enumerate() { + if let Some(rules) = &ws.workspace_rules { + for r in rules { + workspace_matching_rules.push(WorkspaceMatchingRule { + monitor_index: i, + workspace_index: j, + matching_rule: r.clone(), + initial_only: false, + }); + } + } + + if let Some(rules) = &ws.initial_workspace_rules { + for r in rules { + workspace_matching_rules.push(WorkspaceMatchingRule { + monitor_index: i, + workspace_index: j, + matching_rule: r.clone(), + initial_only: true, + }); + } + } + } + } + } + + // Check for configs that should be tied to a specific display that isn't loaded right now + // and cache a monitor with those configs with the specific `serial_number_id` so that when + // those devices are connected later we can use the correct config from the cache. + // if configs_with_preference.len() > configs_used.len() { + // for i in configs_with_preference + // .iter() + // .filter(|i| !configs_used.contains(i)) + // { + // let id = { + // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + // display_index_preferences.get(i).cloned() + // }; + // if let (Some(id), Some(monitor_config)) = + // (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) + // { + // // The name, device, device_id and serial_number_id can be empty here since + // // once the monitor with this preferred index actually connects the + // // `load_monitor_information` function will update these fields. + // let mut m = monitor::new( + // 0, + // Rect::default(), + // Rect::default(), + // "".into(), + // "".into(), + // "".into(), + // None, + // ); + // + // m.ensure_workspace_count(monitor_config.workspaces.len()); + // m.work_area_offset = monitor_config.work_area_offset; + // m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; + // m.window_based_work_area_offset_limit = monitor_config + // .window_based_work_area_offset_limit + // .unwrap_or(1); + // m.container_padding = monitor_config.container_padding; + // m.workspace_padding = monitor_config.workspace_padding; + // m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + // + // m.update_workspaces_globals(offset); + // + // for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { + // if let Some(workspace_config) = monitor_config.workspaces.get(j) { + // ws.load_static_config(workspace_config)?; + // } + // } + // + // monitor_reconciliator::insert_in_monitor_cache(&id, m); + // } + // } + // } + + wm.enforce_workspace_rules()?; + + // if value.border == Some(true) { + // border_manager::BORDER_ENABLED.store(true, Ordering::SeqCst); + // } + + Ok(()) + } + + pub fn reload(path: &PathBuf, wm: &mut WindowManager) -> eyre::Result<()> { + let mut value = Self::read(path)?; + + value.apply_globals()?; + + // let configs_with_preference: Vec<_> = + // DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect(); + let configs_with_preference = []; + let mut configs_used = Vec::new(); + + let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); + workspace_matching_rules.clear(); + drop(workspace_matching_rules); + + let offset = wm.work_area_offset; + for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() { + // let preferred_config_idx = { + // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + // let c_idx = display_index_preferences.iter().find_map(|(c_idx, id)| { + // (monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id) + // || monitor.device_id.eq(id)) + // .then_some(*c_idx) + // }); + // c_idx + // }; + + let preferred_config_idx = None; + + let idx = preferred_config_idx.or({ + // Monitor without preferred config idx. + // Get index of first config that is not a preferred config of some other monitor + // and that has not been used yet. This might return `None` as well, in that case + // this monitor won't have a config tied to it and will use the default values. + let m_config_count = value + .monitors + .as_ref() + .map(|ms| ms.len()) + .unwrap_or_default(); + (0..m_config_count) + .find(|i| !configs_with_preference.contains(i) && !configs_used.contains(i)) + }); + if let Some(monitor_config) = value + .monitors + .as_ref() + .and_then(|ms| idx.and_then(|i| ms.get(i))) + { + if let Some(used_config_idx) = idx { + configs_used.push(used_config_idx); + } + + monitor.ensure_workspace_count(monitor_config.workspaces.len()); + if monitor.work_area_offset.is_none() { + monitor.work_area_offset = monitor_config.work_area_offset; + } + monitor.window_based_work_area_offset = + monitor_config.window_based_work_area_offset; + monitor.window_based_work_area_offset_limit = monitor_config + .window_based_work_area_offset_limit + .unwrap_or(1); + monitor.container_padding = monitor_config.container_padding; + monitor.workspace_padding = monitor_config.workspace_padding; + // monitor.wallpaper = monitor_config.wallpaper.clone(); + monitor.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + + monitor.update_workspaces_globals(offset); + + for (j, ws) in monitor.workspaces_mut().iter_mut().enumerate() { + if let Some(workspace_config) = monitor_config.workspaces.get(j) { + ws.load_static_config(workspace_config)?; + } + } + + // Check if this monitor config is the preferred config for this monitor and store + // a copy of the monitor itself on the monitor cache if it is. + // if idx == preferred_config_idx { + // let id = monitor + // .serial_number_id + // .as_ref() + // .map_or(&monitor.device_id, |sn| sn); + // monitor_reconciliator::insert_in_monitor_cache(id, monitor.clone()); + // } + + let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); + for (j, ws) in monitor_config.workspaces.iter().enumerate() { + if let Some(rules) = &ws.workspace_rules { + for r in rules { + workspace_matching_rules.push(WorkspaceMatchingRule { + monitor_index: i, + workspace_index: j, + matching_rule: r.clone(), + initial_only: false, + }); + } + } + + if let Some(rules) = &ws.initial_workspace_rules { + for r in rules { + workspace_matching_rules.push(WorkspaceMatchingRule { + monitor_index: i, + workspace_index: j, + matching_rule: r.clone(), + initial_only: true, + }); + } + } + } + } + } + + // Check for configs that should be tied to a specific display that isn't loaded right now + // and cache a monitor with those configs with the specific `serial_number_id` so that when + // those devices are connected later we can use the correct config from the cache. + // if configs_with_preference.len() > configs_used.len() { + // for i in configs_with_preference + // .iter() + // .filter(|i| !configs_used.contains(i)) + // { + // let id = { + // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + // display_index_preferences.get(i).cloned() + // }; + // if let (Some(id), Some(monitor_config)) = + // (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) + // { + // // The name, device, device_id and serial_number_id can be empty here since + // // once the monitor with this preferred index actually connects the + // // `load_monitor_information` function will update these fields. + // let mut m = monitor::new( + // 0, + // Rect::default(), + // Rect::default(), + // "".into(), + // "".into(), + // "".into(), + // None, + // ); + // + // m.ensure_workspace_count(monitor_config.workspaces.len()); + // m.work_area_offset = monitor_config.work_area_offset; + // m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; + // m.window_based_work_area_offset_limit = monitor_config + // .window_based_work_area_offset_limit + // .unwrap_or(1); + // m.container_padding = monitor_config.container_padding; + // m.workspace_padding = monitor_config.workspace_padding; + // m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + // + // m.update_workspaces_globals(offset); + // + // for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { + // if let Some(workspace_config) = monitor_config.workspaces.get(j) { + // ws.load_static_config(workspace_config)?; + // } + // } + // + // monitor_reconciliator::insert_in_monitor_cache(&id, m); + // } + // } + // } + + wm.enforce_workspace_rules()?; + + // border_manager::BORDER_ENABLED.store(value.border.unwrap_or(true), Ordering::SeqCst); + wm.window_management_behaviour.current_behaviour = + value.window_container_behaviour.unwrap_or_default(); + wm.window_management_behaviour.float_override = value.float_override.unwrap_or_default(); + wm.window_management_behaviour.floating_layer_behaviour = + value.floating_layer_behaviour.unwrap_or_default(); + wm.window_management_behaviour.toggle_float_placement = value + .toggle_float_placement + .unwrap_or(Placement::CenterAndResize); + wm.window_management_behaviour.floating_layer_placement = + value.floating_layer_placement.unwrap_or(Placement::Center); + wm.window_management_behaviour.float_override_placement = + value.float_override_placement.unwrap_or(Placement::None); + wm.window_management_behaviour.float_rule_placement = + value.float_rule_placement.unwrap_or(Placement::None); + wm.cross_monitor_move_behaviour = value.cross_monitor_move_behaviour.unwrap_or_default(); + wm.cross_boundary_behaviour = value.cross_boundary_behaviour.unwrap_or_default(); + wm.unmanaged_window_operation_behaviour = value + .unmanaged_window_operation_behaviour + .unwrap_or_default(); + wm.resize_delta = value.resize_delta.unwrap_or(50); + wm.mouse_follows_focus = value.mouse_follows_focus.unwrap_or(true); + wm.work_area_offset = value.global_work_area_offset; + // wm.focus_follows_mouse = value.focus_follows_mouse; + + // match wm.focus_follows_mouse { + // None => WindowsApi::disable_focus_follows_mouse()?, + // Some(FocusFollowsMouseImplementation::Windows) => { + // WindowsApi::enable_focus_follows_mouse()?; + // } + // Some(FocusFollowsMouseImplementation::Komorebi) => {} + // }; + + let monitor_count = wm.monitors().len(); + + for i in 0..monitor_count { + wm.update_focused_workspace_by_monitor_idx(i)?; + // let ws_idx = wm.focused_workspace_idx_for_monitor_idx(i)?; + // wm.apply_wallpaper_for_monitor_workspace(i, ws_idx)?; + } + + Ok(()) + } +} + +fn populate_rules( + matching_rules: &mut Vec, + identifiers: &mut Vec, + regex_identifiers: &mut HashMap, +) -> eyre::Result<()> { + for matching_rule in matching_rules { + if !identifiers.contains(matching_rule) { + match matching_rule { + MatchingRule::Simple(simple) => { + if simple.matching_strategy.is_none() { + simple.matching_strategy = Option::from(MatchingStrategy::Legacy); + } + + if matches!(simple.matching_strategy, Some(MatchingStrategy::Regex)) { + let re = Regex::new(&simple.id)?; + regex_identifiers.insert(simple.id.clone(), re); + } + } + MatchingRule::Composite(composite) => { + for rule in composite { + if rule.matching_strategy.is_none() { + rule.matching_strategy = Option::from(MatchingStrategy::Legacy); + } + + if matches!(rule.matching_strategy, Some(MatchingStrategy::Regex)) { + let re = Regex::new(&rule.id)?; + regex_identifiers.insert(rule.id.clone(), re); + } + } + } + } + identifiers.push(matching_rule.clone()); + } + } + + Ok(()) +} + +#[allow(clippy::too_many_arguments)] +fn handle_asc_file( + path: &PathBuf, + ignore_identifiers: &mut Vec, + object_name_change_identifiers: &mut Vec, + layered_identifiers: &mut Vec, + tray_and_multi_window_identifiers: &mut Vec, + manage_identifiers: &mut Vec, + floating_applications: &mut Vec, + transparency_blacklist: &mut Vec, + slow_application_identifiers: &mut Vec, + regex_identifiers: &mut HashMap, +) -> eyre::Result<()> { + match path.extension() { + None => {} + Some(ext) => { + if ext.to_string_lossy().to_string().as_str() == "json" { + tracing::info!("loading applications.json from: {}", path.display()); + let mut asc = ApplicationSpecificConfiguration::load(path)?; + + for entry in asc.values_mut() { + match entry { + AscApplicationRulesOrSchema::Schema(_) => {} + AscApplicationRulesOrSchema::AscApplicationRules(entry) => { + if let Some(rules) = &mut entry.ignore { + populate_rules(rules, ignore_identifiers, regex_identifiers)?; + } + + if let Some(rules) = &mut entry.manage { + populate_rules(rules, manage_identifiers, regex_identifiers)?; + } + + if let Some(rules) = &mut entry.floating { + populate_rules(rules, floating_applications, regex_identifiers)?; + } + + if let Some(rules) = &mut entry.transparency_ignore { + populate_rules(rules, transparency_blacklist, regex_identifiers)?; + } + + if let Some(rules) = &mut entry.tray_and_multi_window { + populate_rules( + rules, + tray_and_multi_window_identifiers, + regex_identifiers, + )?; + } + + if let Some(rules) = &mut entry.layered { + populate_rules(rules, layered_identifiers, regex_identifiers)?; + } + + if let Some(rules) = &mut entry.object_name_change { + populate_rules( + rules, + object_name_change_identifiers, + regex_identifiers, + )?; + } + + if let Some(rules) = &mut entry.slow_application { + populate_rules( + rules, + slow_application_identifiers, + regex_identifiers, + )?; + } + } + } + } + } + } + } + + Ok(()) +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 0739696a..aee7113c 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -1,7 +1,12 @@ use crate::AccessibilityObserver; use crate::AccessibilityUiElement; +use crate::FLOATING_APPLICATIONS; use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO; +use crate::IGNORE_IDENTIFIERS; use crate::LibraryError; +use crate::MANAGE_IDENTIFIERS; +use crate::PERMAIGNORE_CLASSES; +use crate::REGEX_IDENTIFIERS; use crate::WINDOW_RESTORE_POSITIONS; use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXFocusedAttribute; @@ -23,6 +28,10 @@ use crate::accessibility::notification_constants::kAXWindowResizedNotification; use crate::application::Application; use crate::ax_event_listener::event_tx; use crate::cf_dictionary_value; +use crate::core::ApplicationIdentifier; +use crate::core::config_generation::IdWithIdentifier; +use crate::core::config_generation::MatchingRule; +use crate::core::config_generation::MatchingStrategy; use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; use crate::hidden_frame_bottom_left; @@ -31,6 +40,7 @@ use crate::reaper; use crate::reaper::ReaperNotification; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; +use color_eyre::eyre; use objc2::__framework_prelude::Retained; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; @@ -51,13 +61,16 @@ use objc2_core_graphics::kCGWindowBounds; use objc2_core_graphics::kCGWindowName; use objc2_core_graphics::kCGWindowOwnerName; use objc2_core_graphics::kCGWindowOwnerPID; +use regex::Regex; use serde::Deserialize; use serde::Serialize; +use std::collections::HashMap; use std::collections::hash_map::Entry; use std::ffi::c_void; use std::fmt::Display; use std::fmt::Formatter; use std::fmt::Write; +use std::path::PathBuf; use std::ptr::NonNull; use std::str::FromStr; use strum::Display; @@ -184,6 +197,12 @@ impl Drop for Window { } } +impl PartialEq for Window { + fn eq(&self, other: &Self) -> bool { + self.id == other.id + } +} + impl Display for Window { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { let mut display = format!( @@ -330,6 +349,18 @@ impl Window { } } + pub fn path(&self) -> Option { + if let Ok(Some(path)) = self + .running_application() + .map(|app| unsafe { app.executableURL() }) + .map(|ns_url| ns_url.map(|url| url.to_file_path())) + { + path + } else { + None + } + } + pub fn role(&self) -> Option { AccessibilityApi::copy_attribute_value::(&self.element, kAXRoleAttribute) .map(|s| s.to_string()) @@ -506,6 +537,95 @@ impl Window { Ok(()) } + + #[tracing::instrument(skip_all)] + pub fn should_manage( + self, + event: Option, + // debug: &mut RuleDebug, + ) -> eyre::Result { + if !self.is_valid() { + return Ok(false); + } + + // debug.is_window = true; + + // let rect = Rect::from(MacosApi::window_rect(&self.element).unwrap_or_default()); + // + // if rect.right < MINIMUM_WIDTH.load(Ordering::SeqCst) { + // return Ok(false); + // } + // + // debug.has_minimum_width = true; + // + // if rect.bottom < MINIMUM_HEIGHT.load(Ordering::SeqCst) { + // return Ok(false); + // } + // + // debug.has_minimum_height = true; + + if self.title().is_none() { + return Ok(false); + } + + // debug.has_title = true; + + // let is_cloaked = self.is_cloaked().unwrap_or_default(); + // + // debug.is_cloaked = is_cloaked; + + // let mut allow_cloaked = false; + + // if let Some(event) = event { + // if matches!( + // event, + // WindowManagerEvent::Hide(_, _) | WindowManagerEvent::Cloak(_, _) + // ) { + // allow_cloaked = true; + // } + // } + + // debug.allow_cloaked = allow_cloaked; + + // match (allow_cloaked, is_cloaked) { + // // If allowing cloaked windows, we don't need to check the cloaked status + // (true, _) | + // // If not allowing cloaked windows, we need to ensure the window is not cloaked + // (false, false) => { + if let (Some(title), Some(exe_name), Some(role), Some(subrole), Some(path)) = ( + self.title(), + self.exe(), + self.role(), + self.subrole(), + self.path(), + ) { + // debug.title = Some(title.clone()); + // debug.exe_name = Some(exe_name.clone()); + // debug.class = Some(class.clone()); + // debug.path = Some(path.clone()); + // calls for styles can fail quite often for events with windows that aren't really "windows" + // since we have moved up calls of should_manage to the beginning of the process_event handler, + // we should handle failures here gracefully to be able to continue the execution of process_event + // if let (Ok(style), Ok(ex_style)) = (&self.style(), &self.ex_style()) { + // debug.window_style = Some(*style); + // debug.extended_window_style = Some(*ex_style); + let eligible = window_is_eligible( + self.id, + &title, + &exe_name, + &[&role, &subrole], + &path.to_string_lossy(), + event, + ); + // debug.should_manage = eligible; + return Ok(eligible); + // } + } + // } + // _ => {} + // } + Ok(false) + } } impl From<&CFDictionary> for WindowInfo { @@ -607,3 +727,463 @@ impl AspectRatio { } } } + +#[allow(clippy::too_many_arguments)] +fn window_is_eligible( + _window_id: u32, + title: &str, + exe_name: &str, + classes: &[&str], + path: &str, + // style: &WindowStyle, + // ex_style: &ExtendedWindowStyle, + _event: Option, + // debug: &mut RuleDebug, +) -> bool { + { + let permaignore_classes = PERMAIGNORE_CLASSES.lock(); + for class in classes { + if permaignore_classes.contains(&class.to_string()) { + // debug.matches_permaignore_class = Some(class.clone()); + return false; + } + } + } + + let regex_identifiers = REGEX_IDENTIFIERS.lock(); + + let ignore_identifiers = IGNORE_IDENTIFIERS.lock(); + let should_ignore = if let Some(_rule) = should_act( + title, + exe_name, + classes, + path, + &ignore_identifiers, + ®ex_identifiers, + ) { + // debug.matches_ignore_identifier = Some(rule); + true + } else { + false + }; + + let manage_identifiers = MANAGE_IDENTIFIERS.lock(); + let managed_override = if let Some(_rule) = should_act( + title, + exe_name, + classes, + path, + &manage_identifiers, + ®ex_identifiers, + ) { + // debug.matches_managed_override = Some(rule); + true + } else { + false + }; + + let floating_identifiers = FLOATING_APPLICATIONS.lock(); + if let Some(_rule) = should_act( + title, + exe_name, + classes, + path, + &floating_identifiers, + ®ex_identifiers, + ) { + // debug.matches_floating_applications = Some(rule); + } + + if should_ignore && !managed_override { + return false; + } + + // let layered_whitelist = LAYERED_WHITELIST.lock(); + // let mut allow_layered = if let Some(rule) = should_act( + // title, + // exe_name, + // class, + // path, + // &layered_whitelist, + // ®ex_identifiers, + // ) { + // debug.matches_layered_whitelist = Some(rule); + // true + // } else { + // false + // }; + // + // let known_layered_hwnds = transparency_manager::known_hwnds(); + + // allow_layered = if known_layered_hwnds.contains(&hwnd) + // // we always want to process hide events for windows with transparency, even on other + // // monitors, because we don't want to be left with ghost tiles + // || matches!(event, Some(WindowManagerEvent::Hide(_, _))) + // { + // debug.allow_layered_transparency = true; + // true + // } else { + // allow_layered + // }; + // + // let allow_wsl2_gui = { + // let wsl2_ui_processes = WSL2_UI_PROCESSES.lock(); + // let allow = wsl2_ui_processes.contains(exe_name); + // if allow { + // debug.matches_wsl2_gui = Some(exe_name.clone()) + // } + // + // allow + // }; + + // let titlebars_removed = NO_TITLEBAR.lock(); + // let allow_titlebar_removed = if let Some(rule) = should_act( + // title, + // exe_name, + // class, + // path, + // &titlebars_removed, + // ®ex_identifiers, + // ) { + // debug.matches_no_titlebar = Some(rule); + // true + // } else { + // false + // }; + // + // { + // let slow_application_identifiers = SLOW_APPLICATION_IDENTIFIERS.lock(); + // let should_sleep = should_act( + // title, + // exe_name, + // class, + // path, + // &slow_application_identifiers, + // ®ex_identifiers, + // ) + // .is_some(); + // + // if should_sleep { + // std::thread::sleep(Duration::from_millis( + // SLOW_APPLICATION_COMPENSATION_TIME.load(Ordering::SeqCst), + // )); + // } + // } + + // TODO: not sure about this new manage by default base case for macOS + true +} + +#[allow(clippy::cognitive_complexity, clippy::too_many_lines)] +pub fn should_act( + title: &str, + exe_name: &str, + classes: &[&str], + path: &str, + identifiers: &[MatchingRule], + regex_identifiers: &HashMap, +) -> Option { + let mut matching_rule = None; + for rule in identifiers { + match rule { + MatchingRule::Simple(identifier) => { + if should_act_individual( + title, + exe_name, + classes, + path, + identifier, + regex_identifiers, + ) { + matching_rule = Some(rule.clone()); + }; + } + MatchingRule::Composite(identifiers) => { + let mut composite_results = vec![]; + for identifier in identifiers { + composite_results.push(should_act_individual( + title, + exe_name, + classes, + path, + identifier, + regex_identifiers, + )); + } + + if composite_results.iter().all(|&x| x) { + matching_rule = Some(rule.clone()); + } + } + } + } + + matching_rule +} + +pub fn should_act_individual( + title: &str, + exe_name: &str, + classes: &[&str], + path: &str, + identifier: &IdWithIdentifier, + regex_identifiers: &HashMap, +) -> bool { + let mut should_act = false; + + let mut identifier = identifier.clone(); + identifier.id = identifier.id.replace(".exe", ""); + + match identifier.matching_strategy { + None | Some(MatchingStrategy::Legacy) => match identifier.kind { + ApplicationIdentifier::Title => { + if title.starts_with(&identifier.id) || title.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if class.starts_with(&identifier.id) || class.ends_with(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if exe_name.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if path.eq(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::Equals) => match identifier.kind { + ApplicationIdentifier::Title => { + if title.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if class.eq(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if exe_name.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if path.eq(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::DoesNotEqual) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if !class.eq(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if !exe_name.eq(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.eq(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::StartsWith) => match identifier.kind { + ApplicationIdentifier::Title => { + if title.starts_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if class.starts_with(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if exe_name.starts_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if path.starts_with(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::DoesNotStartWith) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.starts_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if !class.starts_with(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if !exe_name.starts_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.starts_with(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::EndsWith) => match identifier.kind { + ApplicationIdentifier::Title => { + if title.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if class.ends_with(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if exe_name.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if path.ends_with(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::DoesNotEndWith) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if !class.ends_with(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if !exe_name.ends_with(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.ends_with(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::Contains) => match identifier.kind { + ApplicationIdentifier::Title => { + if title.contains(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if class.contains(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if exe_name.contains(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if path.contains(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::DoesNotContain) => match identifier.kind { + ApplicationIdentifier::Title => { + if !title.contains(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Class => { + for class in classes { + if !class.contains(&identifier.id) { + should_act = true; + } + } + } + ApplicationIdentifier::Exe => { + if !exe_name.contains(&identifier.id) { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if !path.contains(&identifier.id) { + should_act = true; + } + } + }, + Some(MatchingStrategy::Regex) => match identifier.kind { + ApplicationIdentifier::Title => { + if let Some(re) = regex_identifiers.get(&identifier.id) + && re.is_match(title) + { + should_act = true; + } + } + ApplicationIdentifier::Class => { + if let Some(re) = regex_identifiers.get(&identifier.id) { + for class in classes { + if re.is_match(class) { + should_act = true; + } + } + } + } + ApplicationIdentifier::Exe => { + if let Some(re) = regex_identifiers.get(&identifier.id) + && re.is_match(exe_name) + { + should_act = true; + } + } + ApplicationIdentifier::Path => { + if let Some(re) = regex_identifiers.get(&identifier.id) + && re.is_match(path) + { + should_act = true; + } + } + }, + } + + should_act +} diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 4791901c..b695d59c 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1,16 +1,20 @@ use crate::CoreFoundationRunLoop; use crate::DATA_DIR; use crate::LibraryError; +use crate::REGEX_IDENTIFIERS; +use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::application::Application; use crate::container::Container; use crate::core::CrossBoundaryBehaviour; use crate::core::MoveBehaviour; +use crate::core::OperationBehaviour; use crate::core::Placement; use crate::core::Sizing; use crate::core::WindowManagementBehaviour; use crate::core::arrangement::Arrangement; use crate::core::arrangement::Axis; +use crate::core::config_generation::MatchingRule; use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; @@ -20,21 +24,28 @@ use crate::lockable_sequence::Lockable; use crate::macos_api::MacosApi; use crate::monitor::Monitor; use crate::ring::Ring; +use crate::static_config::StaticConfig; use crate::window::Window; +use crate::window::should_act_individual; use crate::window_manager_event::WindowManagerEvent; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use color_eyre::eyre::OptionExt; +use color_eyre::eyre::bail; use crossbeam_channel::Receiver; +use hotwatch::Hotwatch; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; +use parking_lot::Mutex; use std::collections::HashMap; +use std::collections::HashSet; use std::collections::hash_map::Entry; use std::io::ErrorKind; use std::num::NonZeroUsize; use std::os::unix::net::UnixListener; use std::path::PathBuf; +use std::sync::Arc; #[derive(Debug)] pub struct WindowManager { @@ -44,6 +55,8 @@ pub struct WindowManager { pub command_listener: UnixListener, pub is_paused: bool, pub resize_delta: i32, + pub hotwatch: Hotwatch, + pub unmanaged_window_operation_behaviour: OperationBehaviour, pub window_management_behaviour: WindowManagementBehaviour, pub cross_monitor_move_behaviour: MoveBehaviour, pub cross_boundary_behaviour: CrossBoundaryBehaviour, @@ -51,10 +64,36 @@ pub struct WindowManager { pub work_area_offset: Option, pub incoming_events: Receiver, pub minimized_windows: HashMap, + pub already_moved_window_handles: Arc>>, } impl_ring_elements!(WindowManager, Monitor); +#[derive(Debug, Clone, Copy)] +struct EnforceWorkspaceRuleOp { + window_id: u32, + origin_monitor_idx: usize, + origin_workspace_idx: usize, + target_monitor_idx: usize, + target_workspace_idx: usize, + floating: bool, +} + +impl EnforceWorkspaceRuleOp { + const fn is_origin(&self, monitor_idx: usize, workspace_idx: usize) -> bool { + self.origin_monitor_idx == monitor_idx && self.origin_workspace_idx == workspace_idx + } + + const fn is_target(&self, monitor_idx: usize, workspace_idx: usize) -> bool { + self.target_monitor_idx == monitor_idx && self.target_workspace_idx == workspace_idx + } + + const fn is_enforced(&self) -> bool { + (self.origin_monitor_idx == self.target_monitor_idx) + && (self.origin_workspace_idx == self.target_workspace_idx) + } +} + impl WindowManager { #[allow(clippy::field_reassign_with_default)] pub fn new( @@ -87,6 +126,8 @@ impl WindowManager { command_listener: listener, is_paused: false, resize_delta: 50, + hotwatch: Hotwatch::new()?, + unmanaged_window_operation_behaviour: Default::default(), window_management_behaviour: behaviour, cross_monitor_move_behaviour: Default::default(), cross_boundary_behaviour: Default::default(), @@ -94,6 +135,7 @@ impl WindowManager { work_area_offset: None, incoming_events: incoming, minimized_windows: HashMap::new(), + already_moved_window_handles: Default::default(), }) } @@ -1851,4 +1893,267 @@ impl WindowManager { Ok(()) } + + #[tracing::instrument(skip(self), level = "debug")] + pub fn enforce_workspace_rules(&mut self) -> eyre::Result<()> { + let mut to_move = vec![]; + + let focused_monitor_idx = self.focused_monitor_idx(); + let focused_workspace_idx = self + .monitors() + .get(focused_monitor_idx) + .ok_or_eyre("there is no monitor with that index")? + .focused_workspace_idx(); + + // scope mutex locks to avoid deadlock if should_update_focused_workspace evaluates to true + // at the end of this function + { + let workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); + let regex_identifiers = REGEX_IDENTIFIERS.lock(); + // Go through all the monitors and workspaces + for (i, monitor) in self.monitors().iter().enumerate() { + for (j, workspace) in monitor.workspaces().iter().enumerate() { + // And all the visible windows (at the top of a container) + for window in workspace.visible_windows().into_iter().flatten() { + if let ( + Some(exe_name), + Some(title), + Some(role), + Some(subrole), + Some(path), + ) = ( + window.exe(), + window.title(), + window.role(), + window.subrole(), + window.path(), + ) { + for rule in &*workspace_matching_rules { + let matched = match &rule.matching_rule { + MatchingRule::Simple(r) => should_act_individual( + &title, + &exe_name, + &[&role, &subrole], + &path.to_string_lossy(), + r, + ®ex_identifiers, + ), + MatchingRule::Composite(r) => { + let mut composite_results = vec![]; + for identifier in r { + composite_results.push(should_act_individual( + &title, + &exe_name, + &[&role, &subrole], + &path.to_string_lossy(), + identifier, + ®ex_identifiers, + )); + } + + composite_results.iter().all(|&x| x) + } + }; + + if matched { + let floating = workspace.floating_windows().contains(window); + + let mut already_moved_window_handles = + self.already_moved_window_handles.lock(); + + if rule.initial_only { + if !already_moved_window_handles.contains(&window.id) { + already_moved_window_handles.insert(window.id); + + self.add_window_handle_to_move_based_on_workspace_rule( + &window + .title() + .ok_or_eyre("could not read window title")?, + window.id, + i, + j, + rule.monitor_index, + rule.workspace_index, + floating, + &mut to_move, + ); + } + } else { + self.add_window_handle_to_move_based_on_workspace_rule( + &window + .title() + .ok_or_eyre("could not read window title")?, + window.id, + i, + j, + rule.monitor_index, + rule.workspace_index, + floating, + &mut to_move, + ); + } + } + } + } + } + } + } + } + + // Only retain operations where the target is not the current workspace + to_move.retain(|op| !op.is_target(focused_monitor_idx, focused_workspace_idx)); + // Only retain operations where the rule has not already been enforced + to_move.retain(|op| !op.is_enforced()); + + let mut should_update_focused_workspace = false; + let mut removed_windows = HashMap::new(); + + // Parse the operation and remove any windows that are not placed according to their rules + for op in &to_move { + let target_area = self + .monitors_mut() + .get_mut(op.target_monitor_idx) + .ok_or_eyre("there is no monitor with that index")? + .work_area_size; + + let origin_monitor = self + .monitors_mut() + .get_mut(op.origin_monitor_idx) + .ok_or_eyre("there is no monitor with that index")?; + + let origin_area = origin_monitor.work_area_size; + + let origin_workspace = origin_monitor + .workspaces_mut() + .get_mut(op.origin_workspace_idx) + .ok_or_eyre("there is no workspace with that index")?; + + // TODO: need to find a way to construct a lightweight window that can be operated on + // let mut window = Window::new(origin_workspace + // .window_by_id(op.window_id) + // .ok_or_eyre("there is no window with the requested id")?); + + let mut window = origin_workspace.remove_window(op.window_id)?; + + // If it is a floating window move it to the target area + if op.floating { + window.move_to_area(&origin_area, &target_area)?; + } + + // Hide the window we are about to remove if it is on the currently focused workspace + if op.is_origin(focused_monitor_idx, focused_workspace_idx) { + window.hide()?; + should_update_focused_workspace = true; + } + + removed_windows.insert(window.id, window); + } + + // Parse the operation again and associate those removed windows with the workspace that + // their rules have defined for them + for op in &to_move { + let window = removed_windows + .get_mut(&op.window_id) + .ok_or_eyre("there is no window")?; + + let target_monitor = self + .monitors_mut() + .get_mut(op.target_monitor_idx) + .ok_or_eyre("there is no monitor with that index")?; + + // The very first time this fn is called, the workspace might not even exist yet + if target_monitor + .workspaces() + .get(op.target_workspace_idx) + .is_none() + { + // If it doesn't, let's make sure it does for the next step + target_monitor.ensure_workspace_count(op.target_workspace_idx + 1); + } + + let target_workspace = target_monitor + .workspaces_mut() + .get_mut(op.target_workspace_idx) + .ok_or_eyre("there is no workspace with that index")?; + + if op.floating { + target_workspace + .floating_windows_mut() + // TODO: not sure about this clone + .push_back(window.clone()); + } else { + //TODO(alex-ds13): should this take into account the target workspace + //`window_container_behaviour`? + //In the case above a floating window should always be moved as floating, + //because it was set as so either manually by the user or by a + //`floating_applications` rule so it should stay that way. But a tiled window + //when moving to another workspace by a `workspace_rule` should honor that + //workspace `window_container_behaviour` in my opinion! Maybe this should be done + //on the `new_container_for_window` function instead. + // TODO: not sure about this clone + target_workspace.new_container_for_window(window)?; + } + } + + // Only re-tile the focused workspace if we need to + if should_update_focused_workspace { + self.update_focused_workspace(false, false)?; + } + + Ok(()) + } + + #[allow(clippy::too_many_arguments)] + #[tracing::instrument(skip(self), level = "debug")] + fn add_window_handle_to_move_based_on_workspace_rule( + &self, + window_title: &String, + window_id: u32, + origin_monitor_idx: usize, + origin_workspace_idx: usize, + target_monitor_idx: usize, + target_workspace_idx: usize, + floating: bool, + to_move: &mut Vec, + ) { + tracing::trace!( + "{} should be on monitor {}, workspace {}", + window_title, + target_monitor_idx, + target_workspace_idx + ); + + // Create an operation outline and save it for later in the fn + to_move.push(EnforceWorkspaceRuleOp { + window_id, + origin_monitor_idx, + origin_workspace_idx, + target_monitor_idx, + target_workspace_idx, + floating, + }); + } + + #[tracing::instrument(skip(self))] + pub fn reload_static_configuration(&mut self, pathbuf: &PathBuf) -> eyre::Result<()> { + tracing::info!("reloading static configuration"); + StaticConfig::reload(pathbuf, self) + } + + #[tracing::instrument(skip(self))] + pub fn handle_unmanaged_window_behaviour(&self) -> eyre::Result<()> { + if matches!( + self.unmanaged_window_operation_behaviour, + OperationBehaviour::NoOp + ) { + let workspace = self.focused_workspace()?; + let focused_hwnd = + MacosApi::foreground_window_id().ok_or_eyre("there is no foreground window")?; + if !workspace.contains_managed_window(focused_hwnd) { + bail!("ignoring commands while active window is not managed by komorebi"); + } + } + + Ok(()) + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 1b413c08..027088e7 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -11,6 +11,7 @@ use crate::core::rect::Rect; use crate::lockable_sequence::LockableSequence; use crate::macos_api::MacosApi; use crate::ring::Ring; +use crate::static_config::WorkspaceConfig; use crate::window::Window; use color_eyre::eyre; use color_eyre::eyre::OptionExt; @@ -46,6 +47,7 @@ pub struct Workspace { pub globals: WorkspaceGlobals, pub layer: WorkspaceLayer, pub floating_layer_behaviour: Option, + pub workspace_config: Option, } #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] @@ -94,6 +96,7 @@ impl Default for Workspace { floating_windows: Default::default(), float_override: None, floating_layer_behaviour: None, + workspace_config: None, } } } @@ -113,6 +116,67 @@ pub struct WorkspaceGlobals { } impl Workspace { + pub fn load_static_config(&mut self, config: &WorkspaceConfig) -> eyre::Result<()> { + self.name = Option::from(config.name.clone()); + + self.container_padding = config.container_padding; + + self.workspace_padding = config.workspace_padding; + + if let Some(layout) = &config.layout { + self.layout = Layout::Default(*layout); + } + + self.tile = + !(config.custom_layout.is_none() && config.layout.is_none() && config.tile.is_none() + || config.tile.is_some_and(|tile| !tile)); + + let mut all_layout_rules = vec![]; + if let Some(layout_rules) = &config.layout_rules { + for (count, rule) in layout_rules { + all_layout_rules.push((*count, Layout::Default(*rule))); + } + + all_layout_rules.sort_by_key(|(i, _)| *i); + self.tile = true; + } + + self.layout_rules = all_layout_rules.clone(); + + self.work_area_offset = config.work_area_offset; + + self.apply_window_based_work_area_offset = + config.apply_window_based_work_area_offset.unwrap_or(true); + + self.window_container_behaviour = config.window_container_behaviour; + + if let Some(window_container_behaviour_rules) = &config.window_container_behaviour_rules { + if window_container_behaviour_rules.is_empty() { + self.window_container_behaviour_rules = None; + } else { + let mut all_rules = vec![]; + for (count, behaviour) in window_container_behaviour_rules { + all_rules.push((*count, *behaviour)); + } + + all_rules.sort_by_key(|(i, _)| *i); + self.window_container_behaviour_rules = Some(all_rules); + } + } else { + self.window_container_behaviour_rules = None; + } + + self.float_override = config.float_override; + self.layout_flip = config.layout_flip; + self.floating_layer_behaviour = config.floating_layer_behaviour; + // self.wallpaper = config.wallpaper.clone(); + self.layout_options = config.layout_options; + + self.workspace_config = Some(config.clone()); + + Ok(()) + } + #[tracing::instrument(skip(self))] pub fn focus_container(&mut self, idx: usize) { tracing::info!("focusing container"); @@ -350,6 +414,40 @@ impl Workspace { } } + if let Some(window) = &self.maximized_window + && window_id == window.id + { + return true; + } + + if let Some(container) = &self.monocle_container + && container.contains_window(window_id) + { + return true; + } + + for window in self.floating_windows() { + if window_id == window.id { + return true; + } + } + + false + } + + pub fn contains_managed_window(&self, window_id: u32) -> bool { + for container in self.containers() { + if container.contains_window(window_id) { + return true; + } + } + + if let Some(window) = &self.maximized_window + && window_id == window.id + { + return true; + } + if let Some(container) = &self.monocle_container && container.contains_window(window_id) { @@ -701,6 +799,26 @@ impl Workspace { self.floating_windows.focus(idx); } + + pub fn visible_windows(&self) -> Vec> { + let mut vec = vec![]; + + vec.push(self.maximized_window.as_ref()); + + if let Some(monocle) = &self.monocle_container { + vec.push(monocle.focused_window()); + } + + for container in self.containers() { + vec.push(container.focused_window()); + } + + for window in self.floating_windows() { + vec.push(Some(window)); + } + + vec + } } impl Workspace { From c84db9a894cfd6ab8e5299efa142f1404d600ea0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 21 Sep 2025 21:07:50 -0700 Subject: [PATCH 029/305] 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. --- Cargo.lock | 69 +++++++++++++ justfile | 2 +- komorebi/Cargo.toml | 3 +- komorebi/src/application.rs | 2 +- komorebi/src/container.rs | 19 +++- komorebi/src/core/mod.rs | 3 + komorebi/src/lib.rs | 18 +++- komorebi/src/monitor.rs | 5 +- komorebi/src/process_command.rs | 46 ++++++++- komorebi/src/state.rs | 168 ++++++++++++++++++++++++++++++++ komorebi/src/window.rs | 75 ++++++++++++-- komorebi/src/window_manager.rs | 6 ++ komorebi/src/workspace.rs | 42 +++++++- komorebic/src/main.rs | 23 +++++ 14 files changed, 462 insertions(+), 19 deletions(-) create mode 100644 komorebi/src/state.rs diff --git a/Cargo.lock b/Cargo.lock index 8a867a2c..1beed588 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -599,6 +599,7 @@ dependencies = [ "dirs", "hotwatch", "lazy_static", + "nanoid", "objc2", "objc2-app-kit", "objc2-application-services", @@ -738,6 +739,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "nanoid" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" +dependencies = [ + "rand", +] + [[package]] name = "nix" version = "0.30.1" @@ -1059,6 +1069,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + [[package]] name = "proc-macro2" version = "1.0.101" @@ -1077,6 +1096,36 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "redox_syscall" version = "0.5.17" @@ -1890,3 +1939,23 @@ name = "windows_x86_64_msvc" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "zerocopy" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/justfile b/justfile index 0beb52cf..b75c6688 100644 --- a/justfile +++ b/justfile @@ -3,7 +3,7 @@ export RUST_BACKTRACE := "full" fmt: test -z "$(rg 'eyre!' --type rust)" || (echo "eyre! macro not allowed"; false) test -z "$(rg 'dbg!' --type rust)" || (echo "dbg! macro not allowed"; false) - test -z "$(rg 'println!' --type rust)" || (echo "println! macro not allowed"; false) + test -z "$(rg 'println!' --type rust ./komorebi)" || (echo "println! macro not allowed"; false) cargo +nightly fmt cargo +stable clippy prettier --write README.md diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 324e797f..15552e31 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -26,4 +26,5 @@ serde_with = "3" strum = { version = "0.27", features = ["derive"] } thiserror = { workspace = true } tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +nanoid = "0.4" \ No newline at end of file diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index 38fa4bfc..52db02ec 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -42,7 +42,7 @@ const NOTIFICATIONS: &[&str] = &[ kAXUIElementDestroyedNotification, ]; -#[derive(Debug, Clone)] +#[derive(Debug, Default, Clone, PartialEq)] pub struct Application { element: AccessibilityUiElement, pub process_id: i32, diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index 07690891..773aa6ae 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -3,13 +3,28 @@ use crate::lockable_sequence::Lockable; use crate::ring::Ring; use crate::window::Window; use color_eyre::eyre; +use nanoid::nanoid; +use serde::Deserialize; +use serde::Serialize; impl_ring_elements!(Container, Window); -#[derive(Debug, Default, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] + pub struct Container { - pub windows: Ring, + pub id: String, pub locked: bool, + pub windows: Ring, +} + +impl Default for Container { + fn default() -> Self { + Self { + id: nanoid!(), + locked: false, + windows: Default::default(), + } + } } impl Lockable for Container { diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 1c81fef0..2db56ab5 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -232,6 +232,9 @@ pub enum SocketMessage { PromoteFocus, PromoteWindow(OperationDirection), ReloadStaticConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + State, + GlobalState, + VisibleWindows, } impl SocketMessage { diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index f7893fc9..9e7142a5 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -1,5 +1,6 @@ #![warn(clippy::all)] +use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityError; use crate::core::ApplicationIdentifier; use crate::core::config_generation::IdWithIdentifier; @@ -51,6 +52,7 @@ pub mod notification_center_listener; pub mod process_command; pub mod process_event; pub mod reaper; +pub mod state; pub mod static_config; pub mod window; pub mod window_manager; @@ -129,7 +131,7 @@ impl Deref for CoreFoundationRunLoop { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct AccessibilityUiElement(pub CFRetained); unsafe impl Sync for AccessibilityUiElement {} unsafe impl Send for AccessibilityUiElement {} @@ -141,7 +143,13 @@ impl Deref for AccessibilityUiElement { } } -#[derive(Debug, Clone)] +impl Default for AccessibilityUiElement { + fn default() -> Self { + Self(unsafe { AXUIElement::new_system_wide() }) + } +} + +#[derive(Debug, Clone, PartialEq)] pub struct AccessibilityObserver(pub CFRetained); unsafe impl Sync for AccessibilityObserver {} unsafe impl Send for AccessibilityObserver {} @@ -153,6 +161,12 @@ impl Deref for AccessibilityObserver { } } +impl Default for AccessibilityObserver { + fn default() -> Self { + Self(AccessibilityApi::create_observer(1, None).unwrap()) + } +} + pub fn cf_array_as(array: &CFArray) -> impl Iterator> + use<'_, T> { let count = CFArray::count(array); (0..count).flat_map(move |idx| { diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 111c3c53..d90b7df2 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -13,12 +13,14 @@ use crate::workspace::WorkspaceGlobals; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use color_eyre::eyre::OptionExt; +use serde::Deserialize; +use serde::Serialize; use std::collections::VecDeque; use std::sync::atomic::Ordering; impl_ring_elements!(Monitor, Workspace); -#[derive(Debug)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct Monitor { pub id: u32, pub workspaces: Ring, @@ -29,6 +31,7 @@ pub struct Monitor { pub window_based_work_area_offset_limit: isize, pub container_padding: Option, pub workspace_padding: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub last_focused_workspace: Option, pub floating_layer_behaviour: Option, } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 888fcde0..ff19ca9b 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -6,12 +6,15 @@ use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::macos_api::MacosApi; use crate::monitor::Monitor; +use crate::state::GlobalState; +use crate::state::State; use crate::window_manager::WindowManager; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use parking_lot::Mutex; +use std::collections::HashMap; use std::io::BufRead; use std::io::BufReader; use std::num::NonZeroUsize; @@ -62,11 +65,11 @@ pub fn listen_for_commands(wm: Arc>) { } impl WindowManager { - #[tracing::instrument(skip(self, _reply))] + #[tracing::instrument(skip(self, reply))] pub fn process_command( &mut self, message: SocketMessage, - mut _reply: impl std::io::Write, + mut reply: impl std::io::Write, ) -> eyre::Result<()> { tracing::info!("processing command: {message}"); self.handle_unmanaged_window_behaviour()?; @@ -793,6 +796,45 @@ impl WindowManager { SocketMessage::ReloadStaticConfiguration(ref pathbuf) => { self.reload_static_configuration(pathbuf)?; } + SocketMessage::State => { + let state = match serde_json::to_string_pretty(&State::from(&*self)) { + Ok(state) => state, + Err(error) => error.to_string(), + }; + + tracing::info!("replying to state"); + + reply.write_all(state.as_bytes())?; + + tracing::info!("replying to state done"); + } + SocketMessage::GlobalState => { + let state = match serde_json::to_string_pretty(&GlobalState::default()) { + Ok(state) => state, + Err(error) => error.to_string(), + }; + + tracing::info!("replying to global state"); + + reply.write_all(state.as_bytes())?; + + tracing::info!("replying to global state done"); + } + SocketMessage::VisibleWindows => { + let mut monitor_visible_windows = HashMap::new(); + + for monitor in self.monitors() { + if let Some(ws) = monitor.focused_workspace() { + monitor_visible_windows + .insert(monitor.id, ws.visible_window_details().clone()); + } + } + + let visible_windows_state = serde_json::to_string_pretty(&monitor_visible_windows) + .unwrap_or_else(|error| error.to_string()); + + reply.write_all(visible_windows_state.as_bytes())?; + } } Ok(()) diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs new file mode 100644 index 00000000..72e17913 --- /dev/null +++ b/komorebi/src/state.rs @@ -0,0 +1,168 @@ +use crate::DATA_DIR; +use crate::HOME_DIR; +use crate::IGNORE_IDENTIFIERS; +use crate::MANAGE_IDENTIFIERS; +use crate::WORKSPACE_MATCHING_RULES; +use crate::core::MoveBehaviour; +use crate::core::OperationBehaviour; +use crate::core::WindowContainerBehaviour; +use crate::core::config_generation::MatchingRule; +use crate::core::config_generation::WorkspaceMatchingRule; +use crate::core::rect::Rect; +use crate::monitor::Monitor; +use crate::ring::Ring; +use crate::window_manager::WindowManager; +use crate::workspace::Workspace; +use serde::Deserialize; +use serde::Serialize; +use std::collections::VecDeque; +use std::path::PathBuf; + +#[allow(clippy::struct_excessive_bools)] +#[derive(Debug, Serialize, Deserialize)] +pub struct GlobalState { + // pub border_enabled: bool, + // pub border_colours: BorderColours, + // pub border_style: BorderStyle, + // pub border_offset: i32, + // pub border_width: i32, + // pub stackbar_mode: StackbarMode, + // pub stackbar_label: StackbarLabel, + // pub stackbar_focused_text_colour: Colour, + // pub stackbar_unfocused_text_colour: Colour, + // pub stackbar_tab_background_colour: Colour, + // pub stackbar_tab_width: i32, + // pub stackbar_height: i32, + // pub transparency_enabled: bool, + // pub transparency_alpha: u8, + // pub transparency_blacklist: Vec, + // pub remove_titlebars: bool, + // #[serde(alias = "float_identifiers")] + pub ignore_identifiers: Vec, + pub manage_identifiers: Vec, + // pub layered_whitelist: Vec, + // pub tray_and_multi_window_identifiers: Vec, + // pub name_change_on_launch_identifiers: Vec, + // pub monitor_index_preferences: HashMap, + // pub display_index_preferences: HashMap, + // pub ignored_duplicate_monitor_serial_ids: Vec, + pub workspace_rules: Vec, + // pub window_hiding_behaviour: HidingBehaviour, + pub configuration_dir: PathBuf, + pub data_dir: PathBuf, + // pub custom_ffm: bool, +} + +impl Default for GlobalState { + fn default() -> Self { + Self { + ignore_identifiers: IGNORE_IDENTIFIERS.lock().clone(), + manage_identifiers: MANAGE_IDENTIFIERS.lock().clone(), + workspace_rules: WORKSPACE_MATCHING_RULES.lock().clone(), + configuration_dir: HOME_DIR.clone(), + data_dir: DATA_DIR.clone(), + } + } +} + +#[allow(clippy::struct_excessive_bools)] +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct State { + pub monitors: Ring, + // pub monitor_usr_idx_map: HashMap, + pub is_paused: bool, + pub resize_delta: i32, + pub new_window_behaviour: WindowContainerBehaviour, + pub float_override: bool, + pub cross_monitor_move_behaviour: MoveBehaviour, + pub unmanaged_window_operation_behaviour: OperationBehaviour, + pub work_area_offset: Option, + // pub focus_follows_mouse: Option, + pub mouse_follows_focus: bool, + // pub has_pending_raise_op: bool, +} + +impl From<&WindowManager> for State { + fn from(wm: &WindowManager) -> Self { + // This is used to remove any information that doesn't need to be passed on to subscribers + // or to be shown with the `komorebic state` command. Currently it is only removing the + // `workspace_config` field from every workspace, but more stripping can be added later if + // needed. + let mut stripped_monitors = Ring::default(); + *stripped_monitors.elements_mut() = wm + .monitors() + .iter() + .map(|monitor| Monitor { + id: monitor.id, + size: monitor.size, + work_area_size: monitor.work_area_size, + work_area_offset: monitor.work_area_offset, + window_based_work_area_offset: monitor.window_based_work_area_offset, + window_based_work_area_offset_limit: monitor.window_based_work_area_offset_limit, + workspaces: { + let mut ws = Ring::default(); + *ws.elements_mut() = monitor + .workspaces() + .iter() + .map(|workspace| Workspace { + name: workspace.name.clone(), + containers: workspace.containers.clone(), + monocle_container: workspace.monocle_container.clone(), + monocle_container_restore_idx: workspace.monocle_container_restore_idx, + maximized_window: workspace.maximized_window.clone(), + maximized_window_restore_idx: workspace.maximized_window_restore_idx, + floating_windows: workspace.floating_windows.clone(), + layout: workspace.layout.clone(), + layout_options: workspace.layout_options, + layout_rules: workspace.layout_rules.clone(), + layout_flip: workspace.layout_flip, + workspace_padding: workspace.workspace_padding, + container_padding: workspace.container_padding, + latest_layout: workspace.latest_layout.clone(), + resize_dimensions: workspace.resize_dimensions.clone(), + tile: workspace.tile, + work_area_offset: workspace.work_area_offset, + apply_window_based_work_area_offset: workspace + .apply_window_based_work_area_offset, + window_container_behaviour: workspace.window_container_behaviour, + window_container_behaviour_rules: workspace + .window_container_behaviour_rules + .clone(), + float_override: workspace.float_override, + layer: workspace.layer, + floating_layer_behaviour: workspace.floating_layer_behaviour, + globals: workspace.globals, + // wallpaper: workspace.wallpaper.clone(), + workspace_config: None, + }) + .collect::>(); + ws.focus(monitor.workspaces.focused_idx()); + ws + }, + last_focused_workspace: monitor.last_focused_workspace, + // workspace_names: monitor.workspace_names.clone(), + container_padding: monitor.container_padding, + workspace_padding: monitor.workspace_padding, + // wallpaper: monitor.wallpaper.clone(), + floating_layer_behaviour: monitor.floating_layer_behaviour, + }) + .collect::>(); + stripped_monitors.focus(wm.monitors.focused_idx()); + + Self { + monitors: stripped_monitors, + // monitor_usr_idx_map: wm.monitor_usr_idx_map.clone(), + is_paused: wm.is_paused, + work_area_offset: wm.work_area_offset, + resize_delta: wm.resize_delta, + new_window_behaviour: wm.window_management_behaviour.current_behaviour, + float_override: wm.window_management_behaviour.float_override, + cross_monitor_move_behaviour: wm.cross_monitor_move_behaviour, + // focus_follows_mouse: wm.focus_follows_mouse, + mouse_follows_focus: wm.mouse_follows_focus, + // has_pending_raise_op: wm.has_pending_raise_op, + unmanaged_window_operation_behaviour: wm.unmanaged_window_operation_behaviour, + // has_pending_raise_op: false, + } + } +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index aee7113c..dd1e407e 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -41,6 +41,7 @@ use crate::reaper::ReaperNotification; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use color_eyre::eyre; +use color_eyre::eyre::OptionExt; use objc2::__framework_prelude::Retained; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; @@ -64,6 +65,8 @@ use objc2_core_graphics::kCGWindowOwnerPID; use regex::Regex; use serde::Deserialize; use serde::Serialize; +use serde::Serializer; +use serde::ser::SerializeStruct; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::ffi::c_void; @@ -172,14 +175,39 @@ impl WindowInfo { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Deserialize, PartialEq)] pub struct Window { pub id: u32, + #[serde(skip_deserializing)] pub element: AccessibilityUiElement, + #[serde(skip_deserializing)] pub application: Application, + #[serde(skip_deserializing)] observer: AccessibilityObserver, } +#[allow(clippy::module_name_repetitions)] +#[derive(Debug, Clone, Serialize)] +pub struct WindowDetails { + pub title: String, + pub exe: String, + pub role: String, + pub subrole: String, +} + +impl TryFrom<&Window> for WindowDetails { + type Error = eyre::ErrReport; + + fn try_from(value: &Window) -> std::result::Result { + Ok(Self { + title: value.title().ok_or_eyre("can't read title")?, + exe: value.exe().ok_or_eyre("can't read exee")?, + role: value.role().ok_or_eyre("can't read role")?, + subrole: value.subrole().ok_or_eyre("can't read subrole")?, + }) + } +} + impl Drop for Window { fn drop(&mut self) { // this gets called when a cloned Window is dropped, so we need to make sure it only @@ -197,12 +225,6 @@ impl Drop for Window { } } -impl PartialEq for Window { - fn eq(&self, other: &Self) -> bool { - self.id == other.id - } -} - impl Display for Window { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { let mut display = format!( @@ -232,6 +254,45 @@ impl Display for Window { } } +impl Serialize for Window { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut state = serializer.serialize_struct("Window", 5)?; + state.serialize_field("window_id", &self.id)?; + state.serialize_field( + "title", + &self + .title() + .unwrap_or_else(|| String::from("could not get window title")), + )?; + state.serialize_field( + "exe", + &self + .exe() + .unwrap_or_else(|| String::from("could not get window exe")), + )?; + state.serialize_field( + "role", + &self + .role() + .unwrap_or_else(|| String::from("could not get window accessibility role")), + )?; + state.serialize_field( + "subrole", + &self + .subrole() + .unwrap_or_else(|| String::from("could not get window accessibility subrole")), + )?; + state.serialize_field( + "rect", + &Rect::from(MacosApi::window_rect(&self.element).unwrap_or_default()), + )?; + state.end() + } +} + impl Window { pub fn new( element: CFRetained, diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index b695d59c..d2f6664a 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -94,6 +94,12 @@ impl EnforceWorkspaceRuleOp { } } +impl AsRef for WindowManager { + fn as_ref(&self) -> &Self { + self + } +} + impl WindowManager { #[allow(clippy::field_reassign_with_default)] pub fn new( diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 027088e7..5964daac 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -13,6 +13,7 @@ use crate::macos_api::MacosApi; use crate::ring::Ring; use crate::static_config::WorkspaceConfig; use crate::window::Window; +use crate::window::WindowDetails; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use serde::Deserialize; @@ -21,13 +22,15 @@ use std::fmt::Display; use std::fmt::Formatter; use std::num::NonZeroUsize; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct Workspace { pub name: Option, pub containers: Ring, pub monocle_container: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub monocle_container_restore_idx: Option, pub maximized_window: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub maximized_window_restore_idx: Option, pub floating_windows: Ring, pub layout: Layout, @@ -44,9 +47,11 @@ pub struct Workspace { pub window_container_behaviour: Option, pub window_container_behaviour_rules: Option>, pub float_override: Option, + #[serde(skip)] pub globals: WorkspaceGlobals, pub layer: WorkspaceLayer, pub floating_layer_behaviour: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub workspace_config: Option, } @@ -101,7 +106,7 @@ impl Default for Workspace { } } -#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq)] /// Settings setup either by the parent monitor or by the `WindowManager` pub struct WorkspaceGlobals { pub container_padding: Option, @@ -819,6 +824,39 @@ impl Workspace { vec } + + pub fn visible_window_details(&self) -> Vec { + let mut vec: Vec = vec![]; + + if let Some(maximized) = &self.maximized_window + && let Ok(details) = (maximized).try_into() + { + vec.push(details); + } + + if let Some(monocle) = &self.monocle_container + && let Some(focused) = monocle.focused_window() + && let Ok(details) = focused.try_into() + { + vec.push(details); + } + + for container in self.containers() { + if let Some(focused) = container.focused_window() + && let Ok(details) = focused.try_into() + { + vec.push(details); + } + } + + for window in self.floating_windows() { + if let Ok(details) = window.try_into() { + vec.push(details); + } + } + + vec + } } impl Workspace { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 22ea0408..d1a71899 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -10,6 +10,7 @@ use komorebi_client::PathExt; use komorebi_client::Sizing; use komorebi_client::SocketMessage; use komorebi_client::send_message; +use komorebi_client::send_query; use lazy_static::lazy_static; use std::path::PathBuf; use std::sync::atomic::AtomicBool; @@ -176,6 +177,12 @@ struct Opts { #[derive(Parser)] enum SubCommand { + /// Show a JSON representation of the current window manager state + State, + /// Show a JSON representation of the current global state + GlobalState, + /// Show a JSON representation of visible windows + VisibleWindows, /// Change focus to the window in the specified direction #[clap(arg_required_else_help = true)] Focus(Focus), @@ -340,6 +347,13 @@ enum SubCommand { ToggleCrossMonitorMoveBehaviour, } +fn print_query(message: &SocketMessage) { + match send_query(message) { + Ok(response) => println!("{response}"), + Err(error) => panic!("{}", error), + } +} + fn main() -> eyre::Result<()> { let opts: Opts = Opts::parse(); @@ -545,6 +559,15 @@ fn main() -> eyre::Result<()> { SubCommand::SwapWorkspacesWithMonitor(arg) => { send_message(&SocketMessage::SwapWorkspacesToMonitorNumber(arg.target))?; } + SubCommand::State => { + print_query(&SocketMessage::State); + } + SubCommand::GlobalState => { + print_query(&SocketMessage::GlobalState); + } + SubCommand::VisibleWindows => { + print_query(&SocketMessage::VisibleWindows); + } } Ok(()) From 02523d8b3468dd0abbb51384dedfb7f99c973e92 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 11:45:22 -0700 Subject: [PATCH 030/305] 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. --- Cargo.lock | 95 ++++++++++++++++++++++--------- Cargo.toml | 2 +- deny.toml | 2 +- dependencies.json | 61 +++++++++++++------- komorebi/Cargo.toml | 7 ++- komorebi/src/core/mod.rs | 1 + komorebi/src/core_graphics/mod.rs | 5 ++ komorebi/src/ioreg.rs | 81 ++++++++++++++++++++++++++ komorebi/src/lib.rs | 4 ++ komorebi/src/macos_api.rs | 40 +++++++++---- komorebi/src/monitor.rs | 43 +++++++++++++- komorebi/src/process_command.rs | 12 ++++ komorebi/src/state.rs | 2 + komorebic/src/main.rs | 7 ++- 14 files changed, 300 insertions(+), 62 deletions(-) create mode 100644 komorebi/src/ioreg.rs diff --git a/Cargo.lock b/Cargo.lock index 1beed588..76acb08c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,9 +141,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "cc" -version = "1.2.37" +version = "1.2.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" +checksum = "80f41ae168f955c12fb8960b057d70d0ca153fb83182b57d86380443527be7e9" dependencies = [ "find-msvc-tools", "shlex", @@ -175,9 +175,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.47" +version = "4.5.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" +checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae" dependencies = [ "clap_builder", "clap_derive", @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.47" +version = "4.5.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" +checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9" dependencies = [ "anstream", "anstyle", @@ -281,9 +281,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ "darling_core", "darling_macro", @@ -291,9 +291,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" dependencies = [ "fnv", "ident_case", @@ -305,9 +305,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", @@ -416,9 +416,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" +checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" [[package]] name = "fnv" @@ -608,6 +608,8 @@ dependencies = [ "objc2-foundation", "parking_lot", "pastey", + "quick-xml 0.38.3", + "quickxml_to_serde", "regex", "serde", "serde_json_lenient", @@ -718,6 +720,15 @@ version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +[[package]] +name = "minidom" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe549115a674f5ec64c754d85e37d6f42664bd0ef4ffb62b619489ad99c6cb1a" +dependencies = [ + "quick-xml 0.17.2", +] + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -1087,6 +1098,37 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-xml" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe1e430bdcf30c9fdc25053b9c459bb1a4672af4617b6c783d7d91dc17c6bbb0" +dependencies = [ + "memchr", +] + +[[package]] +name = "quick-xml" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quickxml_to_serde" +version = "0.6.1" +source = "git+https://github.com/LGUG2Z/quickxml_to_serde.git#312fabc913738c544dfcf299f5e73de4f6932236" +dependencies = [ + "minidom", + "regex", + "serde", + "serde_derive", + "serde_json_lenient", +] + [[package]] name = "quote" version = "1.0.40" @@ -1267,9 +1309,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.225" +version = "1.0.226" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" +checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd" dependencies = [ "serde_core", "serde_derive", @@ -1277,18 +1319,18 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.225" +version = "1.0.226" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" +checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.225" +version = "1.0.226" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" +checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33" dependencies = [ "proc-macro2", "quote", @@ -1322,9 +1364,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.14.0" +version = "3.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" +checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" dependencies = [ "base64", "chrono", @@ -1342,9 +1384,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.14.0" +version = "3.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" +checksum = "327ada00f7d64abaac1e55a6911e90cf665aa051b9a561c7006c157f4633135e" dependencies = [ "darling", "proc-macro2", @@ -1452,11 +1494,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.43" +version = "0.3.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031" +checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" dependencies = [ "deranged", + "itoa", "num-conv", "powerfmt", "serde", diff --git a/Cargo.toml b/Cargo.toml index 35a63335..5581106a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,4 @@ lazy_static = "1" pastey = "0.1" serde = { version = "1", features = ["derive"] } serde_json = { package = "serde_json_lenient", version = "0.2" } -thiserror = "2" +thiserror = "2" \ No newline at end of file diff --git a/deny.toml b/deny.toml index 4bcaa988..b33143d8 100644 --- a/deny.toml +++ b/deny.toml @@ -63,5 +63,5 @@ unknown-registry = "deny" unknown-git = "deny" allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-git = [ - # "https://github.com/LGUG2Z/komorebi-for-mac", + "https://github.com/LGUG2Z/quickxml_to_serde", ] \ No newline at end of file diff --git a/dependencies.json b/dependencies.json index cfe2f739..a60bb042 100644 --- a/dependencies.json +++ b/dependencies.json @@ -19,8 +19,8 @@ "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.47 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -36,6 +36,7 @@ "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -64,8 +65,12 @@ "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", + "rand_chacha 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "rand_core 0.6.4 registry+https://github.com/rust-lang/crates.io-index", "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", @@ -73,12 +78,12 @@ "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", - "serde 1.0.225 registry+https://github.com/rust-lang/crates.io-index", - "serde_core 1.0.225 registry+https://github.com/rust-lang/crates.io-index", - "serde_derive 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde 1.0.226 registry+https://github.com/rust-lang/crates.io-index", + "serde_core 1.0.226 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.14.0 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.14.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", @@ -86,7 +91,8 @@ "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", - "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index" + "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -102,6 +108,12 @@ "notify-debouncer-full 0.1.0 registry+https://github.com/rust-lang/crates.io-index" ] ], + [ + "BSD-2-Clause", + [ + "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" + ] + ], [ "BSL-1.0", [ @@ -132,8 +144,8 @@ "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.47 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.47 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -142,9 +154,9 @@ "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", - "darling 0.20.11 registry+https://github.com/rust-lang/crates.io-index", - "darling_core 0.20.11 registry+https://github.com/rust-lang/crates.io-index", - "darling_macro 0.20.11 registry+https://github.com/rust-lang/crates.io-index", + "darling 0.21.3 registry+https://github.com/rust-lang/crates.io-index", + "darling_core 0.21.3 registry+https://github.com/rust-lang/crates.io-index", + "darling_macro 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -154,6 +166,7 @@ "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "fsevent-sys 4.1.0 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -168,6 +181,7 @@ "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "nanoid 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", @@ -190,8 +204,15 @@ "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", + "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", + "quick-xml 0.38.3 registry+https://github.com/rust-lang/crates.io-index", + "quickxml_to_serde 0.6.1 git+https://github.com/LGUG2Z/quickxml_to_serde.git", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", + "rand_chacha 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "rand_core 0.6.4 registry+https://github.com/rust-lang/crates.io-index", "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", @@ -199,12 +220,12 @@ "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", - "serde 1.0.225 registry+https://github.com/rust-lang/crates.io-index", - "serde_core 1.0.225 registry+https://github.com/rust-lang/crates.io-index", - "serde_derive 1.0.225 registry+https://github.com/rust-lang/crates.io-index", + "serde 1.0.226 registry+https://github.com/rust-lang/crates.io-index", + "serde_core 1.0.226 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.14.0 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.14.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "strsim 0.11.1 registry+https://github.com/rust-lang/crates.io-index", @@ -223,12 +244,14 @@ "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", - "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index" + "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "MPL-2.0", [ + "minidom 0.12.0 registry+https://github.com/rust-lang/crates.io-index", "option-ext 0.2.0 registry+https://github.com/rust-lang/crates.io-index" ] ], diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 15552e31..1f73abfe 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -11,6 +11,7 @@ ctrlc = { version = "3", features = ["termination"] } dirs = { workspace = true } hotwatch = "0.5" lazy_static = { workspace = true } +nanoid = "0.4" objc2 = "0.6" objc2-app-kit = "0.3" objc2-application-services = "0.3" @@ -19,6 +20,9 @@ objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } objc2-foundation = "0.3" parking_lot = "0.12" pastey = { workspace = true } +quick-xml = { version = "0.38", features = ["serialize"] } +# forked to patch in serde_json_lenient and update some old dependencies +quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } regex = "1" serde = { workspace = true } serde_json = { workspace = true } @@ -26,5 +30,4 @@ serde_with = "3" strum = { version = "0.27", features = ["derive"] } thiserror = { workspace = true } tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } -nanoid = "0.4" \ No newline at end of file +tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 2db56ab5..a0901c53 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -235,6 +235,7 @@ pub enum SocketMessage { State, GlobalState, VisibleWindows, + MonitorInformation, } impl SocketMessage { diff --git a/komorebi/src/core_graphics/mod.rs b/komorebi/src/core_graphics/mod.rs index b7758e4c..bf7b71ea 100644 --- a/komorebi/src/core_graphics/mod.rs +++ b/komorebi/src/core_graphics/mod.rs @@ -5,6 +5,7 @@ use objc2_core_foundation::CGFloat; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_graphics::CGDisplayBounds; +use objc2_core_graphics::CGDisplaySerialNumber; use objc2_core_graphics::CGGetDisplaysWithPoint; use objc2_core_graphics::CGGetOnlineDisplayList; use objc2_core_graphics::CGRectIntersectsRect; @@ -57,6 +58,10 @@ impl CoreGraphicsApi { unsafe { CGDisplayBounds(display_id) } } + pub fn display_serial_number(display_id: u32) -> u32 { + unsafe { CGDisplaySerialNumber(display_id) } + } + pub fn display_bounds_for_window_rect(window_rect: CGRect) -> Option { let mut displays: Vec = Vec::with_capacity(1); let mut display_count = 0; diff --git a/komorebi/src/ioreg.rs b/komorebi/src/ioreg.rs new file mode 100644 index 00000000..2d7b7eee --- /dev/null +++ b/komorebi/src/ioreg.rs @@ -0,0 +1,81 @@ +use crate::monitor::MonitorInfo; +use color_eyre::eyre; +use color_eyre::eyre::bail; +use quickxml_to_serde::Config; +use quickxml_to_serde::xml_string_to_json; +use std::process::Command; + +use serde_json::Value; +pub struct IoReg; + +impl IoReg { + #[tracing::instrument] + pub fn query_monitors() -> eyre::Result> { + let output = Command::new("ioreg") + .arg("-a") + .arg("-c") + .arg("IOMobileFramebufferShim") + .output()?; + + if !output.status.success() { + bail!( + "ioreg command failed: {}", + String::from_utf8_lossy(&output.stderr) + ); + } + let xml_output = String::from_utf8(output.stdout)?; + let value = xml_string_to_json(xml_output, &Config::new_with_defaults())?; + let mut results = vec![]; + find_display_entries(&value, &mut results); + + Ok(results) + } +} + +fn find_display_entries(value: &Value, results: &mut Vec) { + match value { + Value::Object(obj) => { + if let ( + Some(Value::Array(keys)), + Some(Value::Array(strings)), + Some(Value::Array(integers)), + ) = (obj.get("key"), obj.get("string"), obj.get("integer")) + { + let has_product_name = keys + .iter() + .any(|k| k.as_str().map(|s| s == "ProductName").unwrap_or(false)); + + if has_product_name + && strings.len() >= 3 + && integers.len() >= 5 + && let (Some(alpha_serial), Some(manuf_id), Some(product_name)) = ( + strings[0].as_str(), + strings[1].as_str(), + strings[2].as_str(), + ) + { + results.push(MonitorInfo { + alphanumeric_serial_number: alpha_serial.to_string(), + manufacturer_id: manuf_id.to_string(), + product_name: product_name.to_string(), + legacy_manufacturer_id: integers[0].as_u64().unwrap_or(0).to_string(), + product_id: integers[1].as_u64().unwrap_or(0).to_string(), + serial_number: integers[2].as_u64().unwrap_or(0) as u32, + week_of_manufacture: integers[3].as_u64().unwrap_or(0).to_string(), + year_of_manufacture: integers[4].as_u64().unwrap_or(0).to_string(), + }); + } + } + + for v in obj.values() { + find_display_entries(v, results); + } + } + Value::Array(arr) => { + for item in arr { + find_display_entries(item, results); + } + } + _ => {} + } +} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 9e7142a5..34b2a33c 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -10,6 +10,7 @@ use crate::core::config_generation::WorkspaceMatchingRule; use crate::core_graphics::error::CoreGraphicsError; use crate::window::AspectRatio; use crate::window::PredefinedAspectRatio; +use color_eyre::eyre; use core::pathext::PathExt; use lazy_static::lazy_static; use objc2_application_services::AXObserver; @@ -44,6 +45,7 @@ pub mod core; pub mod core_graphics; pub mod display_reconfiguration_listener; pub mod input_event_listener; +pub mod ioreg; pub mod lockable_sequence; pub mod macos_api; pub mod monitor; @@ -186,6 +188,8 @@ pub enum LibraryError { Accessibility(#[from] AccessibilityError), #[error(transparent)] CoreGraphics(#[from] CoreGraphicsError), + #[error(transparent)] + Eyre(#[from] eyre::Error), } pub fn hidden_frame_bottom_left(screen_frame: CGRect, window_size: CGSize) -> CGRect { diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index d33e86fa..17c55b55 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -11,6 +11,7 @@ use crate::cf_array_as; use crate::container::Container; use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; +use crate::ioreg::IoReg; use crate::monitor::Monitor; use crate::window::WindowInfo; use crate::window_manager::WindowManager; @@ -36,25 +37,41 @@ use std::sync::Arc; pub struct MacosApi; impl MacosApi { + #[tracing::instrument(skip_all)] pub fn load_monitor_information(wm: &mut WindowManager) -> Result<(), LibraryError> { + let monitor_info = IoReg::query_monitors()?; + let mut monitor_info_map = HashMap::new(); + for m in monitor_info { + monitor_info_map.insert(m.serial_number, m); + } + let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); for display_id in CoreGraphicsApi::connected_display_ids()? { let display_bounds = CoreGraphicsApi::display_bounds(display_id); + let serial_number = CoreGraphicsApi::display_serial_number(display_id); - for screen in &screens { - let menu_bar_height = screen.frame().size.height - - screen.visibleFrame().size.height - - screen.visibleFrame().origin.y; + if let Some(info) = monitor_info_map.get(&serial_number) { + for screen in &screens { + let menu_bar_height = screen.frame().size.height + - screen.visibleFrame().size.height + - screen.visibleFrame().origin.y; - if screen.frame() == display_bounds { - let size = Rect::from(display_bounds); - let mut work_area_size = Rect::from(display_bounds); - work_area_size.top += menu_bar_height as i32; - work_area_size.bottom = screen.visibleFrame().size.height as i32; + if screen.frame() == display_bounds { + let size = Rect::from(display_bounds); + let mut work_area_size = Rect::from(display_bounds); + work_area_size.top += menu_bar_height as i32; + work_area_size.bottom = screen.visibleFrame().size.height as i32; - let monitor = Monitor::new(display_id, size, work_area_size); - wm.monitors.elements_mut().push_back(monitor); + let monitor = Monitor::new( + display_id, + size, + work_area_size, + &info.product_name, + &info.alphanumeric_serial_number, + ); + wm.monitors.elements_mut().push_back(monitor); + } } } } @@ -101,6 +118,7 @@ impl MacosApi { Ok(()) } + #[tracing::instrument(skip_all)] pub fn load_workspace_information(wm: &mut WindowManager) -> Result<(), LibraryError> { let mut monitor_size_map = HashMap::new(); let mut monitor_workspace_map = HashMap::new(); diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index d90b7df2..1e3fb96a 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -18,11 +18,44 @@ use serde::Serialize; use std::collections::VecDeque; use std::sync::atomic::Ordering; +#[derive(Debug, Serialize, Deserialize)] +pub struct MonitorInfo { + pub alphanumeric_serial_number: String, + pub manufacturer_id: String, + pub product_name: String, + pub legacy_manufacturer_id: String, + pub product_id: String, + pub serial_number: u32, + pub week_of_manufacture: String, + pub year_of_manufacture: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct MonitorInformation { + pub id: u32, + pub device: String, + pub serial_number_id: String, + pub size: Rect, +} + +impl From<&Monitor> for MonitorInformation { + fn from(value: &Monitor) -> Self { + Self { + id: value.id, + device: value.device.clone(), + serial_number_id: value.serial_number_id.clone(), + size: value.size, + } + } +} + impl_ring_elements!(Monitor, Workspace); #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct Monitor { pub id: u32, + pub device: String, + pub serial_number_id: String, pub workspaces: Ring, pub size: Rect, pub work_area_offset: Option, @@ -38,12 +71,20 @@ pub struct Monitor { impl Monitor { #[allow(clippy::field_reassign_with_default)] - pub fn new(id: u32, size: Rect, work_area_size: Rect) -> Self { + pub fn new( + id: u32, + size: Rect, + work_area_size: Rect, + device: &str, + serial_number_id: &str, + ) -> Self { let mut workspaces = Ring::default(); workspaces.elements_mut().push_back(Workspace::default()); Self { id, + device: device.to_string(), + serial_number_id: serial_number_id.to_string(), workspaces, size, work_area_offset: None, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index ff19ca9b..ce38aa41 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -6,6 +6,7 @@ use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::macos_api::MacosApi; use crate::monitor::Monitor; +use crate::monitor::MonitorInformation; use crate::state::GlobalState; use crate::state::State; use crate::window_manager::WindowManager; @@ -835,6 +836,17 @@ impl WindowManager { reply.write_all(visible_windows_state.as_bytes())?; } + SocketMessage::MonitorInformation => { + let mut monitors = vec![]; + for monitor in self.monitors() { + monitors.push(MonitorInformation::from(monitor)); + } + + let monitors_state = serde_json::to_string_pretty(&monitors) + .unwrap_or_else(|error| error.to_string()); + + reply.write_all(monitors_state.as_bytes())?; + } } Ok(()) diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs index 72e17913..856897ff 100644 --- a/komorebi/src/state.rs +++ b/komorebi/src/state.rs @@ -94,6 +94,8 @@ impl From<&WindowManager> for State { .iter() .map(|monitor| Monitor { id: monitor.id, + device: monitor.device.clone(), + serial_number_id: monitor.serial_number_id.clone(), size: monitor.size, work_area_size: monitor.work_area_size, work_area_offset: monitor.work_area_offset, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index d1a71899..157be97d 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -183,6 +183,9 @@ enum SubCommand { GlobalState, /// Show a JSON representation of visible windows VisibleWindows, + /// Show information about connected monitors + #[clap(alias = "monitor-info")] + MonitorInformation, /// Change focus to the window in the specified direction #[clap(arg_required_else_help = true)] Focus(Focus), @@ -243,7 +246,6 @@ enum SubCommand { PromoteFocus, /// Promote the window in the specified direction PromoteWindow(PromoteWindow), - /// Move the focused window to the specified monitor #[clap(arg_required_else_help = true)] MoveToMonitor(MoveToMonitor), @@ -568,6 +570,9 @@ fn main() -> eyre::Result<()> { SubCommand::VisibleWindows => { print_query(&SocketMessage::VisibleWindows); } + SubCommand::MonitorInformation => { + print_query(&SocketMessage::MonitorInformation); + } } Ok(()) From f6997577f1d68e045795e008b7c7251781636861 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 13:31:43 -0700 Subject: [PATCH 031/305] 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. --- justfile | 3 + komorebi/src/notification_center_listener.rs | 8 +- komorebi/src/process_command.rs | 2 + komorebi/src/process_event.rs | 81 ++++++++++++++++++-- komorebi/src/static_config.rs | 1 + komorebi/src/window.rs | 40 ++++++++++ komorebi/src/window_manager.rs | 41 ++++++++-- komorebi/src/window_manager_event.rs | 13 ++++ 8 files changed, 174 insertions(+), 15 deletions(-) diff --git a/justfile b/justfile index b75c6688..5b342e9c 100644 --- a/justfile +++ b/justfile @@ -8,6 +8,9 @@ fmt: cargo +stable clippy prettier --write README.md +fix: + cargo clippy --fix --allow-dirty + clean: cargo clean diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs index 22bf5d3f..f82b5d29 100644 --- a/komorebi/src/notification_center_listener.rs +++ b/komorebi/src/notification_center_listener.rs @@ -1,4 +1,5 @@ use crate::app_kit_notification_constants::AppKitWorkspaceNotification; +use crate::application::Application; use crate::ax_event_listener::event_tx; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; @@ -33,6 +34,7 @@ define_class! { fn handle_notification(&self, notif: &NSNotification) { unsafe { let mut process_id = None; + let mut window_id = None; let mut valid_keys = vec![]; if let Some(user_info) = notif.userInfo() { @@ -48,7 +50,9 @@ define_class! { && let Some(application) = application_key.downcast_ref::() { process_id = Some(application.processIdentifier()); - // TODO: maybe get the window IDs here too? + if let Ok(application) = Application::new(application.processIdentifier()) { + window_id = application.main_window_id(); + } } } @@ -68,7 +72,7 @@ define_class! { && let Some(event) = WindowManagerEvent::from_system_notification( SystemNotification::AppKitWorkspace(notification), process_id, - None, + window_id, ) && let Err(error) = event_tx().send(event) { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index ce38aa41..96a2bdeb 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -849,6 +849,8 @@ impl WindowManager { } } + self.update_known_window_ids(); + Ok(()) } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 10b5cce0..da329812 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,6 +1,8 @@ +use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::accessibility::notification_constants::AccessibilityNotification; use crate::ax_event_listener::event_tx; +use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::window::Window; @@ -11,6 +13,7 @@ use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use parking_lot::Mutex; use std::sync::Arc; +use tracing::instrument; #[tracing::instrument] pub fn listen_for_events(wm: Arc>) { @@ -37,6 +40,7 @@ pub fn listen_for_events(wm: Arc>) { } impl WindowManager { + #[instrument(skip_all)] pub fn process_event(&mut self, event: WindowManagerEvent) -> eyre::Result<()> { if self.is_paused { tracing::trace!("ignoring while paused"); @@ -65,8 +69,9 @@ impl WindowManager { } tracing::info!( - "processing event: {event} for process {}", - event.process_id() + "processing event: {event} for process {} with notification {}", + event.process_id(), + event.notification(), ); self.enforce_workspace_rules()?; @@ -74,8 +79,12 @@ impl WindowManager { match event { WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; + let application_name = application.name().unwrap_or_default().clone(); if let Some(window_id) = application.main_window_id() { + let is_known = self.known_window_ids.get(&window_id).cloned(); + let mut is_on_current_workspace = false; + // TODO: figure out if this applies on macOS too // don't want to trigger the full workspace updates when there are no managed // containers - this makes floating windows on empty workspaces go into very @@ -89,6 +98,10 @@ impl WindowManager { } let workspace = self.focused_workspace_mut()?; + if workspace.contains_window(window_id) { + is_on_current_workspace = true; + } + let floating_window_idx = workspace .floating_windows() .iter() @@ -106,11 +119,37 @@ impl WindowManager { if let Some(window) = monocle.focused_window() { window.focus(false)?; } - } else { - // if this fails, the app was probably open but windowless when komorebi - // launched, so the window hasn't been registered - we should treat it - // as a "Show" event - if workspace.focus_container_by_window(window_id).is_err() { + } else if !is_on_current_workspace && is_known.is_none() { + // thanks, I hate it - need to do this so that we don't mess up + // the workspace rules, but also don't miss events from dumb + // apps like notes, mail etc. + let mut has_matching_workspace_rule = false; + let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + for rule in &*workspace_rules { + match &rule.matching_rule { + MatchingRule::Simple(r) => { + if r.id.trim_end_matches(".exe") == application_name { + has_matching_workspace_rule = true; + } + } + // TODO: this is pretty coarse + MatchingRule::Composite(rules) => { + for r in rules { + if r.id.trim_end_matches(".exe") == application_name + { + has_matching_workspace_rule = true; + } + } + } + } + } + + if !has_matching_workspace_rule + && workspace.focus_container_by_window(window_id).is_err() + { + // if this fails, the app was probably open but windowless when komorebi + // launched, so the window hasn't been registered - we should treat it + // as a "Show" event event_tx().send(WindowManagerEvent::Show( notification, event.process_id(), @@ -128,12 +167,19 @@ impl WindowManager { self.update_focused_workspace(self.mouse_follows_focus, false)?; } } + Some(idx) => { if let Some(_window) = workspace.floating_windows().get(idx) { workspace.layer = WorkspaceLayer::Floating; } } } + + // maybe we don't need a separate reconciliator module?? this works pretty well! + if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { + self.focus_monitor(m_idx)?; + self.focus_workspace(w_idx)?; + } } if matches!( @@ -162,13 +208,29 @@ impl WindowManager { } } - if let Some(window_id) = window_id { + if let (Some(window_id), Some(element)) = (window_id, &window_element) { let workspace = self.focused_workspace()?; if workspace.contains_window(window_id) { // ignore bogus show events tracing::debug!("ignoring show event for window already on workspace"); create = false; } + + if let Some((m_idx, w_idx)) = self.known_window_ids.get(&window_id) + && let Some(focused_workspace_idx) = self + .monitors() + .get(*m_idx) + .map(|m| m.focused_workspace_idx()) + && *m_idx != self.focused_monitor_idx() + && *w_idx != focused_workspace_idx + { + tracing::debug!( + "ignoring show event for window already associated with another workspace" + ); + + Window::hide_adhoc(window_id, element)?; + create = false; + } } if create { @@ -205,6 +267,9 @@ impl WindowManager { } } + self.enforce_workspace_rules()?; + self.update_known_window_ids(); + Ok(()) } } diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 20e9a95e..ddf188b7 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -1155,6 +1155,7 @@ impl StaticConfig { run_loop: CoreFoundationRunLoop(run_loop.clone()), minimized_windows: Default::default(), already_moved_window_handles: Default::default(), + known_window_ids: Default::default(), }; // match value.focus_follows_mouse { diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index dd1e407e..ecee0016 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -355,6 +355,46 @@ impl Window { Ok(()) } + #[tracing::instrument(skip_all)] + pub fn hide_adhoc( + id: u32, + element: &CFRetained, + ) -> Result<(), AccessibilityError> { + let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); + if let Entry::Vacant(entry) = window_restore_positions.entry(id) { + let rect = MacosApi::window_rect(element)?; + if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { + entry.insert(rect); + drop(window_restore_positions); + + // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API + let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); + + tracing::debug!( + "hiding window with id {id} and setting restore point to {},{}", + rect.origin.x, + rect.origin.y, + ); + + AccessibilityApi::set_attribute_ax_value( + element, + kAXPositionAttribute, + AXValueType::CGPoint, + hidden_rect.origin, + )?; + + AccessibilityApi::set_attribute_ax_value( + element, + kAXSizeAttribute, + AXValueType::CGSize, + hidden_rect.size, + )?; + } + } + + Ok(()) + } + pub fn minimize(&mut self) -> Result<(), AccessibilityError> { let cf_boolean = CFBoolean::new(true); let value = &**cf_boolean; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index d2f6664a..1e3116fe 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -65,6 +65,8 @@ pub struct WindowManager { pub incoming_events: Receiver, pub minimized_windows: HashMap, pub already_moved_window_handles: Arc>>, + /// Maps each known window id to the (monitor, workspace) index pair managing it + pub known_window_ids: HashMap, } impl_ring_elements!(WindowManager, Monitor); @@ -142,6 +144,7 @@ impl WindowManager { incoming_events: incoming, minimized_windows: HashMap::new(), already_moved_window_handles: Default::default(), + known_window_ids: Default::default(), }) } @@ -2034,11 +2037,6 @@ impl WindowManager { .get_mut(op.origin_workspace_idx) .ok_or_eyre("there is no workspace with that index")?; - // TODO: need to find a way to construct a lightweight window that can be operated on - // let mut window = Window::new(origin_workspace - // .window_by_id(op.window_id) - // .ok_or_eyre("there is no window with the requested id")?); - let mut window = origin_workspace.remove_window(op.window_id)?; // If it is a floating window move it to the target area @@ -2162,4 +2160,37 @@ impl WindowManager { Ok(()) } + + pub fn update_known_window_ids(&mut self) { + tracing::trace!("updating list of known window_ids"); + let mut known_window_ids = HashMap::new(); + for (m_idx, monitor) in self.monitors().iter().enumerate() { + for (w_idx, workspace) in monitor.workspaces().iter().enumerate() { + for container in workspace.containers() { + for window in container.windows() { + known_window_ids.insert(window.id, (m_idx, w_idx)); + } + } + + for window in workspace.floating_windows() { + known_window_ids.insert(window.id, (m_idx, w_idx)); + } + + if let Some(window) = &workspace.maximized_window { + known_window_ids.insert(window.id, (m_idx, w_idx)); + } + + if let Some(container) = &workspace.monocle_container { + for window in container.windows() { + known_window_ids.insert(window.id, (m_idx, w_idx)); + } + } + } + } + + if self.known_window_ids != known_window_ids { + // Store new window_ids + self.known_window_ids = known_window_ids; + } + } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index e9c4d764..0cb79b3d 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -78,4 +78,17 @@ impl WindowManagerEvent { | WindowManagerEvent::Restore(_, process_id, _) => *process_id, } } + + pub fn notification(&self) -> String { + match self { + WindowManagerEvent::FocusChange(n, _, _) + | WindowManagerEvent::Show(n, _) + | WindowManagerEvent::Destroy(n, _) + | WindowManagerEvent::Minimize(n, _, _) + | WindowManagerEvent::Restore(n, _, _) => match n { + SystemNotification::Accessibility(a) => a.to_string(), + SystemNotification::AppKitWorkspace(a) => a.to_string(), + }, + } + } } From 84d27f83e0266cbb1a0d306cd606e1b4dd8955bf Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 14:26:18 -0700 Subject: [PATCH 032/305] fix(wm): make hidden windows take up less space --- flake.nix | 16 +++------------- justfile | 1 + komorebi/src/lib.rs | 2 +- shell.nix | 1 + 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 2f621e73..9fdf000b 100644 --- a/flake.nix +++ b/flake.nix @@ -42,17 +42,7 @@ // { inherit version; pname = "komorebi"; - cargoExtraArgs = "-p komorebi"; - src = ./.; - } - ); - - komorebic = craneLib.buildPackage ( - commonArgs - // { - inherit version; - pname = "komorebic"; - cargoExtraArgs = "-p komorebic"; + cargoExtraArgs = "-p komorebi -p komorebic"; src = ./.; } ); @@ -62,9 +52,9 @@ }; packages = flake-utils.lib.flattenTree rec { - inherit komorebi komorebic; + inherit komorebi; default = komorebi; }; } ); -} \ No newline at end of file +} diff --git a/justfile b/justfile index 5b342e9c..610d38aa 100644 --- a/justfile +++ b/justfile @@ -6,6 +6,7 @@ fmt: test -z "$(rg 'println!' --type rust ./komorebi)" || (echo "println! macro not allowed"; false) cargo +nightly fmt cargo +stable clippy + alejandra . prettier --write README.md fix: diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 34b2a33c..63e1673c 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -195,7 +195,7 @@ pub enum LibraryError { pub fn hidden_frame_bottom_left(screen_frame: CGRect, window_size: CGSize) -> CGRect { let visible_sliver: f64 = 1.0; let origin_x = screen_frame.origin.x - (window_size.width - visible_sliver); - let origin_y = screen_frame.origin.y - (window_size.height - visible_sliver); + let origin_y = screen_frame.origin.y + screen_frame.size.height - visible_sliver; CGRect::new(CGPoint::new(origin_x, origin_y), window_size) } diff --git a/shell.nix b/shell.nix index 1389867d..7d2091ea 100644 --- a/shell.nix +++ b/shell.nix @@ -11,5 +11,6 @@ with pkgs; jq prettier cargo-udeps + alejandra ]; } From 465fa02afc5d0803e5c59655c869128b94eccc88 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 14:46:28 -0700 Subject: [PATCH 033/305] 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. --- Cargo.lock | 1079 +++++++++++++++++++++++++++++++++- deny.toml | 5 +- dependencies.json | 131 ++++- komorebi/src/core/pathext.rs | 2 + komorebic/Cargo.toml | 3 +- komorebic/src/main.rs | 27 + 6 files changed, 1233 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76acb08c..ce355d15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,6 +85,12 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.5.0" @@ -139,6 +145,12 @@ version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + [[package]] name = "cc" version = "1.2.38" @@ -247,6 +259,16 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -361,12 +383,32 @@ dependencies = [ "objc2", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "dyn-clone" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -393,6 +435,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + [[package]] name = "file-id" version = "0.1.0" @@ -426,6 +474,30 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fsevent-sys" version = "4.1.0" @@ -435,6 +507,56 @@ dependencies = [ "libc", ] +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "getrandom" version = "0.2.16" @@ -443,7 +565,19 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.1+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.7+wasi-0.2.4", ] [[package]] @@ -452,6 +586,25 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "h2" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.11.4", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -487,6 +640,126 @@ dependencies = [ "notify-debouncer-full", ] +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + [[package]] name = "iana-time-zone" version = "0.1.64" @@ -511,12 +784,119 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + [[package]] name = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indenter" version = "0.3.4" @@ -566,6 +946,33 @@ dependencies = [ "libc", ] +[[package]] +name = "io-uring" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" +dependencies = [ + "bitflags 2.9.4", + "cfg-if", + "libc", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -638,6 +1045,7 @@ dependencies = [ "komorebi-client", "lazy_static", "pastey", + "reqwest", ] [[package]] @@ -689,6 +1097,12 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + [[package]] name = "lock_api" version = "0.4.13" @@ -720,6 +1134,12 @@ version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "minidom" version = "0.12.0" @@ -746,10 +1166,21 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.1+wasi-snapshot-preview1", "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +dependencies = [ + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", +] + [[package]] name = "nanoid" version = "0.4.0" @@ -759,6 +1190,23 @@ dependencies = [ "rand", ] +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nix" version = "0.30.1" @@ -785,7 +1233,7 @@ dependencies = [ "kqueue", "libc", "log", - "mio", + "mio 0.8.11", "walkdir", "windows-sys 0.48.0", ] @@ -1027,6 +1475,50 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +[[package]] +name = "openssl" +version = "0.10.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +dependencies = [ + "bitflags 2.9.4", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -1068,12 +1560,39 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + [[package]] name = "pin-project-lite" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a" +dependencies = [ + "zerovec", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1138,6 +1657,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "rand" version = "0.8.5" @@ -1165,7 +1690,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.16", ] [[package]] @@ -1183,7 +1708,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ - "getrandom", + "getrandom 0.2.16", "libredox", "thiserror", ] @@ -1237,6 +1762,62 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +[[package]] +name = "reqwest" +version = "0.12.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rustc-demangle" version = "0.1.26" @@ -1256,6 +1837,39 @@ dependencies = [ "windows-sys 0.61.0", ] +[[package]] +name = "rustls" +version = "0.23.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.22" @@ -1277,6 +1891,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.0", +] + [[package]] name = "schemars" version = "0.9.0" @@ -1307,6 +1930,29 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.9.4", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.226" @@ -1362,6 +2008,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_with" version = "3.14.1" @@ -1409,12 +2067,34 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.11.1" @@ -1442,6 +2122,12 @@ dependencies = [ "syn", ] +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.106" @@ -1453,6 +2139,60 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.9.4", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84fa4d11fadde498443cca10fd3ac23c951f0dc59e080e9f4b93d4df4e4eea53" +dependencies = [ + "fastrand", + "getrandom 0.3.3", + "once_cell", + "rustix", + "windows-sys 0.61.0", +] + [[package]] name = "terminal_size" version = "0.4.3" @@ -1523,6 +2263,111 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +dependencies = [ + "backtrace", + "bytes", + "io-uring", + "libc", + "mio 1.0.4", + "pin-project-lite", + "slab", + "socket2", + "windows-sys 0.59.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f63835928ca123f1bef57abbcd23bb2ba0ac9ae1235f1e65bda0d06e7786bd" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags 2.9.4", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.41" @@ -1594,12 +2439,42 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "unicode-ident" version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -1612,6 +2487,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "walkdir" version = "2.5.0" @@ -1622,12 +2503,39 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasi" +version = "0.14.7+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" +dependencies = [ + "wasip2", +] + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.103" @@ -1655,6 +2563,19 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0b221ff421256839509adbb55998214a70d829d3a28c69b4a6672e9d2a42f67" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.103" @@ -1687,6 +2608,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "web-sys" +version = "0.3.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbe734895e869dc429d78c4b433f8d17d95f8d05317440b4fad5ab2d33e596dc" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi-util" version = "0.1.11" @@ -1705,8 +2636,8 @@ dependencies = [ "windows-implement", "windows-interface", "windows-link 0.2.0", - "windows-result", - "windows-strings", + "windows-result 0.4.0", + "windows-strings 0.5.0", ] [[package]] @@ -1743,6 +2674,26 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +[[package]] +name = "windows-registry" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" +dependencies = [ + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows-result" version = "0.4.0" @@ -1752,6 +2703,15 @@ dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows-strings" version = "0.5.0" @@ -1779,6 +2739,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.60.2" @@ -1983,6 +2952,42 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.8.27" @@ -2002,3 +3007,63 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/deny.toml b/deny.toml index b33143d8..c22b2f35 100644 --- a/deny.toml +++ b/deny.toml @@ -16,6 +16,7 @@ allow = [ "0BSD", "Apache-2.0", "Artistic-2.0", + "BSD-3-Clause", "CC0-1.0", "MIT", "MPL-2.0", @@ -23,11 +24,9 @@ allow = [ "Zlib", "LicenseRef-Komorebi-2.0", - # these are also ok, but not yet used # "BSD-2-Clause", - # "BSD-3-Clause", # "BSL-1.0", # "ISC", # "MIT-0", @@ -63,5 +62,5 @@ unknown-registry = "deny" unknown-git = "deny" allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-git = [ - "https://github.com/LGUG2Z/quickxml_to_serde", + "https://github.com/LGUG2Z/quickxml_to_serde", ] \ No newline at end of file diff --git a/dependencies.json b/dependencies.json index a60bb042..5a21e314 100644 --- a/dependencies.json +++ b/dependencies.json @@ -15,8 +15,10 @@ "anstyle 1.0.11 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "atomic-waker 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", + "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", @@ -26,29 +28,53 @@ "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "colorchoice 1.0.4 registry+https://github.com/rust-lang/crates.io-index", + "core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index", + "core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index", + "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", + "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", + "futures-channel 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-core 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-sink 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-task 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-util 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "http 1.3.1 registry+https://github.com/rust-lang/crates.io-index", + "httparse 1.10.1 registry+https://github.com/rust-lang/crates.io-index", + "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", + "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", + "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", + "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", + "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -64,7 +90,9 @@ "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", + "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", @@ -74,25 +102,39 @@ "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "rustls-pki-types 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", + "security-framework-sys 2.15.0 registry+https://github.com/rust-lang/crates.io-index", "serde 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_core 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_derive 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", + "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", + "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "stable_deref_trait 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", + "sync_wrapper 1.0.2 registry+https://github.com/rust-lang/crates.io-index", + "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "url 2.5.7 registry+https://github.com/rust-lang/crates.io-index", + "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" + "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", + "zeroize 1.8.1 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -114,6 +156,12 @@ "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" ] ], + [ + "BSD-3-Clause", + [ + "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index" + ] + ], [ "BSL-1.0", [ @@ -138,10 +186,13 @@ "anstyle 1.0.11 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "atomic-waker 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", + "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", @@ -151,6 +202,8 @@ "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "colorchoice 1.0.4 registry+https://github.com/rust-lang/crates.io-index", + "core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index", + "core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -161,17 +214,42 @@ "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index", + "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", + "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", + "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", "fsevent-sys 4.1.0 registry+https://github.com/rust-lang/crates.io-index", + "futures-channel 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-core 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-sink 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-task 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "futures-util 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "h2 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "http 1.3.1 registry+https://github.com/rust-lang/crates.io-index", + "http-body 1.0.1 registry+https://github.com/rust-lang/crates.io-index", + "http-body-util 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "httparse 1.10.1 registry+https://github.com/rust-lang/crates.io-index", + "hyper 1.7.0 registry+https://github.com/rust-lang/crates.io-index", + "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "hyper-util 0.1.17 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", + "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", + "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", + "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -180,8 +258,11 @@ "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index", + "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "mio 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "nanoid 0.4.0 registry+https://github.com/rust-lang/crates.io-index", + "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", @@ -203,7 +284,9 @@ "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", + "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", + "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", @@ -216,36 +299,60 @@ "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "rustls-pki-types 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", + "security-framework-sys 2.15.0 registry+https://github.com/rust-lang/crates.io-index", "serde 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_core 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_derive 1.0.226 registry+https://github.com/rust-lang/crates.io-index", "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", + "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", + "slab 0.4.11 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", + "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "stable_deref_trait 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "strsim 0.11.1 registry+https://github.com/rust-lang/crates.io-index", "strum 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", + "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", + "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", + "tokio 1.47.1 registry+https://github.com/rust-lang/crates.io-index", + "tokio-native-tls 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "tokio-util 0.7.16 registry+https://github.com/rust-lang/crates.io-index", + "tower 0.5.2 registry+https://github.com/rust-lang/crates.io-index", + "tower-http 0.6.6 registry+https://github.com/rust-lang/crates.io-index", + "tower-layer 0.3.3 registry+https://github.com/rust-lang/crates.io-index", + "tower-service 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "tracing 0.1.41 registry+https://github.com/rust-lang/crates.io-index", "tracing-attributes 0.1.30 registry+https://github.com/rust-lang/crates.io-index", "tracing-core 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "tracing-error 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "tracing-log 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", + "try-lock 0.2.5 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "url 2.5.7 registry+https://github.com/rust-lang/crates.io-index", + "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" + "want 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", + "zeroize 1.8.1 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -258,7 +365,25 @@ [ "Unicode-3.0", [ - "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index" + "icu_collections 2.0.0 registry+https://github.com/rust-lang/crates.io-index", + "icu_locale_core 2.0.0 registry+https://github.com/rust-lang/crates.io-index", + "icu_normalizer 2.0.0 registry+https://github.com/rust-lang/crates.io-index", + "icu_normalizer_data 2.0.0 registry+https://github.com/rust-lang/crates.io-index", + "icu_properties 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_properties_data 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_provider 2.0.0 registry+https://github.com/rust-lang/crates.io-index", + "litemap 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "potential_utf 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "tinystr 0.8.1 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "writeable 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "yoke 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "yoke-derive 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "zerofrom 0.1.6 registry+https://github.com/rust-lang/crates.io-index", + "zerofrom-derive 0.1.6 registry+https://github.com/rust-lang/crates.io-index", + "zerotrie 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "zerovec 0.11.4 registry+https://github.com/rust-lang/crates.io-index", + "zerovec-derive 0.11.1 registry+https://github.com/rust-lang/crates.io-index" ] ], [ diff --git a/komorebi/src/core/pathext.rs b/komorebi/src/core/pathext.rs index 7110c485..ec8c3adc 100644 --- a/komorebi/src/core/pathext.rs +++ b/komorebi/src/core/pathext.rs @@ -26,7 +26,9 @@ impl> PathExt for P { for c in self.as_ref().components() { match c { + #[allow(unused_mut)] Component::Normal(mut c) => { + #[cfg(target_os = "windows")] // Special case for ~ and $HOME, replace with $Env:USERPROFILE if c == OsStr::new("~") || c.eq_ignore_ascii_case("$HOME") { c = OsStr::new("$Env:USERPROFILE"); diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index 73bb2a8c..f16774f2 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -10,4 +10,5 @@ clap = { workspace = true } color-eyre = { workspace = true } dirs = { workspace = true } lazy_static = { workspace = true } -pastey = { workspace = true } \ No newline at end of file +pastey = { workspace = true } +reqwest = { version = "0.12", features = ["blocking"] } \ No newline at end of file diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 157be97d..f61d718e 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -12,6 +12,8 @@ use komorebi_client::SocketMessage; use komorebi_client::send_message; use komorebi_client::send_query; use lazy_static::lazy_static; +use std::fs::OpenOptions; +use std::io::Write; use std::path::PathBuf; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; @@ -347,6 +349,9 @@ enum SubCommand { ToggleLock, /// Toggle the behaviour when moving windows across monitor boundaries ToggleCrossMonitorMoveBehaviour, + /// Fetch the latest version of applications.json from komorebi-application-specific-configuration + #[clap(alias = "fetch-asc")] + FetchAppSpecificConfiguration, } fn print_query(message: &SocketMessage) { @@ -573,6 +578,28 @@ fn main() -> eyre::Result<()> { SubCommand::MonitorInformation => { print_query(&SocketMessage::MonitorInformation); } + SubCommand::FetchAppSpecificConfiguration => { + let content = reqwest::blocking::get("https://raw.githubusercontent.com/LGUG2Z/komorebi-application-specific-configuration/master/applications.mac.json")? + .text()?; + + let output_file = HOME_DIR.join("applications.json"); + + let mut file = OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(&output_file)?; + + file.write_all(content.as_bytes())?; + + println!( + "Latest version of applications.mac.json from https://github.com/LGUG2Z/komorebi-application-specific-configuration downloaded\n" + ); + println!( + "You can add this to your komorebi.json static configuration file like this: \n\n\"app_specific_configuration_path\": \"{}\"", + output_file.display().to_string().replace("\\", "/") + ); + } } Ok(()) From de2c105fe185398ba8237111585ccf7675de0263 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 14:59:08 -0700 Subject: [PATCH 034/305] chore(deps): flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- flake.lock | 18 +++++++++--------- flake.nix | 7 +++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 35a34384..fbadd33e 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1757183466, - "narHash": "sha256-kTdCCMuRE+/HNHES5JYsbRHmgtr+l9mOtf5dpcMppVc=", + "lastModified": 1758215636, + "narHash": "sha256-8nkzkPbdxze8CxWhKWlcLbJEU1vfLM/nVqRlTy17V54=", "owner": "ipetkov", "repo": "crane", - "rev": "d599ae4847e7f87603e7082d73ca673aa93c916d", + "rev": "a669fe77a8b0cd6f11419d89ea45a16691ca5121", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1757745802, - "narHash": "sha256-hLEO2TPj55KcUFUU1vgtHE9UEIOjRcH/4QbmfHNF820=", + "lastModified": 1758277210, + "narHash": "sha256-iCGWf/LTy+aY0zFu8q12lK8KuZp7yvdhStehhyX1v8w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c23193b943c6c689d70ee98ce3128239ed9e32d1", + "rev": "8eaee110344796db060382e15d3af0a9fc396e0e", "type": "github" }, "original": { @@ -78,11 +78,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1757930296, - "narHash": "sha256-Z9u5VszKs8rfEvg2AsFucWEjl7wMtAln9l1b78cfBh4=", + "lastModified": 1758508617, + "narHash": "sha256-kx2uELmVnAbiekj/YFfWR26OXqXedImkhe2ocnbumTA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "09442765a05c2ca617c20ed68d9613da92a2d96b", + "rev": "d2bac276ac7e669a1f09c48614538a37e3eb6d0f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 9fdf000b..17d16f8a 100644 --- a/flake.nix +++ b/flake.nix @@ -22,11 +22,13 @@ toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + src = craneLib.cleanCargoSource ./.; version = "0.1.0"; + pname = "komorebi"; commonArgs = { - inherit src; + inherit src version pname; nativeBuildInputs = with pkgs; []; doCheck = false; buildInputs = with pkgs; [ @@ -40,10 +42,7 @@ komorebi = craneLib.buildPackage ( commonArgs // { - inherit version; - pname = "komorebi"; cargoExtraArgs = "-p komorebi -p komorebic"; - src = ./.; } ); in { From a8de084a85c4af18d3dc35d7e0655d5c44f4ca01 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 15:06:39 -0700 Subject: [PATCH 035/305] refactor(clippy): apply rustc 1.90.0 lints --- komorebi/src/core/arrangement.rs | 2 +- komorebi/src/core/direction.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/komorebi/src/core/arrangement.rs b/komorebi/src/core/arrangement.rs index c4915e06..60a67ae0 100644 --- a/komorebi/src/core/arrangement.rs +++ b/komorebi/src/core/arrangement.rs @@ -784,7 +784,7 @@ fn recursive_fibonacci( right: resized.right, bottom: resized.bottom, }] - } else if idx % 2 != 0 { + } else if !idx.is_multiple_of(2) { let mut res = vec![Rect { left: resized.left, top: main_y, diff --git a/komorebi/src/core/direction.rs b/komorebi/src/core/direction.rs index 2d8238f0..6df24716 100644 --- a/komorebi/src/core/direction.rs +++ b/komorebi/src/core/direction.rs @@ -101,7 +101,7 @@ impl Direction for DefaultLayout { Self::Scrolling => false, }, OperationDirection::Down => match self { - Self::BSP => idx != count - 1 && idx % 2 != 0, + Self::BSP => idx != count - 1 && !idx.is_multiple_of(2), Self::Columns => false, Self::Rows => idx != count - 1, Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != count - 1, @@ -121,7 +121,7 @@ impl Direction for DefaultLayout { Self::Scrolling => idx != 0, }, OperationDirection::Right => match self { - Self::BSP => idx % 2 == 0 && idx != count - 1, + Self::BSP => idx.is_multiple_of(2) && idx != count - 1, Self::Columns => idx != count - 1, Self::Rows => false, Self::VerticalStack => idx == 0, @@ -145,7 +145,7 @@ impl Direction for DefaultLayout { ) -> usize { match self { Self::BSP => { - if idx % 2 == 0 { + if idx.is_multiple_of(2) { idx - 1 } else { idx - 2 @@ -189,7 +189,7 @@ impl Direction for DefaultLayout { ) -> usize { match self { Self::BSP => { - if idx % 2 == 0 { + if idx.is_multiple_of(2) { idx - 2 } else { idx - 1 From 474f7e26d8f0084e914d2627db4d44a2e2258a43 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 15:42:19 -0700 Subject: [PATCH 036/305] feat(wm): ensure we don't run multiple komorebi procs --- Cargo.lock | 104 +++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 1 + dependencies.json | 1 + komorebi/Cargo.toml | 1 + komorebi/src/main.rs | 15 +++++++ 5 files changed, 119 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce355d15..5cd044cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -772,7 +772,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core", + "windows-core 0.62.0", ] [[package]] @@ -1022,6 +1022,7 @@ dependencies = [ "serde_json_lenient", "serde_with", "strum", + "sysinfo", "thiserror", "tracing", "tracing-subscriber", @@ -1251,6 +1252,15 @@ dependencies = [ "walkdir", ] +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + [[package]] name = "nu-ansi-term" version = "0.50.1" @@ -2159,6 +2169,19 @@ dependencies = [ "syn", ] +[[package]] +name = "sysinfo" +version = "0.34.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b93974b3d3aeaa036504b8eefd4c039dced109171c1ae973f1dc63b2c7e4b2" +dependencies = [ + "libc", + "memchr", + "ntapi", + "objc2-core-foundation", + "windows", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -2618,6 +2641,22 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" version = "0.1.11" @@ -2627,19 +2666,58 @@ dependencies = [ "windows-sys 0.61.0", ] +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +dependencies = [ + "windows-core 0.57.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +dependencies = [ + "windows-implement 0.57.0", + "windows-interface 0.57.0", + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" dependencies = [ - "windows-implement", - "windows-interface", + "windows-implement 0.60.0", + "windows-interface 0.59.1", "windows-link 0.2.0", "windows-result 0.4.0", "windows-strings 0.5.0", ] +[[package]] +name = "windows-implement" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-implement" version = "0.60.0" @@ -2651,6 +2729,17 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-interface" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-interface" version = "0.59.1" @@ -2685,6 +2774,15 @@ dependencies = [ "windows-strings 0.4.2", ] +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.3.4" diff --git a/Cargo.toml b/Cargo.toml index 5581106a..3dff4a05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,5 @@ lazy_static = "1" pastey = "0.1" serde = { version = "1", features = ["derive"] } serde_json = { package = "serde_json_lenient", version = "0.2" } +sysinfo = "0.34" thiserror = "2" \ No newline at end of file diff --git a/dependencies.json b/dependencies.json index 5a21e314..b9a067e5 100644 --- a/dependencies.json +++ b/dependencies.json @@ -324,6 +324,7 @@ "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", + "sysinfo 0.34.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 1f73abfe..faf322d8 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -28,6 +28,7 @@ serde = { workspace = true } serde_json = { workspace = true } serde_with = "3" strum = { version = "0.27", features = ["derive"] } +sysinfo = { workspace = true } thiserror = { workspace = true } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index ce2eb93b..75b49875 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -32,6 +32,8 @@ use std::sync::Arc; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use std::sync::mpsc; +use sysinfo::Process; +use sysinfo::ProcessesToUpdate; use tracing_subscriber::EnvFilter; fn check_permissions() -> eyre::Result<()> { @@ -121,6 +123,19 @@ struct Opts { fn main() -> eyre::Result<()> { let opts: Opts = Opts::parse(); setup()?; + + let mut system = sysinfo::System::new(); + system.refresh_processes(ProcessesToUpdate::All, true); + + let matched_procs: Vec<&Process> = system.processes_by_name("komorebi".as_ref()).collect(); + + if matched_procs.len() > 1 { + tracing::error!( + "komorebi is already running, please exit the existing process before starting a new one" + ); + std::process::exit(1); + } + check_permissions()?; if !DATA_DIR.is_dir() { From 7467b8e30a2a6a043ad5df0a0509b5ab3fb02654 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 15:45:04 -0700 Subject: [PATCH 037/305] feat(cli): add config and datadir commands --- komorebic/src/main.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index f61d718e..eb4502a4 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -179,6 +179,12 @@ struct Opts { #[derive(Parser)] enum SubCommand { + /// Show the path to komorebi.json + #[clap(alias = "config")] + Configuration, + /// Show the path to komorebi's data directory in $HOME/Library/Application Support + #[clap(alias = "datadir")] + DataDirectory, /// Show a JSON representation of the current window manager state State, /// Show a JSON representation of the current global state @@ -365,6 +371,19 @@ fn main() -> eyre::Result<()> { let opts: Opts = Opts::parse(); match opts.subcmd { + SubCommand::Configuration => { + let static_config = HOME_DIR.join("komorebi.json"); + + if static_config.exists() { + println!("{}", static_config.display()); + } + } + SubCommand::DataDirectory => { + let dir = &*DATA_DIR; + if dir.exists() { + println!("{}", dir.display()); + } + } SubCommand::Focus(arg) => { send_message(&SocketMessage::FocusWindow(arg.operation_direction))?; } From d77ae2d03a65847b760a46311f1c8649f4776071 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 15:55:17 -0700 Subject: [PATCH 038/305] 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. --- Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++--- Cargo.toml | 2 ++ dependencies.json | 22 +++++++++++++++++ komorebi/Cargo.toml | 1 + komorebi/src/main.rs | 56 ++++++++++++++++++++++++++++++++++++------- komorebic/Cargo.toml | 2 ++ komorebic/src/main.rs | 16 +++++++++++++ 7 files changed, 140 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5cd044cb..686e7115 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,8 +180,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" dependencies = [ "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-link 0.2.0", ] @@ -498,6 +500,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs-tail" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73c8ee8694b2ad6d79aa976ad8572ca376c0450290041e6e3ae75147356b6ad2" +dependencies = [ + "memchr", +] + [[package]] name = "fsevent-sys" version = "4.1.0" @@ -1023,8 +1034,9 @@ dependencies = [ "serde_with", "strum", "sysinfo", - "thiserror", + "thiserror 2.0.16", "tracing", + "tracing-appender", "tracing-subscriber", ] @@ -1040,9 +1052,11 @@ dependencies = [ name = "komorebic" version = "0.1.0" dependencies = [ + "chrono", "clap", "color-eyre", "dirs", + "fs-tail", "komorebi-client", "lazy_static", "pastey", @@ -1720,7 +1734,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror", + "thiserror 2.0.16", ] [[package]] @@ -2226,13 +2240,33 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.16", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2402,6 +2436,18 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror 1.0.69", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.30" diff --git a/Cargo.toml b/Cargo.toml index 3dff4a05..5c616db2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,8 @@ members = [ [workspace.dependencies] clap = { version = "4", features = ["derive", "wrap_help"] } +chrono-tz = "0.10" +chrono = "0.4" color-eyre = "0.6" dirs = "6" lazy_static = "1" diff --git a/dependencies.json b/dependencies.json index b9a067e5..eddbdc10 100644 --- a/dependencies.json +++ b/dependencies.json @@ -21,6 +21,7 @@ "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", + "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", @@ -33,6 +34,7 @@ "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "deranged 0.5.3 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", @@ -59,6 +61,7 @@ "http 1.3.1 registry+https://github.com/rust-lang/crates.io-index", "httparse 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "iana-time-zone 0.1.64 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", @@ -75,6 +78,8 @@ "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", + "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -93,6 +98,7 @@ "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", @@ -126,9 +132,13 @@ "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", + "time 0.3.44 registry+https://github.com/rust-lang/crates.io-index", + "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", "url 2.5.7 registry+https://github.com/rust-lang/crates.io-index", "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", @@ -195,6 +205,7 @@ "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", @@ -210,6 +221,7 @@ "darling 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "darling_core 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "darling_macro 0.21.3 registry+https://github.com/rust-lang/crates.io-index", + "deranged 0.5.3 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -223,6 +235,7 @@ "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", + "fs-tail 0.1.4 registry+https://github.com/rust-lang/crates.io-index", "fsevent-sys 4.1.0 registry+https://github.com/rust-lang/crates.io-index", "futures-channel 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-core 0.3.31 registry+https://github.com/rust-lang/crates.io-index", @@ -243,6 +256,7 @@ "hyper 1.7.0 registry+https://github.com/rust-lang/crates.io-index", "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "hyper-util 0.1.17 registry+https://github.com/rust-lang/crates.io-index", + "iana-time-zone 0.1.64 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", @@ -265,6 +279,8 @@ "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", + "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -287,6 +303,7 @@ "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", @@ -329,9 +346,13 @@ "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", + "time 0.3.44 registry+https://github.com/rust-lang/crates.io-index", + "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "tokio 1.47.1 registry+https://github.com/rust-lang/crates.io-index", "tokio-native-tls 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "tokio-util 0.7.16 registry+https://github.com/rust-lang/crates.io-index", @@ -340,6 +361,7 @@ "tower-layer 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "tower-service 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "tracing 0.1.41 registry+https://github.com/rust-lang/crates.io-index", + "tracing-appender 0.2.3 registry+https://github.com/rust-lang/crates.io-index", "tracing-attributes 0.1.30 registry+https://github.com/rust-lang/crates.io-index", "tracing-core 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "tracing-error 0.2.1 registry+https://github.com/rust-lang/crates.io-index", diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index faf322d8..bcc4a28d 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -31,4 +31,5 @@ strum = { version = "0.27", features = ["derive"] } sysinfo = { workspace = true } thiserror = { workspace = true } tracing = "0.1" +tracing-appender = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 75b49875..d6fda8b4 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -1,6 +1,7 @@ #![warn(clippy::all)] use clap::Parser; +use clap::ValueEnum; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; @@ -27,6 +28,7 @@ use objc2_core_graphics::CGMainDisplayID; use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; use parking_lot::Mutex; +use serde::Deserialize; use std::path::PathBuf; use std::sync::Arc; use std::sync::atomic::AtomicBool; @@ -34,7 +36,9 @@ use std::sync::atomic::Ordering; use std::sync::mpsc; use sysinfo::Process; use sysinfo::ProcessesToUpdate; +use tracing_appender::non_blocking::WorkerGuard; use tracing_subscriber::EnvFilter; +use tracing_subscriber::layer::SubscriberExt; fn check_permissions() -> eyre::Result<()> { unsafe { @@ -54,7 +58,7 @@ fn check_permissions() -> eyre::Result<()> { } } -pub fn setup() -> eyre::Result<()> { +fn setup(log_level: LogLevel) -> eyre::Result<(WorkerGuard, WorkerGuard)> { if std::env::var("RUST_LIB_BACKTRACE").is_err() { unsafe { std::env::set_var("RUST_LIB_BACKTRACE", "1"); @@ -65,13 +69,38 @@ pub fn setup() -> eyre::Result<()> { if std::env::var("RUST_LOG").is_err() { unsafe { - std::env::set_var("RUST_LOG", "info"); + std::env::set_var( + "RUST_LOG", + match log_level { + LogLevel::Error => "error", + LogLevel::Warn => "warn", + LogLevel::Info => "info", + LogLevel::Debug => "debug", + LogLevel::Trace => "trace", + }, + ); } } + + let appender = tracing_appender::rolling::daily(&*DATA_DIR, "komorebi_plaintext.log"); + let color_appender = tracing_appender::rolling::daily(&*DATA_DIR, "komorebi.log"); + let (non_blocking, guard) = tracing_appender::non_blocking(appender); + let (color_non_blocking, color_guard) = tracing_appender::non_blocking(color_appender); + tracing::subscriber::set_global_default( tracing_subscriber::fmt::Subscriber::builder() .with_env_filter(EnvFilter::from_default_env()) - .finish(), + .finish() + .with( + tracing_subscriber::fmt::Layer::default() + .with_writer(non_blocking) + .with_ansi(false), + ) + .with( + tracing_subscriber::fmt::Layer::default() + .with_writer(color_non_blocking) + .with_ansi(true), + ), )?; // https://github.com/tokio-rs/tracing/blob/master/examples/examples/panic_hook.rs @@ -102,7 +131,18 @@ pub fn setup() -> eyre::Result<()> { ); })); - Ok(()) + Ok((guard, color_guard)) +} + +#[derive(Default, Deserialize, ValueEnum, Clone)] +#[serde(rename_all = "snake_case")] +enum LogLevel { + Error, + Warn, + #[default] + Info, + Debug, + Trace, } #[derive(Parser)] @@ -115,14 +155,14 @@ struct Opts { // /// Do not attempt to auto-apply a dumped state temp file from a previously running instance of komorebi // #[clap(long)] // clean_state: bool, - // /// Level of log output verbosity - // #[clap(long, value_enum, default_value_t=LogLevel::Info)] - // log_level: LogLevel, + /// Level of log output verbosity + #[clap(long, value_enum, default_value_t=LogLevel::Info)] + log_level: LogLevel, } fn main() -> eyre::Result<()> { let opts: Opts = Opts::parse(); - setup()?; + let (_guard, _color_guard) = setup(opts.log_level)?; let mut system = sysinfo::System::new(); system.refresh_processes(ProcessesToUpdate::All, true); diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index f16774f2..bb363d5a 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -7,8 +7,10 @@ edition = "2024" komorebi-client = { path = "../komorebi-client", default-features = false } clap = { workspace = true } +chrono = { workspace = true } color-eyre = { workspace = true } dirs = { workspace = true } +fs-tail = "0.1" lazy_static = { workspace = true } pastey = { workspace = true } reqwest = { version = "0.12", features = ["blocking"] } \ No newline at end of file diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index eb4502a4..a9eaed0a 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1,7 +1,9 @@ #![warn(clippy::all)] +use chrono::Utc; use clap::Parser; use color_eyre::eyre; +use fs_tail::TailedFile; use komorebi_client::Axis; use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; @@ -12,7 +14,9 @@ use komorebi_client::SocketMessage; use komorebi_client::send_message; use komorebi_client::send_query; use lazy_static::lazy_static; +use std::fs::File; use std::fs::OpenOptions; +use std::io::BufRead; use std::io::Write; use std::path::PathBuf; use std::sync::atomic::AtomicBool; @@ -185,6 +189,8 @@ enum SubCommand { /// Show the path to komorebi's data directory in $HOME/Library/Application Support #[clap(alias = "datadir")] DataDirectory, + /// Tail komorebi's process logs (cancel with Ctrl-C) + Log, /// Show a JSON representation of the current window manager state State, /// Show a JSON representation of the current global state @@ -384,6 +390,16 @@ fn main() -> eyre::Result<()> { println!("{}", dir.display()); } } + SubCommand::Log => { + let timestamp = Utc::now().format("%Y-%m-%d").to_string(); + let color_log = DATA_DIR.join(format!("komorebi.log.{timestamp}")); + let file = TailedFile::new(File::open(color_log)?); + let locked = file.lock(); + #[allow(clippy::significant_drop_in_scrutinee, clippy::lines_filter_map_ok)] + for line in locked.lines().flatten() { + println!("{line}"); + } + } SubCommand::Focus(arg) => { send_message(&SocketMessage::FocusWindow(arg.operation_direction))?; } From b020b5bb69c4167135f5a7864634ac636460ef26 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 16:37:30 -0700 Subject: [PATCH 039/305] feat(cli): add start and stop commands --- Cargo.lock | 1 + komorebi-client/src/lib.rs | 1 + komorebi/src/main.rs | 4 +- komorebic/Cargo.toml | 3 +- komorebic/src/main.rs | 116 +++++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 686e7115..f90f8c34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1061,6 +1061,7 @@ dependencies = [ "lazy_static", "pastey", "reqwest", + "sysinfo", ] [[package]] diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 2a0febd2..fb5eaaee 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -6,6 +6,7 @@ pub use komorebi::core::cycle_direction::CycleDirection; pub use komorebi::core::default_layout::DefaultLayout; pub use komorebi::core::operation_direction::OperationDirection; pub use komorebi::core::pathext::PathExt; +pub use komorebi::core::pathext::replace_env_in_path; use std::borrow::Borrow; use std::io::BufReader; use std::io::Read; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index d6fda8b4..a7f8197e 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -167,7 +167,9 @@ fn main() -> eyre::Result<()> { let mut system = sysinfo::System::new(); system.refresh_processes(ProcessesToUpdate::All, true); - let matched_procs: Vec<&Process> = system.processes_by_name("komorebi".as_ref()).collect(); + let matched_procs: Vec<&Process> = system + .processes_by_exact_name("komorebi".as_ref()) + .collect(); if matched_procs.len() > 1 { tracing::error!( diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index bb363d5a..2897b47b 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -13,4 +13,5 @@ dirs = { workspace = true } fs-tail = "0.1" lazy_static = { workspace = true } pastey = { workspace = true } -reqwest = { version = "0.12", features = ["blocking"] } \ No newline at end of file +reqwest = { version = "0.12", features = ["blocking"] } +sysinfo = { workspace = true } \ No newline at end of file diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index a9eaed0a..08942d70 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -11,6 +11,7 @@ use komorebi_client::OperationDirection; use komorebi_client::PathExt; use komorebi_client::Sizing; use komorebi_client::SocketMessage; +use komorebi_client::replace_env_in_path; use komorebi_client::send_message; use komorebi_client::send_query; use lazy_static::lazy_static; @@ -19,8 +20,13 @@ use std::fs::OpenOptions; use std::io::BufRead; use std::io::Write; use std::path::PathBuf; +use std::process::Command; +use std::process::Stdio; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; +use std::time::Duration; +use sysinfo::ProcessesToUpdate; +use sysinfo::Signal; lazy_static! { static ref HAS_CUSTOM_CONFIG_HOME: AtomicBool = AtomicBool::new(false); @@ -174,6 +180,18 @@ pub struct MoveToMonitorWorkspace { target_workspace: usize, } +#[derive(Parser)] +#[allow(clippy::struct_excessive_bools)] +struct Start { + /// Path to a static configuration JSON file + #[clap(short, long)] + #[clap(value_parser = replace_env_in_path)] + config: Option, + // /// Do not attempt to auto-apply a dumped state temp file from a previously running instance of komorebi + // #[clap(long)] + // clean_state: bool, +} + #[derive(Parser)] #[clap(author, about, version)] struct Opts { @@ -183,6 +201,10 @@ struct Opts { #[derive(Parser)] enum SubCommand { + /// Start komorebi as a background process + Start(Start), + /// Stop the komorebi process and restore all hidden windows + Stop, /// Show the path to komorebi.json #[clap(alias = "config")] Configuration, @@ -377,6 +399,100 @@ fn main() -> eyre::Result<()> { let opts: Opts = Opts::parse(); match opts.subcmd { + SubCommand::Start(arg) => { + let mut command = &mut Command::new("komorebi"); + + if let Some(config) = &arg.config { + command = + command.args(["--config", &format!("'--config=\"{}\"'", config.display())]) + }; + + command = command + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .stdin(Stdio::null()); + + let mut system = sysinfo::System::new_all(); + system.refresh_processes(ProcessesToUpdate::All, true); + + let mut attempts = 0; + let mut running = system + .processes_by_exact_name("komorebi".as_ref()) + .next() + .is_some(); + + while !running && attempts <= 2 { + command.spawn()?; + + print!("Waiting for komorebi to start..."); + std::thread::sleep(Duration::from_secs(3)); + + system.refresh_processes(ProcessesToUpdate::All, true); + + if system + .processes_by_exact_name("komorebi".as_ref()) + .next() + .is_some() + { + println!("Started!"); + running = true; + } else { + println!("komorebi did not start... Trying again"); + attempts += 1; + } + } + + if !running { + println!("\nRunning komorebi directly for detailed error output\n"); + if let Some(config) = &arg.config { + if let Ok(output) = Command::new("komorebi") + .arg(format!("'--config=\"{}\"'", config.display())) + .output() + { + println!("{}", String::from_utf8(output.stderr)?); + } + } else if let Ok(output) = Command::new("komorebi").output() { + println!("{}", String::from_utf8(output.stderr)?); + } + + return Ok(()); + } + + println!("\nThank you for using komorebi!\n"); + println!("# Commercial Use License"); + println!( + "* View licensing options https://lgug2z.com/software/komorebi - A commercial use license is required to use komorebi at work" + ); + println!("\n# Personal Use Sponsorship"); + println!( + "* Become a sponsor https://github.com/sponsors/LGUG2Z - $5/month makes a big difference" + ); + println!("* Leave a tip https://ko-fi.com/lgug2z - An alternative to GitHub Sponsors"); + println!("\n# Community"); + println!( + "* Join the Discord https://discord.gg/mGkn66PHkx - Chat, ask questions, share your desktops" + ); + println!( + "* Subscribe to https://youtube.com/@LGUG2Z - Development videos, feature previews and release overviews" + ); + println!( + "* Explore the Awesome Komorebi list https://github.com/LGUG2Z/awesome-komorebi - Projects in the komorebi ecosystem" + ); + println!("\n# Documentation"); + println!( + "* Read the docs https://lgug2z.github.io/komorebi - Quickly search through all komorebic commands" + ); + } + SubCommand::Stop => { + let mut system = sysinfo::System::new_all(); + system.refresh_processes(ProcessesToUpdate::All, true); + + let running = system.processes_by_exact_name("komorebi".as_ref()).next(); + + if let Some(process) = running { + process.kill_with(Signal::Interrupt); + } + } SubCommand::Configuration => { let static_config = HOME_DIR.join("komorebi.json"); From f3b256bcbf338ecceed1f0ac3699a0659dccb023 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 18:59:38 -0700 Subject: [PATCH 040/305] 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). --- komorebi/src/lib.rs | 4 + komorebi/src/monitor.rs | 1 + komorebi/src/process_event.rs | 214 +++++++++++++++++++++------------- komorebi/src/window.rs | 27 ++++- shell.nix | 2 + 5 files changed, 166 insertions(+), 82 deletions(-) diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 63e1673c..4f153344 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -116,6 +116,10 @@ lazy_static! { })])); static ref PERMAIGNORE_CLASSES: Arc>> = Arc::new(Mutex::new(vec!["Chrome_RenderWidgetHostHWND".to_string(),])); + static ref TABBED_APPLICATIONS: Arc>> = Arc::new(Mutex::new(vec![ + "Finder".to_string(), + "Ghostty".to_string() + ])); } pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 1e3fb96a..a742905f 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -103,6 +103,7 @@ impl Monitor { } } + #[tracing::instrument(skip_all)] pub fn update_focused_workspace(&mut self, offset: Option) -> eyre::Result<()> { let offset = if self.work_area_offset.is_some() { self.work_area_offset diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index da329812..694892b0 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,3 +1,4 @@ +use crate::TABBED_APPLICATIONS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::accessibility::notification_constants::AccessibilityNotification; @@ -5,6 +6,7 @@ use crate::ax_event_listener::event_tx; use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; +use crate::macos_api::MacosApi; use crate::window::Window; use crate::window_manager::WindowManager; use crate::window_manager_event::SystemNotification; @@ -80,106 +82,138 @@ impl WindowManager { WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; let application_name = application.name().unwrap_or_default().clone(); + let mut tabbed_window = false; if let Some(window_id) = application.main_window_id() { - let is_known = self.known_window_ids.get(&window_id).cloned(); - let mut is_on_current_workspace = false; - - // TODO: figure out if this applies on macOS too - // don't want to trigger the full workspace updates when there are no managed - // containers - this makes floating windows on empty workspaces go into very - // annoying focus change loops which prevents users from interacting with them - if !matches!( - self.focused_workspace()?.layout, - Layout::Default(DefaultLayout::Scrolling) - ) && !self.focused_workspace()?.containers().is_empty() + if matches!( + notification, + SystemNotification::Accessibility( + AccessibilityNotification::AXMainWindowChanged + ) + ) && let Some(element) = application.main_window() { - self.update_focused_workspace(self.mouse_follows_focus, false)?; - } + let workspace = self.focused_workspace_mut()?; - let workspace = self.focused_workspace_mut()?; - if workspace.contains_window(window_id) { - is_on_current_workspace = true; - } - - let floating_window_idx = workspace - .floating_windows() - .iter() - .position(|w| w.id == window_id); - - match floating_window_idx { - None => { - // if let Some(w) = workspace.maximized_window() { - // if w.hwnd == window_id { - // return Ok(()); - // } - // } - - if let Some(monocle) = &workspace.monocle_container { - if let Some(window) = monocle.focused_window() { - window.focus(false)?; + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&application_name) { + for window in workspace.visible_windows().iter().flatten() { + if window.application.name().unwrap_or_default() == application_name + { + let tab_rect = MacosApi::window_rect(&element)?; + let main_rect = MacosApi::window_rect(&window.element)?; + if tab_rect == main_rect { + tracing::debug!("ignoring focus change for tabbed window"); + tabbed_window = true; + } } - } else if !is_on_current_workspace && is_known.is_none() { - // thanks, I hate it - need to do this so that we don't mess up - // the workspace rules, but also don't miss events from dumb - // apps like notes, mail etc. - let mut has_matching_workspace_rule = false; - let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); - for rule in &*workspace_rules { - match &rule.matching_rule { - MatchingRule::Simple(r) => { - if r.id.trim_end_matches(".exe") == application_name { - has_matching_workspace_rule = true; - } - } - // TODO: this is pretty coarse - MatchingRule::Composite(rules) => { - for r in rules { + } + } + + drop(tabbed_applications); + } + + if !tabbed_window { + let is_known = self.known_window_ids.get(&window_id).cloned(); + let mut is_on_current_workspace = false; + + // TODO: figure out if this applies on macOS too + // don't want to trigger the full workspace updates when there are no managed + // containers - this makes floating windows on empty workspaces go into very + // annoying focus change loops which prevents users from interacting with them + if !matches!( + self.focused_workspace()?.layout, + Layout::Default(DefaultLayout::Scrolling) + ) && !self.focused_workspace()?.containers().is_empty() + { + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } + + let workspace = self.focused_workspace_mut()?; + if workspace.contains_window(window_id) { + is_on_current_workspace = true; + } + + let floating_window_idx = workspace + .floating_windows() + .iter() + .position(|w| w.id == window_id); + + match floating_window_idx { + None => { + // if let Some(w) = workspace.maximized_window() { + // if w.hwnd == window_id { + // return Ok(()); + // } + // } + + if let Some(monocle) = &workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(false)?; + } + } else if !is_on_current_workspace && is_known.is_none() { + // thanks, I hate it - need to do this so that we don't mess up + // the workspace rules, but also don't miss events from dumb + // apps like notes, mail etc. + let mut has_matching_workspace_rule = false; + let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + for rule in &*workspace_rules { + match &rule.matching_rule { + MatchingRule::Simple(r) => { if r.id.trim_end_matches(".exe") == application_name { has_matching_workspace_rule = true; } } + // TODO: this is pretty coarse + MatchingRule::Composite(rules) => { + for r in rules { + if r.id.trim_end_matches(".exe") + == application_name + { + has_matching_workspace_rule = true; + } + } + } } } + + if !has_matching_workspace_rule + && workspace.focus_container_by_window(window_id).is_err() + { + // if this fails, the app was probably open but windowless when komorebi + // launched, so the window hasn't been registered - we should treat it + // as a "Show" event + event_tx().send(WindowManagerEvent::Show( + notification, + event.process_id(), + ))? + } } - if !has_matching_workspace_rule - && workspace.focus_container_by_window(window_id).is_err() + workspace.layer = WorkspaceLayer::Tiling; + + if matches!( + self.focused_workspace()?.layout, + Layout::Default(DefaultLayout::Scrolling) + ) && !self.focused_workspace()?.containers().is_empty() { - // if this fails, the app was probably open but windowless when komorebi - // launched, so the window hasn't been registered - we should treat it - // as a "Show" event - event_tx().send(WindowManagerEvent::Show( - notification, - event.process_id(), - ))? + self.update_focused_workspace(self.mouse_follows_focus, false)?; } } - workspace.layer = WorkspaceLayer::Tiling; - - if matches!( - self.focused_workspace()?.layout, - Layout::Default(DefaultLayout::Scrolling) - ) && !self.focused_workspace()?.containers().is_empty() - { - self.update_focused_workspace(self.mouse_follows_focus, false)?; + Some(idx) => { + if let Some(_window) = workspace.floating_windows().get(idx) { + workspace.layer = WorkspaceLayer::Floating; + } } } - Some(idx) => { - if let Some(_window) = workspace.floating_windows().get(idx) { - workspace.layer = WorkspaceLayer::Floating; - } + // maybe we don't need a separate reconciliator module?? this works pretty well! + if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { + self.focus_monitor(m_idx)?; + self.focus_workspace(w_idx)?; } } - - // maybe we don't need a separate reconciliator module?? this works pretty well! - if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { - self.focus_monitor(m_idx)?; - self.focus_workspace(w_idx)?; - } } if matches!( @@ -187,15 +221,18 @@ impl WindowManager { SystemNotification::Accessibility( AccessibilityNotification::AXMainWindowChanged ) - ) { + ) && !tabbed_window + { self.reap_invalid_windows_for_application(process_id)?; self.update_focused_workspace(false, false)?; } } - // TODO: upate this to work with floating applications / rules + // TODO: update this to work with floating applications / rules WindowManagerEvent::Show(_, process_id) => { let mut window_id = None; let mut window_element = None; + let mut application_name = String::new(); + let mut tabbed_window = false; let mut create = true; { @@ -205,11 +242,28 @@ impl WindowManager { { window_id = Some(wid); window_element = Some(element.clone()); + application_name = application.name().unwrap_or_default().clone(); } } if let (Some(window_id), Some(element)) = (window_id, &window_element) { let workspace = self.focused_workspace()?; + + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&application_name) { + for window in workspace.visible_windows().iter().flatten() { + if window.application.name().unwrap_or_default() == application_name { + let tab_rect = MacosApi::window_rect(element)?; + let main_rect = MacosApi::window_rect(&window.element)?; + if tab_rect == main_rect { + tabbed_window = true; + } + } + } + } + + drop(tabbed_applications); + if workspace.contains_window(window_id) { // ignore bogus show events tracing::debug!("ignoring show event for window already on workspace"); @@ -233,7 +287,7 @@ impl WindowManager { } } - if create { + if create && !tabbed_window { let application = self.application(process_id)?; if let Some(element) = window_element && let Ok(window) = Window::new(element, application.clone()) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index ecee0016..593ed0a4 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -7,6 +7,7 @@ use crate::LibraryError; use crate::MANAGE_IDENTIFIERS; use crate::PERMAIGNORE_CLASSES; use crate::REGEX_IDENTIFIERS; +use crate::TABBED_APPLICATIONS; use crate::WINDOW_RESTORE_POSITIONS; use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXFocusedAttribute; @@ -487,7 +488,18 @@ impl Window { match self.set_point(CGPoint::new(rect.left as CGFloat, rect.top as CGFloat)) { Ok(_) => {} Err(error) => { - reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + let mut should_reap = true; + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&self.application.name().unwrap_or_default()) + && self.is_valid() + { + should_reap = false; + } + + if should_reap { + reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + } + return Err(error); } } @@ -495,7 +507,18 @@ impl Window { match self.set_size(CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat)) { Ok(_) => Ok(()), Err(error) => { - reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + let mut should_reap = true; + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&self.application.name().unwrap_or_default()) + && self.is_valid() + { + should_reap = false; + } + + if should_reap { + reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + } + Err(error) } } diff --git a/shell.nix b/shell.nix index 7d2091ea..110aaf91 100644 --- a/shell.nix +++ b/shell.nix @@ -3,6 +3,8 @@ with pkgs; mkShell { name = "komorebi"; + RUST_BACKTRACE = "full"; + buildInputs = [ just gcc From 627d15024165dda06bc15f981f3e2b1116896202 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 22 Sep 2025 21:39:01 -0700 Subject: [PATCH 041/305] 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. --- .gitignore | 1 + Cargo.lock | 236 ++++++++++++++++++++++++++------ Cargo.toml | 3 +- dependencies.json | 44 +++++- komorebi-client/src/lib.rs | 1 + komorebi/Cargo.toml | 6 +- komorebi/build.rs | 5 + komorebi/src/core/mod.rs | 13 ++ komorebi/src/lib.rs | 2 + komorebi/src/main.rs | 2 +- komorebi/src/monitor.rs | 16 +++ komorebi/src/process_command.rs | 54 ++++++++ komorebic/Cargo.toml | 7 +- komorebic/build.rs | 12 ++ komorebic/src/main.rs | 15 +- 15 files changed, 369 insertions(+), 48 deletions(-) create mode 100644 komorebi/build.rs create mode 100644 komorebic/build.rs diff --git a/.gitignore b/.gitignore index d7ae555d..afe4db65 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /result* /.idea /.direnv +/komorebic/applications.json diff --git a/Cargo.lock b/Cargo.lock index f90f8c34..0db6d5a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,6 +158,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80f41ae168f955c12fb8960b057d70d0ca153fb83182b57d86380443527be7e9" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -261,6 +263,26 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "const_format" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -597,6 +619,19 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "git2" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" +dependencies = [ + "bitflags 2.9.4", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "h2" version = "0.4.12" @@ -984,6 +1019,12 @@ dependencies = [ "serde", ] +[[package]] +name = "is_debug" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fe266d2e243c931d8190177f20bf7f24eed45e96f39e87dc49a27b32d12d407" + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -996,6 +1037,16 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.3", + "libc", +] + [[package]] name = "js-sys" version = "0.3.80" @@ -1032,6 +1083,7 @@ dependencies = [ "serde", "serde_json_lenient", "serde_with", + "shadow-rs", "strum", "sysinfo", "thiserror 2.0.16", @@ -1061,6 +1113,7 @@ dependencies = [ "lazy_static", "pastey", "reqwest", + "shadow-rs", "sysinfo", ] @@ -1096,6 +1149,18 @@ version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" +[[package]] +name = "libgit2-sys" +version = "0.18.2+1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + [[package]] name = "libredox" version = "0.1.10" @@ -1107,6 +1172,18 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "libz-sys" +version = "1.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.11.0" @@ -1300,6 +1377,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "objc2" version = "0.6.2" @@ -1435,6 +1521,16 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "objc2-io-kit" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a" +dependencies = [ + "libc", + "objc2-core-foundation", +] + [[package]] name = "objc2-io-surface" version = "0.3.1" @@ -2077,6 +2173,19 @@ dependencies = [ "syn", ] +[[package]] +name = "shadow-rs" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8aa5c0570cd9654158bd39f0f8caba24edbc058313946e89f4648b1de1ecf49" +dependencies = [ + "const_format", + "git2", + "is_debug", + "time", + "tzdb", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -2186,14 +2295,15 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.34.2" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b93974b3d3aeaa036504b8eefd4c039dced109171c1ae973f1dc63b2c7e4b2" +checksum = "07cec4dc2d2e357ca1e610cfb07de2fa7a10fc3e9fe89f72545f3d244ea87753" dependencies = [ "libc", "memchr", "ntapi", "objc2-core-foundation", + "objc2-io-kit", "windows", ] @@ -2298,7 +2408,9 @@ checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -2515,12 +2627,44 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tz-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1450bf2b99397e72070e7935c89facaa80092ac812502200375f1f7d33c71a1" + +[[package]] +name = "tzdb" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0be2ea5956f295449f47c0b825c5e109022ff1a6a53bb4f77682a87c2341fbf5" +dependencies = [ + "iana-time-zone", + "tz-rs", + "tzdb_data", +] + +[[package]] +name = "tzdb_data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c4c81d75033770e40fbd3643ce7472a1a9fd301f90b7139038228daf8af03ec" +dependencies = [ + "tz-rs", +] + [[package]] name = "unicode-ident" version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "untrusted" version = "0.9.0" @@ -2721,24 +2865,37 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.57.0" +version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "windows-core 0.57.0", - "windows-targets 0.52.6", + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", ] [[package]] name = "windows-core" -version = "0.57.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement 0.57.0", - "windows-interface 0.57.0", - "windows-result 0.1.2", - "windows-targets 0.52.6", + "windows-implement", + "windows-interface", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", ] [[package]] @@ -2747,22 +2904,22 @@ version = "0.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" dependencies = [ - "windows-implement 0.60.0", - "windows-interface 0.59.1", + "windows-implement", + "windows-interface", "windows-link 0.2.0", "windows-result 0.4.0", "windows-strings 0.5.0", ] [[package]] -name = "windows-implement" -version = "0.57.0" +name = "windows-future" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "proc-macro2", - "quote", - "syn", + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading", ] [[package]] @@ -2776,17 +2933,6 @@ dependencies = [ "syn", ] -[[package]] -name = "windows-interface" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "windows-interface" version = "0.59.1" @@ -2810,6 +2956,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", +] + [[package]] name = "windows-registry" version = "0.5.3" @@ -2821,15 +2977,6 @@ dependencies = [ "windows-strings 0.4.2", ] -[[package]] -name = "windows-result" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-result" version = "0.3.4" @@ -2959,6 +3106,15 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" diff --git a/Cargo.toml b/Cargo.toml index 5c616db2..4167c6d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,5 +17,6 @@ lazy_static = "1" pastey = "0.1" serde = { version = "1", features = ["derive"] } serde_json = { package = "serde_json_lenient", version = "0.2" } -sysinfo = "0.34" +shadow-rs = "1" +sysinfo = "0.37" thiserror = "2" \ No newline at end of file diff --git a/dependencies.json b/dependencies.json index eddbdc10..1140615e 100644 --- a/dependencies.json +++ b/dependencies.json @@ -20,6 +20,7 @@ "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.38 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", @@ -45,6 +46,7 @@ "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", "futures-channel 0.3.31 registry+https://github.com/rust-lang/crates.io-index", @@ -55,6 +57,7 @@ "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -69,10 +72,14 @@ "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", + "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", + "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", + "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", @@ -80,6 +87,7 @@ "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", + "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -88,6 +96,7 @@ "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", @@ -98,6 +107,7 @@ "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "pkg-config 0.3.32 registry+https://github.com/rust-lang/crates.io-index", "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", @@ -123,6 +133,8 @@ "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "shadow-rs 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "stable_deref_trait 1.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -139,10 +151,15 @@ "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", "time 0.3.44 registry+https://github.com/rust-lang/crates.io-index", "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", + "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", + "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", + "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", "url 2.5.7 registry+https://github.com/rust-lang/crates.io-index", "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "vcpkg 0.2.15 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.1 registry+https://github.com/rust-lang/crates.io-index" ] @@ -203,6 +220,7 @@ "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.38 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", @@ -233,6 +251,7 @@ "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", "fs-tail 0.1.4 registry+https://github.com/rust-lang/crates.io-index", @@ -245,6 +264,7 @@ "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", "h2 0.4.12 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -264,10 +284,14 @@ "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", + "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", + "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", + "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -281,6 +305,7 @@ "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", + "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -292,6 +317,7 @@ "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-encode 4.1.0 registry+https://github.com/rust-lang/crates.io-index", "objc2-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", @@ -303,6 +329,7 @@ "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "pkg-config 0.3.32 registry+https://github.com/rust-lang/crates.io-index", "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", @@ -331,7 +358,9 @@ "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "shadow-rs 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", + "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "slab 0.4.11 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", @@ -341,7 +370,7 @@ "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", - "sysinfo 0.34.2 registry+https://github.com/rust-lang/crates.io-index", + "sysinfo 0.37.0 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", @@ -368,16 +397,26 @@ "tracing-log 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", "try-lock 0.2.5 registry+https://github.com/rust-lang/crates.io-index", + "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", + "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", "url 2.5.7 registry+https://github.com/rust-lang/crates.io-index", "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "vcpkg 0.2.15 registry+https://github.com/rust-lang/crates.io-index", "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index", "want 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.1 registry+https://github.com/rust-lang/crates.io-index" ] ], + [ + "MIT-0", + [ + "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index" + ] + ], [ "MPL-2.0", [ @@ -421,6 +460,8 @@ [ "Zlib", [ + "const_format 0.2.34 registry+https://github.com/rust-lang/crates.io-index", + "const_format_proc_macros 0.2.34 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -431,6 +472,7 @@ "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index" ] diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index fb5eaaee..1043b01e 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,6 +1,7 @@ pub use komorebi::DATA_DIR; pub use komorebi::core::Sizing; pub use komorebi::core::SocketMessage; +pub use komorebi::core::StateQuery; pub use komorebi::core::arrangement::Axis; pub use komorebi::core::cycle_direction::CycleDirection; pub use komorebi::core::default_layout::DefaultLayout; diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index bcc4a28d..cbb465fc 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -27,9 +27,13 @@ regex = "1" serde = { workspace = true } serde_json = { workspace = true } serde_with = "3" +shadow-rs = { workspace = true } strum = { version = "0.27", features = ["derive"] } sysinfo = { workspace = true } thiserror = { workspace = true } tracing = "0.1" tracing-appender = "0.2" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } \ No newline at end of file +tracing-subscriber = { version = "0.3", features = ["env-filter"] } + +[build-dependencies] +shadow-rs = { workspace = true } \ No newline at end of file diff --git a/komorebi/build.rs b/komorebi/build.rs new file mode 100644 index 00000000..44fad00f --- /dev/null +++ b/komorebi/build.rs @@ -0,0 +1,5 @@ +use shadow_rs::ShadowBuilder; + +fn main() { + ShadowBuilder::builder().build().unwrap(); +} diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index a0901c53..5a1c4cad 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -163,6 +163,18 @@ pub enum ApplicationIdentifier { Path, } +#[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] +pub enum StateQuery { + FocusedMonitorIndex, + FocusedWorkspaceIndex, + FocusedContainerIndex, + FocusedWindowIndex, + FocusedWorkspaceName, + FocusedWorkspaceLayout, + FocusedContainerKind, + Version, +} + #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] #[serde(tag = "type", content = "content")] @@ -236,6 +248,7 @@ pub enum SocketMessage { GlobalState, VisibleWindows, MonitorInformation, + Query(StateQuery), } impl SocketMessage { diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 4f153344..d8502480 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -122,6 +122,8 @@ lazy_static! { ])); } +shadow_rs::shadow!(build); + pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(5); diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index a7f8197e..89fbf972 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -146,7 +146,7 @@ enum LogLevel { } #[derive(Parser)] -#[clap(author, about, version)] +#[clap(author, about, version = komorebi::build::CLAP_LONG_VERSION)] struct Opts { /// Path to a static configuration JSON file #[clap(short, long)] diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index a742905f..a6c10a47 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -458,4 +458,20 @@ impl Monitor { .resize(ensure_count, Workspace::default()); } } + + pub fn focused_workspace_name(&self) -> Option { + self.focused_workspace() + .map(|w| w.name.clone()) + .unwrap_or(None) + } + + pub fn focused_workspace_layout(&self) -> Option { + self.focused_workspace().and_then(|workspace| { + if workspace.tile { + Some(workspace.layout.clone()) + } else { + None + } + }) + } } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 96a2bdeb..a9ac0cc8 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,7 +1,10 @@ +use crate::build; use crate::core::MoveBehaviour; use crate::core::SocketMessage; +use crate::core::StateQuery; use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; +use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::macos_api::MacosApi; @@ -847,6 +850,57 @@ impl WindowManager { reply.write_all(monitors_state.as_bytes())?; } + SocketMessage::Query(query) => { + let response = match query { + StateQuery::FocusedMonitorIndex => self.focused_monitor_idx().to_string(), + StateQuery::FocusedWorkspaceIndex => self + .focused_monitor() + .ok_or_eyre("there is no monitor")? + .focused_workspace_idx() + .to_string(), + StateQuery::FocusedContainerIndex => self + .focused_workspace()? + .focused_container_idx() + .to_string(), + StateQuery::FocusedWindowIndex => { + self.focused_container()?.focused_window_idx().to_string() + } + StateQuery::FocusedWorkspaceName => { + let focused_monitor = + self.focused_monitor().ok_or_eyre("there is no monitor")?; + + focused_monitor + .focused_workspace_name() + .unwrap_or_else(|| focused_monitor.focused_workspace_idx().to_string()) + } + StateQuery::Version => build::VERSION.to_string(), + StateQuery::FocusedWorkspaceLayout => { + let focused_monitor = + self.focused_monitor().ok_or_eyre("there is no monitor")?; + + focused_monitor.focused_workspace_layout().map_or_else( + || "None".to_string(), + |layout| match layout { + Layout::Default(default_layout) => default_layout.to_string(), + }, + ) + } + StateQuery::FocusedContainerKind => { + match self.focused_workspace()?.focused_container() { + None => "None".to_string(), + Some(container) => { + if container.windows().len() > 1 { + "Stack".to_string() + } else { + "Single".to_string() + } + } + } + } + }; + + reply.write_all(response.as_bytes())?; + } } self.update_known_window_ids(); diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index 2897b47b..969fa980 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -14,4 +14,9 @@ fs-tail = "0.1" lazy_static = { workspace = true } pastey = { workspace = true } reqwest = { version = "0.12", features = ["blocking"] } -sysinfo = { workspace = true } \ No newline at end of file +shadow-rs = { workspace = true } +sysinfo = { workspace = true } + +[build-dependencies] +reqwest = { version = "0.12", features = ["blocking"] } +shadow-rs = { workspace = true } diff --git a/komorebic/build.rs b/komorebic/build.rs new file mode 100644 index 00000000..6da11b8a --- /dev/null +++ b/komorebic/build.rs @@ -0,0 +1,12 @@ +use shadow_rs::ShadowBuilder; + +fn main() { + if std::fs::metadata("applications.json").is_err() { + let applications_json = reqwest::blocking::get( + "https://raw.githubusercontent.com/LGUG2Z/komorebi-application-specific-configuration/master/applications.mac.json" + ).unwrap().text().unwrap(); + std::fs::write("applications.json", applications_json).unwrap(); + } + + ShadowBuilder::builder().build().unwrap(); +} diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 08942d70..1772babc 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -11,6 +11,7 @@ use komorebi_client::OperationDirection; use komorebi_client::PathExt; use komorebi_client::Sizing; use komorebi_client::SocketMessage; +use komorebi_client::StateQuery; use komorebi_client::replace_env_in_path; use komorebi_client::send_message; use komorebi_client::send_query; @@ -51,6 +52,8 @@ lazy_static! { .join("komorebi"); } +shadow_rs::shadow!(build); + macro_rules! gen_enum_subcommand_args { // SubCommand Pattern: Enum Type ( $( $name:ident: $element:ty ),+ $(,)? ) => { @@ -87,7 +90,7 @@ gen_enum_subcommand_args! { CycleLayout: CycleDirection, // WatchConfiguration: BooleanState, // MouseFollowsFocus: BooleanState, - // Query: StateQuery, + Query: StateQuery, // WindowHidingBehaviour: HidingBehaviour, // CrossMonitorMoveBehaviour: MoveBehaviour, // UnmanagedWindowOperationBehaviour: OperationBehaviour, @@ -193,7 +196,7 @@ struct Start { } #[derive(Parser)] -#[clap(author, about, version)] +#[clap(author, about, version = build::CLAP_LONG_VERSION)] struct Opts { #[clap(subcommand)] subcmd: SubCommand, @@ -222,6 +225,9 @@ enum SubCommand { /// Show information about connected monitors #[clap(alias = "monitor-info")] MonitorInformation, + /// Query the current window manager state + #[clap(arg_required_else_help = true)] + Query(Query), /// Change focus to the window in the specified direction #[clap(arg_required_else_help = true)] Focus(Focus), @@ -424,7 +430,7 @@ fn main() -> eyre::Result<()> { while !running && attempts <= 2 { command.spawn()?; - print!("Waiting for komorebi to start..."); + print!("Waiting for komorebi to start... "); std::thread::sleep(Duration::from_secs(3)); system.refresh_processes(ProcessesToUpdate::All, true); @@ -723,6 +729,9 @@ fn main() -> eyre::Result<()> { SubCommand::GlobalState => { print_query(&SocketMessage::GlobalState); } + SubCommand::Query(arg) => { + print_query(&SocketMessage::Query(arg.state_query)); + } SubCommand::VisibleWindows => { print_query(&SocketMessage::VisibleWindows); } From 712f2d86a00e897418f27d661f816e94aefaf0dc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 10:04:13 -0700 Subject: [PATCH 042/305] 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. --- komorebi/src/macos_api.rs | 1 + komorebi/src/process_event.rs | 38 ++++++++++++-- komorebi/src/reaper.rs | 33 ++++++++++++ komorebi/src/window.rs | 94 ++++++++++++++++------------------- komorebi/src/workspace.rs | 35 +++++++++++-- 5 files changed, 144 insertions(+), 57 deletions(-) diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 17c55b55..23652e2d 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -187,6 +187,7 @@ impl MacosApi { )?) } + #[tracing::instrument(skip_all)] pub fn window_rect(element: &AXUIElement) -> Result { let mut position_receiver = std::ptr::null(); let mut size_receiver = std::ptr::null(); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 694892b0..d5ddb390 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,6 +1,8 @@ use crate::TABBED_APPLICATIONS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; +use crate::accessibility::error::AccessibilityApiError; +use crate::accessibility::error::AccessibilityError; use crate::accessibility::notification_constants::AccessibilityNotification; use crate::ax_event_listener::event_tx; use crate::core::config_generation::MatchingRule; @@ -96,17 +98,47 @@ impl WindowManager { let tabbed_applications = TABBED_APPLICATIONS.lock(); if tabbed_applications.contains(&application_name) { - for window in workspace.visible_windows().iter().flatten() { - if window.application.name().unwrap_or_default() == application_name + let mut first_tab_destroyed = false; + + for window in workspace.visible_windows() { + if let Some(window) = window + && window.application.name().unwrap_or_default() + == application_name { let tab_rect = MacosApi::window_rect(&element)?; - let main_rect = MacosApi::window_rect(&window.element)?; + let main_rect = match MacosApi::window_rect(&window.element) { + Ok(rect) => rect, + Err(AccessibilityError::Api( + AccessibilityApiError::InvalidUIElement, + )) => { + // this means we have closed the 1st tab, so we need this window object to be reaped + // and for the new 1st tab to be the key element of the window struct + event_tx().send(WindowManagerEvent::Show( + notification, + event.process_id(), + ))?; + + first_tab_destroyed = true; + + tracing::debug!( + "first tab of a native tabbed app was destroyed; reaping window and sending a new show event" + ); + + tab_rect + } + Err(error) => return Err(error.into()), + }; + if tab_rect == main_rect { tracing::debug!("ignoring focus change for tabbed window"); tabbed_window = true; } } } + + if first_tab_destroyed { + self.reap_invalid_windows_for_application(process_id)?; + } } drop(tabbed_applications); diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs index 2dfb62b5..a2fc3fc4 100644 --- a/komorebi/src/reaper.rs +++ b/komorebi/src/reaper.rs @@ -1,3 +1,6 @@ +use crate::TABBED_APPLICATIONS; +use crate::accessibility::error::AccessibilityError; +use crate::window::Window; use crate::window_manager::WindowManager; use crossbeam_channel::Receiver; use crossbeam_channel::Sender; @@ -69,6 +72,15 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> w.id != window_id }); } + + workspace.floating_windows_mut().retain(|w| { + if w.id == window_id { + should_update = true; + tracing::info!("reaping window: {window_id}"); + } + + w.id != window_id + }); } } @@ -87,3 +99,24 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> Ok(()) } + +pub fn notify_on_error( + window: &Window, + result: Result<(), AccessibilityError>, +) -> Result<(), AccessibilityError> { + if let Err(_error) = &result { + let mut should_reap = true; + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&window.application.name().unwrap_or_default()) + && window.is_valid() + { + should_reap = false; + } + + if should_reap { + send_notification(ReaperNotification::InvalidWindow(window.id)); + } + } + + result +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 593ed0a4..3a51e9ff 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -7,7 +7,6 @@ use crate::LibraryError; use crate::MANAGE_IDENTIFIERS; use crate::PERMAIGNORE_CLASSES; use crate::REGEX_IDENTIFIERS; -use crate::TABBED_APPLICATIONS; use crate::WINDOW_RESTORE_POSITIONS; use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXFocusedAttribute; @@ -38,7 +37,6 @@ use crate::core_graphics::CoreGraphicsApi; use crate::hidden_frame_bottom_left; use crate::macos_api::MacosApi; use crate::reaper; -use crate::reaper::ReaperNotification; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use color_eyre::eyre; @@ -348,8 +346,8 @@ impl Window { rect.origin.y, ); - self.set_point(hidden_rect.origin)?; - self.set_size(hidden_rect.size)?; + self.set_point(hidden_rect.origin, true)?; + self.set_size(hidden_rect.size, true)?; } } @@ -419,8 +417,8 @@ impl Window { .unwrap_or_else(|| String::from("")) ); - self.set_point(cg_rect.origin)?; - self.set_size(cg_rect.size)?; + self.set_point(cg_rect.origin, true)?; + self.set_size(cg_rect.size, true)?; should_remove_restore_position = true; } @@ -485,49 +483,31 @@ impl Window { } pub fn set_position(&self, rect: &Rect) -> Result<(), AccessibilityError> { - match self.set_point(CGPoint::new(rect.left as CGFloat, rect.top as CGFloat)) { - Ok(_) => {} - Err(error) => { - let mut should_reap = true; - let tabbed_applications = TABBED_APPLICATIONS.lock(); - if tabbed_applications.contains(&self.application.name().unwrap_or_default()) - && self.is_valid() - { - should_reap = false; - } - - if should_reap { - reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); - } - - return Err(error); - } - } - - match self.set_size(CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat)) { - Ok(_) => Ok(()), - Err(error) => { - let mut should_reap = true; - let tabbed_applications = TABBED_APPLICATIONS.lock(); - if tabbed_applications.contains(&self.application.name().unwrap_or_default()) - && self.is_valid() - { - should_reap = false; - } - - if should_reap { - reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); - } - - Err(error) - } - } + self.set_point( + CGPoint::new(rect.left as CGFloat, rect.top as CGFloat), + true, + )?; + self.set_size( + CGSize::new(rect.right as CGFloat, rect.bottom as CGFloat), + true, + ) } pub fn focus(&self, mouse_follows_focus: bool) -> Result<(), LibraryError> { unsafe { - self.running_application()? - .activateWithOptions(NSApplicationActivationOptions::empty()); + match self.running_application() { + Ok(running_application) => { + running_application + .activateWithOptions(NSApplicationActivationOptions::empty()); + } + Err(error) => { + tracing::warn!( + "failed to get running application for {} ({:?}): {error}", + self.application.process_id, + self.application.name() + ); + } + } let cf_boolean = CFBoolean::new(true); let value = &**cf_boolean; @@ -548,22 +528,34 @@ impl Window { AccessibilityApi::set_attribute_cf_value(&self.element, kAXFocusedAttribute, value) } - pub fn set_point(&self, point: CGPoint) -> Result<(), AccessibilityError> { - AccessibilityApi::set_attribute_ax_value( + pub fn set_point(&self, point: CGPoint, should_reap: bool) -> Result<(), AccessibilityError> { + let result = AccessibilityApi::set_attribute_ax_value( &self.element, kAXPositionAttribute, AXValueType::CGPoint, point, - ) + ); + + if should_reap { + reaper::notify_on_error(self, result) + } else { + result + } } - pub fn set_size(&self, size: CGSize) -> Result<(), AccessibilityError> { - AccessibilityApi::set_attribute_ax_value( + pub fn set_size(&self, size: CGSize, should_reap: bool) -> Result<(), AccessibilityError> { + let result = AccessibilityApi::set_attribute_ax_value( &self.element, kAXSizeAttribute, AXValueType::CGSize, size, - ) + ); + + if should_reap { + reaper::notify_on_error(self, result) + } else { + result + } } pub fn center(&mut self, work_area: &Rect, resize: bool) -> Result<(), AccessibilityError> { diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 5964daac..c1b3fbb4 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -287,12 +287,14 @@ impl Workspace { insertion_idx } + #[tracing::instrument(skip(self))] pub fn reap_invalid_windows_for_application( &mut self, process_id: i32, valid_window_ids: &[u32], ) -> eyre::Result { let mut invalid_window_ids = vec![]; + let mut invalid_floating_window_ids = vec![]; for container in self.containers() { if let Some(focused_window) = container.focused_window() && focused_window.application.process_id == process_id @@ -309,11 +311,33 @@ impl Workspace { } } + for window in self.floating_windows() { + if window.application.process_id == process_id { + if !valid_window_ids.contains(&window.id) { + invalid_floating_window_ids.push(window.id); + } + + // if accessibility API calls fail on AXError::InvalidUIElement + // let's try and nuke these early + if !window.is_valid() { + invalid_floating_window_ids.push(window.id); + } + } + } + for window_id in &invalid_window_ids { self.remove_window(*window_id)?; } - Ok(invalid_window_ids.len()) + for window_id in &invalid_floating_window_ids { + self.remove_floating_window(*window_id); + } + + tracing::debug!( + "reaping invalid windows {invalid_window_ids:?} {invalid_floating_window_ids:?}" + ); + + Ok(invalid_window_ids.len() + invalid_floating_window_ids.len()) } pub fn remove_window(&mut self, window_id: u32) -> eyre::Result { @@ -538,8 +562,10 @@ impl Workspace { should_hide = true } - if should_hide { - window.hide()?; + if should_hide && let Err(error) = window.hide() { + tracing::warn!( + "failed to hide floating window, but this might be because it is already hidden: {error}" + ); } } @@ -773,7 +799,10 @@ impl Workspace { pub fn remove_focused_floating_window(&mut self) -> Option { let window_id = MacosApi::foreground_window_id()?; + self.remove_floating_window(window_id) + } + pub fn remove_floating_window(&mut self, window_id: u32) -> Option { let mut idx = None; for (i, window) in self.floating_windows().iter().enumerate() { if window_id == window.id { From 0ede90ae5dc2bbacf3e7212ea59b20c23b4dc183 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 13:34:48 -0700 Subject: [PATCH 043/305] 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. --- komorebi/src/application.rs | 14 ++-- komorebi/src/input_event_listener.rs | 22 +++++++ komorebi/src/lib.rs | 23 ++----- komorebi/src/main.rs | 6 +- komorebi/src/notification_center_listener.rs | 5 +- komorebi/src/process_event.rs | 64 ++++++++++++++----- komorebi/src/window.rs | 16 ++--- komorebi/src/window_manager_event.rs | 18 +++++- ...er.rs => window_manager_event_listener.rs} | 8 ++- 9 files changed, 120 insertions(+), 56 deletions(-) rename komorebi/src/{ax_event_listener.rs => window_manager_event_listener.rs} (68%) diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index 52db02ec..d9cc66df 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -13,10 +13,10 @@ use crate::accessibility::notification_constants::kAXApplicationShownNotificatio use crate::accessibility::notification_constants::kAXMainWindowChangedNotification; use crate::accessibility::notification_constants::kAXUIElementDestroyedNotification; use crate::accessibility::notification_constants::kAXWindowCreatedNotification; -use crate::ax_event_listener::event_tx; use crate::window::Window; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; +use crate::window_manager_event_listener; use objc2_application_services::AXObserver; use objc2_application_services::AXUIElement; use objc2_core_foundation::CFArray; @@ -76,13 +76,11 @@ unsafe extern "C-unwind" fn application_observer_callback( None, ) { - if let Err(error) = event_tx().send(event) { - tracing::error!("failed to send window manager event: {error}"); - } else { - tracing::debug!( - "notification: {notification}, process: {process_id}, name: \"{name}\"", - ); - } + tracing::debug!( + "notification: {notification}, process: {process_id}, name: \"{name}\"", + ); + + window_manager_event_listener::send_notification(event); } } } diff --git a/komorebi/src/input_event_listener.rs b/komorebi/src/input_event_listener.rs index f6f466a1..f43e03b1 100644 --- a/komorebi/src/input_event_listener.rs +++ b/komorebi/src/input_event_listener.rs @@ -1,5 +1,11 @@ +use crate::accessibility::AccessibilityApi; +use crate::macos_api::MacosApi; use crate::reaper; use crate::reaper::ReaperNotification; +use crate::window_manager_event::ManualNotification; +use crate::window_manager_event::SystemNotification; +use crate::window_manager_event::WindowManagerEvent; +use crate::window_manager_event_listener; use objc2_core_foundation::CFMachPort; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; @@ -24,6 +30,22 @@ extern "C-unwind" fn callback( _listener: *mut c_void, ) -> *mut CGEvent { reaper::send_notification(ReaperNotification::MouseUpKeyUp); + if let Some(element) = MacosApi::foreground_window() { + let mut pid = 0; + unsafe { + element.pid(NonNull::from_mut(&mut pid)); + } + + if pid != 0 + && let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::Manual(ManualNotification::ShowOnInputEvent), + pid, + AccessibilityApi::window_id(&element).ok(), + ) + { + window_manager_event_listener::send_notification(event); + } + } unsafe { event_ref.as_mut() } } impl InputEventListener { diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index d8502480..5fda1262 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -39,7 +39,6 @@ pub mod ring; pub mod accessibility; pub mod app_kit_notification_constants; pub mod application; -pub mod ax_event_listener; pub mod container; pub mod core; pub mod core_graphics; @@ -59,6 +58,7 @@ pub mod static_config; pub mod window; pub mod window_manager; pub mod window_manager_event; +pub mod window_manager_event_listener; pub mod workspace; lazy_static! { @@ -89,23 +89,12 @@ lazy_static! { static ref REGEX_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(HashMap::new())); static ref MANAGE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![])); - static ref IGNORE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![ - MatchingRule::Simple(IdWithIdentifier { - kind: ApplicationIdentifier::Class, - id: String::from("OPContainerClass"), - matching_strategy: Option::from(MatchingStrategy::Equals), - }), - MatchingRule::Simple(IdWithIdentifier { - kind: ApplicationIdentifier::Class, - id: String::from("IHWindowClass"), - matching_strategy: Option::from(MatchingStrategy::Equals), - }), - MatchingRule::Simple(IdWithIdentifier { + static ref IGNORE_IDENTIFIERS: Arc>> = + Arc::new(Mutex::new(vec![MatchingRule::Simple(IdWithIdentifier { kind: ApplicationIdentifier::Exe, - id: String::from("komorebi-bar.exe"), + id: String::from("Spotlight"), matching_strategy: Option::from(MatchingStrategy::Equals), - }) - ])); + })])); static ref SESSION_FLOATING_APPLICATIONS: Arc>> = Arc::new(Mutex::new(Vec::new())); static ref FLOATING_APPLICATIONS: Arc>> = @@ -120,6 +109,8 @@ lazy_static! { "Finder".to_string(), "Ghostty".to_string() ])); + static ref DO_NOT_OBSERVE_APPLICATIONS: Arc>> = + Arc::new(Mutex::new(vec!["Spotlight".to_string(),])); } shadow_rs::shadow!(build); diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 89fbf972..f260cc94 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -7,7 +7,6 @@ use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; use komorebi::HOME_DIR; use komorebi::UPDATE_MONITOR_WORK_AREAS; -use komorebi::ax_event_listener; use komorebi::core::pathext::replace_env_in_path; use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; use komorebi::input_event_listener::InputEventListener; @@ -19,6 +18,7 @@ use komorebi::process_event::listen_for_events; use komorebi::reaper; use komorebi::static_config::StaticConfig; use komorebi::window_manager::WindowManager; +use komorebi::window_manager_event_listener; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; use objc2_core_foundation::CFRunLoop; @@ -213,14 +213,14 @@ fn main() -> eyre::Result<()> { Arc::new(Mutex::new(StaticConfig::preload( config, - ax_event_listener::event_rx(), + window_manager_event_listener::event_rx(), None, &run_loop, )?)) } else { Arc::new(Mutex::new(WindowManager::new( &run_loop, - ax_event_listener::event_rx(), + window_manager_event_listener::event_rx(), None, )?)) }; diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs index f82b5d29..7f71b1c6 100644 --- a/komorebi/src/notification_center_listener.rs +++ b/komorebi/src/notification_center_listener.rs @@ -1,8 +1,8 @@ use crate::app_kit_notification_constants::AppKitWorkspaceNotification; use crate::application::Application; -use crate::ax_event_listener::event_tx; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; +use crate::window_manager_event_listener; use objc2::AnyThread; use objc2::define_class; use objc2::msg_send; @@ -74,9 +74,8 @@ define_class! { process_id, window_id, ) - && let Err(error) = event_tx().send(event) { - tracing::error!("failed to send window manager event: {error}"); + window_manager_event_listener::send_notification(event); }; } } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index d5ddb390..66c1e518 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -4,15 +4,16 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityApiError; use crate::accessibility::error::AccessibilityError; use crate::accessibility::notification_constants::AccessibilityNotification; -use crate::ax_event_listener::event_tx; use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::macos_api::MacosApi; use crate::window::Window; use crate::window_manager::WindowManager; +use crate::window_manager_event::ManualNotification; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; +use crate::window_manager_event_listener; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; use parking_lot::Mutex; @@ -72,11 +73,18 @@ impl WindowManager { return Ok(()); } - tracing::info!( - "processing event: {event} for process {} with notification {}", - event.process_id(), - event.notification(), - ); + // don't want to spam logs for manually triggered hacks triggered + // from the input listener + if !matches!( + event, + WindowManagerEvent::Show(SystemNotification::Manual(_), _) + ) { + tracing::info!( + "processing event: {event} for process {} with notification {}", + event.process_id(), + event.notification(), + ); + } self.enforce_workspace_rules()?; @@ -113,10 +121,19 @@ impl WindowManager { )) => { // this means we have closed the 1st tab, so we need this window object to be reaped // and for the new 1st tab to be the key element of the window struct - event_tx().send(WindowManagerEvent::Show( - notification, - event.process_id(), - ))?; + if let Some(event) = + WindowManagerEvent::from_system_notification( + SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeFirstTabDestroyed, + ), + event.process_id(), + Some(window_id), + ) + { + window_manager_event_listener::send_notification( + event, + ); + } first_tab_destroyed = true; @@ -215,10 +232,19 @@ impl WindowManager { // if this fails, the app was probably open but windowless when komorebi // launched, so the window hasn't been registered - we should treat it // as a "Show" event - event_tx().send(WindowManagerEvent::Show( - notification, - event.process_id(), - ))? + if let Some(event) = + WindowManagerEvent::from_system_notification( + SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeWindowlessAppRestored, + ), + event.process_id(), + Some(window_id), + ) + { + window_manager_event_listener::send_notification( + event, + ); + } } } @@ -297,8 +323,16 @@ impl WindowManager { drop(tabbed_applications); if workspace.contains_window(window_id) { + if !matches!( + event, + WindowManagerEvent::Show(SystemNotification::Manual(_), _) + ) { + // don't want to spam logs for manually triggered hacks triggered + // from the input listener + tracing::debug!("ignoring show event for window already on workspace"); + } + // ignore bogus show events - tracing::debug!("ignoring show event for window already on workspace"); create = false; } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 3a51e9ff..8c32f202 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -26,7 +26,6 @@ use crate::accessibility::notification_constants::kAXWindowMiniaturizedNotificat use crate::accessibility::notification_constants::kAXWindowMovedNotification; use crate::accessibility::notification_constants::kAXWindowResizedNotification; use crate::application::Application; -use crate::ax_event_listener::event_tx; use crate::cf_dictionary_value; use crate::core::ApplicationIdentifier; use crate::core::config_generation::IdWithIdentifier; @@ -39,6 +38,7 @@ use crate::macos_api::MacosApi; use crate::reaper; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; +use crate::window_manager_event_listener; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use objc2::__framework_prelude::Retained; @@ -115,14 +115,12 @@ unsafe extern "C-unwind" fn window_observer_callback( window_id, ) { - if let Err(error) = event_tx().send(event) { - tracing::error!("failed to send window manager event: {error}"); - } else { - tracing::debug!( - "notification: {}, process: {process_id}, name: \"{name}\"", - notification, - ); - } + tracing::debug!( + "notification: {}, process: {process_id}, name: \"{name}\"", + notification, + ); + + window_manager_event_listener::send_notification(event); } } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 0cb79b3d..386a8af3 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -11,6 +11,14 @@ use strum::Display; pub enum SystemNotification { Accessibility(AccessibilityNotification), AppKitWorkspace(AppKitWorkspaceNotification), + Manual(ManualNotification), +} + +#[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] +pub enum ManualNotification { + ShowOnInputEvent, + ShowOnFocusChangeFirstTabDestroyed, + ShowOnFocusChangeWindowlessAppRestored, } #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] @@ -45,7 +53,14 @@ impl WindowManagerEvent { | SystemNotification::Accessibility(AccessibilityNotification::AXApplicationShown) | SystemNotification::AppKitWorkspace( AppKitWorkspaceNotification::NSWorkspaceDidLaunchApplicationNotification, - ) => Some(WindowManagerEvent::Show(notification, process_id)), + ) + | SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeWindowlessAppRestored, + ) + | SystemNotification::Manual(ManualNotification::ShowOnFocusChangeFirstTabDestroyed) + | SystemNotification::Manual(ManualNotification::ShowOnInputEvent) => { + Some(WindowManagerEvent::Show(notification, process_id)) + } SystemNotification::Accessibility(AccessibilityNotification::AXUIElementDestroyed) | SystemNotification::AppKitWorkspace( AppKitWorkspaceNotification::NSWorkspaceDidTerminateApplicationNotification, @@ -88,6 +103,7 @@ impl WindowManagerEvent { | WindowManagerEvent::Restore(n, _, _) => match n { SystemNotification::Accessibility(a) => a.to_string(), SystemNotification::AppKitWorkspace(a) => a.to_string(), + SystemNotification::Manual(m) => m.to_string(), }, } } diff --git a/komorebi/src/ax_event_listener.rs b/komorebi/src/window_manager_event_listener.rs similarity index 68% rename from komorebi/src/ax_event_listener.rs rename to komorebi/src/window_manager_event_listener.rs index 2afdd702..555e3641 100644 --- a/komorebi/src/ax_event_listener.rs +++ b/komorebi/src/window_manager_event_listener.rs @@ -10,10 +10,16 @@ fn channel() -> &'static (Sender, Receiver Sender { +fn event_tx() -> Sender { channel().0.clone() } pub fn event_rx() -> Receiver { channel().1.clone() } + +pub fn send_notification(notification: WindowManagerEvent) { + if event_tx().try_send(notification).is_err() { + tracing::warn!("channel is full; dropping notification") + } +} From d49de398b6e8927f5f67cdcbe94a99456c9160bc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 14:17:57 -0700 Subject: [PATCH 044/305] 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. --- komorebi/src/core/mod.rs | 3 + komorebi/src/process_command.rs | 56 +++++++++++++ komorebi/src/process_event.rs | 139 +++++++++++++++++++++++++++++++- komorebi/src/window.rs | 136 ++++++++++++++++++++++--------- komorebi/src/window_manager.rs | 75 +++++++++++++++++ komorebic/src/main.rs | 15 ++++ 6 files changed, 380 insertions(+), 44 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 5a1c4cad..dcdb4c7c 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -249,6 +249,9 @@ pub enum SocketMessage { VisibleWindows, MonitorInformation, Query(StateQuery), + SessionFloatRule, + SessionFloatRules, + ClearSessionFloatRules, } impl SocketMessage { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index a9ac0cc8..7384fcd5 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,9 +1,15 @@ +use crate::FLOATING_APPLICATIONS; +use crate::SESSION_FLOATING_APPLICATIONS; use crate::build; +use crate::core::ApplicationIdentifier; use crate::core::MoveBehaviour; use crate::core::SocketMessage; use crate::core::StateQuery; use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; +use crate::core::config_generation::IdWithIdentifier; +use crate::core::config_generation::MatchingRule; +use crate::core::config_generation::MatchingStrategy; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; @@ -12,6 +18,7 @@ use crate::monitor::Monitor; use crate::monitor::MonitorInformation; use crate::state::GlobalState; use crate::state::State; +use crate::window::AdhocWindow; use crate::window_manager::WindowManager; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; @@ -901,6 +908,55 @@ impl WindowManager { reply.write_all(response.as_bytes())?; } + SocketMessage::SessionFloatRule => { + let foreground_window = + MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?; + let (exe, title, role) = ( + AdhocWindow::exe(&foreground_window), + AdhocWindow::title(&foreground_window), + AdhocWindow::role(&foreground_window), + ); + + if let (Some(exe), Some(title), Some(role)) = (exe, title, role) { + let rule = MatchingRule::Composite(vec![ + IdWithIdentifier { + kind: ApplicationIdentifier::Exe, + id: exe, + matching_strategy: Option::from(MatchingStrategy::Equals), + }, + IdWithIdentifier { + kind: ApplicationIdentifier::Title, + id: title, + matching_strategy: Option::from(MatchingStrategy::Equals), + }, + IdWithIdentifier { + kind: ApplicationIdentifier::Class, + id: role, + matching_strategy: Option::from(MatchingStrategy::Equals), + }, + ]); + + let mut floating_applications = FLOATING_APPLICATIONS.lock(); + floating_applications.push(rule.clone()); + let mut session_floating_applications = SESSION_FLOATING_APPLICATIONS.lock(); + session_floating_applications.push(rule.clone()); + + self.toggle_float(true)?; + } + } + SocketMessage::SessionFloatRules => { + let session_floating_applications = SESSION_FLOATING_APPLICATIONS.lock(); + let rules = serde_json::to_string_pretty(&*session_floating_applications) + .unwrap_or_else(|error| error.to_string()); + + reply.write_all(rules.as_bytes())?; + } + SocketMessage::ClearSessionFloatRules => { + let mut floating_applications = FLOATING_APPLICATIONS.lock(); + let mut session_floating_applications = SESSION_FLOATING_APPLICATIONS.lock(); + floating_applications.retain(|r| !session_floating_applications.contains(r)); + session_floating_applications.clear() + } } self.update_known_window_ids(); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 66c1e518..217470d7 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,14 +1,19 @@ +use crate::FLOATING_APPLICATIONS; +use crate::REGEX_IDENTIFIERS; use crate::TABBED_APPLICATIONS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityApiError; use crate::accessibility::error::AccessibilityError; use crate::accessibility::notification_constants::AccessibilityNotification; +use crate::core::WindowContainerBehaviour; use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::macos_api::MacosApi; +use crate::window::AdhocWindow; use crate::window::Window; +use crate::window::should_act; use crate::window_manager::WindowManager; use crate::window_manager_event::ManualNotification; use crate::window_manager_event::SystemNotification; @@ -16,6 +21,7 @@ use crate::window_manager_event::WindowManagerEvent; use crate::window_manager_event_listener; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; +use color_eyre::eyre::OptionExt; use parking_lot::Mutex; use std::sync::Arc; use tracing::instrument; @@ -287,6 +293,10 @@ impl WindowManager { } // TODO: update this to work with floating applications / rules WindowManagerEvent::Show(_, process_id) => { + let focused_monitor_idx = self.focused_monitor_idx(); + let focused_workspace_idx = + self.focused_workspace_idx_for_monitor_idx(focused_monitor_idx)?; + let mut window_id = None; let mut window_element = None; let mut application_name = String::new(); @@ -348,7 +358,7 @@ impl WindowManager { "ignoring show event for window already associated with another workspace" ); - Window::hide_adhoc(window_id, element)?; + AdhocWindow::hide(window_id, element)?; create = false; } } @@ -356,14 +366,135 @@ impl WindowManager { if create && !tabbed_window { let application = self.application(process_id)?; if let Some(element) = window_element - && let Ok(window) = Window::new(element, application.clone()) + && let Ok(mut window) = Window::new(element, application.clone()) { window.observe(&self.run_loop)?; + let behaviour = self.window_management_behaviour( + focused_monitor_idx, + focused_workspace_idx, + ); let workspace = self.focused_workspace_mut()?; - workspace.new_container_for_window(&window)?; + let workspace_contains_window = workspace.contains_window(window.id); + let monocle_container = workspace.monocle_container.clone(); - self.update_focused_workspace(false, false)?; + let floating_applications = FLOATING_APPLICATIONS.lock(); + let mut should_float = false; + + if !floating_applications.is_empty() { + let regex_identifiers = REGEX_IDENTIFIERS.lock(); + + if let ( + Some(title), + Some(exe_name), + Some(role), + Some(subrole), + Some(path), + ) = ( + window.title(), + window.exe(), + window.role(), + window.subrole(), + window.path(), + ) { + should_float = should_act( + &title, + &exe_name, + &[&role, &subrole], + &path.to_string_lossy(), + &floating_applications, + ®ex_identifiers, + ) + .is_some(); + } + } + + if behaviour.float_override + || behaviour.floating_layer_override + // TODO: look into if we want to have a Manage command here too + || (should_float /*&& !matches!(event, WindowManagerEvent::Manage(_))*/ ) + { + let placement = if behaviour.floating_layer_override { + // Floating layer override placement + behaviour.floating_layer_placement + } else if behaviour.float_override { + // Float override placement + behaviour.float_override_placement + } else { + // Float rule placement + behaviour.float_rule_placement + }; + // Center floating windows according to the proper placement if not + // on a floating workspace + let center_spawned_floats = placement.should_center() && workspace.tile; + workspace.floating_windows_mut().push_back(window.clone()); + workspace.layer = WorkspaceLayer::Floating; + if center_spawned_floats { + let mut floating_window = window.clone(); + floating_window.center( + &workspace.globals.work_area, + placement.should_resize(), + )?; + } + + self.update_focused_workspace(false, false)?; + } else { + match behaviour.current_behaviour { + WindowContainerBehaviour::Create => { + workspace.new_container_for_window(&window)?; + workspace.layer = WorkspaceLayer::Tiling; + self.update_focused_workspace(false, false)?; + } + WindowContainerBehaviour::Append => { + workspace + .focused_container_mut() + .ok_or_eyre("there is no focused container")? + .add_window(&window)?; + workspace.layer = WorkspaceLayer::Tiling; + self.update_focused_workspace(true, false)?; + } + } + + // TODO: not sure if this is needed on macOS + if (self.focused_workspace()?.containers().len() == 1 + && self.focused_workspace()?.floating_windows().is_empty()) + || (self.focused_workspace()?.containers().is_empty() + && self.focused_workspace()?.floating_windows().len() == 1) + { + // If after adding this window the workspace only contains 1 window, it + // means it was previously empty and we focused the desktop to unfocus + // any previous window from other workspace, so now we need to focus + // this window again. This is needed because sometimes some windows + // first send the `FocusChange` event and only the `Show` event after + // and we will be focusing the desktop on the `FocusChange` event since + // it is still empty. + window.focus(self.mouse_follows_focus)?; + } + } + + if workspace_contains_window { + let mut monocle_window_event = false; + if let Some(ref monocle) = monocle_container + && let Some(monocle_window) = monocle.focused_window() + { + // we should have the window_id at this point + if monocle_window.id == window_id.unwrap_or_default() { + monocle_window_event = true; + } + } + + let workspace = self.focused_workspace()?; + if !(monocle_window_event || workspace.layer != WorkspaceLayer::Tiling) + && monocle_container.is_some() + { + window.hide()?; + } + } + + // let workspace = self.focused_workspace_mut()?; + // workspace.new_container_for_window(&window)?; + // + // self.update_focused_workspace(false, false)?; } } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 8c32f202..f9f4d908 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -12,6 +12,7 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXFocusedAttribute; use crate::accessibility::attribute_constants::kAXMainAttribute; use crate::accessibility::attribute_constants::kAXMinimizedAttribute; +use crate::accessibility::attribute_constants::kAXParentAttribute; use crate::accessibility::attribute_constants::kAXPositionAttribute; use crate::accessibility::attribute_constants::kAXRoleAttribute; use crate::accessibility::attribute_constants::kAXSizeAttribute; @@ -352,46 +353,6 @@ impl Window { Ok(()) } - #[tracing::instrument(skip_all)] - pub fn hide_adhoc( - id: u32, - element: &CFRetained, - ) -> Result<(), AccessibilityError> { - let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); - if let Entry::Vacant(entry) = window_restore_positions.entry(id) { - let rect = MacosApi::window_rect(element)?; - if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { - entry.insert(rect); - drop(window_restore_positions); - - // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API - let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); - - tracing::debug!( - "hiding window with id {id} and setting restore point to {},{}", - rect.origin.x, - rect.origin.y, - ); - - AccessibilityApi::set_attribute_ax_value( - element, - kAXPositionAttribute, - AXValueType::CGPoint, - hidden_rect.origin, - )?; - - AccessibilityApi::set_attribute_ax_value( - element, - kAXSizeAttribute, - AXValueType::CGSize, - hidden_rect.size, - )?; - } - } - - Ok(()) - } - pub fn minimize(&mut self) -> Result<(), AccessibilityError> { let cf_boolean = CFBoolean::new(true); let value = &**cf_boolean; @@ -742,6 +703,101 @@ impl Window { } } +pub struct AdhocWindow; + +impl AdhocWindow { + pub fn exe(element: &CFRetained) -> Option { + let parent = + AccessibilityApi::copy_attribute_value::(element, kAXParentAttribute)?; + + AccessibilityApi::copy_attribute_value::(&parent, kAXTitleAttribute) + .map(|s| s.to_string()) + } + + pub fn role(element: &CFRetained) -> Option { + AccessibilityApi::copy_attribute_value::(element, kAXRoleAttribute) + .map(|s| s.to_string()) + } + + pub fn subrole(element: &CFRetained) -> Option { + AccessibilityApi::copy_attribute_value::(element, kAXSubroleAttribute) + .map(|s| s.to_string()) + } + + pub fn title(element: &CFRetained) -> Option { + AccessibilityApi::copy_attribute_value::(element, kAXTitleAttribute) + .map(|s| s.to_string()) + } + + #[tracing::instrument(skip_all)] + pub fn hide(id: u32, element: &CFRetained) -> Result<(), AccessibilityError> { + let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); + if let Entry::Vacant(entry) = window_restore_positions.entry(id) { + let rect = MacosApi::window_rect(element)?; + if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { + entry.insert(rect); + drop(window_restore_positions); + + // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API + let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); + + tracing::debug!( + "hiding window with id {id} and setting restore point to {},{}", + rect.origin.x, + rect.origin.y, + ); + + AccessibilityApi::set_attribute_ax_value( + element, + kAXPositionAttribute, + AXValueType::CGPoint, + hidden_rect.origin, + )?; + + AccessibilityApi::set_attribute_ax_value( + element, + kAXSizeAttribute, + AXValueType::CGSize, + hidden_rect.size, + )?; + } + } + + Ok(()) + } + + #[tracing::instrument(skip_all)] + pub fn restore(id: u32, element: &CFRetained) -> Result<(), AccessibilityError> { + let mut should_remove_restore_position = false; + let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); + if let Some(cg_rect) = window_restore_positions.get(&id) { + tracing::debug!("restoring window with id {id} to {cg_rect:?}",); + + AccessibilityApi::set_attribute_ax_value( + element, + kAXPositionAttribute, + AXValueType::CGPoint, + cg_rect.origin, + )?; + + AccessibilityApi::set_attribute_ax_value( + element, + kAXSizeAttribute, + AXValueType::CGSize, + cg_rect.size, + )?; + + should_remove_restore_position = true; + } + + if should_remove_restore_position { + window_restore_positions.remove(&id); + } + + Ok(()) + } +} + impl From<&CFDictionary> for WindowInfo { fn from(value: &CFDictionary) -> Self { unsafe { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 1e3116fe..b30c265c 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -11,6 +11,7 @@ use crate::core::MoveBehaviour; use crate::core::OperationBehaviour; use crate::core::Placement; use crate::core::Sizing; +use crate::core::WindowContainerBehaviour; use crate::core::WindowManagementBehaviour; use crate::core::arrangement::Arrangement; use crate::core::arrangement::Axis; @@ -2193,4 +2194,78 @@ impl WindowManager { self.known_window_ids = known_window_ids; } } + + pub fn window_management_behaviour( + &self, + monitor_idx: usize, + workspace_idx: usize, + ) -> WindowManagementBehaviour { + if let Some(monitor) = self.monitors().get(monitor_idx) + && let Some(workspace) = monitor.workspaces().get(workspace_idx) + { + let current_behaviour = if let Some(behaviour) = workspace.window_container_behaviour { + if workspace.containers().is_empty() + && matches!(behaviour, WindowContainerBehaviour::Append) + { + // You can't append to an empty workspace + WindowContainerBehaviour::Create + } else { + behaviour + } + } else if workspace.containers().is_empty() + && matches!( + self.window_management_behaviour.current_behaviour, + WindowContainerBehaviour::Append + ) + { + // You can't append to an empty workspace + WindowContainerBehaviour::Create + } else { + self.window_management_behaviour.current_behaviour + }; + + let float_override = if let Some(float_override) = workspace.float_override { + float_override + } else { + self.window_management_behaviour.float_override + }; + + let floating_layer_behaviour = + if let Some(behaviour) = workspace.floating_layer_behaviour { + behaviour + } else { + monitor + .floating_layer_behaviour + .unwrap_or(self.window_management_behaviour.floating_layer_behaviour) + }; + + // If the workspace layer is `Floating` and the floating layer behaviour should + // float then change floating_layer_override to true so that new windows spawn + // as floating + let floating_layer_override = matches!(workspace.layer, WorkspaceLayer::Floating) + && floating_layer_behaviour.should_float(); + + return WindowManagementBehaviour { + current_behaviour, + float_override, + floating_layer_override, + floating_layer_behaviour, + toggle_float_placement: self.window_management_behaviour.toggle_float_placement, + floating_layer_placement: self.window_management_behaviour.floating_layer_placement, + float_override_placement: self.window_management_behaviour.float_override_placement, + float_rule_placement: self.window_management_behaviour.float_rule_placement, + }; + } + + WindowManagementBehaviour { + current_behaviour: WindowContainerBehaviour::Create, + float_override: self.window_management_behaviour.float_override, + floating_layer_override: self.window_management_behaviour.floating_layer_override, + floating_layer_behaviour: self.window_management_behaviour.floating_layer_behaviour, + toggle_float_placement: self.window_management_behaviour.toggle_float_placement, + floating_layer_placement: self.window_management_behaviour.floating_layer_placement, + float_override_placement: self.window_management_behaviour.float_override_placement, + float_rule_placement: self.window_management_behaviour.float_rule_placement, + } + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 1772babc..bcb1c6ce 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -392,6 +392,12 @@ enum SubCommand { /// Fetch the latest version of applications.json from komorebi-application-specific-configuration #[clap(alias = "fetch-asc")] FetchAppSpecificConfiguration, + /// Add a rule to float the foreground window for the rest of this session + SessionFloatRule, + /// Show all session float rules + SessionFloatRules, + /// Clear all session float rules + ClearSessionFloatRules, } fn print_query(message: &SocketMessage) { @@ -760,6 +766,15 @@ fn main() -> eyre::Result<()> { output_file.display().to_string().replace("\\", "/") ); } + SubCommand::SessionFloatRule => { + send_message(&SocketMessage::SessionFloatRule)?; + } + SubCommand::SessionFloatRules => { + print_query(&SocketMessage::SessionFloatRules); + } + SubCommand::ClearSessionFloatRules => { + send_message(&SocketMessage::ClearSessionFloatRules)?; + } } Ok(()) From a31dcbc54cd924356e7094c4424b135b03118397 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 14:31:42 -0700 Subject: [PATCH 045/305] 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. --- komorebi/src/input_event_listener.rs | 1 + komorebic/src/main.rs | 421 ++++++++++++++++++++++++--- 2 files changed, 376 insertions(+), 46 deletions(-) diff --git a/komorebi/src/input_event_listener.rs b/komorebi/src/input_event_listener.rs index f43e03b1..8a95db04 100644 --- a/komorebi/src/input_event_listener.rs +++ b/komorebi/src/input_event_listener.rs @@ -48,6 +48,7 @@ extern "C-unwind" fn callback( } unsafe { event_ref.as_mut() } } + impl InputEventListener { pub fn init(run_loop: &CFRunLoop) -> Option { let mouse_event_mask = (1 << CGEventType::LeftMouseUp.0) | (1 << CGEventType::KeyUp.0); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index bcb1c6ce..b5796764 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -204,22 +204,41 @@ struct Opts { #[derive(Parser)] enum SubCommand { - /// Start komorebi as a background process + // #[clap(hide = true)] + // Docgen, + // /// Gather example configurations for a new-user quickstart + // Quickstart, + /// Start komorebi.exe as a background process Start(Start), - /// Stop the komorebi process and restore all hidden windows + /// Stop the komorebi.exe process and restore all hidden windows + // komorebi for Windows signature + // Stop(Stop), Stop, + // /// Kill background processes started by komorebic + // Kill(Kill), + // /// Check komorebi configuration and related files for common errors + // Check(Check), /// Show the path to komorebi.json #[clap(alias = "config")] Configuration, - /// Show the path to komorebi's data directory in $HOME/Library/Application Support + // /// Show the path to komorebi.bar.json + // #[clap(alias = "bar-config")] + // #[clap(alias = "bconfig")] + // BarConfiguration, + // /// Show the path to whkdrc + // #[clap(alias = "whkd")] + // Whkdrc, + /// Show the path to komorebi's data directory in %LOCALAPPDATA% #[clap(alias = "datadir")] DataDirectory, - /// Tail komorebi's process logs (cancel with Ctrl-C) - Log, /// Show a JSON representation of the current window manager state State, /// Show a JSON representation of the current global state GlobalState, + // /// Launch the komorebi-gui debugging tool + // Gui, + // /// Toggle the komorebi-shortcuts helper + // ToggleShortcuts, /// Show a JSON representation of visible windows VisibleWindows, /// Show information about connected monitors @@ -228,21 +247,60 @@ enum SubCommand { /// Query the current window manager state #[clap(arg_required_else_help = true)] Query(Query), + // /// Subscribe to komorebi events using a Unix Domain Socket + // #[clap(arg_required_else_help = true)] + // SubscribeSocket(SubscribeSocket), + // /// Unsubscribe from komorebi events + // #[clap(arg_required_else_help = true)] + // UnsubscribeSocket(UnsubscribeSocket), + // /// Subscribe to komorebi events using a Named Pipe + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "subscribe")] + // SubscribePipe(SubscribePipe), + // /// Unsubscribe from komorebi events + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "unsubscribe")] + // UnsubscribePipe(UnsubscribePipe), + /// Tail komorebi.exe's process logs (cancel with Ctrl-C) + Log, + // /// Quicksave the current resize layout dimensions + // #[clap(alias = "quick-save")] + // QuickSaveResize, + // /// Load the last quicksaved resize layout dimensions + // #[clap(alias = "quick-load")] + // QuickLoadResize, + // /// Save the current resize layout dimensions to a file + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "save")] + // SaveResize(SaveResize), + // /// Load the resize layout dimensions from a file + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "load")] + // LoadResize(LoadResize), /// Change focus to the window in the specified direction #[clap(arg_required_else_help = true)] Focus(Focus), /// Move the focused window in the specified direction #[clap(arg_required_else_help = true)] Move(Move), - /// Stack the focused window in the specified direction - #[clap(arg_required_else_help = true)] - Stack(Stack), + // /// Minimize the focused window + // Minimize, + // /// Close the focused window + // Close, + // /// Forcibly focus the window at the cursor with a left mouse click + // ForceFocus, /// Change focus to the window in the specified cycle direction #[clap(arg_required_else_help = true)] CycleFocus(CycleFocus), /// Move the focused window in the specified cycle direction #[clap(arg_required_else_help = true)] CycleMove(CycleMove), + // /// Focus the first managed window matching the given exe + // #[clap(arg_required_else_help = true)] + // EagerFocus(EagerFocus), + /// Stack the focused window in the specified direction + #[clap(arg_required_else_help = true)] + Stack(Stack), /// Unstack the focused window Unstack, /// Cycle the focused stack in the specified cycle direction @@ -265,29 +323,6 @@ enum SubCommand { /// Resize the focused window or primary column along the specified axis #[clap(arg_required_else_help = true)] ResizeAxis(ResizeAxis), - /// Toggle the paused state for all window tiling - TogglePause, - /// Toggle monocle mode for the focused container - ToggleMonocle, - /// Toggle floating mode for the focused window - ToggleFloat, - /// Toggle between the Tiling and Floating layers on the focused workspace - ToggleWorkspaceLayer, - /// Set the layout on the focused workspace - #[clap(arg_required_else_help = true)] - ChangeLayout(ChangeLayout), - /// Cycle between available layouts - #[clap(arg_required_else_help = true)] - CycleLayout(CycleLayout), - /// Flip the layout on the focused workspace - #[clap(arg_required_else_help = true)] - FlipLayout(FlipLayout), - /// Promote the focused window to the top of the tree - Promote, - /// Promote the user focus to the top of the tree - PromoteFocus, - /// Promote the window in the specified direction - PromoteWindow(PromoteWindow), /// Move the focused window to the specified monitor #[clap(arg_required_else_help = true)] MoveToMonitor(MoveToMonitor), @@ -328,15 +363,6 @@ enum SubCommand { SendToLastWorkspace, /// Move the focused window to the last focused monitor workspace MoveToLastWorkspace, - /// Move the focused workspace to the specified monitor - #[clap(arg_required_else_help = true)] - MoveWorkspaceToMonitor(MoveWorkspaceToMonitor), - /// Move the focused workspace monitor in the given cycle direction - #[clap(arg_required_else_help = true)] - CycleMoveWorkspaceToMonitor(CycleMoveWorkspaceToMonitor), - /// Swap focused monitor workspaces with specified monitor - #[clap(arg_required_else_help = true)] - SwapWorkspacesWithMonitor(SwapWorkspacesWithMonitor), /// Focus the specified monitor #[clap(arg_required_else_help = true)] FocusMonitor(FocusMonitor), @@ -366,11 +392,138 @@ enum SubCommand { CycleWorkspace(CycleWorkspace), /// Focus the next empty workspace in the given cycle direction (if one exists) #[clap(arg_required_else_help = true)] - CycleEmptyWorkspace(CycleEmptyWorkspace), - /// Force the retiling of all managed windows - Retile, + CycleEmptyWorkspace(CycleWorkspace), + /// Move the focused workspace to the specified monitor + #[clap(arg_required_else_help = true)] + MoveWorkspaceToMonitor(MoveWorkspaceToMonitor), + /// Move the focused workspace monitor in the given cycle direction + #[clap(arg_required_else_help = true)] + CycleMoveWorkspaceToMonitor(CycleMoveWorkspaceToMonitor), + /// Swap focused monitor workspaces with specified monitor + #[clap(arg_required_else_help = true)] + SwapWorkspacesWithMonitor(SwapWorkspacesWithMonitor), + // /// Create and append a new workspace on the focused monitor + // NewWorkspace, + // /// Set the resize delta (used by resize-edge and resize-axis) + // #[clap(arg_required_else_help = true)] + // ResizeDelta(ResizeDelta), + // /// Set the invisible border dimensions around each window + // #[clap(arg_required_else_help = true)] + // InvisibleBorders(InvisibleBorders), + // /// Set offsets to exclude parts of the work area from tiling + // #[clap(arg_required_else_help = true)] + // GlobalWorkAreaOffset(GlobalWorkAreaOffset), + // /// Set offsets for a monitor to exclude parts of the work area from tiling + // #[clap(arg_required_else_help = true)] + // MonitorWorkAreaOffset(MonitorWorkAreaOffset), + // /// Set offsets for a workspace to exclude parts of the work area from tiling + // #[clap(arg_required_else_help = true)] + // WorkspaceWorkAreaOffset(WorkspaceWorkAreaOffset), /// Toggle application of the window-based work area offset for the focused workspace ToggleWindowBasedWorkAreaOffset, + // /// Set container padding on the focused workspace + // #[clap(arg_required_else_help = true)] + // FocusedWorkspaceContainerPadding(FocusedWorkspaceContainerPadding), + // /// Set workspace padding on the focused workspace + // #[clap(arg_required_else_help = true)] + // FocusedWorkspacePadding(FocusedWorkspacePadding), + // /// Adjust container padding on the focused workspace + // #[clap(arg_required_else_help = true)] + // AdjustContainerPadding(AdjustContainerPadding), + // /// Adjust workspace padding on the focused workspace + // #[clap(arg_required_else_help = true)] + // AdjustWorkspacePadding(AdjustWorkspacePadding), + /// Set the layout on the focused workspace + #[clap(arg_required_else_help = true)] + ChangeLayout(ChangeLayout), + /// Cycle between available layouts + #[clap(arg_required_else_help = true)] + CycleLayout(CycleLayout), + // /// Set the number of visible columns for the Scrolling layout on the focused workspace + // #[clap(arg_required_else_help = true)] + // ScrollingLayoutColumns(ScrollingLayoutColumns), + // /// Load a custom layout from file for the focused workspace + // #[clap(hide = true)] + // #[clap(arg_required_else_help = true)] + // LoadCustomLayout(LoadCustomLayout), + /// Flip the layout on the focused workspace + #[clap(arg_required_else_help = true)] + FlipLayout(FlipLayout), + /// Promote the focused window to the top of the tree + Promote, + /// Promote the user focus to the top of the tree + PromoteFocus, + /// Promote the window in the specified direction + PromoteWindow(PromoteWindow), + /// Force the retiling of all managed windows + Retile, + // /// Set the monitor index preference for a monitor identified using its size + // #[clap(arg_required_else_help = true)] + // MonitorIndexPreference(MonitorIndexPreference), + // /// Set the display index preference for a monitor identified using its display name + // #[clap(arg_required_else_help = true)] + // DisplayIndexPreference(DisplayIndexPreference), + // /// Create at least this many workspaces for the specified monitor + // #[clap(arg_required_else_help = true)] + // EnsureWorkspaces(EnsureWorkspaces), + // /// Create these many named workspaces for the specified monitor + // #[clap(arg_required_else_help = true)] + // EnsureNamedWorkspaces(EnsureNamedWorkspaces), + // /// Set the container padding for the specified workspace + // #[clap(arg_required_else_help = true)] + // ContainerPadding(ContainerPadding), + // /// Set the container padding for the specified workspace + // #[clap(arg_required_else_help = true)] + // NamedWorkspaceContainerPadding(NamedWorkspaceContainerPadding), + // /// Set the workspace padding for the specified workspace + // #[clap(arg_required_else_help = true)] + // WorkspacePadding(WorkspacePadding), + // /// Set the workspace padding for the specified workspace + // #[clap(arg_required_else_help = true)] + // NamedWorkspacePadding(NamedWorkspacePadding), + // /// Set the layout for the specified workspace + // #[clap(arg_required_else_help = true)] + // WorkspaceLayout(WorkspaceLayout), + // /// Set the layout for the specified workspace + // #[clap(arg_required_else_help = true)] + // NamedWorkspaceLayout(NamedWorkspaceLayout), + // /// Set a custom layout for the specified workspace + // #[clap(hide = true)] + // #[clap(arg_required_else_help = true)] + // WorkspaceCustomLayout(WorkspaceCustomLayout), + // /// Set a custom layout for the specified workspace + // #[clap(hide = true)] + // #[clap(arg_required_else_help = true)] + // NamedWorkspaceCustomLayout(NamedWorkspaceCustomLayout), + // /// Add a dynamic layout rule for the specified workspace + // #[clap(arg_required_else_help = true)] + // WorkspaceLayoutRule(WorkspaceLayoutRule), + // /// Add a dynamic layout rule for the specified workspace + // #[clap(arg_required_else_help = true)] + // NamedWorkspaceLayoutRule(NamedWorkspaceLayoutRule), + // /// Add a dynamic custom layout for the specified workspace + // #[clap(hide = true)] + // #[clap(arg_required_else_help = true)] + // WorkspaceCustomLayoutRule(WorkspaceCustomLayoutRule), + // /// Add a dynamic custom layout for the specified workspace + // #[clap(hide = true)] + // #[clap(arg_required_else_help = true)] + // NamedWorkspaceCustomLayoutRule(NamedWorkspaceCustomLayoutRule), + // /// Clear all dynamic layout rules for the specified workspace + // #[clap(arg_required_else_help = true)] + // ClearWorkspaceLayoutRules(ClearWorkspaceLayoutRules), + // /// Clear all dynamic layout rules for the specified workspace + // #[clap(arg_required_else_help = true)] + // ClearNamedWorkspaceLayoutRules(ClearNamedWorkspaceLayoutRules), + // /// Enable or disable window tiling for the specified workspace + // #[clap(arg_required_else_help = true)] + // WorkspaceTiling(WorkspaceTiling), + // /// Enable or disable window tiling for the specified workspace + // #[clap(arg_required_else_help = true)] + // NamedWorkspaceTiling(NamedWorkspaceTiling), + // /// Set the workspace name for the specified workspace + // #[clap(arg_required_else_help = true)] + // WorkspaceName(WorkspaceName), /// Toggle the behaviour for new windows (stacking or dynamic tiling) ToggleWindowContainerBehaviour, /// Enable or disable float override, which makes it so every new window opens in floating mode @@ -383,21 +536,197 @@ enum SubCommand { /// mode, for the currently focused workspace. If there was no override value set for the /// workspace previously it takes the opposite of the global value. ToggleWorkspaceFloatOverride, + /// Toggle between the Tiling and Floating layers on the focused workspace + ToggleWorkspaceLayer, + /// Toggle the paused state for all window tiling + TogglePause, /// Toggle window tiling on the focused workspace ToggleTiling, + /// Toggle floating mode for the focused window + ToggleFloat, + /// Toggle monocle mode for the focused container + ToggleMonocle, + // /// Toggle native maximization for the focused window + // ToggleMaximize, /// Toggle a lock for the focused container, ensuring it will not be displaced by any new windows ToggleLock, + // /// Restore all hidden windows (debugging command) + // RestoreWindows, + // /// Force komorebi to manage the focused window + // Manage, + // /// Unmanage a window that was forcibly managed + // Unmanage, + // /// Replace the configuration of a running instance of komorebi from a static configuration file + // #[clap(arg_required_else_help = true)] + // ReplaceConfiguration(ReplaceConfiguration), + // /// Reload legacy komorebi.ahk or komorebi.ps1 configurations (if they exist) + // ReloadConfiguration, + // /// Enable or disable watching of legacy komorebi.ahk or komorebi.ps1 configurations (if they exist) + // #[clap(arg_required_else_help = true)] + // WatchConfiguration(WatchConfiguration), + // /// For legacy komorebi.ahk or komorebi.ps1 configurations, signal that the final configuration option has been sent + // CompleteConfiguration, + // /// DEPRECATED since v0.1.22 + // #[clap(arg_required_else_help = true)] + // #[clap(hide = true)] + // AltFocusHack(AltFocusHack), + // /// Set the window behaviour when switching workspaces / cycling stacks + // #[clap(arg_required_else_help = true)] + // WindowHidingBehaviour(WindowHidingBehaviour), + // /// Set the behaviour when moving windows across monitor boundaries + // #[clap(arg_required_else_help = true)] + // CrossMonitorMoveBehaviour(CrossMonitorMoveBehaviour), /// Toggle the behaviour when moving windows across monitor boundaries ToggleCrossMonitorMoveBehaviour, - /// Fetch the latest version of applications.json from komorebi-application-specific-configuration - #[clap(alias = "fetch-asc")] - FetchAppSpecificConfiguration, + // /// Set the operation behaviour when the focused window is not managed + // #[clap(arg_required_else_help = true)] + // UnmanagedWindowOperationBehaviour(UnmanagedWindowOperationBehaviour), /// Add a rule to float the foreground window for the rest of this session SessionFloatRule, /// Show all session float rules SessionFloatRules, /// Clear all session float rules ClearSessionFloatRules, + // /// Add a rule to ignore the specified application + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "float-rule")] + // IgnoreRule(IgnoreRule), + // /// Add a rule to always manage the specified application + // #[clap(arg_required_else_help = true)] + // ManageRule(ManageRule), + // /// Add a rule to associate an application with a workspace on first show + // #[clap(arg_required_else_help = true)] + // InitialWorkspaceRule(InitialWorkspaceRule), + // /// Add a rule to associate an application with a named workspace on first show + // #[clap(arg_required_else_help = true)] + // InitialNamedWorkspaceRule(InitialNamedWorkspaceRule), + // /// Add a rule to associate an application with a workspace + // #[clap(arg_required_else_help = true)] + // WorkspaceRule(WorkspaceRule), + // /// Add a rule to associate an application with a named workspace + // #[clap(arg_required_else_help = true)] + // NamedWorkspaceRule(NamedWorkspaceRule), + // /// Remove all application association rules for a workspace by monitor and workspace index + // #[clap(arg_required_else_help = true)] + // ClearWorkspaceRules(ClearWorkspaceRules), + // /// Remove all application association rules for a named workspace + // #[clap(arg_required_else_help = true)] + // ClearNamedWorkspaceRules(ClearNamedWorkspaceRules), + // /// Remove all application association rules for all workspaces + // ClearAllWorkspaceRules, + // /// Enforce all workspace rules, including initial workspace rules that have already been applied + // EnforceWorkspaceRules, + // /// Identify an application that sends EVENT_OBJECT_NAMECHANGE on launch + // #[clap(arg_required_else_help = true)] + // IdentifyObjectNameChangeApplication(IdentifyObjectNameChangeApplication), + // /// Identify an application that closes to the system tray + // #[clap(arg_required_else_help = true)] + // IdentifyTrayApplication(IdentifyTrayApplication), + // /// Identify an application that has WS_EX_LAYERED, but should still be managed + // #[clap(arg_required_else_help = true)] + // IdentifyLayeredApplication(IdentifyLayeredApplication), + // /// Whitelist an application for title bar removal + // #[clap(arg_required_else_help = true)] + // RemoveTitleBar(RemoveTitleBar), + // /// Toggle title bars for whitelisted applications + // ToggleTitleBars, + // /// Identify an application that has overflowing borders + // #[clap(hide = true)] + // #[clap(alias = "identify-border-overflow")] + // IdentifyBorderOverflowApplication(IdentifyBorderOverflowApplication), + // /// Enable or disable borders + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "active-window-border")] + // Border(Border), + // /// Set the colour for a window border kind + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "active-window-border-colour")] + // BorderColour(BorderColour), + // /// Set the border width + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "active-window-border-width")] + // BorderWidth(BorderWidth), + // /// Set the border offset + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "active-window-border-offset")] + // BorderOffset(BorderOffset), + // /// Set the border style + // #[clap(arg_required_else_help = true)] + // BorderStyle(BorderStyle), + // /// Set the border implementation + // #[clap(arg_required_else_help = true)] + // BorderImplementation(BorderImplementation), + // /// Set the stackbar mode + // #[clap(arg_required_else_help = true)] + // StackbarMode(StackbarMode), + // /// Enable or disable transparency for unfocused windows + // #[clap(arg_required_else_help = true)] + // Transparency(Transparency), + // /// Set the alpha value for unfocused window transparency + // #[clap(arg_required_else_help = true)] + // TransparencyAlpha(TransparencyAlpha), + // /// Toggle transparency for unfocused windows + // ToggleTransparency, + // /// Enable or disable movement animations + // #[clap(arg_required_else_help = true)] + // Animation(Animation), + // /// Set the duration for movement animations in ms + // #[clap(arg_required_else_help = true)] + // AnimationDuration(AnimationDuration), + // /// Set the frames per second for movement animations + // #[clap(arg_required_else_help = true)] + // AnimationFps(AnimationFps), + // /// Set the ease function for movement animations + // #[clap(arg_required_else_help = true)] + // AnimationStyle(AnimationStyle), + // /// Enable or disable focus follows mouse for the operating system + // #[clap(hide = true)] + // #[clap(arg_required_else_help = true)] + // FocusFollowsMouse(FocusFollowsMouse), + // /// Toggle focus follows mouse for the operating system + // #[clap(hide = true)] + // #[clap(arg_required_else_help = true)] + // ToggleFocusFollowsMouse(ToggleFocusFollowsMouse), + // /// Enable or disable mouse follows focus on all workspaces + // #[clap(arg_required_else_help = true)] + // MouseFollowsFocus(MouseFollowsFocus), + // /// Toggle mouse follows focus on all workspaces + // ToggleMouseFollowsFocus, + // /// Generate common app-specific configurations and fixes to use in komorebi.ahk + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "ahk-asc")] + // AhkAppSpecificConfiguration(AhkAppSpecificConfiguration), + // /// Generate common app-specific configurations and fixes in a PowerShell script + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "pwsh-asc")] + // PwshAppSpecificConfiguration(PwshAppSpecificConfiguration), + // /// Convert a v1 ASC YAML file to a v2 ASC JSON file + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "convert-asc")] + // ConvertAppSpecificConfiguration(ConvertAppSpecificConfiguration), + // /// Format a YAML file for use with the 'app-specific-configuration' command + // #[clap(arg_required_else_help = true)] + // #[clap(alias = "fmt-asc")] + // #[clap(hide = true)] + // FormatAppSpecificConfiguration(FormatAppSpecificConfiguration), + /// Fetch the latest version of applications.json from komorebi-application-specific-configuration + #[clap(alias = "fetch-asc")] + FetchAppSpecificConfiguration, + // /// Generate a JSON Schema for applications.json + // #[clap(alias = "asc-schema")] + // ApplicationSpecificConfigurationSchema, + // /// Generate a JSON Schema of subscription notifications + // NotificationSchema, + // /// Generate a JSON Schema of socket messages + // SocketSchema, + // /// Generate a JSON Schema of the static configuration file + // StaticConfigSchema, + // /// Generates a static configuration JSON file based on the current window manager state + // GenerateStaticConfig, + // /// Generates the komorebi.lnk shortcut in shell:startup to autostart komorebi + // EnableAutostart(EnableAutostart), + // /// Deletes the komorebi.lnk shortcut in shell:startup to disable autostart + // DisableAutostart, } fn print_query(message: &SocketMessage) { From dddd79d39dfee9713d254ad32909393635e01289 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 14:37:19 -0700 Subject: [PATCH 046/305] 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. --- komorebi/src/core/mod.rs | 155 ++++++++++++++++++++++++++++++++++----- 1 file changed, 138 insertions(+), 17 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index dcdb4c7c..1d24faf3 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -175,6 +175,7 @@ pub enum StateQuery { Version, } +// serde_as must be before derive #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] #[serde(tag = "type", content = "content")] @@ -210,23 +211,53 @@ pub enum SocketMessage { CycleMoveWorkspaceToMonitor(CycleDirection), MoveWorkspaceToMonitorNumber(usize), SwapWorkspacesToMonitorNumber(usize), - ChangeLayout(DefaultLayout), - CycleLayout(CycleDirection), - FlipLayout(Axis), - ToggleWorkspaceWindowContainerBehaviour, - ToggleWorkspaceFloatOverride, + // ForceFocus, + // Close, + // Minimize, + Promote, + PromoteFocus, + PromoteWindow(OperationDirection), + // EagerFocus(String), + // LockMonitorWorkspaceContainer(usize, usize, usize), + // UnlockMonitorWorkspaceContainer(usize, usize, usize), ToggleLock, ToggleFloat, ToggleMonocle, + // ToggleMaximize, ToggleWindowContainerBehaviour, ToggleFloatOverride, + // WindowHidingBehaviour(HidingBehaviour), ToggleCrossMonitorMoveBehaviour, + // CrossMonitorMoveBehaviour(MoveBehaviour), + // UnmanagedWindowOperationBehaviour(OperationBehaviour), + // Current Workspace Commands + // ManageFocusedWindow, + // UnmanageFocusedWindow, + // AdjustContainerPadding(Sizing, i32), + // AdjustWorkspacePadding(Sizing, i32), + ChangeLayout(DefaultLayout), + CycleLayout(CycleDirection), + // ScrollingLayoutColumns(NonZeroUsize), + // ChangeLayoutCustom(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + FlipLayout(Axis), + ToggleWorkspaceWindowContainerBehaviour, + ToggleWorkspaceFloatOverride, + // Monitor and Workspace Commands + // MonitorIndexPreference(usize, i32, i32, i32, i32), + // DisplayIndexPreference(usize, String), + // EnsureWorkspaces(usize, usize), + // EnsureNamedWorkspaces(usize, Vec), + // NewWorkspace, ToggleTiling, - ToggleWindowBasedWorkAreaOffset, + // Stop, + // StopIgnoreRestore, TogglePause, - ToggleWorkspaceLayer, - // TODO: look into maximized windows - // ToggleMaximize, + Retile, + RetileWithResizeDimensions, + // QuickSave, + // QuickLoad, + // Save(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + // Load(#[serde_as(as = "ResolvedPathBuf")] PathBuf), CycleFocusMonitor(CycleDirection), CycleFocusWorkspace(CycleDirection), CycleFocusEmptyWorkspace(CycleDirection), @@ -238,20 +269,110 @@ pub enum SocketMessage { FocusWorkspaceNumbers(usize), FocusMonitorWorkspaceNumber(usize, usize), FocusNamedWorkspace(String), - Retile, - RetileWithResizeDimensions, - Promote, - PromoteFocus, - PromoteWindow(OperationDirection), + // ContainerPadding(usize, usize, i32), + // NamedWorkspaceContainerPadding(String, i32), + // FocusedWorkspaceContainerPadding(i32), + // WorkspacePadding(usize, usize, i32), + // NamedWorkspacePadding(String, i32), + // FocusedWorkspacePadding(i32), + // WorkspaceTiling(usize, usize, bool), + // NamedWorkspaceTiling(String, bool), + // WorkspaceName(usize, usize, String), + // WorkspaceLayout(usize, usize, DefaultLayout), + // NamedWorkspaceLayout(String, DefaultLayout), + // WorkspaceLayoutCustom(usize, usize, #[serde_as(as = "ResolvedPathBuf")] PathBuf), + // NamedWorkspaceLayoutCustom(String, #[serde_as(as = "ResolvedPathBuf")] PathBuf), + // WorkspaceLayoutRule(usize, usize, usize, DefaultLayout), + // NamedWorkspaceLayoutRule(String, usize, DefaultLayout), + // WorkspaceLayoutCustomRule( + // usize, + // usize, + // usize, + // #[serde_as(as = "ResolvedPathBuf")] PathBuf, + // ), + // NamedWorkspaceLayoutCustomRule(String, usize, #[serde_as(as = "ResolvedPathBuf")] PathBuf), + // ClearWorkspaceLayoutRules(usize, usize), + // ClearNamedWorkspaceLayoutRules(String), + ToggleWorkspaceLayer, + // Configuration + // ReloadConfiguration, + // ReplaceConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), ReloadStaticConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + // WatchConfiguration(bool), + // CompleteConfiguration, + // AltFocusHack(bool), + // Theme(Box), + // Animation(bool, Option), + // AnimationDuration(u64, Option), + // AnimationFps(u64), + // AnimationStyle(AnimationStyle, Option), + // #[serde(alias = "ActiveWindowBorder")] + // Border(bool), + // #[serde(alias = "ActiveWindowBorderColour")] + // BorderColour(WindowKind, u32, u32, u32), + // #[serde(alias = "ActiveWindowBorderStyle")] + // BorderStyle(BorderStyle), + // BorderWidth(i32), + // BorderOffset(i32), + // BorderImplementation(BorderImplementation), + // Transparency(bool), + // ToggleTransparency, + // TransparencyAlpha(u8), + // InvisibleBorders(Rect), + // StackbarMode(StackbarMode), + // StackbarLabel(StackbarLabel), + // StackbarFocusedTextColour(u32, u32, u32), + // StackbarUnfocusedTextColour(u32, u32, u32), + // StackbarBackgroundColour(u32, u32, u32), + // StackbarHeight(i32), + // StackbarTabWidth(i32), + // StackbarFontSize(i32), + // StackbarFontFamily(Option), + // WorkAreaOffset(Rect), + // MonitorWorkAreaOffset(usize, Rect), + // WorkspaceWorkAreaOffset(usize, usize, Rect), + ToggleWindowBasedWorkAreaOffset, + // ResizeDelta(i32), + // InitialWorkspaceRule(ApplicationIdentifier, String, usize, usize), + // InitialNamedWorkspaceRule(ApplicationIdentifier, String, String), + // WorkspaceRule(ApplicationIdentifier, String, usize, usize), + // NamedWorkspaceRule(ApplicationIdentifier, String, String), + // ClearWorkspaceRules(usize, usize), + // ClearNamedWorkspaceRules(String), + // ClearAllWorkspaceRules, + // EnforceWorkspaceRules, + SessionFloatRule, + SessionFloatRules, + ClearSessionFloatRules, + #[serde(alias = "FloatRule")] + // IgnoreRule(ApplicationIdentifier, String), + // ManageRule(ApplicationIdentifier, String), + // IdentifyObjectNameChangeApplication(ApplicationIdentifier, String), + // IdentifyTrayApplication(ApplicationIdentifier, String), + // IdentifyLayeredApplication(ApplicationIdentifier, String), + // IdentifyBorderOverflowApplication(ApplicationIdentifier, String), State, GlobalState, VisibleWindows, MonitorInformation, Query(StateQuery), - SessionFloatRule, - SessionFloatRules, - ClearSessionFloatRules, + // FocusFollowsMouse(FocusFollowsMouseImplementation, bool), + // ToggleFocusFollowsMouse(FocusFollowsMouseImplementation), + // MouseFollowsFocus(bool), + // ToggleMouseFollowsFocus, + // RemoveTitleBar(ApplicationIdentifier, String), + // ToggleTitleBars, + // AddSubscriberSocket(String), + // AddSubscriberSocketWithOptions(String, SubscribeOptions), + // RemoveSubscriberSocket(String), + // AddSubscriberPipe(String), + // RemoveSubscriberPipe(String), + // ApplicationSpecificConfigurationSchema, + // NotificationSchema, + // SocketSchema, + // StaticConfigSchema, + // GenerateStaticConfig, + // DebugWindow(isize), } impl SocketMessage { From 10aabdac2c1bfd33627aad214fbe16a183ba8672 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 15:04:52 -0700 Subject: [PATCH 047/305] 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. --- komorebi/src/workspace.rs | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index c1b3fbb4..5c8f647c 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -18,6 +18,7 @@ use color_eyre::eyre; use color_eyre::eyre::OptionExt; use serde::Deserialize; use serde::Serialize; +use std::collections::HashMap; use std::fmt::Display; use std::fmt::Formatter; use std::num::NonZeroUsize; @@ -287,6 +288,55 @@ impl Workspace { insertion_idx } + pub fn prune_duplicate_windows(&mut self) -> eyre::Result<()> { + let mut tracker = HashMap::new(); + let mut to_prune_from_containers = vec![]; + let mut to_prune_from_floating = vec![]; + + for container in self.containers() { + for window in container.windows() { + let entry = tracker.entry(window.id).or_insert(0); + *entry += 1; + } + } + + if let Some(container) = &self.monocle_container { + for window in container.windows() { + let entry = tracker.entry(window.id).or_insert(0); + *entry += 1; + } + } + + for (window_id, count) in &tracker { + if *count > 1 { + to_prune_from_containers.push(*window_id); + } + } + + for id in to_prune_from_containers { + self.remove_window(id)?; + tracker.remove(&id); + } + + for window in self.floating_windows() { + let entry = tracker.entry(window.id).or_insert(0); + *entry += 1; + } + + for (window_id, count) in &tracker { + if *count > 1 { + to_prune_from_floating.push(*window_id); + } + } + + for id in to_prune_from_floating { + self.remove_window(id)?; + tracker.remove(&id); + } + + Ok(()) + } + #[tracing::instrument(skip(self))] pub fn reap_invalid_windows_for_application( &mut self, @@ -891,6 +941,7 @@ impl Workspace { impl Workspace { pub fn update(&mut self) -> eyre::Result<()> { // make sure we are never holding on to empty containers + self.prune_duplicate_windows()?; self.containers_mut().retain(|c| !c.windows().is_empty()); let container_padding = self From 7178609daf7b65f1a57871af0050b4c263ad4801 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 19:33:29 -0700 Subject: [PATCH 048/305] 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. --- komorebi-client/src/lib.rs | 1 + komorebi/src/core/mod.rs | 20 ++-- komorebi/src/process_command.rs | 202 ++++++++++++++++++++++++++++++++ komorebic/src/main.rs | 193 +++++++++++++++++++++++++----- 4 files changed, 377 insertions(+), 39 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 1043b01e..f5e02391 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,4 +1,5 @@ pub use komorebi::DATA_DIR; +pub use komorebi::core::ApplicationIdentifier; pub use komorebi::core::Sizing; pub use komorebi::core::SocketMessage; pub use komorebi::core::StateQuery; diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 1d24faf3..fc268b3a 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -333,20 +333,20 @@ pub enum SocketMessage { // WorkspaceWorkAreaOffset(usize, usize, Rect), ToggleWindowBasedWorkAreaOffset, // ResizeDelta(i32), - // InitialWorkspaceRule(ApplicationIdentifier, String, usize, usize), - // InitialNamedWorkspaceRule(ApplicationIdentifier, String, String), - // WorkspaceRule(ApplicationIdentifier, String, usize, usize), - // NamedWorkspaceRule(ApplicationIdentifier, String, String), - // ClearWorkspaceRules(usize, usize), - // ClearNamedWorkspaceRules(String), - // ClearAllWorkspaceRules, - // EnforceWorkspaceRules, + InitialWorkspaceRule(ApplicationIdentifier, String, usize, usize), + InitialNamedWorkspaceRule(ApplicationIdentifier, String, String), + WorkspaceRule(ApplicationIdentifier, String, usize, usize), + NamedWorkspaceRule(ApplicationIdentifier, String, String), + ClearWorkspaceRules(usize, usize), + ClearNamedWorkspaceRules(String), + ClearAllWorkspaceRules, + EnforceWorkspaceRules, SessionFloatRule, SessionFloatRules, ClearSessionFloatRules, #[serde(alias = "FloatRule")] - // IgnoreRule(ApplicationIdentifier, String), - // ManageRule(ApplicationIdentifier, String), + IgnoreRule(ApplicationIdentifier, String), + ManageRule(ApplicationIdentifier, String), // IdentifyObjectNameChangeApplication(ApplicationIdentifier, String), // IdentifyTrayApplication(ApplicationIdentifier, String), // IdentifyLayeredApplication(ApplicationIdentifier, String), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7384fcd5..394fc79a 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,5 +1,8 @@ use crate::FLOATING_APPLICATIONS; +use crate::IGNORE_IDENTIFIERS; +use crate::MANAGE_IDENTIFIERS; use crate::SESSION_FLOATING_APPLICATIONS; +use crate::WORKSPACE_MATCHING_RULES; use crate::build; use crate::core::ApplicationIdentifier; use crate::core::MoveBehaviour; @@ -10,6 +13,7 @@ use crate::core::arrangement::Axis; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; +use crate::core::config_generation::WorkspaceMatchingRule; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; @@ -957,6 +961,204 @@ impl WindowManager { floating_applications.retain(|r| !session_floating_applications.contains(r)); session_floating_applications.clear() } + SocketMessage::InitialWorkspaceRule(identifier, ref id, monitor_idx, workspace_idx) => { + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + let workspace_matching_rule = WorkspaceMatchingRule { + monitor_index: monitor_idx, + workspace_index: workspace_idx, + matching_rule: MatchingRule::Simple(IdWithIdentifier { + kind: identifier, + id: id.to_string(), + matching_strategy: Some(MatchingStrategy::Legacy), + }), + initial_only: true, + }; + + if !workspace_rules.contains(&workspace_matching_rule) { + workspace_rules.push(workspace_matching_rule); + } + } + SocketMessage::InitialNamedWorkspaceRule(identifier, ref id, ref workspace) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + let workspace_matching_rule = WorkspaceMatchingRule { + monitor_index: monitor_idx, + workspace_index: workspace_idx, + matching_rule: MatchingRule::Simple(IdWithIdentifier { + kind: identifier, + id: id.to_string(), + matching_strategy: Some(MatchingStrategy::Legacy), + }), + initial_only: true, + }; + + if !workspace_rules.contains(&workspace_matching_rule) { + workspace_rules.push(workspace_matching_rule); + } + } + } + SocketMessage::WorkspaceRule(identifier, ref id, monitor_idx, workspace_idx) => { + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + let workspace_matching_rule = WorkspaceMatchingRule { + monitor_index: monitor_idx, + workspace_index: workspace_idx, + matching_rule: MatchingRule::Simple(IdWithIdentifier { + kind: identifier, + id: id.to_string(), + matching_strategy: Some(MatchingStrategy::Legacy), + }), + initial_only: false, + }; + + if !workspace_rules.contains(&workspace_matching_rule) { + workspace_rules.push(workspace_matching_rule); + } + } + SocketMessage::NamedWorkspaceRule(identifier, ref id, ref workspace) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + let workspace_matching_rule = WorkspaceMatchingRule { + monitor_index: monitor_idx, + workspace_index: workspace_idx, + matching_rule: MatchingRule::Simple(IdWithIdentifier { + kind: identifier, + id: id.to_string(), + matching_strategy: Some(MatchingStrategy::Legacy), + }), + initial_only: false, + }; + + if !workspace_rules.contains(&workspace_matching_rule) { + workspace_rules.push(workspace_matching_rule); + } + } + } + SocketMessage::ClearWorkspaceRules(monitor_idx, workspace_idx) => { + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + + workspace_rules.retain(|r| { + r.monitor_index != monitor_idx && r.workspace_index != workspace_idx + }); + } + SocketMessage::ClearNamedWorkspaceRules(ref workspace) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + workspace_rules.retain(|r| { + r.monitor_index != monitor_idx && r.workspace_index != workspace_idx + }); + } + } + SocketMessage::ClearAllWorkspaceRules => { + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + workspace_rules.clear(); + } + SocketMessage::EnforceWorkspaceRules => { + { + let mut already_moved = self.already_moved_window_handles.lock(); + already_moved.clear(); + } + self.enforce_workspace_rules()?; + } + SocketMessage::IgnoreRule(identifier, ref id) => { + let mut ignore_identifiers = IGNORE_IDENTIFIERS.lock(); + + let mut should_push = true; + for i in &*ignore_identifiers { + if let MatchingRule::Simple(i) = i + && i.id.eq(id) + { + should_push = false; + } + } + + if should_push { + ignore_identifiers.push(MatchingRule::Simple(IdWithIdentifier { + kind: identifier, + id: id.clone(), + matching_strategy: Option::from(MatchingStrategy::Legacy), + })); + } + + let offset = self.work_area_offset; + + let mut window_ids_to_purge = vec![]; + for (i, monitor) in self.monitors().iter().enumerate() { + for container in monitor + .focused_workspace() + .ok_or_eyre("there is no workspace")? + .containers() + { + for window in container.windows() { + match identifier { + ApplicationIdentifier::Path => { + if window.path().unwrap_or_default().to_string_lossy() == *id { + window_ids_to_purge.push((i, window.id)); + } + } + ApplicationIdentifier::Exe => { + if window.exe().unwrap_or_default() == *id { + window_ids_to_purge.push((i, window.id)); + } + } + ApplicationIdentifier::Class => { + if window.role().unwrap_or_default() == *id { + window_ids_to_purge.push((i, window.id)); + } + + if window.subrole().unwrap_or_default() == *id { + window_ids_to_purge.push((i, window.id)); + } + } + ApplicationIdentifier::Title => { + if window.title().unwrap_or_default() == *id { + window_ids_to_purge.push((i, window.id)); + } + } + } + } + } + } + + for (monitor_idx, id) in window_ids_to_purge { + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + monitor + .focused_workspace_mut() + .ok_or_eyre("there is no focused workspace")? + .remove_window(id)?; + + monitor.update_focused_workspace(offset)?; + } + } + SocketMessage::ManageRule(identifier, ref id) => { + let mut manage_identifiers = MANAGE_IDENTIFIERS.lock(); + + let mut should_push = true; + for m in &*manage_identifiers { + if let MatchingRule::Simple(m) = m + && m.id.eq(id) + { + should_push = false; + } + } + + if should_push { + manage_identifiers.push(MatchingRule::Simple(IdWithIdentifier { + kind: identifier, + id: id.clone(), + matching_strategy: Option::from(MatchingStrategy::Legacy), + })); + } + } } self.update_known_window_ids(); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index b5796764..12b00e92 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -4,6 +4,7 @@ use chrono::Utc; use clap::Parser; use color_eyre::eyre; use fs_tail::TailedFile; +use komorebi_client::ApplicationIdentifier; use komorebi_client::Axis; use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; @@ -143,6 +144,89 @@ gen_named_target_subcommand_args! { ClearNamedWorkspaceLayoutRules } +macro_rules! gen_application_target_subcommand_args { + // SubCommand Pattern + ( $( $name:ident ),+ $(,)? ) => { + $( + #[derive(clap::Parser)] + pub struct $name { + #[clap(value_enum)] + identifier: ApplicationIdentifier, + /// Identifier as a string + id: String, + } + )+ + }; +} + +gen_application_target_subcommand_args! { + IgnoreRule, + ManageRule, + IdentifyTrayApplication, + IdentifyLayeredApplication, + IdentifyObjectNameChangeApplication, + IdentifyBorderOverflowApplication, + RemoveTitleBar, +} + +#[derive(Parser)] +struct InitialWorkspaceRule { + #[clap(value_enum)] + identifier: ApplicationIdentifier, + /// Identifier as a string + id: String, + /// Monitor index (zero-indexed) + monitor: usize, + /// Workspace index on the specified monitor (zero-indexed) + workspace: usize, +} + +#[derive(Parser)] +struct InitialNamedWorkspaceRule { + #[clap(value_enum)] + identifier: ApplicationIdentifier, + /// Identifier as a string + id: String, + /// Name of a workspace + workspace: String, +} + +#[derive(Parser)] +struct WorkspaceRule { + #[clap(value_enum)] + identifier: ApplicationIdentifier, + /// Identifier as a string + id: String, + /// Monitor index (zero-indexed) + monitor: usize, + /// Workspace index on the specified monitor (zero-indexed) + workspace: usize, +} + +#[derive(Parser)] +struct NamedWorkspaceRule { + #[clap(value_enum)] + identifier: ApplicationIdentifier, + /// Identifier as a string + id: String, + /// Name of a workspace + workspace: String, +} + +#[derive(Parser)] +struct ClearWorkspaceRules { + /// Monitor index (zero-indexed) + monitor: usize, + /// Workspace index on the specified monitor (zero-indexed) + workspace: usize, +} + +#[derive(Parser)] +struct ClearNamedWorkspaceRules { + /// Name of a workspace + workspace: String, +} + #[derive(Parser)] struct Resize { #[clap(value_enum)] @@ -587,35 +671,35 @@ enum SubCommand { SessionFloatRules, /// Clear all session float rules ClearSessionFloatRules, - // /// Add a rule to ignore the specified application - // #[clap(arg_required_else_help = true)] - // #[clap(alias = "float-rule")] - // IgnoreRule(IgnoreRule), - // /// Add a rule to always manage the specified application - // #[clap(arg_required_else_help = true)] - // ManageRule(ManageRule), - // /// Add a rule to associate an application with a workspace on first show - // #[clap(arg_required_else_help = true)] - // InitialWorkspaceRule(InitialWorkspaceRule), - // /// Add a rule to associate an application with a named workspace on first show - // #[clap(arg_required_else_help = true)] - // InitialNamedWorkspaceRule(InitialNamedWorkspaceRule), - // /// Add a rule to associate an application with a workspace - // #[clap(arg_required_else_help = true)] - // WorkspaceRule(WorkspaceRule), - // /// Add a rule to associate an application with a named workspace - // #[clap(arg_required_else_help = true)] - // NamedWorkspaceRule(NamedWorkspaceRule), - // /// Remove all application association rules for a workspace by monitor and workspace index - // #[clap(arg_required_else_help = true)] - // ClearWorkspaceRules(ClearWorkspaceRules), - // /// Remove all application association rules for a named workspace - // #[clap(arg_required_else_help = true)] - // ClearNamedWorkspaceRules(ClearNamedWorkspaceRules), - // /// Remove all application association rules for all workspaces - // ClearAllWorkspaceRules, - // /// Enforce all workspace rules, including initial workspace rules that have already been applied - // EnforceWorkspaceRules, + /// Add a rule to ignore the specified application + #[clap(arg_required_else_help = true)] + #[clap(alias = "float-rule")] + IgnoreRule(IgnoreRule), + /// Add a rule to always manage the specified application + #[clap(arg_required_else_help = true)] + ManageRule(ManageRule), + /// Add a rule to associate an application with a workspace on first show + #[clap(arg_required_else_help = true)] + InitialWorkspaceRule(InitialWorkspaceRule), + /// Add a rule to associate an application with a named workspace on first show + #[clap(arg_required_else_help = true)] + InitialNamedWorkspaceRule(InitialNamedWorkspaceRule), + /// Add a rule to associate an application with a workspace + #[clap(arg_required_else_help = true)] + WorkspaceRule(WorkspaceRule), + /// Add a rule to associate an application with a named workspace + #[clap(arg_required_else_help = true)] + NamedWorkspaceRule(NamedWorkspaceRule), + /// Remove all application association rules for a workspace by monitor and workspace index + #[clap(arg_required_else_help = true)] + ClearWorkspaceRules(ClearWorkspaceRules), + /// Remove all application association rules for a named workspace + #[clap(arg_required_else_help = true)] + ClearNamedWorkspaceRules(ClearNamedWorkspaceRules), + /// Remove all application association rules for all workspaces + ClearAllWorkspaceRules, + /// Enforce all workspace rules, including initial workspace rules that have already been applied + EnforceWorkspaceRules, // /// Identify an application that sends EVENT_OBJECT_NAMECHANGE on launch // #[clap(arg_required_else_help = true)] // IdentifyObjectNameChangeApplication(IdentifyObjectNameChangeApplication), @@ -1104,6 +1188,57 @@ fn main() -> eyre::Result<()> { SubCommand::ClearSessionFloatRules => { send_message(&SocketMessage::ClearSessionFloatRules)?; } + SubCommand::IgnoreRule(arg) => { + send_message(&SocketMessage::IgnoreRule(arg.identifier, arg.id))?; + } + SubCommand::ManageRule(arg) => { + send_message(&SocketMessage::ManageRule(arg.identifier, arg.id))?; + } + SubCommand::InitialWorkspaceRule(arg) => { + send_message(&SocketMessage::InitialWorkspaceRule( + arg.identifier, + arg.id, + arg.monitor, + arg.workspace, + ))?; + } + SubCommand::InitialNamedWorkspaceRule(arg) => { + send_message(&SocketMessage::InitialNamedWorkspaceRule( + arg.identifier, + arg.id, + arg.workspace, + ))?; + } + SubCommand::WorkspaceRule(arg) => { + send_message(&SocketMessage::WorkspaceRule( + arg.identifier, + arg.id, + arg.monitor, + arg.workspace, + ))?; + } + SubCommand::NamedWorkspaceRule(arg) => { + send_message(&SocketMessage::NamedWorkspaceRule( + arg.identifier, + arg.id, + arg.workspace, + ))?; + } + SubCommand::ClearWorkspaceRules(arg) => { + send_message(&SocketMessage::ClearWorkspaceRules( + arg.monitor, + arg.workspace, + ))?; + } + SubCommand::ClearNamedWorkspaceRules(arg) => { + send_message(&SocketMessage::ClearNamedWorkspaceRules(arg.workspace))?; + } + SubCommand::ClearAllWorkspaceRules => { + send_message(&SocketMessage::ClearAllWorkspaceRules)?; + } + SubCommand::EnforceWorkspaceRules => { + send_message(&SocketMessage::EnforceWorkspaceRules)?; + } } Ok(()) From 0b177215807653fd066c3f81f5fccf9674426320 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Sep 2025 21:29:01 -0700 Subject: [PATCH 049/305] feat(cli): implement eager-focus cmd This commit implements SocketMessage::EagerFocus and the corresponding komorebic eager-focus command. Mostly a straight migration from komorebi. --- komorebi/src/container.rs | 12 ++++++ komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 76 +++++++++++++++++++++++++++++++++ komorebi/src/workspace.rs | 42 ++++++++++++++++++ komorebic/src/main.rs | 15 +++++-- 5 files changed, 143 insertions(+), 4 deletions(-) diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index 773aa6ae..d25f6696 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -39,6 +39,18 @@ impl Lockable for Container { } impl Container { + pub fn idx_from_exe(&self, exe: &str) -> Option { + for (idx, window) in self.windows().iter().enumerate() { + if let Some(window_exe) = window.exe() + && exe == window_exe + { + return Option::from(idx); + } + } + + None + } + pub fn contains_window(&self, window_id: u32) -> bool { for window in self.windows() { if window.id == window_id { diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index fc268b3a..d8eb163c 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -217,7 +217,7 @@ pub enum SocketMessage { Promote, PromoteFocus, PromoteWindow(OperationDirection), - // EagerFocus(String), + EagerFocus(String), // LockMonitorWorkspaceContainer(usize, usize, usize), // UnlockMonitorWorkspaceContainer(usize, usize, usize), ToggleLock, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 394fc79a..90e8feaa 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -26,6 +26,7 @@ use crate::window::AdhocWindow; use crate::window_manager::WindowManager; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; +use crate::workspace::WorkspaceWindowLocation; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use parking_lot::Mutex; @@ -96,6 +97,81 @@ impl WindowManager { self.focus_container_in_direction(direction)?; self.promote_container_to_front()? } + SocketMessage::EagerFocus(ref exe) => { + let focused_monitor_idx = self.focused_monitor_idx(); + let mouse_follows_focus = self.mouse_follows_focus; + + let mut window_location = None; + let mut monitor_to_focus = None; + let mut needs_workspace_loading = false; + + 'search: for (monitor_idx, monitor) in self.monitors_mut().iter_mut().enumerate() { + for (workspace_idx, workspace) in monitor.workspaces().iter().enumerate() { + if let Some(location) = workspace.location_from_exe(exe) { + window_location = Some(location); + + if monitor_idx != focused_monitor_idx { + monitor_to_focus = Some(monitor_idx); + } + + // Focus workspace if it is not already the focused one, without + // loading it so that we don't give focus to the wrong window, we will + // load it later after focusing the wanted window + let focused_ws_idx = monitor.focused_workspace_idx(); + if focused_ws_idx != workspace_idx { + monitor.last_focused_workspace = Option::from(focused_ws_idx); + monitor.focus_workspace(workspace_idx)?; + needs_workspace_loading = true; + } + + break 'search; + } + } + } + + if let Some(monitor_idx) = monitor_to_focus { + self.focus_monitor(monitor_idx)?; + } + + if let Some(location) = window_location { + match location { + WorkspaceWindowLocation::Monocle(window_idx) => { + self.focus_container_window(window_idx)?; + } + WorkspaceWindowLocation::Maximized => { + if let Some(window) = + &mut self.focused_workspace_mut()?.maximized_window + { + window.focus(mouse_follows_focus)?; + } + } + WorkspaceWindowLocation::Container(container_idx, window_idx) => { + let focused_container_idx = self.focused_container_idx()?; + if container_idx != focused_container_idx { + self.focused_workspace_mut()?.focus_container(container_idx); + } + + self.focus_container_window(window_idx)?; + } + WorkspaceWindowLocation::Floating(window_idx) => { + if let Some(window) = self + .focused_workspace_mut()? + .floating_windows_mut() + .get_mut(window_idx) + { + window.focus(mouse_follows_focus)?; + } + } + } + + if needs_workspace_loading { + let mouse_follows_focus = self.mouse_follows_focus; + if let Some(monitor) = self.focused_monitor_mut() { + monitor.load_focused_workspace(mouse_follows_focus)?; + } + } + } + } SocketMessage::FocusWindow(direction) => { let focused_workspace = self.focused_workspace()?; match focused_workspace.layer { diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 5c8f647c..898bb430 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -107,6 +107,14 @@ impl Default for Workspace { } } +#[derive(Debug)] +pub enum WorkspaceWindowLocation { + Monocle(usize), // window_idx + Maximized, + Container(usize, usize), // container_idx, window_idx + Floating(usize), // idx in floating_windows +} + #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq)] /// Settings setup either by the parent monitor or by the `WindowManager` pub struct WorkspaceGlobals { @@ -514,6 +522,40 @@ impl Workspace { false } + pub fn location_from_exe(&self, exe: &str) -> Option { + for (container_idx, container) in self.containers().iter().enumerate() { + if let Some(window_idx) = container.idx_from_exe(exe) { + return Some(WorkspaceWindowLocation::Container( + container_idx, + window_idx, + )); + } + } + + if let Some(window) = &self.maximized_window + && let Some(window_exe) = window.exe() + && exe == window_exe + { + return Some(WorkspaceWindowLocation::Maximized); + } + + if let Some(container) = &self.monocle_container + && let Some(window_idx) = container.idx_from_exe(exe) + { + return Some(WorkspaceWindowLocation::Monocle(window_idx)); + } + + for (window_idx, window) in self.floating_windows().iter().enumerate() { + if let Some(window_exe) = window.exe() + && exe == window_exe + { + return Some(WorkspaceWindowLocation::Floating(window_idx)); + } + } + + None + } + pub fn contains_managed_window(&self, window_id: u32) -> bool { for container in self.containers() { if container.contains_window(window_id) { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 12b00e92..c7e44df3 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -279,6 +279,12 @@ struct Start { // clean_state: bool, } +#[derive(Parser)] +struct EagerFocus { + /// Case-sensitive exe identifier + exe: String, +} + #[derive(Parser)] #[clap(author, about, version = build::CLAP_LONG_VERSION)] struct Opts { @@ -379,9 +385,9 @@ enum SubCommand { /// Move the focused window in the specified cycle direction #[clap(arg_required_else_help = true)] CycleMove(CycleMove), - // /// Focus the first managed window matching the given exe - // #[clap(arg_required_else_help = true)] - // EagerFocus(EagerFocus), + /// Focus the first managed window matching the given exe + #[clap(arg_required_else_help = true)] + EagerFocus(EagerFocus), /// Stack the focused window in the specified direction #[clap(arg_required_else_help = true)] Stack(Stack), @@ -1239,6 +1245,9 @@ fn main() -> eyre::Result<()> { SubCommand::EnforceWorkspaceRules => { send_message(&SocketMessage::EnforceWorkspaceRules)?; } + SubCommand::EagerFocus(arg) => { + send_message(&SocketMessage::EagerFocus(arg.exe))?; + } } Ok(()) From b2d4dff929fbbf34cfeb1d286fb379cab01e4764 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 08:38:03 -0700 Subject: [PATCH 050/305] 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. --- komorebi-client/src/lib.rs | 1 + komorebi/Cargo.toml | 1 + komorebi/src/core/mod.rs | 64 +++-- komorebi/src/monitor.rs | 4 + komorebi/src/process_command.rs | 149 ++++++++++ komorebi/src/window_manager.rs | 254 +++++++++++++++++ komorebic/Cargo.toml | 4 + komorebic/src/main.rs | 478 +++++++++++++++++++++++++++----- 8 files changed, 870 insertions(+), 85 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index f5e02391..8c0018b3 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -9,6 +9,7 @@ pub use komorebi::core::default_layout::DefaultLayout; pub use komorebi::core::operation_direction::OperationDirection; pub use komorebi::core::pathext::PathExt; pub use komorebi::core::pathext::replace_env_in_path; +pub use komorebi::core::rect::Rect; use std::borrow::Borrow; use std::io::BufReader; use std::io::Read; diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index cbb465fc..3a0f1062 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "komorebi" version = "0.1.0" +description = "A tiling window manager for macOS" edition = "2024" [dependencies] diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index d8eb163c..67782e87 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -3,10 +3,12 @@ use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; use crate::core::operation_direction::OperationDirection; use crate::core::pathext::ResolvedPathBuf; +use crate::core::rect::Rect; use clap::ValueEnum; use color_eyre::eyre; use serde::Deserialize; use serde::Serialize; +use std::num::NonZeroUsize; use std::path::PathBuf; use std::str::FromStr; use strum::Display; @@ -40,6 +42,22 @@ pub enum Sizing { Decrease, } +impl Sizing { + #[must_use] + pub const fn adjust_by(&self, value: i32, adjustment: i32) -> i32 { + match self { + Self::Increase => value + adjustment, + Self::Decrease => { + if value > 0 && value - adjustment >= 0 { + value - adjustment + } else { + value + } + } + } + } +} + #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)] pub struct WindowManagementBehaviour { /// The current WindowContainerBehaviour to be used @@ -233,11 +251,11 @@ pub enum SocketMessage { // Current Workspace Commands // ManageFocusedWindow, // UnmanageFocusedWindow, - // AdjustContainerPadding(Sizing, i32), - // AdjustWorkspacePadding(Sizing, i32), + AdjustContainerPadding(Sizing, i32), + AdjustWorkspacePadding(Sizing, i32), ChangeLayout(DefaultLayout), CycleLayout(CycleDirection), - // ScrollingLayoutColumns(NonZeroUsize), + ScrollingLayoutColumns(NonZeroUsize), // ChangeLayoutCustom(#[serde_as(as = "ResolvedPathBuf")] PathBuf), FlipLayout(Axis), ToggleWorkspaceWindowContainerBehaviour, @@ -247,7 +265,7 @@ pub enum SocketMessage { // DisplayIndexPreference(usize, String), // EnsureWorkspaces(usize, usize), // EnsureNamedWorkspaces(usize, Vec), - // NewWorkspace, + NewWorkspace, ToggleTiling, // Stop, // StopIgnoreRestore, @@ -269,21 +287,21 @@ pub enum SocketMessage { FocusWorkspaceNumbers(usize), FocusMonitorWorkspaceNumber(usize, usize), FocusNamedWorkspace(String), - // ContainerPadding(usize, usize, i32), - // NamedWorkspaceContainerPadding(String, i32), - // FocusedWorkspaceContainerPadding(i32), - // WorkspacePadding(usize, usize, i32), - // NamedWorkspacePadding(String, i32), - // FocusedWorkspacePadding(i32), - // WorkspaceTiling(usize, usize, bool), - // NamedWorkspaceTiling(String, bool), - // WorkspaceName(usize, usize, String), - // WorkspaceLayout(usize, usize, DefaultLayout), - // NamedWorkspaceLayout(String, DefaultLayout), + ContainerPadding(usize, usize, i32), + NamedWorkspaceContainerPadding(String, i32), + FocusedWorkspaceContainerPadding(i32), + WorkspacePadding(usize, usize, i32), + NamedWorkspacePadding(String, i32), + FocusedWorkspacePadding(i32), + WorkspaceTiling(usize, usize, bool), + NamedWorkspaceTiling(String, bool), + WorkspaceName(usize, usize, String), + WorkspaceLayout(usize, usize, DefaultLayout), + NamedWorkspaceLayout(String, DefaultLayout), // WorkspaceLayoutCustom(usize, usize, #[serde_as(as = "ResolvedPathBuf")] PathBuf), // NamedWorkspaceLayoutCustom(String, #[serde_as(as = "ResolvedPathBuf")] PathBuf), - // WorkspaceLayoutRule(usize, usize, usize, DefaultLayout), - // NamedWorkspaceLayoutRule(String, usize, DefaultLayout), + WorkspaceLayoutRule(usize, usize, usize, DefaultLayout), + NamedWorkspaceLayoutRule(String, usize, DefaultLayout), // WorkspaceLayoutCustomRule( // usize, // usize, @@ -291,8 +309,8 @@ pub enum SocketMessage { // #[serde_as(as = "ResolvedPathBuf")] PathBuf, // ), // NamedWorkspaceLayoutCustomRule(String, usize, #[serde_as(as = "ResolvedPathBuf")] PathBuf), - // ClearWorkspaceLayoutRules(usize, usize), - // ClearNamedWorkspaceLayoutRules(String), + ClearWorkspaceLayoutRules(usize, usize), + ClearNamedWorkspaceLayoutRules(String), ToggleWorkspaceLayer, // Configuration // ReloadConfiguration, @@ -328,11 +346,11 @@ pub enum SocketMessage { // StackbarTabWidth(i32), // StackbarFontSize(i32), // StackbarFontFamily(Option), - // WorkAreaOffset(Rect), - // MonitorWorkAreaOffset(usize, Rect), - // WorkspaceWorkAreaOffset(usize, usize, Rect), + WorkAreaOffset(Rect), + MonitorWorkAreaOffset(usize, Rect), + WorkspaceWorkAreaOffset(usize, usize, Rect), ToggleWindowBasedWorkAreaOffset, - // ResizeDelta(i32), + ResizeDelta(i32), InitialWorkspaceRule(ApplicationIdentifier, String, usize, usize), InitialNamedWorkspaceRule(ApplicationIdentifier, String, String), WorkspaceRule(ApplicationIdentifier, String, usize, usize), diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index a6c10a47..61265227 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -180,6 +180,10 @@ impl Monitor { Ok(()) } + pub fn new_workspace_idx(&self) -> usize { + self.workspaces().len() + } + #[tracing::instrument(skip(self))] pub fn move_container_to_workspace( &mut self, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 90e8feaa..50c53c8e 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -14,6 +14,8 @@ use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; use crate::core::config_generation::WorkspaceMatchingRule; +use crate::core::default_layout::LayoutOptions; +use crate::core::default_layout::ScrollingLayoutOptions; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; @@ -1235,6 +1237,153 @@ impl WindowManager { })); } } + SocketMessage::NewWorkspace => { + self.new_workspace()?; + } + SocketMessage::ContainerPadding(monitor_idx, workspace_idx, size) => { + self.set_container_padding(monitor_idx, workspace_idx, size)?; + } + SocketMessage::NamedWorkspaceContainerPadding(ref workspace, size) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + self.set_container_padding(monitor_idx, workspace_idx, size)?; + } + } + SocketMessage::WorkspacePadding(monitor_idx, workspace_idx, size) => { + self.set_workspace_padding(monitor_idx, workspace_idx, size)?; + } + SocketMessage::NamedWorkspacePadding(ref workspace, size) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + self.set_workspace_padding(monitor_idx, workspace_idx, size)?; + } + } + SocketMessage::FocusedWorkspaceContainerPadding(adjustment) => { + let focused_monitor_idx = self.focused_monitor_idx(); + + let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?; + + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + + self.set_container_padding(focused_monitor_idx, focused_workspace_idx, adjustment)?; + } + SocketMessage::FocusedWorkspacePadding(adjustment) => { + let focused_monitor_idx = self.focused_monitor_idx(); + + let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?; + + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + + self.set_workspace_padding(focused_monitor_idx, focused_workspace_idx, adjustment)?; + } + SocketMessage::WorkspaceTiling(monitor_idx, workspace_idx, tile) => { + self.set_workspace_tiling(monitor_idx, workspace_idx, tile)?; + } + SocketMessage::WorkspaceLayout(monitor_idx, workspace_idx, layout) => { + self.set_workspace_layout_default(monitor_idx, workspace_idx, layout)?; + } + SocketMessage::WorkspaceLayoutRule( + monitor_idx, + workspace_idx, + at_container_count, + layout, + ) => { + self.add_workspace_layout_default_rule( + monitor_idx, + workspace_idx, + at_container_count, + layout, + )?; + } + SocketMessage::NamedWorkspaceTiling(ref workspace, tile) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + self.set_workspace_tiling(monitor_idx, workspace_idx, tile)?; + } + } + SocketMessage::WorkspaceName(monitor_idx, workspace_idx, ref name) => { + self.set_workspace_name(monitor_idx, workspace_idx, name.to_string())?; + } + SocketMessage::NamedWorkspaceLayout(ref workspace, layout) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + self.set_workspace_layout_default(monitor_idx, workspace_idx, layout)?; + } + } + SocketMessage::ClearWorkspaceLayoutRules(monitor_idx, workspace_idx) => { + self.clear_workspace_layout_rules(monitor_idx, workspace_idx)?; + } + SocketMessage::WorkAreaOffset(rect) => { + self.work_area_offset = Option::from(rect); + self.retile_all(false)?; + } + SocketMessage::MonitorWorkAreaOffset(monitor_idx, rect) => { + if let Some(monitor) = self.monitors_mut().get_mut(monitor_idx) { + monitor.work_area_offset = Option::from(rect); + self.retile_all(false)?; + } + } + SocketMessage::WorkspaceWorkAreaOffset(monitor_idx, workspace_idx, rect) => { + if let Some(monitor) = self.monitors_mut().get_mut(monitor_idx) + && let Some(workspace) = monitor.workspaces_mut().get_mut(workspace_idx) + { + workspace.work_area_offset = Option::from(rect); + self.retile_all(false)? + } + } + SocketMessage::ResizeDelta(delta) => { + self.resize_delta = delta; + } + SocketMessage::AdjustContainerPadding(sizing, adjustment) => { + self.adjust_container_padding(sizing, adjustment)?; + } + SocketMessage::AdjustWorkspacePadding(sizing, adjustment) => { + self.adjust_workspace_padding(sizing, adjustment)?; + } + SocketMessage::ScrollingLayoutColumns(count) => { + let focused_workspace = self.focused_workspace_mut()?; + + let options = match focused_workspace.layout_options { + Some(mut opts) => { + if let Some(scrolling) = &mut opts.scrolling { + scrolling.columns = count.into(); + } + + opts + } + None => LayoutOptions { + scrolling: Some(ScrollingLayoutOptions { + columns: count.into(), + }), + }, + }; + + focused_workspace.layout_options = Some(options); + self.update_focused_workspace(false, false)?; + } + SocketMessage::NamedWorkspaceLayoutRule(ref workspace, at_container_count, layout) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + self.add_workspace_layout_default_rule( + monitor_idx, + workspace_idx, + at_container_count, + layout, + )?; + } + } + SocketMessage::ClearNamedWorkspaceLayoutRules(ref workspace) => { + if let Some((monitor_idx, workspace_idx)) = + self.monitor_workspace_index_by_name(workspace) + { + self.clear_workspace_layout_rules(monitor_idx, workspace_idx)?; + } + } } self.update_known_window_ids(); diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index b30c265c..6dd54078 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -597,6 +597,40 @@ impl WindowManager { self.update_focused_workspace(self.mouse_follows_focus, false) } + #[tracing::instrument(skip(self))] + pub fn set_workspace_layout_default( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + layout: DefaultLayout, + ) -> eyre::Result<()> { + tracing::info!("setting workspace layout"); + + let focused_monitor_idx = self.focused_monitor_idx(); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let focused_workspace_idx = monitor.focused_workspace_idx(); + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("there is no monitor")?; + + workspace.layout = Layout::Default(layout); + + // If this is the focused workspace on a non-focused screen, let's update it + if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { + workspace.update()?; + Ok(()) + } else { + Ok(self.update_focused_workspace(false, false)?) + } + } + pub fn focused_workspace_idx(&self) -> eyre::Result { Ok(self .focused_monitor() @@ -645,6 +679,21 @@ impl WindowManager { .ok_or_eyre("there is no workspace") } + #[tracing::instrument(skip(self))] + pub fn new_workspace(&mut self) -> eyre::Result<()> { + tracing::info!("adding new workspace"); + + let mouse_follows_focus = self.mouse_follows_focus; + let monitor = self + .focused_monitor_mut() + .ok_or_eyre("there is no workspace")?; + + monitor.focus_workspace(monitor.new_workspace_idx())?; + monitor.load_focused_workspace(mouse_follows_focus)?; + + self.update_focused_workspace(self.mouse_follows_focus, false) + } + pub fn focused_container(&self) -> eyre::Result<&Container> { self.focused_workspace()? .focused_container() @@ -2268,4 +2317,209 @@ impl WindowManager { float_rule_placement: self.window_management_behaviour.float_rule_placement, } } + + #[tracing::instrument(skip(self))] + pub fn set_workspace_padding( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + size: i32, + ) -> eyre::Result<()> { + tracing::info!("setting workspace padding"); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("there is no monitor")?; + + workspace.workspace_padding = Option::from(size); + + self.update_focused_workspace(false, false) + } + + #[tracing::instrument(skip(self))] + pub fn set_workspace_name( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + name: String, + ) -> eyre::Result<()> { + tracing::info!("setting workspace name"); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("there is no monitor")?; + + workspace.name = Option::from(name.clone()); + // monitor.workspace_names.insert(workspace_idx, name); + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn set_container_padding( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + size: i32, + ) -> eyre::Result<()> { + tracing::info!("setting container padding"); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("there is no monitor")?; + + workspace.container_padding = Option::from(size); + + self.update_focused_workspace(false, false) + } + + #[tracing::instrument(skip(self))] + pub fn set_workspace_tiling( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + tile: bool, + ) -> eyre::Result<()> { + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("there is no monitor")?; + + workspace.tile = tile; + + self.update_focused_workspace(false, false) + } + + #[tracing::instrument(skip(self))] + pub fn add_workspace_layout_default_rule( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + at_container_count: usize, + layout: DefaultLayout, + ) -> eyre::Result<()> { + tracing::info!("setting workspace layout"); + + let focused_monitor_idx = self.focused_monitor_idx(); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let focused_workspace_idx = monitor.focused_workspace_idx(); + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("there is no monitor")?; + + let rules: &mut Vec<(usize, Layout)> = &mut workspace.layout_rules; + rules.retain(|pair| pair.0 != at_container_count); + rules.push((at_container_count, Layout::Default(layout))); + rules.sort_by(|a, b| a.0.cmp(&b.0)); + + // If this is the focused workspace on a non-focused screen, let's update it + if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { + workspace.update()?; + Ok(()) + } else { + Ok(self.update_focused_workspace(false, false)?) + } + } + + #[tracing::instrument(skip(self))] + pub fn clear_workspace_layout_rules( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + ) -> eyre::Result<()> { + tracing::info!("clearing workspace layout rules"); + + let focused_monitor_idx = self.focused_monitor_idx(); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let focused_workspace_idx = monitor.focused_workspace_idx(); + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("there is no monitor")?; + + let rules: &mut Vec<(usize, Layout)> = &mut workspace.layout_rules; + rules.clear(); + + // If this is the focused workspace on a non-focused screen, let's update it + if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { + workspace.update()?; + Ok(()) + } else { + Ok(self.update_focused_workspace(false, false)?) + } + } + + #[tracing::instrument(skip(self))] + pub fn adjust_workspace_padding( + &mut self, + sizing: Sizing, + adjustment: i32, + ) -> eyre::Result<()> { + tracing::info!("adjusting workspace padding"); + + let workspace = self.focused_workspace_mut()?; + + let padding = workspace + .workspace_padding + .ok_or_eyre("there is no workspace padding")?; + + workspace.workspace_padding = Option::from(sizing.adjust_by(padding, adjustment)); + + self.update_focused_workspace(false, false) + } + + #[tracing::instrument(skip(self))] + pub fn adjust_container_padding( + &mut self, + sizing: Sizing, + adjustment: i32, + ) -> eyre::Result<()> { + tracing::info!("adjusting container padding"); + + let workspace = self.focused_workspace_mut()?; + + let padding = workspace + .container_padding + .ok_or_eyre("there is no container padding")?; + + workspace.container_padding = Option::from(sizing.adjust_by(padding, adjustment)); + + self.update_focused_workspace(false, false) + } } diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index 969fa980..c54fbd8f 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "komorebic" version = "0.1.0" +description = "The command-line interface for Komorebi, a tiling window manager for macOS" edition = "2024" [dependencies] @@ -20,3 +21,6 @@ sysinfo = { workspace = true } [build-dependencies] reqwest = { version = "0.12", features = ["blocking"] } shadow-rs = { workspace = true } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(FALSE)'] } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index c7e44df3..bf99f56d 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -2,6 +2,7 @@ use chrono::Utc; use clap::Parser; +use clap::ValueEnum; use color_eyre::eyre; use fs_tail::TailedFile; use komorebi_client::ApplicationIdentifier; @@ -10,6 +11,7 @@ use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; use komorebi_client::OperationDirection; use komorebi_client::PathExt; +use komorebi_client::Rect; use komorebi_client::Sizing; use komorebi_client::SocketMessage; use komorebi_client::StateQuery; @@ -21,6 +23,7 @@ use std::fs::File; use std::fs::OpenOptions; use std::io::BufRead; use std::io::Write; +use std::num::NonZeroUsize; use std::path::PathBuf; use std::process::Command; use std::process::Stdio; @@ -55,6 +58,21 @@ lazy_static! { shadow_rs::shadow!(build); +#[derive(Copy, Clone, ValueEnum)] +enum BooleanState { + Enable, + Disable, +} + +impl From for bool { + fn from(b: BooleanState) -> Self { + match b { + BooleanState::Enable => true, + BooleanState::Disable => false, + } + } +} + macro_rules! gen_enum_subcommand_args { // SubCommand Pattern: Enum Type ( $( $name:ident: $element:ty ),+ $(,)? ) => { @@ -144,6 +162,149 @@ gen_named_target_subcommand_args! { ClearNamedWorkspaceLayoutRules } +// Thanks to @danielhenrymantilla for showing me how to use cfg_attr with an optional argument like +// this on the Rust Programming Language Community Discord Server +macro_rules! gen_workspace_subcommand_args { + // Workspace Property: #[enum] Value Enum (if the value is an Enum) + // Workspace Property: Value Type (if the value is anything else) + ( $( $name:ident: $(#[enum] $(@$value_enum:tt)?)? $value:ty ),+ $(,)? ) => ( + pastey::paste! { + $( + #[derive(clap::Parser)] + pub struct [] { + /// Monitor index (zero-indexed) + monitor: usize, + + /// Workspace index on the specified monitor (zero-indexed) + workspace: usize, + + $(#[clap(value_enum)] $($value_enum)?)? + #[cfg_attr( + all($(FALSE $($value_enum)?)?), + doc = ""$name " of the workspace as a "$value "" + )] + value: $value, + } + )+ + } + ) +} + +gen_workspace_subcommand_args! { + Name: String, + Layout: #[enum] DefaultLayout, + Tiling: #[enum] BooleanState, +} + +macro_rules! gen_named_workspace_subcommand_args { + // Workspace Property: #[enum] Value Enum (if the value is an Enum) + // Workspace Property: Value Type (if the value is anything else) + ( $( $name:ident: $(#[enum] $(@$value_enum:tt)?)? $value:ty ),+ $(,)? ) => ( + pastey::paste! { + $( + #[derive(clap::Parser)] + pub struct [] { + /// Target workspace name + workspace: String, + + $(#[clap(value_enum)] $($value_enum)?)? + #[cfg_attr( + all($(FALSE $($value_enum)?)?), + doc = ""$name " of the workspace as a "$value "" + )] + value: $value, + } + )+ + } + ) +} + +gen_named_workspace_subcommand_args! { + Layout: #[enum] DefaultLayout, + Tiling: #[enum] BooleanState, +} + +macro_rules! gen_focused_workspace_padding_subcommand_args { + // SubCommand Pattern + ( $( $name:ident ),+ $(,)? ) => { + $( + #[derive(clap::Parser)] + pub struct $name { + /// Pixels size to set as an integer + size: i32, + } + )+ + }; +} + +gen_focused_workspace_padding_subcommand_args! { + FocusedWorkspaceContainerPadding, + FocusedWorkspacePadding, +} + +macro_rules! gen_padding_subcommand_args { + // SubCommand Pattern + ( $( $name:ident ),+ $(,)? ) => { + $( + #[derive(clap::Parser)] + pub struct $name { + /// Monitor index (zero-indexed) + monitor: usize, + /// Workspace index on the specified monitor (zero-indexed) + workspace: usize, + /// Pixels to pad with as an integer + size: i32, + } + )+ + }; +} + +gen_padding_subcommand_args! { + ContainerPadding, + WorkspacePadding, +} + +macro_rules! gen_named_padding_subcommand_args { + // SubCommand Pattern + ( $( $name:ident ),+ $(,)? ) => { + $( + #[derive(clap::Parser)] + pub struct $name { + /// Target workspace name + workspace: String, + + /// Pixels to pad with as an integer + size: i32, + } + )+ + }; +} + +gen_named_padding_subcommand_args! { + NamedWorkspaceContainerPadding, + NamedWorkspacePadding, +} + +macro_rules! gen_padding_adjustment_subcommand_args { + // SubCommand Pattern + ( $( $name:ident ),+ $(,)? ) => { + $( + #[derive(clap::Parser)] + pub struct $name { + #[clap(value_enum)] + sizing: Sizing, + /// Pixels to adjust by as an integer + adjustment: i32, + } + )+ + }; +} + +gen_padding_adjustment_subcommand_args! { + AdjustContainerPadding, + AdjustWorkspacePadding, +} + macro_rules! gen_application_target_subcommand_args { // SubCommand Pattern ( $( $name:ident ),+ $(,)? ) => { @@ -169,6 +330,15 @@ gen_application_target_subcommand_args! { RemoveTitleBar, } +#[derive(Parser)] +pub struct ClearWorkspaceLayoutRules { + /// Monitor index (zero-indexed) + monitor: usize, + + /// Workspace index on the specified monitor (zero-indexed) + workspace: usize, +} + #[derive(Parser)] struct InitialWorkspaceRule { #[clap(value_enum)] @@ -243,6 +413,54 @@ struct ResizeAxis { sizing: Sizing, } +#[derive(Parser)] +struct ResizeDelta { + /// The delta of pixels by which to increase or decrease window dimensions when resizing + pixels: i32, +} + +#[derive(Parser)] +struct GlobalWorkAreaOffset { + /// Size of the left work area offset (set right to left * 2 to maintain right padding) + left: i32, + /// Size of the top work area offset (set bottom to the same value to maintain bottom padding) + top: i32, + /// Size of the right work area offset + right: i32, + /// Size of the bottom work area offset + bottom: i32, +} + +#[derive(Parser)] +struct MonitorWorkAreaOffset { + /// Monitor index (zero-indexed) + monitor: usize, + /// Size of the left work area offset (set right to left * 2 to maintain right padding) + left: i32, + /// Size of the top work area offset (set bottom to the same value to maintain bottom padding) + top: i32, + /// Size of the right work area offset + right: i32, + /// Size of the bottom work area offset + bottom: i32, +} + +#[derive(Parser)] +struct WorkspaceWorkAreaOffset { + /// Monitor index (zero-indexed) + monitor: usize, + /// Workspace index (zero-indexed) + workspace: usize, + /// Size of the left work area offset (set right to left * 2 to maintain right padding) + left: i32, + /// Size of the top work area offset (set bottom to the same value to maintain bottom padding) + top: i32, + /// Size of the right work area offset + right: i32, + /// Size of the bottom work area offset + bottom: i32, +} + #[derive(Parser)] struct FocusMonitorWorkspace { /// Target monitor index (zero-indexed) @@ -285,6 +503,12 @@ struct EagerFocus { exe: String, } +#[derive(Parser)] +struct ScrollingLayoutColumns { + /// Desired number of visible columns + count: NonZeroUsize, +} + #[derive(Parser)] #[clap(author, about, version = build::CLAP_LONG_VERSION)] struct Opts { @@ -492,46 +716,46 @@ enum SubCommand { /// Swap focused monitor workspaces with specified monitor #[clap(arg_required_else_help = true)] SwapWorkspacesWithMonitor(SwapWorkspacesWithMonitor), - // /// Create and append a new workspace on the focused monitor - // NewWorkspace, - // /// Set the resize delta (used by resize-edge and resize-axis) - // #[clap(arg_required_else_help = true)] - // ResizeDelta(ResizeDelta), + /// Create and append a new workspace on the focused monitor + NewWorkspace, + /// Set the resize delta (used by resize-edge and resize-axis) + #[clap(arg_required_else_help = true)] + ResizeDelta(ResizeDelta), // /// Set the invisible border dimensions around each window // #[clap(arg_required_else_help = true)] // InvisibleBorders(InvisibleBorders), - // /// Set offsets to exclude parts of the work area from tiling - // #[clap(arg_required_else_help = true)] - // GlobalWorkAreaOffset(GlobalWorkAreaOffset), - // /// Set offsets for a monitor to exclude parts of the work area from tiling - // #[clap(arg_required_else_help = true)] - // MonitorWorkAreaOffset(MonitorWorkAreaOffset), - // /// Set offsets for a workspace to exclude parts of the work area from tiling - // #[clap(arg_required_else_help = true)] - // WorkspaceWorkAreaOffset(WorkspaceWorkAreaOffset), + /// Set offsets to exclude parts of the work area from tiling + #[clap(arg_required_else_help = true)] + GlobalWorkAreaOffset(GlobalWorkAreaOffset), + /// Set offsets for a monitor to exclude parts of the work area from tiling + #[clap(arg_required_else_help = true)] + MonitorWorkAreaOffset(MonitorWorkAreaOffset), + /// Set offsets for a workspace to exclude parts of the work area from tiling + #[clap(arg_required_else_help = true)] + WorkspaceWorkAreaOffset(WorkspaceWorkAreaOffset), /// Toggle application of the window-based work area offset for the focused workspace ToggleWindowBasedWorkAreaOffset, - // /// Set container padding on the focused workspace - // #[clap(arg_required_else_help = true)] - // FocusedWorkspaceContainerPadding(FocusedWorkspaceContainerPadding), - // /// Set workspace padding on the focused workspace - // #[clap(arg_required_else_help = true)] - // FocusedWorkspacePadding(FocusedWorkspacePadding), - // /// Adjust container padding on the focused workspace - // #[clap(arg_required_else_help = true)] - // AdjustContainerPadding(AdjustContainerPadding), - // /// Adjust workspace padding on the focused workspace - // #[clap(arg_required_else_help = true)] - // AdjustWorkspacePadding(AdjustWorkspacePadding), + /// Set container padding on the focused workspace + #[clap(arg_required_else_help = true)] + FocusedWorkspaceContainerPadding(FocusedWorkspaceContainerPadding), + /// Set workspace padding on the focused workspace + #[clap(arg_required_else_help = true)] + FocusedWorkspacePadding(FocusedWorkspacePadding), + /// Adjust container padding on the focused workspace + #[clap(arg_required_else_help = true)] + AdjustContainerPadding(AdjustContainerPadding), + /// Adjust workspace padding on the focused workspace + #[clap(arg_required_else_help = true)] + AdjustWorkspacePadding(AdjustWorkspacePadding), /// Set the layout on the focused workspace #[clap(arg_required_else_help = true)] ChangeLayout(ChangeLayout), /// Cycle between available layouts #[clap(arg_required_else_help = true)] CycleLayout(CycleLayout), - // /// Set the number of visible columns for the Scrolling layout on the focused workspace - // #[clap(arg_required_else_help = true)] - // ScrollingLayoutColumns(ScrollingLayoutColumns), + /// Set the number of visible columns for the Scrolling layout on the focused workspace + #[clap(arg_required_else_help = true)] + ScrollingLayoutColumns(ScrollingLayoutColumns), // /// Load a custom layout from file for the focused workspace // #[clap(hide = true)] // #[clap(arg_required_else_help = true)] @@ -559,24 +783,24 @@ enum SubCommand { // /// Create these many named workspaces for the specified monitor // #[clap(arg_required_else_help = true)] // EnsureNamedWorkspaces(EnsureNamedWorkspaces), - // /// Set the container padding for the specified workspace - // #[clap(arg_required_else_help = true)] - // ContainerPadding(ContainerPadding), - // /// Set the container padding for the specified workspace - // #[clap(arg_required_else_help = true)] - // NamedWorkspaceContainerPadding(NamedWorkspaceContainerPadding), - // /// Set the workspace padding for the specified workspace - // #[clap(arg_required_else_help = true)] - // WorkspacePadding(WorkspacePadding), - // /// Set the workspace padding for the specified workspace - // #[clap(arg_required_else_help = true)] - // NamedWorkspacePadding(NamedWorkspacePadding), - // /// Set the layout for the specified workspace - // #[clap(arg_required_else_help = true)] - // WorkspaceLayout(WorkspaceLayout), - // /// Set the layout for the specified workspace - // #[clap(arg_required_else_help = true)] - // NamedWorkspaceLayout(NamedWorkspaceLayout), + /// Set the container padding for the specified workspace + #[clap(arg_required_else_help = true)] + ContainerPadding(ContainerPadding), + /// Set the container padding for the specified workspace + #[clap(arg_required_else_help = true)] + NamedWorkspaceContainerPadding(NamedWorkspaceContainerPadding), + /// Set the workspace padding for the specified workspace + #[clap(arg_required_else_help = true)] + WorkspacePadding(WorkspacePadding), + /// Set the workspace padding for the specified workspace + #[clap(arg_required_else_help = true)] + NamedWorkspacePadding(NamedWorkspacePadding), + /// Set the layout for the specified workspace + #[clap(arg_required_else_help = true)] + WorkspaceLayout(WorkspaceLayout), + /// Set the layout for the specified workspace + #[clap(arg_required_else_help = true)] + NamedWorkspaceLayout(NamedWorkspaceLayout), // /// Set a custom layout for the specified workspace // #[clap(hide = true)] // #[clap(arg_required_else_help = true)] @@ -599,21 +823,21 @@ enum SubCommand { // #[clap(hide = true)] // #[clap(arg_required_else_help = true)] // NamedWorkspaceCustomLayoutRule(NamedWorkspaceCustomLayoutRule), - // /// Clear all dynamic layout rules for the specified workspace - // #[clap(arg_required_else_help = true)] - // ClearWorkspaceLayoutRules(ClearWorkspaceLayoutRules), - // /// Clear all dynamic layout rules for the specified workspace - // #[clap(arg_required_else_help = true)] - // ClearNamedWorkspaceLayoutRules(ClearNamedWorkspaceLayoutRules), - // /// Enable or disable window tiling for the specified workspace - // #[clap(arg_required_else_help = true)] - // WorkspaceTiling(WorkspaceTiling), - // /// Enable or disable window tiling for the specified workspace - // #[clap(arg_required_else_help = true)] - // NamedWorkspaceTiling(NamedWorkspaceTiling), - // /// Set the workspace name for the specified workspace - // #[clap(arg_required_else_help = true)] - // WorkspaceName(WorkspaceName), + /// Clear all dynamic layout rules for the specified workspace + #[clap(arg_required_else_help = true)] + ClearWorkspaceLayoutRules(ClearWorkspaceLayoutRules), + /// Clear all dynamic layout rules for the specified workspace + #[clap(arg_required_else_help = true)] + ClearNamedWorkspaceLayoutRules(ClearNamedWorkspaceLayoutRules), + /// Enable or disable window tiling for the specified workspace + #[clap(arg_required_else_help = true)] + WorkspaceTiling(WorkspaceTiling), + /// Enable or disable window tiling for the specified workspace + #[clap(arg_required_else_help = true)] + NamedWorkspaceTiling(NamedWorkspaceTiling), + /// Set the workspace name for the specified workspace + #[clap(arg_required_else_help = true)] + WorkspaceName(WorkspaceName), /// Toggle the behaviour for new windows (stacking or dynamic tiling) ToggleWindowContainerBehaviour, /// Enable or disable float override, which makes it so every new window opens in floating mode @@ -1248,6 +1472,136 @@ fn main() -> eyre::Result<()> { SubCommand::EagerFocus(arg) => { send_message(&SocketMessage::EagerFocus(arg.exe))?; } + SubCommand::NewWorkspace => { + send_message(&SocketMessage::NewWorkspace)?; + } + SubCommand::WorkspaceName(name) => { + send_message(&SocketMessage::WorkspaceName( + name.monitor, + name.workspace, + name.value, + ))?; + } + SubCommand::ResizeDelta(arg) => { + send_message(&SocketMessage::ResizeDelta(arg.pixels))?; + } + SubCommand::MonitorWorkAreaOffset(arg) => { + send_message(&SocketMessage::MonitorWorkAreaOffset( + arg.monitor, + Rect { + left: arg.left, + top: arg.top, + right: arg.right, + bottom: arg.bottom, + }, + ))?; + } + SubCommand::GlobalWorkAreaOffset(arg) => { + send_message(&SocketMessage::WorkAreaOffset(Rect { + left: arg.left, + top: arg.top, + right: arg.right, + bottom: arg.bottom, + }))?; + } + + SubCommand::WorkspaceWorkAreaOffset(arg) => { + send_message(&SocketMessage::WorkspaceWorkAreaOffset( + arg.monitor, + arg.workspace, + Rect { + left: arg.left, + top: arg.top, + right: arg.right, + bottom: arg.bottom, + }, + ))?; + } + SubCommand::ContainerPadding(arg) => { + send_message(&SocketMessage::ContainerPadding( + arg.monitor, + arg.workspace, + arg.size, + ))?; + } + SubCommand::NamedWorkspaceContainerPadding(arg) => { + send_message(&SocketMessage::NamedWorkspaceContainerPadding( + arg.workspace, + arg.size, + ))?; + } + SubCommand::WorkspacePadding(arg) => { + send_message(&SocketMessage::WorkspacePadding( + arg.monitor, + arg.workspace, + arg.size, + ))?; + } + SubCommand::NamedWorkspacePadding(arg) => { + send_message(&SocketMessage::NamedWorkspacePadding( + arg.workspace, + arg.size, + ))?; + } + SubCommand::FocusedWorkspacePadding(arg) => { + send_message(&SocketMessage::FocusedWorkspacePadding(arg.size))?; + } + SubCommand::FocusedWorkspaceContainerPadding(arg) => { + send_message(&SocketMessage::FocusedWorkspaceContainerPadding(arg.size))?; + } + SubCommand::AdjustWorkspacePadding(arg) => { + send_message(&SocketMessage::AdjustWorkspacePadding( + arg.sizing, + arg.adjustment, + ))?; + } + SubCommand::AdjustContainerPadding(arg) => { + send_message(&SocketMessage::AdjustContainerPadding( + arg.sizing, + arg.adjustment, + ))?; + } + SubCommand::WorkspaceLayout(arg) => { + send_message(&SocketMessage::WorkspaceLayout( + arg.monitor, + arg.workspace, + arg.value, + ))?; + } + SubCommand::NamedWorkspaceLayout(arg) => { + send_message(&SocketMessage::NamedWorkspaceLayout( + arg.workspace, + arg.value, + ))?; + } + + SubCommand::WorkspaceTiling(arg) => { + send_message(&SocketMessage::WorkspaceTiling( + arg.monitor, + arg.workspace, + arg.value.into(), + ))?; + } + SubCommand::NamedWorkspaceTiling(arg) => { + send_message(&SocketMessage::NamedWorkspaceTiling( + arg.workspace, + arg.value.into(), + ))?; + } + SubCommand::ScrollingLayoutColumns(arg) => { + send_message(&SocketMessage::ScrollingLayoutColumns(arg.count))?; + } + SubCommand::ClearWorkspaceLayoutRules(arg) => { + send_message(&SocketMessage::ClearWorkspaceLayoutRules( + arg.monitor, + arg.workspace, + ))?; + } + SubCommand::ClearNamedWorkspaceLayoutRules(arg) => { + send_message(&SocketMessage::ClearNamedWorkspaceLayoutRules( + arg.workspace, + ))?; + } } Ok(()) From 8d9d60b2e1809167ae983761bb315c33aac04aa9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 14:49:22 -0700 Subject: [PATCH 051/305] 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. --- komorebi-client/src/lib.rs | 2 + komorebi/src/core/mod.rs | 12 +-- komorebi/src/process_command.rs | 18 ++++ komorebi/src/window_manager.rs | 42 ++++++++++ komorebic/src/main.rs | 140 ++++++++++++++++++++++++++------ 5 files changed, 182 insertions(+), 32 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 8c0018b3..abd04df0 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,5 +1,7 @@ pub use komorebi::DATA_DIR; pub use komorebi::core::ApplicationIdentifier; +pub use komorebi::core::MoveBehaviour; +pub use komorebi::core::OperationBehaviour; pub use komorebi::core::Sizing; pub use komorebi::core::SocketMessage; pub use komorebi::core::StateQuery; diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 67782e87..3db62d89 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -246,8 +246,8 @@ pub enum SocketMessage { ToggleFloatOverride, // WindowHidingBehaviour(HidingBehaviour), ToggleCrossMonitorMoveBehaviour, - // CrossMonitorMoveBehaviour(MoveBehaviour), - // UnmanagedWindowOperationBehaviour(OperationBehaviour), + CrossMonitorMoveBehaviour(MoveBehaviour), + UnmanagedWindowOperationBehaviour(OperationBehaviour), // Current Workspace Commands // ManageFocusedWindow, // UnmanageFocusedWindow, @@ -263,8 +263,8 @@ pub enum SocketMessage { // Monitor and Workspace Commands // MonitorIndexPreference(usize, i32, i32, i32, i32), // DisplayIndexPreference(usize, String), - // EnsureWorkspaces(usize, usize), - // EnsureNamedWorkspaces(usize, Vec), + EnsureWorkspaces(usize, usize), + EnsureNamedWorkspaces(usize, Vec), NewWorkspace, ToggleTiling, // Stop, @@ -376,8 +376,8 @@ pub enum SocketMessage { Query(StateQuery), // FocusFollowsMouse(FocusFollowsMouseImplementation, bool), // ToggleFocusFollowsMouse(FocusFollowsMouseImplementation), - // MouseFollowsFocus(bool), - // ToggleMouseFollowsFocus, + MouseFollowsFocus(bool), + ToggleMouseFollowsFocus, // RemoveTitleBar(ApplicationIdentifier, String), // ToggleTitleBars, // AddSubscriberSocket(String), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 50c53c8e..bcef2259 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1384,6 +1384,24 @@ impl WindowManager { self.clear_workspace_layout_rules(monitor_idx, workspace_idx)?; } } + SocketMessage::EnsureWorkspaces(monitor_idx, workspace_count) => { + self.ensure_workspaces_for_monitor(monitor_idx, workspace_count)?; + } + SocketMessage::EnsureNamedWorkspaces(monitor_idx, ref names) => { + self.ensure_named_workspaces_for_monitor(monitor_idx, names)?; + } + SocketMessage::MouseFollowsFocus(enable) => { + self.mouse_follows_focus = enable; + } + SocketMessage::ToggleMouseFollowsFocus => { + self.mouse_follows_focus = !self.mouse_follows_focus; + } + SocketMessage::CrossMonitorMoveBehaviour(behaviour) => { + self.cross_monitor_move_behaviour = behaviour; + } + SocketMessage::UnmanagedWindowOperationBehaviour(behaviour) => { + self.unmanaged_window_operation_behaviour = behaviour; + } } self.update_known_window_ids(); diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 6dd54078..8634d91e 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -2522,4 +2522,46 @@ impl WindowManager { self.update_focused_workspace(false, false) } + + #[tracing::instrument(skip(self))] + pub fn ensure_workspaces_for_monitor( + &mut self, + monitor_idx: usize, + workspace_count: usize, + ) -> eyre::Result<()> { + tracing::info!("ensuring workspace count"); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + monitor.ensure_workspace_count(workspace_count); + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn ensure_named_workspaces_for_monitor( + &mut self, + monitor_idx: usize, + names: &Vec, + ) -> eyre::Result<()> { + tracing::info!("ensuring workspace count"); + + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + monitor.ensure_workspace_count(names.len()); + + for (workspace_idx, name) in names.iter().enumerate() { + if let Some(workspace) = monitor.workspaces_mut().get_mut(workspace_idx) { + workspace.name = Option::from(name.clone()); + } + } + + Ok(()) + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index bf99f56d..de382fed 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -9,6 +9,8 @@ use komorebi_client::ApplicationIdentifier; use komorebi_client::Axis; use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; +use komorebi_client::MoveBehaviour; +use komorebi_client::OperationBehaviour; use komorebi_client::OperationDirection; use komorebi_client::PathExt; use komorebi_client::Rect; @@ -108,11 +110,11 @@ gen_enum_subcommand_args! { ChangeLayout: DefaultLayout, CycleLayout: CycleDirection, // WatchConfiguration: BooleanState, - // MouseFollowsFocus: BooleanState, + MouseFollowsFocus: BooleanState, Query: StateQuery, // WindowHidingBehaviour: HidingBehaviour, - // CrossMonitorMoveBehaviour: MoveBehaviour, - // UnmanagedWindowOperationBehaviour: OperationBehaviour, + CrossMonitorMoveBehaviour: MoveBehaviour, + UnmanagedWindowOperationBehaviour: OperationBehaviour, PromoteWindow: OperationDirection, } @@ -485,6 +487,49 @@ pub struct MoveToMonitorWorkspace { target_workspace: usize, } +#[derive(Parser)] +pub struct WorkspaceLayoutRule { + /// Monitor index (zero-indexed) + monitor: usize, + + /// Workspace index on the specified monitor (zero-indexed) + workspace: usize, + + /// The number of window containers on-screen required to trigger this layout rule + at_container_count: usize, + + #[clap(value_enum)] + layout: DefaultLayout, +} + +#[derive(Parser)] +pub struct NamedWorkspaceLayoutRule { + /// Target workspace name + workspace: String, + + /// The number of window containers on-screen required to trigger this layout rule + at_container_count: usize, + + #[clap(value_enum)] + layout: DefaultLayout, +} + +#[derive(Parser)] +struct EnsureWorkspaces { + /// Monitor index (zero-indexed) + monitor: usize, + /// Number of desired workspaces + workspace_count: usize, +} + +#[derive(Parser)] +struct EnsureNamedWorkspaces { + /// Monitor index (zero-indexed) + monitor: usize, + /// Names of desired workspaces + names: Vec, +} + #[derive(Parser)] #[allow(clippy::struct_excessive_bools)] struct Start { @@ -777,12 +822,12 @@ enum SubCommand { // /// Set the display index preference for a monitor identified using its display name // #[clap(arg_required_else_help = true)] // DisplayIndexPreference(DisplayIndexPreference), - // /// Create at least this many workspaces for the specified monitor - // #[clap(arg_required_else_help = true)] - // EnsureWorkspaces(EnsureWorkspaces), - // /// Create these many named workspaces for the specified monitor - // #[clap(arg_required_else_help = true)] - // EnsureNamedWorkspaces(EnsureNamedWorkspaces), + /// Create at least this many workspaces for the specified monitor + #[clap(arg_required_else_help = true)] + EnsureWorkspaces(EnsureWorkspaces), + /// Create these many named workspaces for the specified monitor + #[clap(arg_required_else_help = true)] + EnsureNamedWorkspaces(EnsureNamedWorkspaces), /// Set the container padding for the specified workspace #[clap(arg_required_else_help = true)] ContainerPadding(ContainerPadding), @@ -809,12 +854,12 @@ enum SubCommand { // #[clap(hide = true)] // #[clap(arg_required_else_help = true)] // NamedWorkspaceCustomLayout(NamedWorkspaceCustomLayout), - // /// Add a dynamic layout rule for the specified workspace - // #[clap(arg_required_else_help = true)] - // WorkspaceLayoutRule(WorkspaceLayoutRule), - // /// Add a dynamic layout rule for the specified workspace - // #[clap(arg_required_else_help = true)] - // NamedWorkspaceLayoutRule(NamedWorkspaceLayoutRule), + /// Add a dynamic layout rule for the specified workspace + #[clap(arg_required_else_help = true)] + WorkspaceLayoutRule(WorkspaceLayoutRule), + /// Add a dynamic layout rule for the specified workspace + #[clap(arg_required_else_help = true)] + NamedWorkspaceLayoutRule(NamedWorkspaceLayoutRule), // /// Add a dynamic custom layout for the specified workspace // #[clap(hide = true)] // #[clap(arg_required_else_help = true)] @@ -887,14 +932,14 @@ enum SubCommand { // /// Set the window behaviour when switching workspaces / cycling stacks // #[clap(arg_required_else_help = true)] // WindowHidingBehaviour(WindowHidingBehaviour), - // /// Set the behaviour when moving windows across monitor boundaries - // #[clap(arg_required_else_help = true)] - // CrossMonitorMoveBehaviour(CrossMonitorMoveBehaviour), + /// Set the behaviour when moving windows across monitor boundaries + #[clap(arg_required_else_help = true)] + CrossMonitorMoveBehaviour(CrossMonitorMoveBehaviour), /// Toggle the behaviour when moving windows across monitor boundaries ToggleCrossMonitorMoveBehaviour, - // /// Set the operation behaviour when the focused window is not managed - // #[clap(arg_required_else_help = true)] - // UnmanagedWindowOperationBehaviour(UnmanagedWindowOperationBehaviour), + /// Set the operation behaviour when the focused window is not managed + #[clap(arg_required_else_help = true)] + UnmanagedWindowOperationBehaviour(UnmanagedWindowOperationBehaviour), /// Add a rule to float the foreground window for the rest of this session SessionFloatRule, /// Show all session float rules @@ -1001,11 +1046,11 @@ enum SubCommand { // #[clap(hide = true)] // #[clap(arg_required_else_help = true)] // ToggleFocusFollowsMouse(ToggleFocusFollowsMouse), - // /// Enable or disable mouse follows focus on all workspaces - // #[clap(arg_required_else_help = true)] - // MouseFollowsFocus(MouseFollowsFocus), - // /// Toggle mouse follows focus on all workspaces - // ToggleMouseFollowsFocus, + /// Enable or disable mouse follows focus on all workspaces + #[clap(arg_required_else_help = true)] + MouseFollowsFocus(MouseFollowsFocus), + /// Toggle mouse follows focus on all workspaces + ToggleMouseFollowsFocus, // /// Generate common app-specific configurations and fixes to use in komorebi.ahk // #[clap(arg_required_else_help = true)] // #[clap(alias = "ahk-asc")] @@ -1602,6 +1647,49 @@ fn main() -> eyre::Result<()> { arg.workspace, ))?; } + SubCommand::EnsureWorkspaces(workspaces) => { + send_message(&SocketMessage::EnsureWorkspaces( + workspaces.monitor, + workspaces.workspace_count, + ))?; + } + SubCommand::EnsureNamedWorkspaces(arg) => { + send_message(&SocketMessage::EnsureNamedWorkspaces( + arg.monitor, + arg.names, + ))?; + } + SubCommand::WorkspaceLayoutRule(arg) => { + send_message(&SocketMessage::WorkspaceLayoutRule( + arg.monitor, + arg.workspace, + arg.at_container_count, + arg.layout, + ))?; + } + SubCommand::NamedWorkspaceLayoutRule(arg) => { + send_message(&SocketMessage::NamedWorkspaceLayoutRule( + arg.workspace, + arg.at_container_count, + arg.layout, + ))?; + } + SubCommand::CrossMonitorMoveBehaviour(arg) => { + send_message(&SocketMessage::CrossMonitorMoveBehaviour( + arg.move_behaviour, + ))?; + } + SubCommand::UnmanagedWindowOperationBehaviour(arg) => { + send_message(&SocketMessage::UnmanagedWindowOperationBehaviour( + arg.operation_behaviour, + ))?; + } + SubCommand::ToggleMouseFollowsFocus => { + send_message(&SocketMessage::ToggleMouseFollowsFocus)?; + } + SubCommand::MouseFollowsFocus(arg) => { + send_message(&SocketMessage::MouseFollowsFocus(arg.boolean_state.into()))?; + } } Ok(()) From 795ffdfa33d2f60b9b8510aa77082efc59d192a7 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 15:18:04 -0700 Subject: [PATCH 052/305] 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. --- Cargo.lock | 85 +++++++++++++++++------- Cargo.toml | 7 +- komorebi-client/Cargo.toml | 4 ++ komorebi-client/src/lib.rs | 2 + komorebi/Cargo.toml | 9 ++- komorebi/src/core/arrangement.rs | 1 + komorebi/src/core/asc.rs | 3 + komorebi/src/core/config_generation.rs | 7 ++ komorebi/src/core/cycle_direction.rs | 1 + komorebi/src/core/default_layout.rs | 3 + komorebi/src/core/mod.rs | 16 ++++- komorebi/src/core/operation_direction.rs | 1 + komorebi/src/core/pathext.rs | 20 +++--- komorebi/src/core/rect.rs | 1 + komorebi/src/process_command.rs | 40 ++++++++++- komorebi/src/static_config.rs | 4 ++ komorebi/src/window.rs | 2 + komorebic/Cargo.toml | 6 ++ komorebic/src/main.rs | 49 +++++++++++--- 19 files changed, 210 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0db6d5a4..f923e733 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -362,12 +362,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc" +checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" dependencies = [ "powerfmt", - "serde", + "serde_core", ] [[package]] @@ -1049,9 +1049,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.80" +version = "0.3.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852f13bec5eba4ba9afbeb93fd7c13fe56147f055939ae21c43a29a0ecb2702e" +checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305" dependencies = [ "once_cell", "wasm-bindgen", @@ -1080,6 +1080,7 @@ dependencies = [ "quick-xml 0.38.3", "quickxml_to_serde", "regex", + "schemars 0.8.22", "serde", "serde_json_lenient", "serde_with", @@ -1113,6 +1114,8 @@ dependencies = [ "lazy_static", "pastey", "reqwest", + "schemars 0.8.22", + "serde_json_lenient", "shadow-rs", "sysinfo", ] @@ -1145,9 +1148,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.175" +version = "0.2.176" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" +checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" [[package]] name = "libgit2-sys" @@ -2021,6 +2024,18 @@ dependencies = [ "windows-sys 0.61.0", ] +[[package]] +name = "schemars" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + [[package]] name = "schemars" version = "0.9.0" @@ -2045,6 +2060,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "schemars_derive" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -2104,6 +2131,17 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_json" version = "1.0.145" @@ -2152,6 +2190,7 @@ dependencies = [ "hex", "indexmap 1.9.3", "indexmap 2.11.4", + "schemars 0.8.22", "schemars 0.9.0", "schemars 1.0.4", "serde", @@ -2330,9 +2369,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.22.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fa4d11fadde498443cca10fd3ac23c951f0dc59e080e9f4b93d4df4e4eea53" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", "getrandom 0.3.3", @@ -2752,9 +2791,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab10a69fbd0a177f5f649ad4d8d3305499c42bab9aef2f7ff592d0ec8f833819" +checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" dependencies = [ "cfg-if", "once_cell", @@ -2765,9 +2804,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb702423545a6007bbc368fde243ba47ca275e549c8a28617f56f6ba53b1d1c" +checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19" dependencies = [ "bumpalo", "log", @@ -2779,9 +2818,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.53" +version = "0.4.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0b221ff421256839509adbb55998214a70d829d3a28c69b4a6672e9d2a42f67" +checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c" dependencies = [ "cfg-if", "js-sys", @@ -2792,9 +2831,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc65f4f411d91494355917b605e1480033152658d71f722a90647f56a70c88a0" +checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2802,9 +2841,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc003a991398a8ee604a401e194b6b3a39677b3173d6e74495eb51b82e99a32" +checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", @@ -2815,18 +2854,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "293c37f4efa430ca14db3721dfbe48d8c33308096bd44d80ebaa775ab71ba1cf" +checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1" dependencies = [ "unicode-ident", ] [[package]] name = "web-sys" -version = "0.3.80" +version = "0.3.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe734895e869dc429d78c4b433f8d17d95f8d05317440b4fad5ab2d33e596dc" +checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 4167c6d1..a9a94344 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,15 +8,16 @@ members = [ [workspace.dependencies] -clap = { version = "4", features = ["derive", "wrap_help"] } -chrono-tz = "0.10" chrono = "0.4" +chrono-tz = "0.10" +clap = { version = "4", features = ["derive", "wrap_help"] } color-eyre = "0.6" dirs = "6" lazy_static = "1" pastey = "0.1" +schemars = "0.8" serde = { version = "1", features = ["derive"] } serde_json = { package = "serde_json_lenient", version = "0.2" } shadow-rs = "1" sysinfo = "0.37" -thiserror = "2" \ No newline at end of file +thiserror = "2" diff --git a/komorebi-client/Cargo.toml b/komorebi-client/Cargo.toml index 6853093c..3799e2df 100644 --- a/komorebi-client/Cargo.toml +++ b/komorebi-client/Cargo.toml @@ -6,3 +6,7 @@ edition = "2024" [dependencies] komorebi = { path = "../komorebi", default-features = false } serde_json = { workspace = true } + +[features] +default = ["schemars"] +schemars = ["komorebi/default"] diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index abd04df0..7cb3365a 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -6,12 +6,14 @@ pub use komorebi::core::Sizing; pub use komorebi::core::SocketMessage; pub use komorebi::core::StateQuery; pub use komorebi::core::arrangement::Axis; +pub use komorebi::core::asc::ApplicationSpecificConfiguration; pub use komorebi::core::cycle_direction::CycleDirection; pub use komorebi::core::default_layout::DefaultLayout; pub use komorebi::core::operation_direction::OperationDirection; pub use komorebi::core::pathext::PathExt; pub use komorebi::core::pathext::replace_env_in_path; pub use komorebi::core::rect::Rect; +pub use komorebi::static_config::StaticConfig; use std::borrow::Borrow; use std::io::BufReader; use std::io::Read; diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 3a0f1062..f314114f 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -25,9 +25,10 @@ quick-xml = { version = "0.38", features = ["serialize"] } # forked to patch in serde_json_lenient and update some old dependencies quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } regex = "1" +schemars = { workspace = true, optional = true } serde = { workspace = true } serde_json = { workspace = true } -serde_with = "3" +serde_with = { version = "3", features = ["schemars_0_8"] } shadow-rs = { workspace = true } strum = { version = "0.27", features = ["derive"] } sysinfo = { workspace = true } @@ -37,4 +38,8 @@ tracing-appender = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } [build-dependencies] -shadow-rs = { workspace = true } \ No newline at end of file +shadow-rs = { workspace = true } + +[features] +default = ["schemars"] +schemars = ["dep:schemars"] diff --git a/komorebi/src/core/arrangement.rs b/komorebi/src/core/arrangement.rs index 60a67ae0..6f9c9410 100644 --- a/komorebi/src/core/arrangement.rs +++ b/komorebi/src/core/arrangement.rs @@ -570,6 +570,7 @@ impl Arrangement for DefaultLayout { } #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum Axis { Horizontal, Vertical, diff --git a/komorebi/src/core/asc.rs b/komorebi/src/core/asc.rs index dd4e1414..51f39245 100644 --- a/komorebi/src/core/asc.rs +++ b/komorebi/src/core/asc.rs @@ -10,9 +10,11 @@ use std::ops::DerefMut; use std::path::PathBuf; #[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct ApplicationSpecificConfiguration(pub BTreeMap); #[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(untagged)] pub enum AscApplicationRulesOrSchema { AscApplicationRules(AscApplicationRules), @@ -46,6 +48,7 @@ impl ApplicationSpecificConfiguration { /// Rules that determine how an application is handled #[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct AscApplicationRules { /// Rules to ignore specific windows #[serde(skip_serializing_if = "Option::is_none")] diff --git a/komorebi/src/core/config_generation.rs b/komorebi/src/core/config_generation.rs index 3dfbe2fd..ceb3aa70 100644 --- a/komorebi/src/core/config_generation.rs +++ b/komorebi/src/core/config_generation.rs @@ -7,6 +7,7 @@ use strum::EnumString; use super::ApplicationIdentifier; #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] pub enum ApplicationOptions { @@ -18,6 +19,7 @@ pub enum ApplicationOptions { } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(untagged)] pub enum MatchingRule { Simple(IdWithIdentifier), @@ -25,6 +27,7 @@ pub enum MatchingRule { } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct WorkspaceMatchingRule { pub monitor_index: usize, pub workspace_index: usize, @@ -33,6 +36,7 @@ pub struct WorkspaceMatchingRule { } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct IdWithIdentifier { pub kind: ApplicationIdentifier, pub id: String, @@ -41,6 +45,7 @@ pub struct IdWithIdentifier { } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum MatchingStrategy { Legacy, Equals, @@ -55,6 +60,7 @@ pub enum MatchingStrategy { } #[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct IdWithIdentifierAndComment { pub kind: ApplicationIdentifier, pub id: String, @@ -75,6 +81,7 @@ impl From for IdWithIdentifier { } #[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct ApplicationConfiguration { pub name: String, pub identifier: IdWithIdentifier, diff --git a/komorebi/src/core/cycle_direction.rs b/komorebi/src/core/cycle_direction.rs index bf820bdb..e75dec60 100644 --- a/komorebi/src/core/cycle_direction.rs +++ b/komorebi/src/core/cycle_direction.rs @@ -7,6 +7,7 @@ use strum::Display; use strum::EnumString; #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum CycleDirection { Previous, Next, diff --git a/komorebi/src/core/default_layout.rs b/komorebi/src/core/default_layout.rs index ff85705d..aa71fbf5 100644 --- a/komorebi/src/core/default_layout.rs +++ b/komorebi/src/core/default_layout.rs @@ -10,6 +10,7 @@ use strum::EnumString; #[derive( Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq, Display, EnumString, ValueEnum, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum DefaultLayout { BSP, Columns, @@ -24,12 +25,14 @@ pub enum DefaultLayout { } #[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct LayoutOptions { /// Options related to the Scrolling layout pub scrolling: Option, } #[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct ScrollingLayoutOptions { /// Desired number of visible columns (default: 3) pub columns: usize, diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 3db62d89..ef3dc96f 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -28,6 +28,7 @@ pub mod rect; #[derive( Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum OperationBehaviour { /// Process komorebic commands on temporarily unmanaged/floated windows #[default] @@ -37,6 +38,7 @@ pub enum OperationBehaviour { } #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum Sizing { Increase, Decrease, @@ -86,6 +88,7 @@ pub struct WindowManagementBehaviour { #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum WindowContainerBehaviour { /// Create a new container for each new window #[default] @@ -97,6 +100,7 @@ pub enum WindowContainerBehaviour { #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum FloatingLayerBehaviour { /// Tile new windows (unless they match a float rule or float override is active) #[default] @@ -108,6 +112,7 @@ pub enum FloatingLayerBehaviour { #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum Placement { /// Does not change the size or position of the window #[default] @@ -146,6 +151,7 @@ impl Placement { #[derive( Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum MoveBehaviour { /// Swap the window container with the window container at the edge of the adjacent monitor #[default] @@ -159,6 +165,7 @@ pub enum MoveBehaviour { #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum CrossBoundaryBehaviour { /// Attempt to perform actions across a workspace boundary Workspace, @@ -170,6 +177,7 @@ pub enum CrossBoundaryBehaviour { #[derive( Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, )] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum ApplicationIdentifier { #[serde(alias = "exe")] Exe, @@ -182,6 +190,7 @@ pub enum ApplicationIdentifier { } #[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum StateQuery { FocusedMonitorIndex, FocusedWorkspaceIndex, @@ -196,6 +205,7 @@ pub enum StateQuery { // serde_as must be before derive #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(tag = "type", content = "content")] pub enum SocketMessage { // Window / Container Commands @@ -385,10 +395,10 @@ pub enum SocketMessage { // RemoveSubscriberSocket(String), // AddSubscriberPipe(String), // RemoveSubscriberPipe(String), - // ApplicationSpecificConfigurationSchema, + ApplicationSpecificConfigurationSchema, // NotificationSchema, - // SocketSchema, - // StaticConfigSchema, + SocketSchema, + StaticConfigSchema, // GenerateStaticConfig, // DebugWindow(isize), } diff --git a/komorebi/src/core/operation_direction.rs b/komorebi/src/core/operation_direction.rs index dd526271..bb9d68eb 100644 --- a/komorebi/src/core/operation_direction.rs +++ b/komorebi/src/core/operation_direction.rs @@ -6,6 +6,7 @@ use serde::Serialize; use std::num::NonZeroUsize; #[derive(Clone, Copy, Debug, Serialize, Deserialize, ValueEnum)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum OperationDirection { Left, Right, diff --git a/komorebi/src/core/pathext.rs b/komorebi/src/core/pathext.rs index ec8c3adc..ad383677 100644 --- a/komorebi/src/core/pathext.rs +++ b/komorebi/src/core/pathext.rs @@ -123,16 +123,16 @@ impl<'de> serde_with::DeserializeAs<'de, PathBuf> for ResolvedPathBuf { } } -// #[cfg(feature = "schemars")] -// impl serde_with::schemars_0_8::JsonSchemaAs for ResolvedPathBuf { -// fn schema_name() -> String { -// "PathBuf".to_owned() -// } -// -// fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { -// ::json_schema(gen) -// } -// } +#[cfg(feature = "schemars")] +impl serde_with::schemars_0_8::JsonSchemaAs for ResolvedPathBuf { + fn schema_name() -> String { + "PathBuf".to_string() + } + + fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::schema::Schema { + ::json_schema(generator) + } +} /// Custom deserializer for [`Option>`] that uses /// [`PathExt::replace_env`] to resolve environment variables in the paths. diff --git a/komorebi/src/core/rect.rs b/komorebi/src/core/rect.rs index f46fbfba..67cc33ec 100644 --- a/komorebi/src/core/rect.rs +++ b/komorebi/src/core/rect.rs @@ -8,6 +8,7 @@ use serde::Deserialize; use serde::Serialize; #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Rect { pub left: i32, pub top: i32, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index bcef2259..643ffd5b 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -10,6 +10,7 @@ use crate::core::SocketMessage; use crate::core::StateQuery; use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; +use crate::core::asc::ApplicationSpecificConfiguration; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; @@ -24,6 +25,7 @@ use crate::monitor::Monitor; use crate::monitor::MonitorInformation; use crate::state::GlobalState; use crate::state::State; +use crate::static_config::StaticConfig; use crate::window::AdhocWindow; use crate::window_manager::WindowManager; use crate::workspace::Workspace; @@ -1402,6 +1404,40 @@ impl WindowManager { SocketMessage::UnmanagedWindowOperationBehaviour(behaviour) => { self.unmanaged_window_operation_behaviour = behaviour; } + SocketMessage::ApplicationSpecificConfigurationSchema => { + #[cfg(feature = "schemars")] + { + let asc = schemars::schema_for!(Vec); + let schema = serde_json::to_string_pretty(&asc)?; + + reply.write_all(schema.as_bytes())?; + } + } + SocketMessage::SocketSchema => { + #[cfg(feature = "schemars")] + { + let socket_message = schemars::schema_for!(SocketMessage); + let schema = serde_json::to_string_pretty(&socket_message)?; + + reply.write_all(schema.as_bytes())?; + } + } + SocketMessage::StaticConfigSchema => { + #[cfg(feature = "schemars")] + { + let settings = schemars::r#gen::SchemaSettings::default().with(|s| { + s.option_nullable = false; + s.option_add_null_type = false; + s.inline_subschemas = true; + }); + + let generator = settings.into_generator(); + let socket_message = generator.into_root_schema_for::(); + let schema = serde_json::to_string_pretty(&socket_message)?; + + reply.write_all(schema.as_bytes())?; + } + } } self.update_known_window_ids(); @@ -1471,8 +1507,8 @@ pub fn read_commands_uds( if wm.is_paused { return match message { SocketMessage::TogglePause - // | SocketMessage::State - // | SocketMessage::GlobalState + | SocketMessage::State + | SocketMessage::GlobalState // | SocketMessage::Stop => Ok(wm.process_command(message, &mut stream)?), _ => { diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index ddf188b7..72ba23fa 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -132,6 +132,7 @@ use std::sync::atomic::Ordering; // serde_as must be before derive #[serde_with::serde_as] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct WorkspaceConfig { /// Name pub name: String, @@ -268,6 +269,7 @@ impl From<&Workspace> for WorkspaceConfig { } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct MonitorConfig { /// Workspace configurations pub workspaces: Vec, @@ -335,6 +337,7 @@ impl From<&Monitor> for MonitorConfig { #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(untagged)] pub enum AppSpecificConfigurationPath { /// A single applications.json file @@ -345,6 +348,7 @@ pub enum AppSpecificConfigurationPath { #[serde_with::serde_as] #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] /// The `komorebi.json` static configuration file reference for `v0.1.39` pub struct StaticConfig { // /// DISCOURAGED: Minimum width for a window to be eligible for tiling diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index f9f4d908..260c6b98 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -860,6 +860,7 @@ impl From<&CFDictionary> for WindowBounds { } #[derive(Copy, Clone, Debug, Display, EnumString, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(untagged)] pub enum AspectRatio { /// A predefined aspect ratio @@ -875,6 +876,7 @@ impl Default for AspectRatio { } #[derive(Copy, Clone, Debug, Default, Display, EnumString, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum PredefinedAspectRatio { /// 21:9 Ultrawide, diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index c54fbd8f..289980d5 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -15,6 +15,8 @@ fs-tail = "0.1" lazy_static = { workspace = true } pastey = { workspace = true } reqwest = { version = "0.12", features = ["blocking"] } +schemars = { workspace = true, optional = true } +serde_json = { workspace = true } shadow-rs = { workspace = true } sysinfo = { workspace = true } @@ -22,5 +24,9 @@ sysinfo = { workspace = true } reqwest = { version = "0.12", features = ["blocking"] } shadow-rs = { workspace = true } +[features] +default = ["schemars"] +schemars = ["dep:schemars", "komorebi-client/default"] + [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(FALSE)'] } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index de382fed..143b6031 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -6,6 +6,7 @@ use clap::ValueEnum; use color_eyre::eyre; use fs_tail::TailedFile; use komorebi_client::ApplicationIdentifier; +use komorebi_client::ApplicationSpecificConfiguration; use komorebi_client::Axis; use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; @@ -17,6 +18,7 @@ use komorebi_client::Rect; use komorebi_client::Sizing; use komorebi_client::SocketMessage; use komorebi_client::StateQuery; +use komorebi_client::StaticConfig; use komorebi_client::replace_env_in_path; use komorebi_client::send_message; use komorebi_client::send_query; @@ -1071,15 +1073,15 @@ enum SubCommand { /// Fetch the latest version of applications.json from komorebi-application-specific-configuration #[clap(alias = "fetch-asc")] FetchAppSpecificConfiguration, - // /// Generate a JSON Schema for applications.json - // #[clap(alias = "asc-schema")] - // ApplicationSpecificConfigurationSchema, - // /// Generate a JSON Schema of subscription notifications + /// Generate a JSON Schema for applications.json + #[clap(alias = "asc-schema")] + ApplicationSpecificConfigurationSchema, + /// Generate a JSON Schema of subscription notifications // NotificationSchema, - // /// Generate a JSON Schema of socket messages - // SocketSchema, - // /// Generate a JSON Schema of the static configuration file - // StaticConfigSchema, + /// Generate a JSON Schema of socket messages + SocketSchema, + /// Generate a JSON Schema of the static configuration file + StaticConfigSchema, // /// Generates a static configuration JSON file based on the current window manager state // GenerateStaticConfig, // /// Generates the komorebi.lnk shortcut in shell:startup to autostart komorebi @@ -1690,6 +1692,37 @@ fn main() -> eyre::Result<()> { SubCommand::MouseFollowsFocus(arg) => { send_message(&SocketMessage::MouseFollowsFocus(arg.boolean_state.into()))?; } + SubCommand::ApplicationSpecificConfigurationSchema => { + #[cfg(feature = "schemars")] + { + let asc = schemars::schema_for!(ApplicationSpecificConfiguration); + let schema = serde_json::to_string_pretty(&asc)?; + println!("{schema}"); + } + } + SubCommand::SocketSchema => { + #[cfg(feature = "schemars")] + { + let socket_message = schemars::schema_for!(SocketMessage); + let schema = serde_json::to_string_pretty(&socket_message)?; + println!("{schema}"); + } + } + SubCommand::StaticConfigSchema => { + #[cfg(feature = "schemars")] + { + let settings = schemars::r#gen::SchemaSettings::default().with(|s| { + s.option_nullable = false; + s.option_add_null_type = false; + s.inline_subschemas = true; + }); + + let generator = settings.into_generator(); + let socket_message = generator.into_root_schema_for::(); + let schema = serde_json::to_string_pretty(&socket_message)?; + println!("{schema}"); + } + } } Ok(()) From 8a17e0ad006ecb7a839392cbe6f333fc0e4341fb Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 16:29:36 -0700 Subject: [PATCH 053/305] 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. --- justfile | 5 +- .../accessibility/notification_constants.rs | 1 + .../src/app_kit_notification_constants.rs | 1 + komorebi/src/container.rs | 2 +- komorebi/src/core/layout.rs | 1 + komorebi/src/core/mod.rs | 13 ++- komorebi/src/lib.rs | 93 +++++++++++++++++++ komorebi/src/main.rs | 12 +++ komorebi/src/monitor.rs | 1 + komorebi/src/monitor_reconciliator.rs | 20 +++- komorebi/src/process_command.rs | 88 +++++++++--------- komorebi/src/process_event.rs | 17 +++- komorebi/src/ring.rs | 1 + komorebi/src/state.rs | 49 ++++++++++ komorebi/src/window.rs | 27 +++++- komorebi/src/window_manager.rs | 39 ++++++++ komorebi/src/window_manager_event.rs | 3 + komorebi/src/workspace.rs | 2 + komorebic/src/main.rs | 37 ++++++-- 19 files changed, 347 insertions(+), 65 deletions(-) diff --git a/justfile b/justfile index 610d38aa..31882336 100644 --- a/justfile +++ b/justfile @@ -15,9 +15,12 @@ fix: clean: cargo clean -install target: +install-with-jsonschema target: cargo +stable install --path {{ target }} --locked --target-dir ~/.cargo/bin +install target: + cargo +stable install --path {{ target }} --locked --target-dir ~/.cargo/bin --no-default-features + build target: cargo +stable build --package {{ target }} --locked --release diff --git a/komorebi/src/accessibility/notification_constants.rs b/komorebi/src/accessibility/notification_constants.rs index 8bd11d37..f0e79b7a 100644 --- a/komorebi/src/accessibility/notification_constants.rs +++ b/komorebi/src/accessibility/notification_constants.rs @@ -48,6 +48,7 @@ pub const kAXAnnouncementKey: &str = "AXAnnouncementKey"; pub const kAXUIElementTitleKey: &str = "AXUIElementTitleKey"; #[derive(Debug, Copy, Clone, PartialEq, Eq, EnumString, Display, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum AccessibilityNotification { AXMainWindowChanged, AXFocusedWindowChanged, diff --git a/komorebi/src/app_kit_notification_constants.rs b/komorebi/src/app_kit_notification_constants.rs index d77c328e..67283bc3 100644 --- a/komorebi/src/app_kit_notification_constants.rs +++ b/komorebi/src/app_kit_notification_constants.rs @@ -10,6 +10,7 @@ use strum::Display; use strum::EnumString; #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display, EnumString)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum AppKitWorkspaceNotification { // A notification that the workspace posts when any of the accessibility display options change. NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification, diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index d25f6696..1bbcf093 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -10,7 +10,7 @@ use serde::Serialize; impl_ring_elements!(Container, Window); #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] - +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Container { pub id: String, pub locked: bool, diff --git a/komorebi/src/core/layout.rs b/komorebi/src/core/layout.rs index dd4131b6..a3ec0713 100644 --- a/komorebi/src/core/layout.rs +++ b/komorebi/src/core/layout.rs @@ -5,6 +5,7 @@ use serde::Deserialize; use serde::Serialize; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum Layout { Default(DefaultLayout), } diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index ef3dc96f..55b170d3 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -202,6 +202,13 @@ pub enum StateQuery { Version, } +#[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct SubscribeOptions { + /// Only emit notifications when the window manager state has changed + pub filter_state_changes: bool, +} + // serde_as must be before derive #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)] @@ -390,9 +397,9 @@ pub enum SocketMessage { ToggleMouseFollowsFocus, // RemoveTitleBar(ApplicationIdentifier, String), // ToggleTitleBars, - // AddSubscriberSocket(String), - // AddSubscriberSocketWithOptions(String, SubscribeOptions), - // RemoveSubscriberSocket(String), + AddSubscriberSocket(String), + AddSubscriberSocketWithOptions(String, SubscribeOptions), + RemoveSubscriberSocket(String), // AddSubscriberPipe(String), // RemoveSubscriberPipe(String), ApplicationSpecificConfigurationSchema, diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 5fda1262..2269fab3 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -3,13 +3,18 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityError; use crate::core::ApplicationIdentifier; +use crate::core::SocketMessage; +use crate::core::SubscribeOptions; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; use crate::core::config_generation::WorkspaceMatchingRule; use crate::core_graphics::error::CoreGraphicsError; +use crate::monitor_reconciliator::MonitorNotification; +use crate::state::State; use crate::window::AspectRatio; use crate::window::PredefinedAspectRatio; +use crate::window_manager_event::WindowManagerEvent; use color_eyre::eyre; use core::pathext::PathExt; use lazy_static::lazy_static; @@ -25,8 +30,12 @@ use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; use parking_lot::Mutex; use regex::Regex; +use serde::Deserialize; +use serde::Serialize; use std::collections::HashMap; +use std::io::Write; use std::ops::Deref; +use std::os::unix::net::UnixStream; use std::path::PathBuf; use std::ptr::NonNull; use std::sync::Arc; @@ -78,6 +87,10 @@ lazy_static! { pub static ref DATA_DIR: PathBuf = dirs::data_local_dir() .expect("there is no local data directory") .join("komorebi"); + pub static ref SUBSCRIPTION_SOCKETS: Arc>> = + Arc::new(Mutex::new(HashMap::new())); + pub static ref SUBSCRIPTION_SOCKET_OPTIONS: Arc>> = + Arc::new(Mutex::new(HashMap::new())); static ref FLOATING_WINDOW_TOGGLE_ASPECT_RATIO: Arc> = Arc::new(Mutex::new( AspectRatio::Predefined(PredefinedAspectRatio::Widescreen) )); @@ -118,6 +131,86 @@ shadow_rs::shadow!(build); pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(5); +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(untagged)] +pub enum NotificationEvent { + WindowManager(WindowManagerEvent), + Socket(SocketMessage), + Monitor(MonitorNotification), + // TODO: See if we want reaper notifications as well + // // TODO: See if we're actually gonna use this + // VirtualDesktop(VirtualDesktopNotification), +} + +// #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub enum VirtualDesktopNotification { +// EnteredAssociatedVirtualDesktop, +// LeftAssociatedVirtualDesktop, +// } + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct Notification { + pub event: NotificationEvent, + pub state: State, +} + +pub fn notify_subscribers( + notification: Notification, + state_has_been_modified: bool, +) -> eyre::Result<()> { + let is_override_event = matches!( + notification.event, + NotificationEvent::Socket(SocketMessage::AddSubscriberSocket(_)) + | NotificationEvent::Socket(SocketMessage::AddSubscriberSocketWithOptions(_, _)) + // | NotificationEvent::Socket(SocketMessage::Theme(_)) + | NotificationEvent::Socket(SocketMessage::ReloadStaticConfiguration(_)) // | NotificationEvent::WindowManager(WindowManagerEvent::TitleUpdate(_, _)) + // | NotificationEvent::WindowManager(WindowManagerEvent::Show(_, _)) + // | NotificationEvent::WindowManager(WindowManagerEvent::Uncloak(_, _)) + ); + + let notification = &serde_json::to_string(¬ification)?; + let mut stale_sockets = vec![]; + let mut sockets = SUBSCRIPTION_SOCKETS.lock(); + let options = SUBSCRIPTION_SOCKET_OPTIONS.lock(); + + for (socket, path) in &mut *sockets { + let apply_state_filter = (*options) + .get(socket) + .copied() + .unwrap_or_default() + .filter_state_changes; + + if !apply_state_filter || state_has_been_modified || is_override_event { + match UnixStream::connect(path) { + Ok(mut stream) => { + tracing::debug!("pushed notification to subscriber: {socket}"); + stream.write_all(notification.as_bytes())?; + } + Err(_) => { + stale_sockets.push(socket.clone()); + } + } + } + } + + for socket in stale_sockets { + tracing::warn!("removing stale subscription: {socket}"); + sockets.remove(&socket); + let socket_path = DATA_DIR.join(socket); + if let Err(error) = std::fs::remove_file(&socket_path) { + tracing::error!( + "could not remove stale subscriber socket file at {}: {error}", + socket_path.display() + ) + } + } + + Ok(()) +} + #[derive(Debug)] pub struct CoreFoundationRunLoop(pub CFRetained); unsafe impl Sync for CoreFoundationRunLoop {} diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index f260cc94..64111ca4 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -29,6 +29,8 @@ use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; use parking_lot::Mutex; use serde::Deserialize; +use std::net::Shutdown; +use std::os::unix::net::UnixStream; use std::path::PathBuf; use std::sync::Arc; use std::sync::atomic::AtomicBool; @@ -281,5 +283,15 @@ fn main() -> eyre::Result<()> { wm.lock().restore_all_windows(false)?; + let sockets = komorebi::SUBSCRIPTION_SOCKETS.lock(); + for path in (*sockets).values() { + if let Ok(stream) = UnixStream::connect(path) { + stream.shutdown(Shutdown::Both)?; + } + } + + let socket = DATA_DIR.join("komorebi.sock"); + let _ = std::fs::remove_file(socket); + Ok(()) } diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 61265227..bd632388 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -52,6 +52,7 @@ impl From<&Monitor> for MonitorInformation { impl_ring_elements!(Monitor, Workspace); #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Monitor { pub id: u32, pub device: String, diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index d88b8114..dc7ce7d8 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -1,4 +1,8 @@ +use crate::Notification; +use crate::NotificationEvent; use crate::UPDATE_MONITOR_WORK_AREAS; +use crate::notify_subscribers; +use crate::state::State; use crate::window_manager::WindowManager; use crossbeam_channel::Receiver; use crossbeam_channel::Sender; @@ -12,7 +16,7 @@ use std::sync::atomic::Ordering; use strum::Display; #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] - +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum MonitorNotification { Resize(CGDirectDisplayID), } @@ -58,18 +62,30 @@ pub fn listen_for_notifications(wm: Arc>) -> color_eyre::Re Ok(()) } -pub fn handle_notifications(_wm: Arc>) -> color_eyre::Result<()> { +pub fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> { tracing::info!("listening"); let receiver = event_rx(); for notification in receiver { + let wm = wm.lock(); + + let initial_state = State::from(wm.as_ref()); + match notification { MonitorNotification::Resize(_display_id) => { tracing::debug!("handling resize notification"); UPDATE_MONITOR_WORK_AREAS.store(true, Ordering::Relaxed); } } + + notify_subscribers( + Notification { + event: NotificationEvent::Monitor(notification), + state: wm.as_ref().into(), + }, + initial_state.has_been_modified(&wm), + )?; } Ok(()) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 643ffd5b..af17531b 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,7 +1,12 @@ +use crate::DATA_DIR; use crate::FLOATING_APPLICATIONS; use crate::IGNORE_IDENTIFIERS; use crate::MANAGE_IDENTIFIERS; +use crate::Notification; +use crate::NotificationEvent; use crate::SESSION_FLOATING_APPLICATIONS; +use crate::SUBSCRIPTION_SOCKET_OPTIONS; +use crate::SUBSCRIPTION_SOCKETS; use crate::WORKSPACE_MATCHING_RULES; use crate::build; use crate::core::ApplicationIdentifier; @@ -10,7 +15,6 @@ use crate::core::SocketMessage; use crate::core::StateQuery; use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; -use crate::core::asc::ApplicationSpecificConfiguration; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; @@ -21,14 +25,12 @@ use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::macos_api::MacosApi; -use crate::monitor::Monitor; use crate::monitor::MonitorInformation; +use crate::notify_subscribers; use crate::state::GlobalState; use crate::state::State; -use crate::static_config::StaticConfig; use crate::window::AdhocWindow; use crate::window_manager::WindowManager; -use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; use crate::workspace::WorkspaceWindowLocation; use color_eyre::eyre; @@ -92,6 +94,11 @@ impl WindowManager { mut reply: impl std::io::Write, ) -> eyre::Result<()> { tracing::info!("processing command: {message}"); + + #[allow(clippy::useless_asref)] + // We don't have From implemented for &mut WindowManager + let initial_state = State::from(self.as_ref()); + self.handle_unmanaged_window_behaviour()?; match message { @@ -1407,7 +1414,9 @@ impl WindowManager { SocketMessage::ApplicationSpecificConfigurationSchema => { #[cfg(feature = "schemars")] { - let asc = schemars::schema_for!(Vec); + let asc = schemars::schema_for!( + Vec + ); let schema = serde_json::to_string_pretty(&asc)?; reply.write_all(schema.as_bytes())?; @@ -1432,57 +1441,46 @@ impl WindowManager { }); let generator = settings.into_generator(); - let socket_message = generator.into_root_schema_for::(); + let socket_message = + generator.into_root_schema_for::(); let schema = serde_json::to_string_pretty(&socket_message)?; reply.write_all(schema.as_bytes())?; } } + SocketMessage::AddSubscriberSocket(ref socket) => { + let mut sockets = SUBSCRIPTION_SOCKETS.lock(); + let socket_path = DATA_DIR.join(socket); + sockets.insert(socket.clone(), socket_path); + } + SocketMessage::AddSubscriberSocketWithOptions(ref socket, options) => { + let mut sockets = SUBSCRIPTION_SOCKETS.lock(); + let socket_path = DATA_DIR.join(socket); + sockets.insert(socket.clone(), socket_path); + + let mut socket_options = SUBSCRIPTION_SOCKET_OPTIONS.lock(); + socket_options.insert(socket.clone(), options); + } + SocketMessage::RemoveSubscriberSocket(ref socket) => { + let mut sockets = SUBSCRIPTION_SOCKETS.lock(); + sockets.remove(socket); + } } + notify_subscribers( + Notification { + event: NotificationEvent::Socket(message.clone()), + state: self.as_ref().into(), + }, + initial_state.has_been_modified(self.as_ref()), + )?; + self.update_known_window_ids(); + tracing::info!("processed"); + Ok(()) } - - #[tracing::instrument(skip(self))] - pub fn move_workspace_to_monitor(&mut self, idx: usize) -> eyre::Result<()> { - tracing::info!("moving workspace"); - let mouse_follows_focus = self.mouse_follows_focus; - let offset = self.work_area_offset; - let workspace = self - .remove_focused_workspace() - .ok_or_eyre("there is no workspace")?; - - { - let target_monitor: &mut Monitor = self - .monitors_mut() - .get_mut(idx) - .ok_or_eyre("there is no monitor")?; - - target_monitor.workspaces_mut().push_back(workspace); - target_monitor.update_workspaces_globals(offset); - target_monitor.focus_workspace(target_monitor.workspaces().len().saturating_sub(1))?; - target_monitor.load_focused_workspace(mouse_follows_focus)?; - } - - self.focus_monitor(idx)?; - self.update_focused_workspace(mouse_follows_focus, true) - } - - pub fn remove_focused_workspace(&mut self) -> Option { - let focused_monitor: &mut Monitor = self.focused_monitor_mut()?; - let focused_workspace_idx = focused_monitor.focused_workspace_idx(); - let workspace = focused_monitor.remove_workspace_by_idx(focused_workspace_idx); - if let Err(error) = focused_monitor.focus_workspace(focused_workspace_idx.saturating_sub(1)) - { - tracing::error!( - "Error focusing previous workspace while removing the focused workspace: {}", - error - ); - } - workspace - } } pub fn read_commands_uds( diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 217470d7..3620055d 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,4 +1,6 @@ use crate::FLOATING_APPLICATIONS; +use crate::Notification; +use crate::NotificationEvent; use crate::REGEX_IDENTIFIERS; use crate::TABBED_APPLICATIONS; use crate::WORKSPACE_MATCHING_RULES; @@ -11,6 +13,8 @@ use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::macos_api::MacosApi; +use crate::notify_subscribers; +use crate::state::State; use crate::window::AdhocWindow; use crate::window::Window; use crate::window::should_act; @@ -92,6 +96,10 @@ impl WindowManager { ); } + #[allow(clippy::useless_asref)] + // We don't have From implemented for &mut WindowManager + let initial_state = State::from(self.as_ref()); + self.enforce_workspace_rules()?; match event { @@ -518,9 +526,16 @@ impl WindowManager { } } - self.enforce_workspace_rules()?; self.update_known_window_ids(); + notify_subscribers( + Notification { + event: NotificationEvent::WindowManager(event), + state: self.as_ref().into(), + }, + initial_state.has_been_modified(self.as_ref()), + )?; + Ok(()) } } diff --git a/komorebi/src/ring.rs b/komorebi/src/ring.rs index a473209c..147f8da7 100644 --- a/komorebi/src/ring.rs +++ b/komorebi/src/ring.rs @@ -4,6 +4,7 @@ use serde::Deserialize; use serde::Serialize; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Ring { elements: VecDeque, focused: usize, diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs index 856897ff..9aa3f083 100644 --- a/komorebi/src/state.rs +++ b/komorebi/src/state.rs @@ -66,6 +66,7 @@ impl Default for GlobalState { } #[allow(clippy::struct_excessive_bools)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[derive(Clone, Debug, Serialize, Deserialize)] pub struct State { pub monitors: Ring, @@ -168,3 +169,51 @@ impl From<&WindowManager> for State { } } } + +impl State { + pub fn has_been_modified(&self, wm: &WindowManager) -> bool { + let new = Self::from(wm); + + if self.monitors != new.monitors { + return true; + } + + if self.is_paused != new.is_paused { + return true; + } + + if self.new_window_behaviour != new.new_window_behaviour { + return true; + } + + if self.float_override != new.float_override { + return true; + } + + if self.cross_monitor_move_behaviour != new.cross_monitor_move_behaviour { + return true; + } + + if self.unmanaged_window_operation_behaviour != new.unmanaged_window_operation_behaviour { + return true; + } + + if self.work_area_offset != new.work_area_offset { + return true; + } + + // if self.focus_follows_mouse != new.focus_follows_mouse { + // return true; + // } + + if self.mouse_follows_focus != new.mouse_follows_focus { + return true; + } + + // if self.has_pending_raise_op != new.has_pending_raise_op { + // return true; + // } + + false + } +} diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 260c6b98..28bc8e40 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -257,8 +257,8 @@ impl Serialize for Window { where S: Serializer, { - let mut state = serializer.serialize_struct("Window", 5)?; - state.serialize_field("window_id", &self.id)?; + let mut state = serializer.serialize_struct("Window", 6)?; + state.serialize_field("id", &self.id)?; state.serialize_field( "title", &self @@ -291,6 +291,29 @@ impl Serialize for Window { } } +#[cfg(feature = "schemars")] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +struct SerializedWindow { + id: u32, + title: String, + exe: String, + role: String, + subrole: String, + rect: Rect, +} + +#[cfg(feature = "schemars")] +impl schemars::JsonSchema for Window { + fn schema_name() -> String { + "Window".to_string() + } + + fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::schema::Schema { + ::json_schema(generator) + } +} + impl Window { pub fn new( element: CFRetained, diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 8634d91e..d22e7455 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -2564,4 +2564,43 @@ impl WindowManager { Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn move_workspace_to_monitor(&mut self, idx: usize) -> eyre::Result<()> { + tracing::info!("moving workspace"); + let mouse_follows_focus = self.mouse_follows_focus; + let offset = self.work_area_offset; + let workspace = self + .remove_focused_workspace() + .ok_or_eyre("there is no workspace")?; + + { + let target_monitor: &mut Monitor = self + .monitors_mut() + .get_mut(idx) + .ok_or_eyre("there is no monitor")?; + + target_monitor.workspaces_mut().push_back(workspace); + target_monitor.update_workspaces_globals(offset); + target_monitor.focus_workspace(target_monitor.workspaces().len().saturating_sub(1))?; + target_monitor.load_focused_workspace(mouse_follows_focus)?; + } + + self.focus_monitor(idx)?; + self.update_focused_workspace(mouse_follows_focus, true) + } + + pub fn remove_focused_workspace(&mut self) -> Option { + let focused_monitor: &mut Monitor = self.focused_monitor_mut()?; + let focused_workspace_idx = focused_monitor.focused_workspace_idx(); + let workspace = focused_monitor.remove_workspace_by_idx(focused_workspace_idx); + if let Err(error) = focused_monitor.focus_workspace(focused_workspace_idx.saturating_sub(1)) + { + tracing::error!( + "Error focusing previous workspace while removing the focused workspace: {}", + error + ); + } + workspace + } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 386a8af3..0e018465 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -7,6 +7,7 @@ use serde::Serialize; use strum::Display; #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(tag = "type", content = "content")] pub enum SystemNotification { Accessibility(AccessibilityNotification), @@ -15,6 +16,7 @@ pub enum SystemNotification { } #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum ManualNotification { ShowOnInputEvent, ShowOnFocusChangeFirstTabDestroyed, @@ -22,6 +24,7 @@ pub enum ManualNotification { } #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(tag = "type", content = "content")] pub enum WindowManagerEvent { FocusChange(SystemNotification, i32, Option), diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 898bb430..c3401f10 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -24,6 +24,7 @@ use std::fmt::Formatter; use std::num::NonZeroUsize; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Workspace { pub name: Option, pub containers: Ring, @@ -57,6 +58,7 @@ pub struct Workspace { } #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum WorkspaceLayer { #[default] Tiling, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 143b6031..e8f09229 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -6,7 +6,6 @@ use clap::ValueEnum; use color_eyre::eyre; use fs_tail::TailedFile; use komorebi_client::ApplicationIdentifier; -use komorebi_client::ApplicationSpecificConfiguration; use komorebi_client::Axis; use komorebi_client::CycleDirection; use komorebi_client::DefaultLayout; @@ -18,7 +17,6 @@ use komorebi_client::Rect; use komorebi_client::Sizing; use komorebi_client::SocketMessage; use komorebi_client::StateQuery; -use komorebi_client::StaticConfig; use komorebi_client::replace_env_in_path; use komorebi_client::send_message; use komorebi_client::send_query; @@ -423,6 +421,18 @@ struct ResizeDelta { pixels: i32, } +#[derive(Parser)] +struct SubscribeSocket { + /// Name of the socket to send event notifications to + socket: String, +} + +#[derive(Parser)] +struct UnsubscribeSocket { + /// Name of the socket to stop sending event notifications to + socket: String, +} + #[derive(Parser)] struct GlobalWorkAreaOffset { /// Size of the left work area offset (set right to left * 2 to maintain right padding) @@ -608,12 +618,12 @@ enum SubCommand { /// Query the current window manager state #[clap(arg_required_else_help = true)] Query(Query), - // /// Subscribe to komorebi events using a Unix Domain Socket - // #[clap(arg_required_else_help = true)] - // SubscribeSocket(SubscribeSocket), - // /// Unsubscribe from komorebi events - // #[clap(arg_required_else_help = true)] - // UnsubscribeSocket(UnsubscribeSocket), + /// Subscribe to komorebi events using a Unix Domain Socket + #[clap(arg_required_else_help = true)] + SubscribeSocket(SubscribeSocket), + /// Unsubscribe from komorebi events + #[clap(arg_required_else_help = true)] + UnsubscribeSocket(UnsubscribeSocket), // /// Subscribe to komorebi events using a Named Pipe // #[clap(arg_required_else_help = true)] // #[clap(alias = "subscribe")] @@ -1695,7 +1705,7 @@ fn main() -> eyre::Result<()> { SubCommand::ApplicationSpecificConfigurationSchema => { #[cfg(feature = "schemars")] { - let asc = schemars::schema_for!(ApplicationSpecificConfiguration); + let asc = schemars::schema_for!(komorebi_client::ApplicationSpecificConfiguration); let schema = serde_json::to_string_pretty(&asc)?; println!("{schema}"); } @@ -1718,11 +1728,18 @@ fn main() -> eyre::Result<()> { }); let generator = settings.into_generator(); - let socket_message = generator.into_root_schema_for::(); + let socket_message = + generator.into_root_schema_for::(); let schema = serde_json::to_string_pretty(&socket_message)?; println!("{schema}"); } } + SubCommand::SubscribeSocket(arg) => { + send_message(&SocketMessage::AddSubscriberSocket(arg.socket))?; + } + SubCommand::UnsubscribeSocket(arg) => { + send_message(&SocketMessage::RemoveSubscriberSocket(arg.socket))?; + } } Ok(()) From 20c3bbd9a1b5c0d829e5f706153ba009e33e3cbc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 18:27:04 -0700 Subject: [PATCH 054/305] docs(schema): add cmd to generate notification schema --- komorebi-client/src/lib.rs | 1 + komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 9 +++++++++ komorebic/src/main.rs | 10 +++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 7cb3365a..dd1104a9 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,4 +1,5 @@ pub use komorebi::DATA_DIR; +pub use komorebi::Notification; pub use komorebi::core::ApplicationIdentifier; pub use komorebi::core::MoveBehaviour; pub use komorebi::core::OperationBehaviour; diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 55b170d3..4dd7e8d5 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -403,7 +403,7 @@ pub enum SocketMessage { // AddSubscriberPipe(String), // RemoveSubscriberPipe(String), ApplicationSpecificConfigurationSchema, - // NotificationSchema, + NotificationSchema, SocketSchema, StaticConfigSchema, // GenerateStaticConfig, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index af17531b..603cd6f9 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1422,6 +1422,15 @@ impl WindowManager { reply.write_all(schema.as_bytes())?; } } + SocketMessage::NotificationSchema => { + #[cfg(feature = "schemars")] + { + let notification = schemars::schema_for!(Notification); + let schema = serde_json::to_string_pretty(¬ification)?; + + reply.write_all(schema.as_bytes())?; + } + } SocketMessage::SocketSchema => { #[cfg(feature = "schemars")] { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index e8f09229..1b19e894 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1087,7 +1087,7 @@ enum SubCommand { #[clap(alias = "asc-schema")] ApplicationSpecificConfigurationSchema, /// Generate a JSON Schema of subscription notifications - // NotificationSchema, + NotificationSchema, /// Generate a JSON Schema of socket messages SocketSchema, /// Generate a JSON Schema of the static configuration file @@ -1710,6 +1710,14 @@ fn main() -> eyre::Result<()> { println!("{schema}"); } } + SubCommand::NotificationSchema => { + #[cfg(feature = "schemars")] + { + let notification = schemars::schema_for!(komorebi_client::Notification); + let schema = serde_json::to_string_pretty(¬ification)?; + println!("{schema}"); + } + } SubCommand::SocketSchema => { #[cfg(feature = "schemars")] { From e1be883dab3a99d3b908615327278e49cb0d74ca Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 18:38:53 -0700 Subject: [PATCH 055/305] 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. --- komorebi/src/core/mod.rs | 4 ++-- komorebi/src/process_command.rs | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 4dd7e8d5..8ab4be93 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -253,8 +253,8 @@ pub enum SocketMessage { PromoteFocus, PromoteWindow(OperationDirection), EagerFocus(String), - // LockMonitorWorkspaceContainer(usize, usize, usize), - // UnlockMonitorWorkspaceContainer(usize, usize, usize), + LockMonitorWorkspaceContainer(usize, usize, usize), + UnlockMonitorWorkspaceContainer(usize, usize, usize), ToggleLock, ToggleFloat, ToggleMonocle, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 603cd6f9..c525ff54 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -240,7 +240,44 @@ impl WindowManager { } self.focus_container_window(idx)?; } + SocketMessage::LockMonitorWorkspaceContainer( + monitor_idx, + workspace_idx, + container_idx, + ) => { + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("no monitor at the given index")?; + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("no workspace at the given index")?; + + if let Some(container) = workspace.containers_mut().get_mut(container_idx) { + container.locked = true; + } + } + SocketMessage::UnlockMonitorWorkspaceContainer( + monitor_idx, + workspace_idx, + container_idx, + ) => { + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("no monitor at the given index")?; + + let workspace = monitor + .workspaces_mut() + .get_mut(workspace_idx) + .ok_or_eyre("no workspace at the given index")?; + + if let Some(container) = workspace.containers_mut().get_mut(container_idx) { + container.locked = false; + } + } SocketMessage::FlipLayout(layout_flip) => self.flip_layout(layout_flip)?, SocketMessage::ChangeLayout(layout) => self.change_workspace_layout_default(layout)?, SocketMessage::CycleLayout(direction) => self.cycle_layout(direction)?, From 3a24b5111124a5780943d0d76e4309d3b349b1ce Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 21:23:12 -0700 Subject: [PATCH 056/305] 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. --- komorebi/src/input_event_listener.rs | 13 +- komorebi/src/lib.rs | 2 +- komorebi/src/process_event.rs | 202 +++++++++++++++------------ 3 files changed, 122 insertions(+), 95 deletions(-) diff --git a/komorebi/src/input_event_listener.rs b/komorebi/src/input_event_listener.rs index 8a95db04..3be16071 100644 --- a/komorebi/src/input_event_listener.rs +++ b/komorebi/src/input_event_listener.rs @@ -25,12 +25,20 @@ pub struct InputEventListener { extern "C-unwind" fn callback( _: CGEventTapProxy, - _event_type: CGEventType, + event_type: CGEventType, mut event_ref: NonNull, _listener: *mut c_void, ) -> *mut CGEvent { + // this should cover both clicking the close button and closing out something + // by using cmd+w or cmd+q since some apps don't send events on close reaper::send_notification(ReaperNotification::MouseUpKeyUp); - if let Some(element) = MacosApi::foreground_window() { + + // this one is only really for when people "drag" a tab out of one window + // to create another window - we wanna make sure it gets handled because + // events don't get sent sometimes + if event_type == CGEventType::LeftMouseUp + && let Some(element) = MacosApi::foreground_window() + { let mut pid = 0; unsafe { element.pid(NonNull::from_mut(&mut pid)); @@ -46,6 +54,7 @@ extern "C-unwind" fn callback( window_manager_event_listener::send_notification(event); } } + unsafe { event_ref.as_mut() } } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 2269fab3..830ea9e7 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -117,7 +117,7 @@ lazy_static! { matching_strategy: Option::from(MatchingStrategy::Equals), })])); static ref PERMAIGNORE_CLASSES: Arc>> = - Arc::new(Mutex::new(vec!["Chrome_RenderWidgetHostHWND".to_string(),])); + Arc::new(Mutex::new(vec!["AXDialog".to_string(),])); static ref TABBED_APPLICATIONS: Arc>> = Arc::new(Mutex::new(vec![ "Finder".to_string(), "Ghostty".to_string() diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 3620055d..59cbd6c3 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,6 +1,7 @@ use crate::FLOATING_APPLICATIONS; use crate::Notification; use crate::NotificationEvent; +use crate::PERMAIGNORE_CLASSES; use crate::REGEX_IDENTIFIERS; use crate::TABBED_APPLICATIONS; use crate::WORKSPACE_MATCHING_RULES; @@ -8,6 +9,7 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityApiError; use crate::accessibility::error::AccessibilityError; use crate::accessibility::notification_constants::AccessibilityNotification; +use crate::app_kit_notification_constants::AppKitWorkspaceNotification; use crate::core::WindowContainerBehaviour; use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; @@ -94,6 +96,12 @@ impl WindowManager { event.process_id(), event.notification(), ); + } else { + tracing::trace!( + "processing event: {event} for process {} with notification {}", + event.process_id(), + event.notification(), + ); } #[allow(clippy::useless_asref)] @@ -108,11 +116,13 @@ impl WindowManager { let application_name = application.name().unwrap_or_default().clone(); let mut tabbed_window = false; - if let Some(window_id) = application.main_window_id() { - if matches!( + if let Some(window_id) = application.main_window_id() + && matches!( notification, SystemNotification::Accessibility( AccessibilityNotification::AXMainWindowChanged + ) | SystemNotification::AppKitWorkspace( + AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification ) ) && let Some(element) = application.main_window() { @@ -173,120 +183,117 @@ impl WindowManager { } drop(tabbed_applications); - } - if !tabbed_window { - let is_known = self.known_window_ids.get(&window_id).cloned(); - let mut is_on_current_workspace = false; + if !tabbed_window { + let is_known = self.known_window_ids.get(&window_id).cloned(); + let mut is_on_current_workspace = false; - // TODO: figure out if this applies on macOS too - // don't want to trigger the full workspace updates when there are no managed - // containers - this makes floating windows on empty workspaces go into very - // annoying focus change loops which prevents users from interacting with them - if !matches!( - self.focused_workspace()?.layout, - Layout::Default(DefaultLayout::Scrolling) - ) && !self.focused_workspace()?.containers().is_empty() - { - self.update_focused_workspace(self.mouse_follows_focus, false)?; - } + // TODO: figure out if this applies on macOS too + // don't want to trigger the full workspace updates when there are no managed + // containers - this makes floating windows on empty workspaces go into very + // annoying focus change loops which prevents users from interacting with them + if !matches!( + self.focused_workspace()?.layout, + Layout::Default(DefaultLayout::Scrolling) + ) && !self.focused_workspace()?.containers().is_empty() { + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } - let workspace = self.focused_workspace_mut()?; - if workspace.contains_window(window_id) { - is_on_current_workspace = true; - } + let workspace = self.focused_workspace_mut()?; + if workspace.contains_window(window_id) { + is_on_current_workspace = true; + } - let floating_window_idx = workspace - .floating_windows() - .iter() - .position(|w| w.id == window_id); + let floating_window_idx = workspace + .floating_windows() + .iter() + .position(|w| w.id == window_id); - match floating_window_idx { - None => { - // if let Some(w) = workspace.maximized_window() { - // if w.hwnd == window_id { - // return Ok(()); - // } - // } + match floating_window_idx { + None => { + // if let Some(w) = workspace.maximized_window() { + // if w.hwnd == window_id { + // return Ok(()); + // } + // } - if let Some(monocle) = &workspace.monocle_container { - if let Some(window) = monocle.focused_window() { - window.focus(false)?; - } - } else if !is_on_current_workspace && is_known.is_none() { - // thanks, I hate it - need to do this so that we don't mess up - // the workspace rules, but also don't miss events from dumb - // apps like notes, mail etc. - let mut has_matching_workspace_rule = false; - let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); - for rule in &*workspace_rules { - match &rule.matching_rule { - MatchingRule::Simple(r) => { - if r.id.trim_end_matches(".exe") == application_name - { - has_matching_workspace_rule = true; - } - } - // TODO: this is pretty coarse - MatchingRule::Composite(rules) => { - for r in rules { - if r.id.trim_end_matches(".exe") - == application_name + if let Some(monocle) = &workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(false)?; + } + } else if !is_on_current_workspace && is_known.is_none() { + // thanks, I hate it - need to do this so that we don't mess up + // the workspace rules, but also don't miss events from dumb + // apps like notes, mail etc. + let mut has_matching_workspace_rule = false; + let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + for rule in &*workspace_rules { + match &rule.matching_rule { + MatchingRule::Simple(r) => { + if r.id.trim_end_matches(".exe") == application_name { has_matching_workspace_rule = true; } } + // TODO: this is pretty coarse + MatchingRule::Composite(rules) => { + for r in rules { + if r.id.trim_end_matches(".exe") + == application_name + { + has_matching_workspace_rule = true; + } + } + } } } - } - if !has_matching_workspace_rule - && workspace.focus_container_by_window(window_id).is_err() - { - // if this fails, the app was probably open but windowless when komorebi - // launched, so the window hasn't been registered - we should treat it - // as a "Show" event - if let Some(event) = - WindowManagerEvent::from_system_notification( - SystemNotification::Manual( - ManualNotification::ShowOnFocusChangeWindowlessAppRestored, - ), - event.process_id(), - Some(window_id), - ) + if !has_matching_workspace_rule + && workspace.focus_container_by_window(window_id).is_err() { - window_manager_event_listener::send_notification( - event, - ); + // if this fails, the app was probably open but windowless when komorebi + // launched, so the window hasn't been registered - we should treat it + // as a "Show" event + if let Some(event) = + WindowManagerEvent::from_system_notification( + SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeWindowlessAppRestored, + ), + event.process_id(), + Some(window_id), + ) + { + window_manager_event_listener::send_notification( + event, + ); + } } + } else { + workspace.focus_container_by_window(window_id)?; + } + + workspace.layer = WorkspaceLayer::Tiling; + + if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) + && !self.focused_workspace()?.containers().is_empty() { + self.update_focused_workspace(self.mouse_follows_focus, false)?; } } - - workspace.layer = WorkspaceLayer::Tiling; - - if matches!( - self.focused_workspace()?.layout, - Layout::Default(DefaultLayout::Scrolling) - ) && !self.focused_workspace()?.containers().is_empty() - { - self.update_focused_workspace(self.mouse_follows_focus, false)?; + Some(idx) => { + if let Some(_window) = workspace.floating_windows().get(idx) { + workspace.layer = WorkspaceLayer::Floating; + } } } - Some(idx) => { - if let Some(_window) = workspace.floating_windows().get(idx) { - workspace.layer = WorkspaceLayer::Floating; - } + // maybe we don't need a separate reconciliator module?? this works pretty well! + if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { + self.focus_monitor(m_idx)?; + self.focus_workspace(w_idx)?; } } - // maybe we don't need a separate reconciliator module?? this works pretty well! - if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { - self.focus_monitor(m_idx)?; - self.focus_workspace(w_idx)?; - } } - } if matches!( notification, @@ -371,6 +378,17 @@ impl WindowManager { } } + // this happens sometimes because of the mouse event from input listener which emits a show + if let Some(element) = &window_element { + let subrole = AdhocWindow::subrole(element).unwrap_or_default(); + if PERMAIGNORE_CLASSES.lock().contains(&subrole) { + tracing::debug!( + "ignoring AXDialog window that got past the initial filter" + ); + create = false + } + } + if create && !tabbed_window { let application = self.application(process_id)?; if let Some(element) = window_element From e478ab8d0a1889459cb0f02710402cf0c7adcf24 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 07:30:25 -0700 Subject: [PATCH 057/305] 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. --- komorebi/src/core/mod.rs | 4 ++-- komorebi/src/main.rs | 2 +- komorebi/src/process_command.rs | 6 ++++++ komorebi/src/window_manager.rs | 32 ++++++++++++++++++++++++++++++++ komorebic/src/main.rs | 33 +++++++++++++++++++++++---------- 5 files changed, 64 insertions(+), 13 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 8ab4be93..35d34e9c 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -284,8 +284,8 @@ pub enum SocketMessage { EnsureNamedWorkspaces(usize, Vec), NewWorkspace, ToggleTiling, - // Stop, - // StopIgnoreRestore, + Stop, + StopIgnoreRestore, TogglePause, Retile, RetileWithResizeDimensions, diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 64111ca4..e06b0026 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -293,5 +293,5 @@ fn main() -> eyre::Result<()> { let socket = DATA_DIR.join("komorebi.sock"); let _ = std::fs::remove_file(socket); - Ok(()) + std::process::exit(130); } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index c525ff54..0f74b17f 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1511,6 +1511,12 @@ impl WindowManager { let mut sockets = SUBSCRIPTION_SOCKETS.lock(); sockets.remove(socket); } + SocketMessage::Stop => { + self.stop(false)?; + } + SocketMessage::StopIgnoreRestore => { + self.stop(true)?; + } } notify_subscribers( diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index d22e7455..1dcba0e0 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -2,6 +2,7 @@ use crate::CoreFoundationRunLoop; use crate::DATA_DIR; use crate::LibraryError; use crate::REGEX_IDENTIFIERS; +use crate::SUBSCRIPTION_SOCKETS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::application::Application; @@ -43,8 +44,10 @@ use std::collections::HashMap; use std::collections::HashSet; use std::collections::hash_map::Entry; use std::io::ErrorKind; +use std::net::Shutdown; use std::num::NonZeroUsize; use std::os::unix::net::UnixListener; +use std::os::unix::net::UnixStream; use std::path::PathBuf; use std::sync::Arc; @@ -851,6 +854,35 @@ impl WindowManager { workspace.new_container_for_focused_window()?; self.update_focused_workspace(self.mouse_follows_focus, false) } + + #[tracing::instrument(skip(self))] + pub fn stop(&mut self, ignore_restore: bool) -> eyre::Result<()> { + tracing::info!( + "received stop command, restoring all hidden windows and terminating process" + ); + + // TODO: figure out if we wanna do state restores in macOS + // let state = &State::from(&*self); + // std::fs::write( + // DATA_DIR.join("komorebi.state.json"), + // serde_json::to_string_pretty(&state)?, + // )?; + + self.restore_all_windows(ignore_restore)?; + + let sockets = SUBSCRIPTION_SOCKETS.lock(); + for path in (*sockets).values() { + if let Ok(stream) = UnixStream::connect(path) { + stream.shutdown(Shutdown::Both)?; + } + } + + let socket = DATA_DIR.join("komorebi.sock"); + let _ = std::fs::remove_file(socket); + + std::process::exit(0) + } + #[tracing::instrument(skip(self))] pub fn restore_all_windows(&mut self, ignore_restore: bool) -> eyre::Result<()> { tracing::info!("restoring all hidden windows"); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 1b19e894..29caf8fe 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -33,7 +33,6 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use std::time::Duration; use sysinfo::ProcessesToUpdate; -use sysinfo::Signal; lazy_static! { static ref HAS_CUSTOM_CONFIG_HOME: AtomicBool = AtomicBool::new(false); @@ -554,6 +553,13 @@ struct Start { // clean_state: bool, } +#[derive(Parser)] +struct Stop { + /// Do not restore windows after stopping komorebi + #[clap(long, hide = true)] + ignore_restore: bool, +} + #[derive(Parser)] struct EagerFocus { /// Case-sensitive exe identifier @@ -584,7 +590,7 @@ enum SubCommand { /// Stop the komorebi.exe process and restore all hidden windows // komorebi for Windows signature // Stop(Stop), - Stop, + Stop(Stop), // /// Kill background processes started by komorebic // Kill(Kill), // /// Check komorebi configuration and related files for common errors @@ -1195,15 +1201,22 @@ fn main() -> eyre::Result<()> { "* Read the docs https://lgug2z.github.io/komorebi - Quickly search through all komorebic commands" ); } - SubCommand::Stop => { - let mut system = sysinfo::System::new_all(); - system.refresh_processes(ProcessesToUpdate::All, true); - - let running = system.processes_by_exact_name("komorebi".as_ref()).next(); - - if let Some(process) = running { - process.kill_with(Signal::Interrupt); + SubCommand::Stop(arg) => { + if arg.ignore_restore { + send_message(&SocketMessage::StopIgnoreRestore)?; + } else { + send_message(&SocketMessage::Stop)?; } + + // TODO: see if we need a force quit sometimes like we do on Windows + // let mut system = sysinfo::System::new_all(); + // system.refresh_processes(ProcessesToUpdate::All, true); + // + // let running = system.processes_by_exact_name("komorebi".as_ref()).next(); + // + // if let Some(process) = running { + // process.kill_with(Signal::Interrupt); + // } } SubCommand::Configuration => { let static_config = HOME_DIR.join("komorebi.json"); From 8c4c1963bcebfdd9040d6f311ba501dd13508ed6 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 09:52:29 -0700 Subject: [PATCH 058/305] 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. --- komorebi/src/process_event.rs | 245 +++++++++++++++++----------------- 1 file changed, 119 insertions(+), 126 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 59cbd6c3..a010ced3 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,7 +1,6 @@ use crate::FLOATING_APPLICATIONS; use crate::Notification; use crate::NotificationEvent; -use crate::PERMAIGNORE_CLASSES; use crate::REGEX_IDENTIFIERS; use crate::TABBED_APPLICATIONS; use crate::WORKSPACE_MATCHING_RULES; @@ -379,149 +378,143 @@ impl WindowManager { } // this happens sometimes because of the mouse event from input listener which emits a show - if let Some(element) = &window_element { - let subrole = AdhocWindow::subrole(element).unwrap_or_default(); - if PERMAIGNORE_CLASSES.lock().contains(&subrole) { - tracing::debug!( - "ignoring AXDialog window that got past the initial filter" - ); - create = false - } + // before a window has updated things like its subrole, so we need to check again + let application = self.application(process_id)?; + if let Some(element) = &window_element + && let Ok(window) = Window::new(element.clone(), application.clone()) + && !window.should_manage(Some(event))? + { + create = false; } - if create && !tabbed_window { - let application = self.application(process_id)?; - if let Some(element) = window_element - && let Ok(mut window) = Window::new(element, application.clone()) - { - window.observe(&self.run_loop)?; + if create + && !tabbed_window + && let Some(element) = window_element + && let Ok(mut window) = Window::new(element, application.clone()) + { + window.observe(&self.run_loop)?; - let behaviour = self.window_management_behaviour( - focused_monitor_idx, - focused_workspace_idx, - ); - let workspace = self.focused_workspace_mut()?; - let workspace_contains_window = workspace.contains_window(window.id); - let monocle_container = workspace.monocle_container.clone(); + let behaviour = self + .window_management_behaviour(focused_monitor_idx, focused_workspace_idx); + let workspace = self.focused_workspace_mut()?; + let workspace_contains_window = workspace.contains_window(window.id); + let monocle_container = workspace.monocle_container.clone(); - let floating_applications = FLOATING_APPLICATIONS.lock(); - let mut should_float = false; + let floating_applications = FLOATING_APPLICATIONS.lock(); + let mut should_float = false; - if !floating_applications.is_empty() { - let regex_identifiers = REGEX_IDENTIFIERS.lock(); + if !floating_applications.is_empty() { + let regex_identifiers = REGEX_IDENTIFIERS.lock(); - if let ( - Some(title), - Some(exe_name), - Some(role), - Some(subrole), - Some(path), - ) = ( - window.title(), - window.exe(), - window.role(), - window.subrole(), - window.path(), - ) { - should_float = should_act( - &title, - &exe_name, - &[&role, &subrole], - &path.to_string_lossy(), - &floating_applications, - ®ex_identifiers, - ) - .is_some(); - } + if let ( + Some(title), + Some(exe_name), + Some(role), + Some(subrole), + Some(path), + ) = ( + window.title(), + window.exe(), + window.role(), + window.subrole(), + window.path(), + ) { + should_float = should_act( + &title, + &exe_name, + &[&role, &subrole], + &path.to_string_lossy(), + &floating_applications, + ®ex_identifiers, + ) + .is_some(); } + } - if behaviour.float_override + if behaviour.float_override || behaviour.floating_layer_override // TODO: look into if we want to have a Manage command here too || (should_float /*&& !matches!(event, WindowManagerEvent::Manage(_))*/ ) - { - let placement = if behaviour.floating_layer_override { - // Floating layer override placement - behaviour.floating_layer_placement - } else if behaviour.float_override { - // Float override placement - behaviour.float_override_placement - } else { - // Float rule placement - behaviour.float_rule_placement - }; - // Center floating windows according to the proper placement if not - // on a floating workspace - let center_spawned_floats = placement.should_center() && workspace.tile; - workspace.floating_windows_mut().push_back(window.clone()); - workspace.layer = WorkspaceLayer::Floating; - if center_spawned_floats { - let mut floating_window = window.clone(); - floating_window.center( - &workspace.globals.work_area, - placement.should_resize(), - )?; - } - - self.update_focused_workspace(false, false)?; + { + let placement = if behaviour.floating_layer_override { + // Floating layer override placement + behaviour.floating_layer_placement + } else if behaviour.float_override { + // Float override placement + behaviour.float_override_placement } else { - match behaviour.current_behaviour { - WindowContainerBehaviour::Create => { - workspace.new_container_for_window(&window)?; - workspace.layer = WorkspaceLayer::Tiling; - self.update_focused_workspace(false, false)?; - } - WindowContainerBehaviour::Append => { - workspace - .focused_container_mut() - .ok_or_eyre("there is no focused container")? - .add_window(&window)?; - workspace.layer = WorkspaceLayer::Tiling; - self.update_focused_workspace(true, false)?; - } - } + // Float rule placement + behaviour.float_rule_placement + }; + // Center floating windows according to the proper placement if not + // on a floating workspace + let center_spawned_floats = placement.should_center() && workspace.tile; + workspace.floating_windows_mut().push_back(window.clone()); + workspace.layer = WorkspaceLayer::Floating; + if center_spawned_floats { + let mut floating_window = window.clone(); + floating_window + .center(&workspace.globals.work_area, placement.should_resize())?; + } - // TODO: not sure if this is needed on macOS - if (self.focused_workspace()?.containers().len() == 1 - && self.focused_workspace()?.floating_windows().is_empty()) - || (self.focused_workspace()?.containers().is_empty() - && self.focused_workspace()?.floating_windows().len() == 1) - { - // If after adding this window the workspace only contains 1 window, it - // means it was previously empty and we focused the desktop to unfocus - // any previous window from other workspace, so now we need to focus - // this window again. This is needed because sometimes some windows - // first send the `FocusChange` event and only the `Show` event after - // and we will be focusing the desktop on the `FocusChange` event since - // it is still empty. - window.focus(self.mouse_follows_focus)?; + self.update_focused_workspace(false, false)?; + } else { + match behaviour.current_behaviour { + WindowContainerBehaviour::Create => { + workspace.new_container_for_window(&window)?; + workspace.layer = WorkspaceLayer::Tiling; + self.update_focused_workspace(false, false)?; + } + WindowContainerBehaviour::Append => { + workspace + .focused_container_mut() + .ok_or_eyre("there is no focused container")? + .add_window(&window)?; + workspace.layer = WorkspaceLayer::Tiling; + self.update_focused_workspace(true, false)?; } } - if workspace_contains_window { - let mut monocle_window_event = false; - if let Some(ref monocle) = monocle_container - && let Some(monocle_window) = monocle.focused_window() - { - // we should have the window_id at this point - if monocle_window.id == window_id.unwrap_or_default() { - monocle_window_event = true; - } - } - - let workspace = self.focused_workspace()?; - if !(monocle_window_event || workspace.layer != WorkspaceLayer::Tiling) - && monocle_container.is_some() - { - window.hide()?; - } + // TODO: not sure if this is needed on macOS + if (self.focused_workspace()?.containers().len() == 1 + && self.focused_workspace()?.floating_windows().is_empty()) + || (self.focused_workspace()?.containers().is_empty() + && self.focused_workspace()?.floating_windows().len() == 1) + { + // If after adding this window the workspace only contains 1 window, it + // means it was previously empty and we focused the desktop to unfocus + // any previous window from other workspace, so now we need to focus + // this window again. This is needed because sometimes some windows + // first send the `FocusChange` event and only the `Show` event after + // and we will be focusing the desktop on the `FocusChange` event since + // it is still empty. + window.focus(self.mouse_follows_focus)?; } - - // let workspace = self.focused_workspace_mut()?; - // workspace.new_container_for_window(&window)?; - // - // self.update_focused_workspace(false, false)?; } + + if workspace_contains_window { + let mut monocle_window_event = false; + if let Some(ref monocle) = monocle_container + && let Some(monocle_window) = monocle.focused_window() + { + // we should have the window_id at this point + if monocle_window.id == window_id.unwrap_or_default() { + monocle_window_event = true; + } + } + + let workspace = self.focused_workspace()?; + if !(monocle_window_event || workspace.layer != WorkspaceLayer::Tiling) + && monocle_container.is_some() + { + window.hide()?; + } + } + + // let workspace = self.focused_workspace_mut()?; + // workspace.new_container_for_window(&window)?; + // + // self.update_focused_workspace(false, false)?; } } WindowManagerEvent::Destroy(_, process_id) => { From a89b9cf5acc275877a39fc0627f133eb649f2553 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 10:19:11 -0700 Subject: [PATCH 059/305] feat(cli): implement minimize cmd --- komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 5 +++++ komorebi/src/window.rs | 6 ++++++ komorebic/src/main.rs | 7 +++++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 35d34e9c..ea0114c4 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -248,7 +248,7 @@ pub enum SocketMessage { SwapWorkspacesToMonitorNumber(usize), // ForceFocus, // Close, - // Minimize, + Minimize, Promote, PromoteFocus, PromoteWindow(OperationDirection), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 0f74b17f..2262530f 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -240,6 +240,11 @@ impl WindowManager { } self.focus_container_window(idx)?; } + SocketMessage::Minimize => { + let foreground_window = + MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?; + AdhocWindow::minimize(&foreground_window)?; + } SocketMessage::LockMonitorWorkspaceContainer( monitor_idx, workspace_idx, diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 28bc8e40..ed6a4ca7 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -752,6 +752,12 @@ impl AdhocWindow { .map(|s| s.to_string()) } + pub fn minimize(element: &CFRetained) -> Result<(), AccessibilityError> { + let cf_boolean = CFBoolean::new(true); + let value = &**cf_boolean; + AccessibilityApi::set_attribute_cf_value(element, kAXMinimizedAttribute, value) + } + #[tracing::instrument(skip_all)] pub fn hide(id: u32, element: &CFRetained) -> Result<(), AccessibilityError> { let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 29caf8fe..80d6dcdb 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -660,8 +660,8 @@ enum SubCommand { /// Move the focused window in the specified direction #[clap(arg_required_else_help = true)] Move(Move), - // /// Minimize the focused window - // Minimize, + /// Minimize the focused window + Minimize, // /// Close the focused window // Close, // /// Forcibly focus the window at the cursor with a left mouse click @@ -1307,6 +1307,9 @@ fn main() -> eyre::Result<()> { SubCommand::Retile => { send_message(&SocketMessage::Retile)?; } + SubCommand::Minimize => { + send_message(&SocketMessage::Minimize)?; + } SubCommand::Promote => { send_message(&SocketMessage::Promote)?; } From 20d612156802a37eca7bc8d59035c77ce4099915 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 10:29:29 -0700 Subject: [PATCH 060/305] feat(cli): implement close cmd --- komorebi/src/accessibility/action_constants.rs | 12 ++++++++++++ komorebi/src/accessibility/mod.rs | 15 +++++++++++++++ komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 5 +++++ komorebi/src/window.rs | 12 ++++++++++++ komorebic/src/main.rs | 7 +++++-- 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 komorebi/src/accessibility/action_constants.rs diff --git a/komorebi/src/accessibility/action_constants.rs b/komorebi/src/accessibility/action_constants.rs new file mode 100644 index 00000000..6ac84e30 --- /dev/null +++ b/komorebi/src/accessibility/action_constants.rs @@ -0,0 +1,12 @@ +#![allow(non_upper_case_globals)] + +pub const kAXPressAction: &str = "AXPress"; +pub const kAXIncrementAction: &str = "AXIncrement"; +pub const kAXDecrementAction: &str = "AXDecrement"; +pub const kAXConfirmAction: &str = "AXConfirm"; +pub const kAXCancelAction: &str = "AXCancel"; +pub const kAXShowAlternateUIAction: &str = "AXShowAlternateUI"; +pub const kAXShowDefaultUIAction: &str = "AXShowDefaultUI"; +pub const kAXRaiseAction: &str = "AXRaise"; +pub const kAXShowMenuAction: &str = "AXShowMenu"; +pub const kAXPickAction: &str = "AXPick"; diff --git a/komorebi/src/accessibility/mod.rs b/komorebi/src/accessibility/mod.rs index fac385d6..0a799709 100644 --- a/komorebi/src/accessibility/mod.rs +++ b/komorebi/src/accessibility/mod.rs @@ -17,6 +17,7 @@ use objc2_core_foundation::kCFRunLoopDefaultMode; use objc2_core_graphics::CGWindowID; use std::ptr::NonNull; +pub mod action_constants; pub mod attribute_constants; pub mod error; pub mod notification_constants; @@ -100,6 +101,20 @@ impl AccessibilityApi { } } + pub fn perform_action( + element: &AXUIElement, + action: &'static str, + ) -> Result<(), AccessibilityError> { + unsafe { + match AccessibilityError::from( + element.perform_action(&CFString::from_static_str(action)), + ) { + AccessibilityError::Api(AccessibilityApiError::Success) => Ok(()), + error => Err(error), + } + } + } + pub fn create_application(process_id: i32) -> CFRetained { unsafe { AXUIElement::new_application(process_id) } } diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index ea0114c4..95c87194 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -247,7 +247,7 @@ pub enum SocketMessage { MoveWorkspaceToMonitorNumber(usize), SwapWorkspacesToMonitorNumber(usize), // ForceFocus, - // Close, + Close, Minimize, Promote, PromoteFocus, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 2262530f..acfa41b1 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -245,6 +245,11 @@ impl WindowManager { MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?; AdhocWindow::minimize(&foreground_window)?; } + SocketMessage::Close => { + let foreground_window = + MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?; + AdhocWindow::close(&foreground_window)?; + } SocketMessage::LockMonitorWorkspaceContainer( monitor_idx, workspace_idx, diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index ed6a4ca7..cfdc2c95 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -9,6 +9,8 @@ use crate::PERMAIGNORE_CLASSES; use crate::REGEX_IDENTIFIERS; use crate::WINDOW_RESTORE_POSITIONS; use crate::accessibility::AccessibilityApi; +use crate::accessibility::action_constants::kAXPressAction; +use crate::accessibility::attribute_constants::kAXCloseButtonAttribute; use crate::accessibility::attribute_constants::kAXFocusedAttribute; use crate::accessibility::attribute_constants::kAXMainAttribute; use crate::accessibility::attribute_constants::kAXMinimizedAttribute; @@ -758,6 +760,16 @@ impl AdhocWindow { AccessibilityApi::set_attribute_cf_value(element, kAXMinimizedAttribute, value) } + pub fn close(element: &CFRetained) -> Result<(), AccessibilityError> { + if let Some(close_button) = + AccessibilityApi::copy_attribute_value::(element, kAXCloseButtonAttribute) + { + AccessibilityApi::perform_action(&close_button, kAXPressAction) + } else { + Ok(()) + } + } + #[tracing::instrument(skip_all)] pub fn hide(id: u32, element: &CFRetained) -> Result<(), AccessibilityError> { let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 80d6dcdb..47842915 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -662,8 +662,8 @@ enum SubCommand { Move(Move), /// Minimize the focused window Minimize, - // /// Close the focused window - // Close, + /// Close the focused window + Close, // /// Forcibly focus the window at the cursor with a left mouse click // ForceFocus, /// Change focus to the window in the specified cycle direction @@ -1307,6 +1307,9 @@ fn main() -> eyre::Result<()> { SubCommand::Retile => { send_message(&SocketMessage::Retile)?; } + SubCommand::Close => { + send_message(&SocketMessage::Close)?; + } SubCommand::Minimize => { send_message(&SocketMessage::Minimize)?; } From c59e882a2d0452c1bcec728123739b9d5ba6a475 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 12:34:05 -0700 Subject: [PATCH 061/305] 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. --- komorebi/src/core/mod.rs | 4 +-- komorebi/src/lib.rs | 1 + komorebi/src/process_command.rs | 6 ++++ komorebi/src/process_event.rs | 42 ++++++++++++++++++++++++--- komorebi/src/window.rs | 21 ++++++++++++++ komorebi/src/window_manager.rs | 43 ++++++++++++++++++++++++++++ komorebi/src/window_manager_event.rs | 23 +++++++++++++++ komorebic/src/main.rs | 14 ++++++--- 8 files changed, 144 insertions(+), 10 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 95c87194..1f573bfe 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -266,8 +266,8 @@ pub enum SocketMessage { CrossMonitorMoveBehaviour(MoveBehaviour), UnmanagedWindowOperationBehaviour(OperationBehaviour), // Current Workspace Commands - // ManageFocusedWindow, - // UnmanageFocusedWindow, + ManageFocusedWindow, + UnmanageFocusedWindow, AdjustContainerPadding(Sizing, i32), AdjustWorkspacePadding(Sizing, i32), ChangeLayout(DefaultLayout), diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 830ea9e7..90a89b70 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -124,6 +124,7 @@ lazy_static! { ])); static ref DO_NOT_OBSERVE_APPLICATIONS: Arc>> = Arc::new(Mutex::new(vec!["Spotlight".to_string(),])); + static ref UNMANAGED_WINDOW_IDS: Arc>> = Arc::new(Mutex::new(vec![])); } shadow_rs::shadow!(build); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index acfa41b1..bc8e3ab0 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -250,6 +250,12 @@ impl WindowManager { MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?; AdhocWindow::close(&foreground_window)?; } + SocketMessage::ManageFocusedWindow => { + self.manage_focused_window()?; + } + SocketMessage::UnmanageFocusedWindow => { + self.unmanage_focused_window()?; + } SocketMessage::LockMonitorWorkspaceContainer( monitor_idx, workspace_idx, diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index a010ced3..bed3e37c 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -3,6 +3,7 @@ use crate::Notification; use crate::NotificationEvent; use crate::REGEX_IDENTIFIERS; use crate::TABBED_APPLICATIONS; +use crate::UNMANAGED_WINDOW_IDS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityApiError; @@ -69,9 +70,14 @@ impl WindowManager { if let Some(window_element) = application.main_window() && let Ok(window) = Window::new(window_element, application.clone()) { + let window_id = window.id; let print_window = window.clone(); should_manage = window.should_manage(Some(event))?; + if UNMANAGED_WINDOW_IDS.lock().contains(&window_id) { + should_manage = false; + } + if !should_manage { tracing::debug!( "ignoring event as window should not be managed: {print_window}" @@ -306,7 +312,8 @@ impl WindowManager { } } // TODO: update this to work with floating applications / rules - WindowManagerEvent::Show(_, process_id) => { + WindowManagerEvent::Show(_, process_id) + | WindowManagerEvent::Manage(_, process_id, _) => { let focused_monitor_idx = self.focused_monitor_idx(); let focused_workspace_idx = self.focused_workspace_idx_for_monitor_idx(focused_monitor_idx)?; @@ -432,9 +439,8 @@ impl WindowManager { } if behaviour.float_override - || behaviour.floating_layer_override - // TODO: look into if we want to have a Manage command here too - || (should_float /*&& !matches!(event, WindowManagerEvent::Manage(_))*/ ) + || behaviour.floating_layer_override + || (should_float && !matches!(event, WindowManagerEvent::Manage(_, _, _))) { let placement = if behaviour.floating_layer_override { // Floating layer override placement @@ -521,6 +527,34 @@ impl WindowManager { self.reap_invalid_windows_for_application(process_id)?; self.update_focused_workspace(false, false)?; } + WindowManagerEvent::Unmanage(_, _, window_id) => { + let behaviour = self.window_management_behaviour( + self.focused_monitor_idx(), + self.focused_workspace_idx()?, + ); + + let workspace = self.focused_workspace_mut()?; + let mut window = workspace.remove_window(window_id)?; + + // If we unmanaged a window, it shouldn't be immediately hidden behind managed windows + let placement = if behaviour.floating_layer_override { + // Floating layer override placement + behaviour.floating_layer_placement + } else if behaviour.float_override { + // Float override placement + behaviour.float_override_placement + } else { + // Float rule placement + behaviour.float_rule_placement + }; + + window.center(&workspace.globals.work_area, placement.should_resize())?; + + // we only want to add the window ID after the window has been removed + UNMANAGED_WINDOW_IDS.lock().push(window_id); + + self.update_focused_workspace(false, false)?; + } WindowManagerEvent::Minimize(_, _, window_id) => { self.extract_minimized_window(window_id)?; self.update_focused_workspace(false, false)?; diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index cfdc2c95..24693490 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -731,6 +731,20 @@ impl Window { pub struct AdhocWindow; impl AdhocWindow { + pub fn process_id(element: &CFRetained) -> Option { + let mut process_id = 0; + + unsafe { + element.pid(NonNull::from_mut(&mut process_id)); + } + + if process_id != 0 { + Some(process_id) + } else { + None + } + } + pub fn exe(element: &CFRetained) -> Option { let parent = AccessibilityApi::copy_attribute_value::(element, kAXParentAttribute)?; @@ -837,6 +851,13 @@ impl AdhocWindow { Ok(()) } + + pub fn raise(element: &CFRetained) -> Result<(), AccessibilityError> { + let cf_boolean = CFBoolean::new(true); + let value = &**cf_boolean; + AccessibilityApi::set_attribute_cf_value(element, kAXMainAttribute, value)?; + AccessibilityApi::set_attribute_cf_value(element, kAXFocusedAttribute, value) + } } impl From<&CFDictionary> for WindowInfo { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 1dcba0e0..848abf59 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -3,6 +3,7 @@ use crate::DATA_DIR; use crate::LibraryError; use crate::REGEX_IDENTIFIERS; use crate::SUBSCRIPTION_SOCKETS; +use crate::UNMANAGED_WINDOW_IDS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::application::Application; @@ -27,9 +28,13 @@ use crate::macos_api::MacosApi; use crate::monitor::Monitor; use crate::ring::Ring; use crate::static_config::StaticConfig; +use crate::window::AdhocWindow; use crate::window::Window; use crate::window::should_act_individual; +use crate::window_manager_event::ManualNotification; +use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; +use crate::window_manager_event_listener; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; use color_eyre::eyre; @@ -2635,4 +2640,42 @@ impl WindowManager { } workspace } + + #[tracing::instrument(skip(self))] + pub fn manage_focused_window(&mut self) -> eyre::Result<()> { + let element = MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?; + let window_id = MacosApi::foreground_window_id(); + if let Some(process_id) = AdhocWindow::process_id(&element) + && let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::Manual(ManualNotification::Manage), + process_id, + window_id, + ) + { + UNMANAGED_WINDOW_IDS + .lock() + .retain(|id| *id != window_id.unwrap_or_default()); + + window_manager_event_listener::send_notification(event); + } + + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn unmanage_focused_window(&mut self) -> eyre::Result<()> { + let element = MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?; + let window_id = MacosApi::foreground_window_id(); + if let Some(process_id) = AdhocWindow::process_id(&element) + && let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::Manual(ManualNotification::Unmanage), + process_id, + window_id, + ) + { + window_manager_event_listener::send_notification(event); + } + + Ok(()) + } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 0e018465..9c089921 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -21,6 +21,8 @@ pub enum ManualNotification { ShowOnInputEvent, ShowOnFocusChangeFirstTabDestroyed, ShowOnFocusChangeWindowlessAppRestored, + Manage, + Unmanage, } #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] @@ -32,6 +34,8 @@ pub enum WindowManagerEvent { Destroy(SystemNotification, i32), Minimize(SystemNotification, i32, u32), Restore(SystemNotification, i32, u32), + Manage(SystemNotification, i32, u32), + Unmanage(SystemNotification, i32, u32), } impl WindowManagerEvent { @@ -79,6 +83,10 @@ impl WindowManagerEvent { AccessibilityNotification::AXWindowDeminiaturized, ) => window_id .map(|window_id| WindowManagerEvent::Restore(notification, process_id, window_id)), + SystemNotification::Manual(ManualNotification::Manage) => window_id + .map(|window_id| WindowManagerEvent::Manage(notification, process_id, window_id)), + SystemNotification::Manual(ManualNotification::Unmanage) => window_id + .map(|window_id| WindowManagerEvent::Unmanage(notification, process_id, window_id)), // kAXWindowMovedNotification => {} // kAXWindowResizedNotification => {} // kAXTitleChangedNotification => {} @@ -93,6 +101,8 @@ impl WindowManagerEvent { | WindowManagerEvent::Show(_, process_id) | WindowManagerEvent::Destroy(_, process_id) | WindowManagerEvent::Minimize(_, process_id, _) + | WindowManagerEvent::Manage(_, process_id, _) + | WindowManagerEvent::Unmanage(_, process_id, _) | WindowManagerEvent::Restore(_, process_id, _) => *process_id, } } @@ -103,6 +113,8 @@ impl WindowManagerEvent { | WindowManagerEvent::Show(n, _) | WindowManagerEvent::Destroy(n, _) | WindowManagerEvent::Minimize(n, _, _) + | WindowManagerEvent::Manage(n, _, _) + | WindowManagerEvent::Unmanage(n, _, _) | WindowManagerEvent::Restore(n, _, _) => match n { SystemNotification::Accessibility(a) => a.to_string(), SystemNotification::AppKitWorkspace(a) => a.to_string(), @@ -110,4 +122,15 @@ impl WindowManagerEvent { }, } } + + pub fn window_id(&self) -> Option { + match self { + WindowManagerEvent::FocusChange(_, _, window_id) => *window_id, + WindowManagerEvent::Show(_, _) | WindowManagerEvent::Destroy(_, _) => None, + WindowManagerEvent::Minimize(_, _, window_id) + | WindowManagerEvent::Manage(_, _, window_id) + | WindowManagerEvent::Unmanage(_, _, window_id) + | WindowManagerEvent::Restore(_, _, window_id) => Some(*window_id), + } + } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 47842915..0eccc56f 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -929,10 +929,10 @@ enum SubCommand { ToggleLock, // /// Restore all hidden windows (debugging command) // RestoreWindows, - // /// Force komorebi to manage the focused window - // Manage, - // /// Unmanage a window that was forcibly managed - // Unmanage, + /// Force komorebi to manage the focused window + Manage, + /// Unmanage a window that was forcibly managed + Unmanage, // /// Replace the configuration of a running instance of komorebi from a static configuration file // #[clap(arg_required_else_help = true)] // ReplaceConfiguration(ReplaceConfiguration), @@ -1313,6 +1313,12 @@ fn main() -> eyre::Result<()> { SubCommand::Minimize => { send_message(&SocketMessage::Minimize)?; } + SubCommand::Manage => { + send_message(&SocketMessage::ManageFocusedWindow)?; + } + SubCommand::Unmanage => { + send_message(&SocketMessage::UnmanageFocusedWindow)?; + } SubCommand::Promote => { send_message(&SocketMessage::Promote)?; } From 8f36549fae07685946e96dd618bb62fd343dc393 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 12:41:10 -0700 Subject: [PATCH 062/305] feat(cli): implement generate-static-config cmd --- komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 6 ++++++ komorebi/src/static_config.rs | 6 +++++- komorebic/src/main.rs | 7 +++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 1f573bfe..06184ea4 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -406,7 +406,7 @@ pub enum SocketMessage { NotificationSchema, SocketSchema, StaticConfigSchema, - // GenerateStaticConfig, + GenerateStaticConfig, // DebugWindow(isize), } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index bc8e3ab0..62382f64 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -29,6 +29,7 @@ use crate::monitor::MonitorInformation; use crate::notify_subscribers; use crate::state::GlobalState; use crate::state::State; +use crate::static_config::StaticConfig; use crate::window::AdhocWindow; use crate::window_manager::WindowManager; use crate::workspace::WorkspaceLayer; @@ -1533,6 +1534,11 @@ impl WindowManager { SocketMessage::StopIgnoreRestore => { self.stop(true)?; } + SocketMessage::GenerateStaticConfig => { + let config = serde_json::to_string_pretty(&StaticConfig::from(&*self))?; + + reply.write_all(config.as_bytes())?; + } } notify_subscribers( diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 72ba23fa..58759718 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -258,7 +258,11 @@ impl From<&Workspace> for WorkspaceConfig { work_area_offset: value.work_area_offset, apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset), window_container_behaviour: value.window_container_behaviour, - window_container_behaviour_rules: Option::from(window_container_behaviour_rules), + window_container_behaviour_rules: if window_container_behaviour_rules.is_empty() { + None + } else { + Some(window_container_behaviour_rules) + }, float_override: value.float_override, tile, layout_flip: value.layout_flip, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 0eccc56f..18019743 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1098,8 +1098,8 @@ enum SubCommand { SocketSchema, /// Generate a JSON Schema of the static configuration file StaticConfigSchema, - // /// Generates a static configuration JSON file based on the current window manager state - // GenerateStaticConfig, + /// Generates a static configuration JSON file based on the current window manager state + GenerateStaticConfig, // /// Generates the komorebi.lnk shortcut in shell:startup to autostart komorebi // EnableAutostart(EnableAutostart), // /// Deletes the komorebi.lnk shortcut in shell:startup to disable autostart @@ -1773,6 +1773,9 @@ fn main() -> eyre::Result<()> { SubCommand::UnsubscribeSocket(arg) => { send_message(&SocketMessage::RemoveSubscriberSocket(arg.socket))?; } + SubCommand::GenerateStaticConfig => { + print_query(&SocketMessage::GenerateStaticConfig); + } } Ok(()) From 563c3b8446e092fa18cdbd7b57edd2044f52b158 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 13:53:35 -0700 Subject: [PATCH 063/305] feat(cli): implement save/load resize dimensions cmds --- komorebi/src/core/mod.rs | 8 ++--- komorebi/src/process_command.rs | 55 +++++++++++++++++++++++++++++++++ komorebic/src/main.rs | 54 +++++++++++++++++++++++--------- 3 files changed, 99 insertions(+), 18 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 06184ea4..8084a471 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -289,10 +289,10 @@ pub enum SocketMessage { TogglePause, Retile, RetileWithResizeDimensions, - // QuickSave, - // QuickLoad, - // Save(#[serde_as(as = "ResolvedPathBuf")] PathBuf), - // Load(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + QuickSave, + QuickLoad, + Save(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + Load(#[serde_as(as = "ResolvedPathBuf")] PathBuf), CycleFocusMonitor(CycleDirection), CycleFocusWorkspace(CycleDirection), CycleFocusEmptyWorkspace(CycleDirection), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 62382f64..f951470e 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -35,9 +35,12 @@ use crate::window_manager::WindowManager; use crate::workspace::WorkspaceLayer; use crate::workspace::WorkspaceWindowLocation; use color_eyre::eyre; +use color_eyre::eyre::Context; use color_eyre::eyre::OptionExt; use parking_lot::Mutex; use std::collections::HashMap; +use std::fs::File; +use std::fs::OpenOptions; use std::io::BufRead; use std::io::BufReader; use std::num::NonZeroUsize; @@ -1539,6 +1542,58 @@ impl WindowManager { reply.write_all(config.as_bytes())?; } + SocketMessage::QuickSave => { + let workspace = self.focused_workspace()?; + let resize = &workspace.resize_dimensions; + + let quicksave_json = std::env::temp_dir().join("komorebi.quicksave.json"); + + let file = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(quicksave_json)?; + + serde_json::to_writer_pretty(&file, &resize)?; + } + SocketMessage::QuickLoad => { + let workspace = self.focused_workspace_mut()?; + + let quicksave_json = std::env::temp_dir().join("komorebi.quicksave.json"); + + let file = File::open(&quicksave_json).wrap_err(format!( + "no quicksave found at {}", + quicksave_json.display() + ))?; + + let resize: Vec> = serde_json::from_reader(file)?; + + workspace.resize_dimensions = resize; + self.update_focused_workspace(false, false)?; + } + SocketMessage::Save(ref path) => { + let workspace = self.focused_workspace_mut()?; + let resize = &workspace.resize_dimensions; + + let file = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(path)?; + + serde_json::to_writer_pretty(&file, &resize)?; + } + SocketMessage::Load(ref path) => { + let workspace = self.focused_workspace_mut()?; + + let file = + File::open(path).wrap_err(format!("no file found at {}", path.display()))?; + + let resize: Vec> = serde_json::from_reader(file)?; + + workspace.resize_dimensions = resize; + self.update_focused_workspace(false, false)?; + } } notify_subscribers( diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 18019743..aa4d3c81 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -560,6 +560,20 @@ struct Stop { ignore_restore: bool, } +#[derive(Parser)] +struct SaveResize { + /// File to which the resize layout dimensions should be saved + #[clap(value_parser = replace_env_in_path)] + path: PathBuf, +} + +#[derive(Parser)] +struct LoadResize { + /// File from which the resize layout dimensions should be loaded + #[clap(value_parser = replace_env_in_path)] + path: PathBuf, +} + #[derive(Parser)] struct EagerFocus { /// Case-sensitive exe identifier @@ -640,20 +654,20 @@ enum SubCommand { // UnsubscribePipe(UnsubscribePipe), /// Tail komorebi.exe's process logs (cancel with Ctrl-C) Log, - // /// Quicksave the current resize layout dimensions - // #[clap(alias = "quick-save")] - // QuickSaveResize, - // /// Load the last quicksaved resize layout dimensions - // #[clap(alias = "quick-load")] - // QuickLoadResize, - // /// Save the current resize layout dimensions to a file - // #[clap(arg_required_else_help = true)] - // #[clap(alias = "save")] - // SaveResize(SaveResize), - // /// Load the resize layout dimensions from a file - // #[clap(arg_required_else_help = true)] - // #[clap(alias = "load")] - // LoadResize(LoadResize), + /// Quicksave the current resize layout dimensions + #[clap(alias = "quick-save")] + QuickSaveResize, + /// Load the last quicksaved resize layout dimensions + #[clap(alias = "quick-load")] + QuickLoadResize, + /// Save the current resize layout dimensions to a file + #[clap(arg_required_else_help = true)] + #[clap(alias = "save")] + SaveResize(SaveResize), + /// Load the resize layout dimensions from a file + #[clap(arg_required_else_help = true)] + #[clap(alias = "load")] + LoadResize(LoadResize), /// Change focus to the window in the specified direction #[clap(arg_required_else_help = true)] Focus(Focus), @@ -1776,6 +1790,18 @@ fn main() -> eyre::Result<()> { SubCommand::GenerateStaticConfig => { print_query(&SocketMessage::GenerateStaticConfig); } + SubCommand::QuickSaveResize => { + send_message(&SocketMessage::QuickSave)?; + } + SubCommand::QuickLoadResize => { + send_message(&SocketMessage::QuickLoad)?; + } + SubCommand::SaveResize(arg) => { + send_message(&SocketMessage::Save(arg.path))?; + } + SubCommand::LoadResize(arg) => { + send_message(&SocketMessage::Load(arg.path))?; + } } Ok(()) From 61369df025dbae59472cdc5b302e2a5993fbf9e6 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 14:09:49 -0700 Subject: [PATCH 064/305] 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. --- komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 30 +++++++++++++++++ komorebi/src/process_event.rs | 7 ++-- komorebi/src/window.rs | 60 ++++++++++++++++++++++++--------- 4 files changed, 80 insertions(+), 19 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 8084a471..bf80cf9c 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -407,7 +407,7 @@ pub enum SocketMessage { SocketSchema, StaticConfigSchema, GenerateStaticConfig, - // DebugWindow(isize), + DebugWindow(u32), } impl SocketMessage { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index f951470e..f48ef02f 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -8,7 +8,10 @@ use crate::SESSION_FLOATING_APPLICATIONS; use crate::SUBSCRIPTION_SOCKET_OPTIONS; use crate::SUBSCRIPTION_SOCKETS; use crate::WORKSPACE_MATCHING_RULES; +use crate::accessibility::AccessibilityApi; +use crate::application::Application; use crate::build; +use crate::cf_array_as; use crate::core::ApplicationIdentifier; use crate::core::MoveBehaviour; use crate::core::SocketMessage; @@ -24,6 +27,7 @@ use crate::core::default_layout::ScrollingLayoutOptions; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use crate::core_graphics::CoreGraphicsApi; use crate::macos_api::MacosApi; use crate::monitor::MonitorInformation; use crate::notify_subscribers; @@ -31,12 +35,16 @@ use crate::state::GlobalState; use crate::state::State; use crate::static_config::StaticConfig; use crate::window::AdhocWindow; +use crate::window::RuleDebug; +use crate::window::Window; +use crate::window::WindowInfo; use crate::window_manager::WindowManager; use crate::workspace::WorkspaceLayer; use crate::workspace::WorkspaceWindowLocation; use color_eyre::eyre; use color_eyre::eyre::Context; use color_eyre::eyre::OptionExt; +use objc2_core_foundation::CFDictionary; use parking_lot::Mutex; use std::collections::HashMap; use std::fs::File; @@ -1594,6 +1602,28 @@ impl WindowManager { workspace.resize_dimensions = resize; self.update_focused_workspace(false, false)?; } + SocketMessage::DebugWindow(window_id) => { + if let Some(window_list_info) = CoreGraphicsApi::window_list_info() { + for raw_window_info in cf_array_as::(&window_list_info) { + let raw_info = WindowInfo::new(raw_window_info); + let application = Application::new(raw_info.owner_pid)?; + if let Some(elements) = application.window_elements() { + for element in elements { + if let Ok(wid) = AccessibilityApi::window_id(&element) + && wid == window_id + && let Ok(window) = Window::new(element, application.clone()) + { + let mut rule_debug = RuleDebug::default(); + let _ = window.should_manage(None, &mut rule_debug); + let schema = serde_json::to_string_pretty(&rule_debug)?; + + reply.write_all(schema.as_bytes())?; + } + } + } + } + } + } } notify_subscribers( diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index bed3e37c..e9b3fafd 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -18,6 +18,7 @@ use crate::macos_api::MacosApi; use crate::notify_subscribers; use crate::state::State; use crate::window::AdhocWindow; +use crate::window::RuleDebug; use crate::window::Window; use crate::window::should_act; use crate::window_manager::WindowManager; @@ -64,6 +65,8 @@ impl WindowManager { return Ok(()); } + let mut rule_debug = RuleDebug::default(); + let mut should_manage = true; { let application = self.application(event.process_id())?; @@ -72,7 +75,7 @@ impl WindowManager { { let window_id = window.id; let print_window = window.clone(); - should_manage = window.should_manage(Some(event))?; + should_manage = window.should_manage(Some(event), &mut rule_debug)?; if UNMANAGED_WINDOW_IDS.lock().contains(&window_id) { should_manage = false; @@ -389,7 +392,7 @@ impl WindowManager { let application = self.application(process_id)?; if let Some(element) = &window_element && let Ok(window) = Window::new(element.clone(), application.clone()) - && !window.should_manage(Some(event))? + && !window.should_manage(Some(event), &mut rule_debug)? { create = false; } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 24693490..68869947 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -132,7 +132,7 @@ unsafe extern "C-unwind" fn window_observer_callback( #[derive(Debug, Default)] pub struct WindowInfo { name: Option, - owner_pid: i32, + pub owner_pid: i32, owner_name: String, alpha: f32, bounds: WindowBounds, @@ -642,13 +642,13 @@ impl Window { pub fn should_manage( self, event: Option, - // debug: &mut RuleDebug, + debug: &mut RuleDebug, ) -> eyre::Result { if !self.is_valid() { return Ok(false); } - // debug.is_window = true; + debug.is_window = true; // let rect = Rect::from(MacosApi::window_rect(&self.element).unwrap_or_default()); // @@ -668,7 +668,7 @@ impl Window { return Ok(false); } - // debug.has_title = true; + debug.has_title = true; // let is_cloaked = self.is_cloaked().unwrap_or_default(); // @@ -699,10 +699,11 @@ impl Window { self.subrole(), self.path(), ) { - // debug.title = Some(title.clone()); - // debug.exe_name = Some(exe_name.clone()); - // debug.class = Some(class.clone()); - // debug.path = Some(path.clone()); + debug.title = Some(title.clone()); + debug.exe_name = Some(exe_name.clone()); + debug.role = Some(role.clone()); + debug.subrole = Some(subrole.clone()); + debug.path = Some(path.to_string_lossy().to_string()); // calls for styles can fail quite often for events with windows that aren't really "windows" // since we have moved up calls of should_manage to the beginning of the process_event handler, // we should handle failures here gracefully to be able to continue the execution of process_event @@ -716,6 +717,7 @@ impl Window { &[&role, &subrole], &path.to_string_lossy(), event, + debug, ); // debug.should_manage = eligible; return Ok(eligible); @@ -962,6 +964,32 @@ impl AspectRatio { } } +#[derive(Debug, Default, Serialize, Deserialize)] +pub struct RuleDebug { + pub should_manage: bool, + pub is_window: bool, + // pub has_minimum_width: bool, + // pub has_minimum_height: bool, + pub has_title: bool, + // pub is_cloaked: bool, + // pub allow_cloaked: bool, + // pub allow_layered_transparency: bool, + // pub window_style: Option, + // pub extended_window_style: Option, + pub title: Option, + pub exe_name: Option, + pub role: Option, + pub subrole: Option, + pub path: Option, + pub matches_permaignore_class: Option, + pub matches_ignore_identifier: Option, + pub matches_managed_override: Option, + // pub matches_layered_whitelist: Option, + pub matches_floating_applications: Option, + // pub matches_wsl2_gui: Option, + // pub matches_no_titlebar: Option, +} + #[allow(clippy::too_many_arguments)] fn window_is_eligible( _window_id: u32, @@ -972,13 +1000,13 @@ fn window_is_eligible( // style: &WindowStyle, // ex_style: &ExtendedWindowStyle, _event: Option, - // debug: &mut RuleDebug, + debug: &mut RuleDebug, ) -> bool { { let permaignore_classes = PERMAIGNORE_CLASSES.lock(); for class in classes { if permaignore_classes.contains(&class.to_string()) { - // debug.matches_permaignore_class = Some(class.clone()); + debug.matches_permaignore_class = Some(class.to_string()); return false; } } @@ -987,7 +1015,7 @@ fn window_is_eligible( let regex_identifiers = REGEX_IDENTIFIERS.lock(); let ignore_identifiers = IGNORE_IDENTIFIERS.lock(); - let should_ignore = if let Some(_rule) = should_act( + let should_ignore = if let Some(rule) = should_act( title, exe_name, classes, @@ -995,14 +1023,14 @@ fn window_is_eligible( &ignore_identifiers, ®ex_identifiers, ) { - // debug.matches_ignore_identifier = Some(rule); + debug.matches_ignore_identifier = Some(rule); true } else { false }; let manage_identifiers = MANAGE_IDENTIFIERS.lock(); - let managed_override = if let Some(_rule) = should_act( + let managed_override = if let Some(rule) = should_act( title, exe_name, classes, @@ -1010,14 +1038,14 @@ fn window_is_eligible( &manage_identifiers, ®ex_identifiers, ) { - // debug.matches_managed_override = Some(rule); + debug.matches_managed_override = Some(rule); true } else { false }; let floating_identifiers = FLOATING_APPLICATIONS.lock(); - if let Some(_rule) = should_act( + if let Some(rule) = should_act( title, exe_name, classes, @@ -1025,7 +1053,7 @@ fn window_is_eligible( &floating_identifiers, ®ex_identifiers, ) { - // debug.matches_floating_applications = Some(rule); + debug.matches_floating_applications = Some(rule); } if should_ignore && !managed_override { From c66db5a0bd264949c8c98ee87c56eafbca3a34e9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 14:23:41 -0700 Subject: [PATCH 065/305] 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. --- komorebi/src/core/mod.rs | 2 +- komorebi/src/lib.rs | 3 ++ komorebi/src/process_command.rs | 6 ++- komorebi/src/static_config.rs | 68 ++++++++++++++++----------------- komorebic/src/main.rs | 20 ++++++++-- 5 files changed, 60 insertions(+), 39 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index bf80cf9c..60451749 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -279,7 +279,7 @@ pub enum SocketMessage { ToggleWorkspaceFloatOverride, // Monitor and Workspace Commands // MonitorIndexPreference(usize, i32, i32, i32, i32), - // DisplayIndexPreference(usize, String), + DisplayIndexPreference(usize, String), EnsureWorkspaces(usize, usize), EnsureNamedWorkspaces(usize, Vec), NewWorkspace, diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 90a89b70..e7c157ba 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -29,6 +29,7 @@ use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; use parking_lot::Mutex; +use parking_lot::RwLock; use regex::Regex; use serde::Deserialize; use serde::Serialize; @@ -94,6 +95,8 @@ lazy_static! { static ref FLOATING_WINDOW_TOGGLE_ASPECT_RATIO: Arc> = Arc::new(Mutex::new( AspectRatio::Predefined(PredefinedAspectRatio::Widescreen) )); + static ref DISPLAY_INDEX_PREFERENCES: Arc>> = + Arc::new(RwLock::new(HashMap::new())); static ref WINDOW_RESTORE_POSITIONS: Arc>> = Arc::new(Mutex::new(HashMap::new())); pub static ref UPDATE_MONITOR_WORK_AREAS: Arc = Arc::new(AtomicBool::new(false)); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index f48ef02f..e43bfdcc 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,4 +1,5 @@ use crate::DATA_DIR; +use crate::DISPLAY_INDEX_PREFERENCES; use crate::FLOATING_APPLICATIONS; use crate::IGNORE_IDENTIFIERS; use crate::MANAGE_IDENTIFIERS; @@ -1624,8 +1625,11 @@ impl WindowManager { } } } + SocketMessage::DisplayIndexPreference(index_preference, ref display) => { + let mut display_index_preferences = DISPLAY_INDEX_PREFERENCES.write(); + display_index_preferences.insert(index_preference, display.clone()); + } } - notify_subscribers( Notification { event: NotificationEvent::Socket(message.clone()), diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 58759718..b0030726 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -2,6 +2,7 @@ use crate::CoreFoundationRunLoop; use crate::DATA_DIR; use crate::DEFAULT_CONTAINER_PADDING; use crate::DEFAULT_WORKSPACE_PADDING; +use crate::DISPLAY_INDEX_PREFERENCES; use crate::FLOATING_APPLICATIONS; use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO; use crate::IGNORE_IDENTIFIERS; @@ -480,9 +481,9 @@ pub struct StaticConfig { // /// Set monitor index preferences // #[serde(skip_serializing_if = "Option::is_none")] // pub monitor_index_preferences: Option>, - // /// Set display index preferences - // #[serde(skip_serializing_if = "Option::is_none")] - // pub display_index_preferences: Option>, + /// Set display index preferences + #[serde(skip_serializing_if = "Option::is_none")] + pub display_index_preferences: Option>, // /// Stackbar configuration options // #[serde(skip_serializing_if = "Option::is_none")] // pub stackbar: Option, @@ -772,7 +773,7 @@ impl From<&WindowManager> for StaticConfig { object_name_change_applications: None, object_name_change_title_ignore_list: None, // monitor_index_preferences: Option::from(MONITOR_INDEX_PREFERENCES.lock().clone()), - // display_index_preferences: Option::from(DISPLAY_INDEX_PREFERENCES.read().clone()), + display_index_preferences: Option::from(DISPLAY_INDEX_PREFERENCES.read().clone()), // stackbar: None, // animation: None, // theme: None, @@ -800,10 +801,10 @@ impl StaticConfig { // preferences.clone_from(monitor_index_preferences); // } // - // if let Some(display_index_preferences) = &self.display_index_preferences { - // let mut preferences = DISPLAY_INDEX_PREFERENCES.write(); - // preferences.clone_from(display_index_preferences); - // } + if let Some(display_index_preferences) = &self.display_index_preferences { + let mut preferences = DISPLAY_INDEX_PREFERENCES.write(); + preferences.clone_from(display_index_preferences); + } // if let Some(behaviour) = self.window_hiding_behaviour { // let mut window_hiding_behaviour = HIDING_BEHAVIOUR.lock(); @@ -1197,9 +1198,8 @@ impl StaticConfig { let mut value = Self::read(path)?; let mut wm = wm.lock(); - // let configs_with_preference: Vec<_> = - // DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect(); - let configs_with_preference = []; + let configs_with_preference: Vec<_> = + DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect(); let mut configs_used = Vec::new(); let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); @@ -1210,16 +1210,17 @@ impl StaticConfig { let offset = wm.work_area_offset; for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() { - let preferred_config_idx = None; - // let preferred_config_idx = { - // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); - // let c_idx = display_index_preferences.iter().find_map(|(c_idx, id)| { - // (monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id) - // || monitor.device_id.eq(id)) - // .then_some(*c_idx) - // }); - // c_idx - // }; + let preferred_config_idx = { + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + + display_index_preferences.iter().find_map(|(c_idx, id)| { + if monitor.serial_number_id.eq(id) { + Some(*c_idx) + } else { + None + } + }) + }; let idx = preferred_config_idx.or({ // Monitor without preferred config idx. @@ -1374,9 +1375,8 @@ impl StaticConfig { value.apply_globals()?; - // let configs_with_preference: Vec<_> = - // DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect(); - let configs_with_preference = []; + let configs_with_preference: Vec<_> = + DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect(); let mut configs_used = Vec::new(); let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); @@ -1385,17 +1385,17 @@ impl StaticConfig { let offset = wm.work_area_offset; for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() { - // let preferred_config_idx = { - // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); - // let c_idx = display_index_preferences.iter().find_map(|(c_idx, id)| { - // (monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id) - // || monitor.device_id.eq(id)) - // .then_some(*c_idx) - // }); - // c_idx - // }; + let preferred_config_idx = { + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); - let preferred_config_idx = None; + display_index_preferences.iter().find_map(|(c_idx, id)| { + if monitor.serial_number_id.eq(id) { + Some(*c_idx) + } else { + None + } + }) + }; let idx = preferred_config_idx.or({ // Monitor without preferred config idx. diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index aa4d3c81..51d96779 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -525,6 +525,14 @@ pub struct NamedWorkspaceLayoutRule { layout: DefaultLayout, } +#[derive(Parser)] +struct DisplayIndexPreference { + /// Preferred monitor index (zero-indexed) + index_preference: usize, + /// Display name as identified in komorebic state + display: String, +} + #[derive(Parser)] struct EnsureWorkspaces { /// Monitor index (zero-indexed) @@ -851,9 +859,9 @@ enum SubCommand { // /// Set the monitor index preference for a monitor identified using its size // #[clap(arg_required_else_help = true)] // MonitorIndexPreference(MonitorIndexPreference), - // /// Set the display index preference for a monitor identified using its display name - // #[clap(arg_required_else_help = true)] - // DisplayIndexPreference(DisplayIndexPreference), + /// Set the display index preference for a monitor identified using its display name + #[clap(arg_required_else_help = true)] + DisplayIndexPreference(DisplayIndexPreference), /// Create at least this many workspaces for the specified monitor #[clap(arg_required_else_help = true)] EnsureWorkspaces(EnsureWorkspaces), @@ -1802,6 +1810,12 @@ fn main() -> eyre::Result<()> { SubCommand::LoadResize(arg) => { send_message(&SocketMessage::Load(arg.path))?; } + SubCommand::DisplayIndexPreference(arg) => { + send_message(&SocketMessage::DisplayIndexPreference( + arg.index_preference, + arg.display, + ))?; + } } Ok(()) From 7217f311f299273cc20a5ea8f6d1be116ececf8c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 14:32:06 -0700 Subject: [PATCH 066/305] 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. --- komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 31 +++++++++++++++++++++++++++++++ komorebic/src/main.rs | 16 +++++++++++++--- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 60451749..1a1944d7 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -331,7 +331,7 @@ pub enum SocketMessage { ToggleWorkspaceLayer, // Configuration // ReloadConfiguration, - // ReplaceConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), + ReplaceConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), ReloadStaticConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), // WatchConfiguration(bool), // CompleteConfiguration, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index e43bfdcc..7e4a3746 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -40,6 +40,7 @@ use crate::window::RuleDebug; use crate::window::Window; use crate::window::WindowInfo; use crate::window_manager::WindowManager; +use crate::window_manager_event_listener; use crate::workspace::WorkspaceLayer; use crate::workspace::WorkspaceWindowLocation; use color_eyre::eyre; @@ -1629,6 +1630,36 @@ impl WindowManager { let mut display_index_preferences = DISPLAY_INDEX_PREFERENCES.write(); display_index_preferences.insert(index_preference, display.clone()); } + SocketMessage::ReplaceConfiguration(ref config) => { + // Check that this is a valid static config file first + if StaticConfig::read(config).is_ok() { + // Clear workspace rules; these will need to be replaced + WORKSPACE_MATCHING_RULES.lock().clear(); + // Pause so that restored windows come to the foreground from all workspaces + self.is_paused = true; + // Bring all windows to the foreground + self.restore_all_windows(false)?; + + // Create a new wm from the config path + let mut wm = StaticConfig::preload( + config, + window_manager_event_listener::event_rx(), + self.command_listener.try_clone().ok(), + &self.run_loop.0, + )?; + + // Initialize the new wm + wm.init()?; + + wm.restore_all_windows(true)?; + + // This is equivalent to StaticConfig::postload for this use case + StaticConfig::reload(config, &mut wm)?; + + // Set self to the new wm instance + *self = wm; + } + } } notify_subscribers( Notification { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 51d96779..40ef2dce 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -582,6 +582,13 @@ struct LoadResize { path: PathBuf, } +#[derive(Parser)] +struct ReplaceConfiguration { + /// Static configuration JSON file from which the configuration should be loaded + #[clap(value_parser = replace_env_in_path)] + path: PathBuf, +} + #[derive(Parser)] struct EagerFocus { /// Case-sensitive exe identifier @@ -955,9 +962,9 @@ enum SubCommand { Manage, /// Unmanage a window that was forcibly managed Unmanage, - // /// Replace the configuration of a running instance of komorebi from a static configuration file - // #[clap(arg_required_else_help = true)] - // ReplaceConfiguration(ReplaceConfiguration), + /// Replace the configuration of a running instance of komorebi from a static configuration file + #[clap(arg_required_else_help = true)] + ReplaceConfiguration(ReplaceConfiguration), // /// Reload legacy komorebi.ahk or komorebi.ps1 configurations (if they exist) // ReloadConfiguration, // /// Enable or disable watching of legacy komorebi.ahk or komorebi.ps1 configurations (if they exist) @@ -1816,6 +1823,9 @@ fn main() -> eyre::Result<()> { arg.display, ))?; } + SubCommand::ReplaceConfiguration(arg) => { + send_message(&SocketMessage::ReplaceConfiguration(arg.path))?; + } } Ok(()) From a6ced512d74d4ee32f3291b662d0ca33c81344d3 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 17:19:59 -0700 Subject: [PATCH 067/305] 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. --- .../src/display_reconfiguration_listener.rs | 54 +- komorebi/src/lib.rs | 5 + komorebi/src/macos_api.rs | 174 ++++++- komorebi/src/main.rs | 8 + komorebi/src/monitor.rs | 46 ++ komorebi/src/monitor_reconciliator.rs | 473 +++++++++++++++++- komorebi/src/state.rs | 9 +- komorebi/src/static_config.rs | 102 ++-- komorebi/src/window_manager.rs | 2 + komorebi/src/workspace.rs | 7 + 10 files changed, 797 insertions(+), 83 deletions(-) diff --git a/komorebi/src/display_reconfiguration_listener.rs b/komorebi/src/display_reconfiguration_listener.rs index 0683f2d3..0056d3a5 100644 --- a/komorebi/src/display_reconfiguration_listener.rs +++ b/komorebi/src/display_reconfiguration_listener.rs @@ -18,19 +18,45 @@ unsafe extern "C-unwind" fn callback( tracing::debug!("display: {display_id} resized"); monitor_reconciliator::send_notification(MonitorNotification::Resize(display_id)); } + if flags.contains(CGDisplayChangeSummaryFlags::AddFlag) { + tracing::debug!("display: {display_id} added"); + monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + display_id, + )); + } + + if flags.contains(CGDisplayChangeSummaryFlags::RemoveFlag) { + tracing::debug!("display: {display_id} removed"); + monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + display_id, + )); + } + + if flags.contains(CGDisplayChangeSummaryFlags::EnabledFlag) { + tracing::debug!("display: {display_id} enabled"); + monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + display_id, + )); + } + + if flags.contains(CGDisplayChangeSummaryFlags::DisabledFlag) { + tracing::debug!("display: {display_id} disabled"); + monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + display_id, + )); + } + + if flags.contains(CGDisplayChangeSummaryFlags::MovedFlag) { + tracing::debug!("display: {display_id} moved"); + monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + display_id, + )); + } // if flags.contains(CGDisplayChangeSummaryFlags::BeginConfigurationFlag) { // tracing::debug!("display: {display_id} configured"); // } // - // if flags.contains(CGDisplayChangeSummaryFlags::AddFlag) { - // tracing::debug!("display: {display_id} added"); - // } - // - // if flags.contains(CGDisplayChangeSummaryFlags::RemoveFlag) { - // tracing::debug!("display: {display_id} removed"); - // } - // // if flags.contains(CGDisplayChangeSummaryFlags::MirrorFlag) { // tracing::debug!("display: {display_id} mirrored"); // } @@ -39,18 +65,6 @@ unsafe extern "C-unwind" fn callback( // tracing::debug!("display: {display_id} unmirrored"); // } // - // if flags.contains(CGDisplayChangeSummaryFlags::EnabledFlag) { - // tracing::debug!("display: {display_id} enabled"); - // } - // - // if flags.contains(CGDisplayChangeSummaryFlags::DisabledFlag) { - // tracing::debug!("display: {display_id} disabled"); - // } - // - // if flags.contains(CGDisplayChangeSummaryFlags::DisabledFlag) { - // tracing::debug!("display: {display_id} disabled"); - // } - // // tracing::trace!("display: {display_id}, flags: {flags:?}"); } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index e7c157ba..04b1e9fb 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -10,6 +10,7 @@ use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; use crate::core::config_generation::WorkspaceMatchingRule; use crate::core_graphics::error::CoreGraphicsError; +use crate::monitor::Monitor; use crate::monitor_reconciliator::MonitorNotification; use crate::state::State; use crate::window::AspectRatio; @@ -100,6 +101,10 @@ lazy_static! { static ref WINDOW_RESTORE_POSITIONS: Arc>> = Arc::new(Mutex::new(HashMap::new())); pub static ref UPDATE_MONITOR_WORK_AREAS: Arc = Arc::new(AtomicBool::new(false)); + pub static ref UPDATE_LATEST_MONITOR_INFORMATION: Arc = + Arc::new(AtomicBool::new(false)); + pub static ref LATEST_MONITOR_INFORMATION: Arc>>> = + Arc::new(RwLock::new(None)); static ref WORKSPACE_MATCHING_RULES: Arc>> = Arc::new(Mutex::new(Vec::new())); static ref REGEX_IDENTIFIERS: Arc>> = diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 23652e2d..b5888e17 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -1,3 +1,4 @@ +use crate::DISPLAY_INDEX_PREFERENCES; use crate::LibraryError; use crate::accessibility::AccessibilityApi; use crate::accessibility::attribute_constants::kAXFocusedApplicationAttribute; @@ -39,6 +40,172 @@ pub struct MacosApi; impl MacosApi { #[tracing::instrument(skip_all)] pub fn load_monitor_information(wm: &mut WindowManager) -> Result<(), LibraryError> { + let monitors = &mut wm.monitors; + let monitor_usr_idx_map = &mut wm.monitor_usr_idx_map; + + let monitor_info = IoReg::query_monitors()?; + + let mut monitor_info_map = HashMap::new(); + for m in monitor_info { + monitor_info_map.insert(m.serial_number, m); + } + + let mut all_devices = vec![]; + + let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); + + for display_id in CoreGraphicsApi::connected_display_ids()? { + let display_bounds = CoreGraphicsApi::display_bounds(display_id); + let serial_number = CoreGraphicsApi::display_serial_number(display_id); + + if let Some(info) = monitor_info_map.get(&serial_number) { + for screen in &screens { + let menu_bar_height = screen.frame().size.height + - screen.visibleFrame().size.height + - screen.visibleFrame().origin.y; + + if screen.frame() == display_bounds { + let size = Rect::from(display_bounds); + let mut work_area_size = Rect::from(display_bounds); + work_area_size.top += menu_bar_height as i32; + work_area_size.bottom = screen.visibleFrame().size.height as i32; + + let monitor = Monitor::new( + display_id, + size, + work_area_size, + &info.product_name, + &info.alphanumeric_serial_number, + ); + + all_devices.push(monitor); + } + } + } + } + + 'read: for device in all_devices { + for monitor in monitors.elements() { + if device.serial_number_id.eq(&monitor.serial_number_id) { + continue 'read; + } + } + + let m = device.clone(); + + let mut index_preference = None; + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + for (index, id) in &*display_index_preferences { + if m.serial_number_id.eq(id) { + index_preference = Option::from(index); + } + } + + if let Some(preference) = index_preference { + while *preference >= monitors.elements().len() { + monitors.elements_mut().push_back(Monitor::placeholder()); + } + + let current_serial_id = monitors + .elements_mut() + .get(*preference) + .map_or("", |m| &m.serial_number_id); + if current_serial_id == "PLACEHOLDER" { + let _ = monitors.elements_mut().remove(*preference); + monitors.elements_mut().insert(*preference, m); + } else { + monitors.elements_mut().insert(*preference, m); + } + } else { + monitors.elements_mut().push_back(m); + } + } + + monitors + .elements_mut() + .retain(|m| m.serial_number_id.ne("PLACEHOLDER")); + + // Rebuild monitor index map + *monitor_usr_idx_map = HashMap::new(); + let mut added_monitor_idxs = Vec::new(); + for (index, id) in &*DISPLAY_INDEX_PREFERENCES.read() { + if let Some(m_idx) = monitors + .elements() + .iter() + .position(|m| m.serial_number_id.eq(id)) + { + monitor_usr_idx_map.insert(*index, m_idx); + added_monitor_idxs.push(m_idx); + } + } + + let max_usr_idx = monitors + .elements() + .len() + .max(monitor_usr_idx_map.keys().max().map_or(0, |v| *v)); + + let mut available_usr_idxs = (0..max_usr_idx) + .filter(|i| !monitor_usr_idx_map.contains_key(i)) + .collect::>(); + + let not_added_monitor_idxs = (0..monitors.elements().len()) + .filter(|i| !added_monitor_idxs.contains(i)) + .collect::>(); + + for i in not_added_monitor_idxs { + if let Some(next_usr_idx) = available_usr_idxs.first() { + monitor_usr_idx_map.insert(*next_usr_idx, i); + available_usr_idxs.remove(0); + } else if let Some(idx) = monitor_usr_idx_map.keys().max() { + monitor_usr_idx_map.insert(*idx, i); + } + } + + Ok(()) + } + + pub fn update_monitor_work_areas(wm: Arc>) -> eyre::Result<()> { + let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); + + for display_id in CoreGraphicsApi::connected_display_ids()? { + let display_bounds = CoreGraphicsApi::display_bounds(display_id); + + let mut wm = wm.lock(); + + for screen in &screens { + let menu_bar_height = screen.frame().size.height + - screen.visibleFrame().size.height + - screen.visibleFrame().origin.y; + + if screen.frame() == display_bounds { + let size = Rect::from(display_bounds); + let mut work_area_size = Rect::from(display_bounds); + work_area_size.top += menu_bar_height as i32; + work_area_size.bottom = screen.visibleFrame().size.height as i32; + + for monitor in wm.monitors_mut() { + if monitor.id == display_id { + monitor.size = size; + monitor.work_area_size = work_area_size; + } + + tracing::info!( + "updated monitor size and work area for monitor {display_id}" + ) + } + } + } + + let focus_follows_mouse = wm.mouse_follows_focus; + wm.update_focused_workspace(focus_follows_mouse, true)?; + } + + Ok(()) + } + + pub fn latest_monitor_information() -> Result, LibraryError> { + let mut monitors = vec![]; + let monitor_info = IoReg::query_monitors()?; let mut monitor_info_map = HashMap::new(); for m in monitor_info { @@ -70,16 +237,17 @@ impl MacosApi { &info.product_name, &info.alphanumeric_serial_number, ); - wm.monitors.elements_mut().push_back(monitor); + + monitors.push(monitor); } } } } - Ok(()) + Ok(monitors) } - pub fn update_monitor_work_areas(wm: Arc>) -> eyre::Result<()> { + pub fn reconile_monitors(wm: Arc>) -> eyre::Result<()> { let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); for display_id in CoreGraphicsApi::connected_display_ids()? { diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index e06b0026..7de7467e 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -6,6 +6,8 @@ use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; use komorebi::HOME_DIR; +use komorebi::LATEST_MONITOR_INFORMATION; +use komorebi::UPDATE_LATEST_MONITOR_INFORMATION; use komorebi::UPDATE_MONITOR_WORK_AREAS; use komorebi::core::pathext::replace_env_in_path; use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; @@ -277,6 +279,12 @@ fn main() -> eyre::Result<()> { UPDATE_MONITOR_WORK_AREAS.store(false, Ordering::Relaxed); } + if UPDATE_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { + let mut latest_monitor_information = LATEST_MONITOR_INFORMATION.write(); + // this can only be called on the main thread + *latest_monitor_information = Some(MacosApi::latest_monitor_information()?); + } + // this gets our observer notification callbacks firing autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) }); } diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index bd632388..09d80c2a 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -70,6 +70,33 @@ pub struct Monitor { pub floating_layer_behaviour: Option, } +pub fn new( + id: u32, + size: Rect, + work_area_size: Rect, + device: String, + serial_number_id: String, +) -> Monitor { + let mut workspaces = Ring::default(); + workspaces.elements_mut().push_back(Workspace::default()); + + Monitor { + id, + device, + serial_number_id, + size, + work_area_size, + work_area_offset: None, + window_based_work_area_offset: None, + window_based_work_area_offset_limit: 1, + workspaces, + last_focused_workspace: None, + container_padding: None, + workspace_padding: None, + floating_layer_behaviour: None, + } +} + impl Monitor { #[allow(clippy::field_reassign_with_default)] pub fn new( @@ -104,6 +131,25 @@ impl Monitor { } } + pub fn placeholder() -> Self { + Self { + // temp + id: 2051316, + device: "".to_string(), + serial_number_id: "PLACEHOLDER".to_string(), + size: Default::default(), + work_area_size: Default::default(), + work_area_offset: None, + window_based_work_area_offset: None, + window_based_work_area_offset_limit: 0, + workspaces: Default::default(), + last_focused_workspace: None, + container_padding: None, + workspace_padding: None, + floating_layer_behaviour: None, + } + } + #[tracing::instrument(skip_all)] pub fn update_focused_workspace(&mut self, offset: Option) -> eyre::Result<()> { let offset = if self.work_area_offset.is_some() { diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index dc7ce7d8..04d69da1 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -1,6 +1,12 @@ +use crate::DISPLAY_INDEX_PREFERENCES; +use crate::LATEST_MONITOR_INFORMATION; use crate::Notification; use crate::NotificationEvent; use crate::UPDATE_MONITOR_WORK_AREAS; +use crate::WORKSPACE_MATCHING_RULES; +use crate::core::config_generation::WorkspaceMatchingRule; +use crate::macos_api::MacosApi; +use crate::monitor::Monitor; use crate::notify_subscribers; use crate::state::State; use crate::window_manager::WindowManager; @@ -10,6 +16,7 @@ use objc2_core_graphics::CGDirectDisplayID; use parking_lot::Mutex; use serde::Deserialize; use serde::Serialize; +use std::collections::HashMap; use std::sync::Arc; use std::sync::OnceLock; use std::sync::atomic::Ordering; @@ -19,10 +26,14 @@ use strum::Display; #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum MonitorNotification { Resize(CGDirectDisplayID), + DisplayConnectionChange(CGDirectDisplayID), } static CHANNEL: OnceLock<(Sender, Receiver)> = OnceLock::new(); + +static MONITOR_CACHE: OnceLock>> = OnceLock::new(); + pub fn channel() -> &'static (Sender, Receiver) { CHANNEL.get_or_init(|| crossbeam_channel::bounded(20)) } @@ -35,6 +46,22 @@ fn event_rx() -> Receiver { channel().1.clone() } +pub fn insert_in_monitor_cache(serial_number_id: &str, monitor: Monitor) { + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + let mut dip_ids = display_index_preferences.values(); + let preferred_id = if dip_ids.any(|id| id == serial_number_id) { + monitor.serial_number_id.clone() + } else { + serial_number_id.to_string() + }; + + let mut monitor_cache = MONITOR_CACHE + .get_or_init(|| Mutex::new(HashMap::new())) + .lock(); + + monitor_cache.insert(preferred_id, monitor); +} + pub fn send_notification(notification: MonitorNotification) { if event_tx().try_send(notification).is_err() { tracing::warn!("channel is full; dropping notification") @@ -67,8 +94,8 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result let receiver = event_rx(); - for notification in receiver { - let wm = wm.lock(); + 'receiver: for notification in receiver { + let mut wm = wm.lock(); let initial_state = State::from(wm.as_ref()); @@ -77,6 +104,448 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result tracing::debug!("handling resize notification"); UPDATE_MONITOR_WORK_AREAS.store(true, Ordering::Relaxed); } + MonitorNotification::DisplayConnectionChange(_) => { + tracing::debug!("handling display connection change notification"); + let mut monitor_cache = MONITOR_CACHE + .get_or_init(|| Mutex::new(HashMap::new())) + .lock(); + + let initial_monitor_count = wm.monitors().len(); + + // Get the currently attached display devices + // TODO: I think because of the way the threading model works on macOS we'll + // need to run this on the main thread to get access to info from NSScreen + // let attached_devices = attached_display_devices(display_provider)?; + let mut latest_monitor_information = LATEST_MONITOR_INFORMATION.write(); + *latest_monitor_information = None; + + UPDATE_MONITOR_WORK_AREAS.store(true, Ordering::Relaxed); + + let mut attached_devices = vec![]; + while attached_devices.is_empty() { + if let Some(latest) = &*LATEST_MONITOR_INFORMATION.read() { + attached_devices = latest.clone(); + } + + std::thread::sleep(std::time::Duration::from_millis(100)); + } + + UPDATE_MONITOR_WORK_AREAS.store(false, Ordering::Relaxed); + + // Make sure that in our state any attached displays have the latest Win32 data + for monitor in wm.monitors_mut() { + for attached in &attached_devices { + // let serial_number_ids_match = if let (Some(attached_snid), Some(m_snid)) = + // (&attached.serial_number_id, &monitor.serial_number_id) + // { + // attached_snid.eq(m_snid) + // } else { + // false + // }; + + let serial_number_ids_match = + attached.serial_number_id == monitor.serial_number_id; + + if serial_number_ids_match { + monitor.id = attached.id; + monitor.device = attached.device.clone(); + // monitor.device_id = attached.device_id.clone(); + monitor.serial_number_id = attached.serial_number_id.clone(); + // monitor.name = attached.name.clone(); + monitor.size = attached.size; + monitor.work_area_size = attached.work_area_size; + } + } + } + + if initial_monitor_count == attached_devices.len() { + tracing::debug!("monitor counts match, reconciliation not required"); + drop(wm); + continue 'receiver; + } + + if attached_devices.is_empty() { + tracing::debug!( + "no devices found, skipping reconciliation to avoid breaking state" + ); + drop(wm); + continue 'receiver; + } + + if initial_monitor_count > attached_devices.len() { + tracing::info!( + "monitor count mismatch ({initial_monitor_count} vs {}), removing disconnected monitors", + attached_devices.len() + ); + + // Windows to remove from `known_hwnds` + let mut windows_to_remove = Vec::new(); + + // Collect the ids in our state which aren't in the current attached display ids + // These are monitors that have been removed + let mut newly_removed_displays = vec![]; + + for (m_idx, m) in wm.monitors().iter().enumerate() { + if !attached_devices + .iter() + .any(|attached| attached.serial_number_id.eq(&m.serial_number_id)) + { + let id = m.serial_number_id.clone(); + + newly_removed_displays.push(id.clone()); + + let focused_workspace_idx = m.focused_workspace_idx(); + + for (idx, workspace) in m.workspaces().iter().enumerate() { + let is_focused_workspace = idx == focused_workspace_idx; + let focused_container_idx = workspace.focused_container_idx(); + for (c_idx, container) in workspace.containers().iter().enumerate() + { + let focused_window_idx = container.focused_window_idx(); + for (w_idx, window) in container.windows().iter().enumerate() { + windows_to_remove.push(window.id); + if is_focused_workspace + && c_idx == focused_container_idx + && w_idx == focused_window_idx + { + // TODO: Do we need this on macOS? + // Minimize the focused window since Windows might try + // to move it to another monitor if it was focused. + // if window.is_focused() { + // window.minimize()?; + // } + } + } + } + + // TODO: might not support maximization on macOS + // if let Some(maximized) = &workspace.maximized_window { + // windows_to_remove.push(maximized.id); + // // Minimize the focused window since Windows might try + // // to move it to another monitor if it was focused. + // if maximized.is_focused() { + // maximized.minimize(); + // } + // } + + if let Some(container) = &workspace.monocle_container { + for window in container.windows() { + windows_to_remove.push(window.id); + } + if let Some(_window) = container.focused_window() { + // TODO: Do we need this on macOS? + // Minimize the focused window since Windows might try + // to move it to another monitor if it was focused. + // if window.is_focused() { + // window.minimize(); + // } + } + } + + for window in workspace.floating_windows() { + windows_to_remove.push(window.id); + // TODO: Do we need this on macOS? + // Minimize the focused window since Windows might try + // to move it to another monitor if it was focused. + // if window.is_focused() { + // window.minimize(); + // } + } + } + + // Remove any workspace_rules for this specific monitor + let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + let mut rules_to_remove = Vec::new(); + for (i, rule) in workspace_rules.iter().enumerate().rev() { + if rule.monitor_index == m_idx { + rules_to_remove.push(i); + } + } + for i in rules_to_remove { + workspace_rules.remove(i); + } + + // Let's add their state to the cache for later, make sure to use what + // the user set as preference as the id. + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + let mut dip_ids = display_index_preferences.values(); + + let preferred_id = if dip_ids.any(|id| m.serial_number_id.eq(id)) { + m.serial_number_id.clone() + } else { + id.to_string() + }; + + monitor_cache.insert(preferred_id, m.clone()); + } + } + + // Update known_hwnds + wm.known_window_ids + .retain(|i, _| !windows_to_remove.contains(i)); + + if !newly_removed_displays.is_empty() { + // After we have cached them, remove them from our state + wm.monitors_mut().retain(|m| { + !newly_removed_displays + .iter() + .any(|id| m.serial_number_id.eq(id)) + }); + } + + let post_removal_monitor_count = wm.monitors().len(); + let focused_monitor_idx = wm.focused_monitor_idx(); + if focused_monitor_idx >= post_removal_monitor_count { + wm.focus_monitor(0)?; + } + + let offset = wm.work_area_offset; + + for monitor in wm.monitors_mut() { + // If we have lost a monitor, update everything to filter out any jank + if initial_monitor_count != post_removal_monitor_count { + monitor.update_focused_workspace(offset)?; + } + } + } + + let post_removal_monitor_count = wm.monitors().len(); + + // // This is the list of device ids after we have removed detached displays. We can + // // keep this with just the device_ids without the serial numbers since this is used + // // only to check which one is the newly added monitor below if there is a new + // // monitor. Everything done after with said new monitor will again consider both + // // serial number and device ids. + // let post_removal_device_ids = wm + // .monitors() + // .iter() + // .map(|m| &m.device_id) + // .cloned() + // .collect::>(); + let post_removal_serial_ids = []; + + // // Check for and add any new monitors that may have been plugged in + // // Monitor and display index preferences get applied in this function + MacosApi::load_monitor_information(&mut wm)?; + + let post_addition_monitor_count = wm.monitors().len(); + + if post_addition_monitor_count > post_removal_monitor_count { + tracing::info!( + "monitor count mismatch ({post_removal_monitor_count} vs {post_addition_monitor_count}), adding connected monitors", + ); + + let known_window_ids = wm.known_window_ids.clone(); + let offset = wm.work_area_offset; + let mouse_follows_focus = wm.mouse_follows_focus; + let focused_monitor_idx = wm.focused_monitor_idx(); + let focused_workspace_idx = wm.focused_workspace_idx()?; + + // Look in the updated state for new monitors + for (i, m) in wm.monitors_mut().iter_mut().enumerate() { + // let device_id = &m.device_id; + let serial_id = m.serial_number_id.clone(); + // We identify a new monitor when we encounter a new device id + if !post_removal_serial_ids.contains(&serial_id) { + let mut cache_hit = false; + let mut cached_id = String::new(); + // Check if that device id exists in the cache for this session + if let Some((id, cached)) = monitor_cache.get_key_value(&serial_id) { + cache_hit = true; + cached_id = id.clone(); + + tracing::info!( + "found monitor and workspace configuration for {id} in the monitor cache, applying" + ); + + // If it does, update the cached monitor info with the new one and + // load the cached monitor removing any window that has since been + // closed or moved to another workspace + *m = Monitor { + // Data that should be the one just read from `win32-display-data` + id: m.id, + // name: m.name.clone(), + device: m.device.clone(), + // device_id: m.device_id.clone(), + serial_number_id: m.serial_number_id.clone(), + size: m.size, + work_area_size: m.work_area_size, + + // The rest should come from the cached monitor + work_area_offset: cached.work_area_offset, + window_based_work_area_offset: cached + .window_based_work_area_offset, + window_based_work_area_offset_limit: cached + .window_based_work_area_offset_limit, + workspaces: cached.workspaces.clone(), + last_focused_workspace: cached.last_focused_workspace, + // workspace_names: cached.workspace_names.clone(), + container_padding: cached.container_padding, + workspace_padding: cached.workspace_padding, + // wallpaper: cached.wallpaper.clone(), + floating_layer_behaviour: cached.floating_layer_behaviour, + }; + + let focused_workspace_idx = m.focused_workspace_idx(); + + for (j, workspace) in m.workspaces_mut().iter_mut().enumerate() { + // If this is the focused workspace we need to show (restore) all + // windows that were visible since they were probably minimized by + // Windows. + let is_focused_workspace = j == focused_workspace_idx; + let focused_container_idx = workspace.focused_container_idx(); + + let mut empty_containers = Vec::new(); + for (idx, container) in + workspace.containers_mut().iter_mut().enumerate() + { + container.windows_mut().retain(|window| { + window.exe().is_some() + && !known_window_ids.contains_key(&window.id) + }); + + if container.windows().is_empty() { + empty_containers.push(idx); + } + + if is_focused_workspace { + if let Some(_window) = container.focused_window() { + // TODO: do we need to do this on macOS? + // tracing::debug!( + // "restoring window: {}", + // window.id + // ); + // WindowsApi::restore_window(window.hwnd); + } else { + // If the focused window was moved or removed by + // the user after the disconnect then focus the + // first window and show that one + container.focus_window(0); + // + // if let Some(window) = container.focused_window() { + // WindowsApi::restore_window(window.hwnd); + // } + } + } + } + + // Remove empty containers + for empty_idx in empty_containers { + if empty_idx == focused_container_idx { + workspace.remove_container(empty_idx); + } else { + workspace.remove_container_by_idx(empty_idx); + } + } + + // if let Some(window) = &workspace.maximized_window { + // if window.exe().is_none() + // || known_window_ids.contains_key(&window.id) + // { + // workspace.maximized_window = None; + // } else if is_focused_workspace { + // WindowsApi::restore_window(window.hwnd); + // } + // } + + if let Some(container) = &mut workspace.monocle_container { + container.windows_mut().retain(|window| { + window.exe().is_some() + && !known_window_ids.contains_key(&window.id) + }); + + if container.windows().is_empty() { + workspace.monocle_container = None; + } else if is_focused_workspace { + if let Some(_window) = container.focused_window() { + // WindowsApi::restore_window(window.hwnd); + } else { + // If the focused window was moved or removed by + // the user after the disconnect then focus the + // first window and show that one + container.focus_window(0); + + if let Some(_window) = container.focused_window() { + // WindowsApi::restore_window(window.hwnd); + } + } + } + } + + workspace.floating_windows_mut().retain(|window| { + window.exe().is_some() + && !known_window_ids.contains_key(&window.id) + }); + + if is_focused_workspace { + for _window in workspace.floating_windows() { + // WindowsApi::restore_window(window.hwnd); + } + } + + // Apply workspace rules + let mut workspace_matching_rules = + WORKSPACE_MATCHING_RULES.lock(); + if let Some(rules) = workspace + .workspace_config + .as_ref() + .and_then(|c| c.workspace_rules.as_ref()) + { + for r in rules { + workspace_matching_rules.push(WorkspaceMatchingRule { + monitor_index: i, + workspace_index: j, + matching_rule: r.clone(), + initial_only: false, + }); + } + } + + if let Some(rules) = workspace + .workspace_config + .as_ref() + .and_then(|c| c.initial_workspace_rules.as_ref()) + { + for r in rules { + workspace_matching_rules.push(WorkspaceMatchingRule { + monitor_index: i, + workspace_index: j, + matching_rule: r.clone(), + initial_only: true, + }); + } + } + } + + // Restore windows from new monitor and update the focused + // workspace + m.load_focused_workspace(mouse_follows_focus)?; + m.update_focused_workspace(offset)?; + } + + // Entries in the cache should only be used once; remove the entry there was a cache hit + if cache_hit && !cached_id.is_empty() { + monitor_cache.remove(&cached_id); + } + } + } + + // Refocus the previously focused monitor since the code above might + // steal the focus away. + wm.focus_monitor(focused_monitor_idx)?; + wm.focus_workspace(focused_workspace_idx)?; + } + + let final_count = wm.monitors().len(); + + if post_removal_monitor_count != final_count { + wm.retile_all(true)?; + // Second retile to fix DPI/resolution related jank + // wm.retile_all(true)?; + // Border updates to fix DPI/resolution related jank + // border_manager::send_notification(None); + } + } } notify_subscribers( diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs index 9aa3f083..d6627ff4 100644 --- a/komorebi/src/state.rs +++ b/komorebi/src/state.rs @@ -1,4 +1,5 @@ use crate::DATA_DIR; +use crate::DISPLAY_INDEX_PREFERENCES; use crate::HOME_DIR; use crate::IGNORE_IDENTIFIERS; use crate::MANAGE_IDENTIFIERS; @@ -15,6 +16,7 @@ use crate::window_manager::WindowManager; use crate::workspace::Workspace; use serde::Deserialize; use serde::Serialize; +use std::collections::HashMap; use std::collections::VecDeque; use std::path::PathBuf; @@ -44,7 +46,7 @@ pub struct GlobalState { // pub tray_and_multi_window_identifiers: Vec, // pub name_change_on_launch_identifiers: Vec, // pub monitor_index_preferences: HashMap, - // pub display_index_preferences: HashMap, + pub display_index_preferences: HashMap, // pub ignored_duplicate_monitor_serial_ids: Vec, pub workspace_rules: Vec, // pub window_hiding_behaviour: HidingBehaviour, @@ -58,6 +60,7 @@ impl Default for GlobalState { Self { ignore_identifiers: IGNORE_IDENTIFIERS.lock().clone(), manage_identifiers: MANAGE_IDENTIFIERS.lock().clone(), + display_index_preferences: DISPLAY_INDEX_PREFERENCES.read().clone(), workspace_rules: WORKSPACE_MATCHING_RULES.lock().clone(), configuration_dir: HOME_DIR.clone(), data_dir: DATA_DIR.clone(), @@ -70,7 +73,7 @@ impl Default for GlobalState { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct State { pub monitors: Ring, - // pub monitor_usr_idx_map: HashMap, + pub monitor_usr_idx_map: HashMap, pub is_paused: bool, pub resize_delta: i32, pub new_window_behaviour: WindowContainerBehaviour, @@ -154,7 +157,7 @@ impl From<&WindowManager> for State { Self { monitors: stripped_monitors, - // monitor_usr_idx_map: wm.monitor_usr_idx_map.clone(), + monitor_usr_idx_map: wm.monitor_usr_idx_map.clone(), is_paused: wm.is_paused, work_area_offset: wm.work_area_offset, resize_delta: wm.resize_delta, diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index b0030726..0fb87c49 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -28,7 +28,9 @@ use crate::core::default_layout::LayoutOptions; use crate::core::layout::Layout; use crate::core::pathext::ResolvedPathBuf; use crate::core::rect::Rect; +use crate::monitor; use crate::monitor::Monitor; +use crate::monitor_reconciliator; use crate::ring::Ring; use crate::window::AspectRatio; use crate::window::PredefinedAspectRatio; @@ -1120,7 +1122,7 @@ impl StaticConfig { let mut wm = WindowManager { monitors: Ring::default(), - // monitor_usr_idx_map: HashMap::new(), + monitor_usr_idx_map: HashMap::new(), applications: Default::default(), incoming_events: incoming, command_listener: listener, @@ -1275,13 +1277,10 @@ impl StaticConfig { // Check if this monitor config is the preferred config for this monitor and store // a copy of the monitor itself on the monitor cache if it is. - // if idx == preferred_config_idx { - // let id = monitor - // .serial_number_id - // .as_ref() - // .map_or(&monitor.device_id, |sn| sn); - // monitor_reconciliator::insert_in_monitor_cache(id, monitor.clone()); - // } + if idx == preferred_config_idx { + let id = &monitor.serial_number_id; + monitor_reconciliator::insert_in_monitor_cache(id, monitor.clone()); + } let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); for (j, ws) in monitor_config.workspaces.iter().enumerate() { @@ -1313,53 +1312,46 @@ impl StaticConfig { // Check for configs that should be tied to a specific display that isn't loaded right now // and cache a monitor with those configs with the specific `serial_number_id` so that when // those devices are connected later we can use the correct config from the cache. - // if configs_with_preference.len() > configs_used.len() { - // for i in configs_with_preference - // .iter() - // .filter(|i| !configs_used.contains(i)) - // { - // let id = { - // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); - // display_index_preferences.get(i).cloned() - // }; - // if let (Some(id), Some(monitor_config)) = - // (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) - // { - // // The name, device, device_id and serial_number_id can be empty here since - // // once the monitor with this preferred index actually connects the - // // `load_monitor_information` function will update these fields. - // let mut m = monitor::new( - // 0, - // Rect::default(), - // Rect::default(), - // "".into(), - // "".into(), - // "".into(), - // None, - // ); - // - // m.ensure_workspace_count(monitor_config.workspaces.len()); - // m.work_area_offset = monitor_config.work_area_offset; - // m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; - // m.window_based_work_area_offset_limit = monitor_config - // .window_based_work_area_offset_limit - // .unwrap_or(1); - // m.container_padding = monitor_config.container_padding; - // m.workspace_padding = monitor_config.workspace_padding; - // m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; - // - // m.update_workspaces_globals(offset); - // - // for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { - // if let Some(workspace_config) = monitor_config.workspaces.get(j) { - // ws.load_static_config(workspace_config)?; - // } - // } - // - // monitor_reconciliator::insert_in_monitor_cache(&id, m); - // } - // } - // } + if configs_with_preference.len() > configs_used.len() { + for i in configs_with_preference + .iter() + .filter(|i| !configs_used.contains(i)) + { + let id = { + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + display_index_preferences.get(i).cloned() + }; + if let (Some(id), Some(monitor_config)) = + (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) + { + // The name, device, device_id and serial_number_id can be empty here since + // once the monitor with this preferred index actually connects the + // `load_monitor_information` function will update these fields. + let mut m = + monitor::new(0, Rect::default(), Rect::default(), "".into(), "".into()); + + m.ensure_workspace_count(monitor_config.workspaces.len()); + m.work_area_offset = monitor_config.work_area_offset; + m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; + m.window_based_work_area_offset_limit = monitor_config + .window_based_work_area_offset_limit + .unwrap_or(1); + m.container_padding = monitor_config.container_padding; + m.workspace_padding = monitor_config.workspace_padding; + m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + + m.update_workspaces_globals(offset); + + for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { + if let Some(workspace_config) = monitor_config.workspaces.get(j) { + ws.load_static_config(workspace_config)?; + } + } + + monitor_reconciliator::insert_in_monitor_cache(&id, m); + } + } + } wm.enforce_workspace_rules()?; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 848abf59..2eb9dfa3 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -59,6 +59,7 @@ use std::sync::Arc; #[derive(Debug)] pub struct WindowManager { pub monitors: Ring, + pub monitor_usr_idx_map: HashMap, pub applications: HashMap, pub run_loop: CoreFoundationRunLoop, pub command_listener: UnixListener, @@ -138,6 +139,7 @@ impl WindowManager { Ok(Self { monitors: Ring::default(), + monitor_usr_idx_map: HashMap::new(), applications: Default::default(), run_loop: CoreFoundationRunLoop(run_loop.clone()), command_listener: listener, diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index c3401f10..c1cae466 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -741,6 +741,13 @@ impl Workspace { container } + pub fn remove_container(&mut self, idx: usize) -> Option { + let container = self.remove_container_by_idx(idx); + self.focus_previous_container(); + + container + } + pub fn promote_container(&mut self) -> eyre::Result<()> { let resize = self.resize_dimensions.remove(0); let container = self From f7afe4f8ec85c857451551d2163c3078666450ad Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 25 Sep 2025 17:54:45 -0700 Subject: [PATCH 068/305] 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. --- komorebi/src/process_event.rs | 276 ++++++++++++++------------- komorebi/src/window_manager_event.rs | 10 +- 2 files changed, 152 insertions(+), 134 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index e9b3fafd..9cad66b2 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -119,6 +119,16 @@ impl WindowManager { self.enforce_workspace_rules()?; match event { + WindowManagerEvent::FocusChange( + SystemNotification::Manual(ManualNotification::FocusOnCmdTab), + _, + Some(window_id), + ) => { + let focused_workspace = self.focused_workspace_mut()?; + let container_idx = focused_workspace.container_idx_for_window(window_id); + focused_workspace.focus_container(container_idx.unwrap_or_default()); + self.update_focused_workspace(self.mouse_follows_focus, true)?; + } WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; let application_name = application.name().unwrap_or_default().clone(); @@ -133,175 +143,183 @@ impl WindowManager { AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification ) ) && let Some(element) = application.main_window() - { - let workspace = self.focused_workspace_mut()?; + { + let workspace = self.focused_workspace_mut()?; - let tabbed_applications = TABBED_APPLICATIONS.lock(); - if tabbed_applications.contains(&application_name) { - let mut first_tab_destroyed = false; + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&application_name) { + let mut first_tab_destroyed = false; - for window in workspace.visible_windows() { - if let Some(window) = window - && window.application.name().unwrap_or_default() - == application_name - { - let tab_rect = MacosApi::window_rect(&element)?; - let main_rect = match MacosApi::window_rect(&window.element) { - Ok(rect) => rect, - Err(AccessibilityError::Api( + for window in workspace.visible_windows() { + if let Some(window) = window + && window.application.name().unwrap_or_default() + == application_name + { + let tab_rect = MacosApi::window_rect(&element)?; + let main_rect = match MacosApi::window_rect(&window.element) { + Ok(rect) => rect, + Err(AccessibilityError::Api( AccessibilityApiError::InvalidUIElement, )) => { - // this means we have closed the 1st tab, so we need this window object to be reaped - // and for the new 1st tab to be the key element of the window struct - if let Some(event) = - WindowManagerEvent::from_system_notification( - SystemNotification::Manual( - ManualNotification::ShowOnFocusChangeFirstTabDestroyed, - ), - event.process_id(), - Some(window_id), - ) - { - window_manager_event_listener::send_notification( - event, - ); - } + // this means we have closed the 1st tab, so we need this window object to be reaped + // and for the new 1st tab to be the key element of the window struct + if let Some(event) = + WindowManagerEvent::from_system_notification( + SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeFirstTabDestroyed, + ), + event.process_id(), + Some(window_id), + ) + { + window_manager_event_listener::send_notification( + event, + ); + } - first_tab_destroyed = true; + first_tab_destroyed = true; - tracing::debug!( + tracing::debug!( "first tab of a native tabbed app was destroyed; reaping window and sending a new show event" ); - tab_rect - } - Err(error) => return Err(error.into()), - }; - - if tab_rect == main_rect { - tracing::debug!("ignoring focus change for tabbed window"); - tabbed_window = true; + tab_rect } - } - } + Err(error) => return Err(error.into()), + }; - if first_tab_destroyed { - self.reap_invalid_windows_for_application(process_id)?; + if tab_rect == main_rect { + tracing::debug!("ignoring focus change for tabbed window"); + tabbed_window = true; + } } } - drop(tabbed_applications); + if first_tab_destroyed { + self.reap_invalid_windows_for_application(process_id)?; + } + } - if !tabbed_window { - let is_known = self.known_window_ids.get(&window_id).cloned(); - let mut is_on_current_workspace = false; + drop(tabbed_applications); - // TODO: figure out if this applies on macOS too - // don't want to trigger the full workspace updates when there are no managed - // containers - this makes floating windows on empty workspaces go into very - // annoying focus change loops which prevents users from interacting with them - if !matches!( + if !tabbed_window { + let is_known = self.known_window_ids.get(&window_id).cloned(); + let mut is_on_current_workspace = false; + + // TODO: figure out if this applies on macOS too + // don't want to trigger the full workspace updates when there are no managed + // containers - this makes floating windows on empty workspaces go into very + // annoying focus change loops which prevents users from interacting with them + if !matches!( self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling) ) && !self.focused_workspace()?.containers().is_empty() { - self.update_focused_workspace(self.mouse_follows_focus, false)?; - } + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } - let workspace = self.focused_workspace_mut()?; - if workspace.contains_window(window_id) { - is_on_current_workspace = true; - } + let workspace = self.focused_workspace_mut()?; + if workspace.contains_window(window_id) { + is_on_current_workspace = true; + } - let floating_window_idx = workspace - .floating_windows() - .iter() - .position(|w| w.id == window_id); + let floating_window_idx = workspace + .floating_windows() + .iter() + .position(|w| w.id == window_id); - match floating_window_idx { - None => { - // if let Some(w) = workspace.maximized_window() { - // if w.hwnd == window_id { - // return Ok(()); - // } - // } + match floating_window_idx { + None => { + // if let Some(w) = workspace.maximized_window() { + // if w.hwnd == window_id { + // return Ok(()); + // } + // } - if let Some(monocle) = &workspace.monocle_container { - if let Some(window) = monocle.focused_window() { - window.focus(false)?; - } - } else if !is_on_current_workspace && is_known.is_none() { - // thanks, I hate it - need to do this so that we don't mess up - // the workspace rules, but also don't miss events from dumb - // apps like notes, mail etc. - let mut has_matching_workspace_rule = false; - let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); - for rule in &*workspace_rules { - match &rule.matching_rule { - MatchingRule::Simple(r) => { - if r.id.trim_end_matches(".exe") == application_name + if let Some(monocle) = &workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(false)?; + } + } else if !is_on_current_workspace && is_known.is_none() { + // thanks, I hate it - need to do this so that we don't mess up + // the workspace rules, but also don't miss events from dumb + // apps like notes, mail etc. + let mut has_matching_workspace_rule = false; + let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + for rule in &*workspace_rules { + match &rule.matching_rule { + MatchingRule::Simple(r) => { + if r.id.trim_end_matches(".exe") == application_name + { + has_matching_workspace_rule = true; + } + } + // TODO: this is pretty coarse + MatchingRule::Composite(rules) => { + for r in rules { + if r.id.trim_end_matches(".exe") + == application_name { has_matching_workspace_rule = true; } } - // TODO: this is pretty coarse - MatchingRule::Composite(rules) => { - for r in rules { - if r.id.trim_end_matches(".exe") - == application_name - { - has_matching_workspace_rule = true; - } - } - } } } + } - if !has_matching_workspace_rule - && workspace.focus_container_by_window(window_id).is_err() + if !has_matching_workspace_rule + && workspace.focus_container_by_window(window_id).is_err() + { + // if this fails, the app was probably open but windowless when komorebi + // launched, so the window hasn't been registered - we should treat it + // as a "Show" event + if let Some(event) = + WindowManagerEvent::from_system_notification( + SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeWindowlessAppRestored, + ), + event.process_id(), + Some(window_id), + ) { - // if this fails, the app was probably open but windowless when komorebi - // launched, so the window hasn't been registered - we should treat it - // as a "Show" event - if let Some(event) = - WindowManagerEvent::from_system_notification( - SystemNotification::Manual( - ManualNotification::ShowOnFocusChangeWindowlessAppRestored, - ), - event.process_id(), - Some(window_id), - ) - { - window_manager_event_listener::send_notification( - event, - ); - } + window_manager_event_listener::send_notification( + event, + ); } - } else { - workspace.focus_container_by_window(window_id)?; - } - - workspace.layer = WorkspaceLayer::Tiling; - - if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) - && !self.focused_workspace()?.containers().is_empty() { - self.update_focused_workspace(self.mouse_follows_focus, false)?; } + } else if is_on_current_workspace { + workspace.focus_container_by_window(window_id)?; } - Some(idx) => { - if let Some(_window) = workspace.floating_windows().get(idx) { - workspace.layer = WorkspaceLayer::Floating; - } + + workspace.layer = WorkspaceLayer::Tiling; + + if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) + && !self.focused_workspace()?.containers().is_empty() { + self.update_focused_workspace(self.mouse_follows_focus, false)?; } } - - // maybe we don't need a separate reconciliator module?? this works pretty well! - if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { - self.focus_monitor(m_idx)?; - self.focus_workspace(w_idx)?; + Some(idx) => { + if let Some(_window) = workspace.floating_windows().get(idx) { + workspace.layer = WorkspaceLayer::Floating; + } } } + // maybe we don't need a separate reconciliator module?? this works pretty well! + if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { + self.focus_monitor(m_idx)?; + self.focus_workspace(w_idx)?; + let event = WindowManagerEvent::from_system_notification( + SystemNotification::Manual(ManualNotification::FocusOnCmdTab), + process_id, + Some(window_id) + ); + + if let Some(manual_event) = event { + window_manager_event_listener::send_notification(manual_event); + } + } } + } if matches!( notification, diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 9c089921..f8948dad 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -23,6 +23,7 @@ pub enum ManualNotification { ShowOnFocusChangeWindowlessAppRestored, Manage, Unmanage, + FocusOnCmdTab, } #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] @@ -51,11 +52,10 @@ impl WindowManagerEvent { ) | SystemNotification::AppKitWorkspace( AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification, - ) => Some(WindowManagerEvent::FocusChange( - notification, - process_id, - window_id, - )), + ) + | SystemNotification::Manual(ManualNotification::FocusOnCmdTab) => Some( + WindowManagerEvent::FocusChange(notification, process_id, window_id), + ), SystemNotification::Accessibility(AccessibilityNotification::AXWindowCreated) | SystemNotification::Accessibility(AccessibilityNotification::AXApplicationShown) | SystemNotification::AppKitWorkspace( From fa6ce669f758df655a81ebbfdce00e11112a185d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 09:53:35 -0700 Subject: [PATCH 069/305] 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. --- Cargo.lock | 29 ++++ justfile | 3 + komorebi/Cargo.toml | 1 + komorebi/src/lib.rs | 2 + komorebi/src/macos_api.rs | 187 +++++++++++++------------- komorebi/src/main.rs | 50 ++++++- komorebi/src/monitor_reconciliator.rs | 54 +++++--- 7 files changed, 213 insertions(+), 113 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f923e733..1a0abddb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -492,6 +492,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "fnv" version = "1.0.7" @@ -1671,10 +1677,13 @@ version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ + "backtrace", "cfg-if", "libc", + "petgraph", "redox_syscall", "smallvec", + "thread-id", "windows-targets 0.52.6", ] @@ -1690,6 +1699,16 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.11.4", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -2430,6 +2449,16 @@ dependencies = [ "syn", ] +[[package]] +name = "thread-id" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe8f25bbdd100db7e1d34acf7fd2dc59c4bf8f7483f505eaa7d4f12f76cc0ea" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "thread_local" version = "1.1.9" diff --git a/justfile b/justfile index 31882336..2df678da 100644 --- a/justfile +++ b/justfile @@ -39,6 +39,9 @@ debug target $RUST_LOG="debug": trace target $RUST_LOG="trace": just run {{ target }} +deadlock $RUST_LOG="trace": + cargo +stable run --bin komorebi --locked --no-default-features --features deadlock_detection + depgen: cargo deny check cargo deny list --format json | jq 'del(.unlicensed)' > dependencies.json diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index f314114f..d7b9b651 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -42,4 +42,5 @@ shadow-rs = { workspace = true } [features] default = ["schemars"] +deadlock_detection = ["parking_lot/deadlock_detection"] schemars = ["dep:schemars"] diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 04b1e9fb..844d7d26 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -103,6 +103,8 @@ lazy_static! { pub static ref UPDATE_MONITOR_WORK_AREAS: Arc = Arc::new(AtomicBool::new(false)); pub static ref UPDATE_LATEST_MONITOR_INFORMATION: Arc = Arc::new(AtomicBool::new(false)); + pub static ref LOAD_LATEST_MONITOR_INFORMATION: Arc = + Arc::new(AtomicBool::new(false)); pub static ref LATEST_MONITOR_INFORMATION: Arc>>> = Arc::new(RwLock::new(None)); static ref WORKSPACE_MATCHING_RULES: Arc>> = diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index b5888e17..4e6066ad 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -14,10 +14,12 @@ use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; use crate::ioreg::IoReg; use crate::monitor::Monitor; +use crate::monitor::MonitorInfo; use crate::window::WindowInfo; use crate::window_manager::WindowManager; use color_eyre::eyre; use objc2::MainThreadMarker; +use objc2_app_kit::NSDeviceDescriptionKey; use objc2_app_kit::NSEvent; use objc2_app_kit::NSScreen; use objc2_application_services::AXUIElement; @@ -28,6 +30,9 @@ use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFString; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; +use objc2_core_foundation::CGSize; +use objc2_core_graphics::CGMainDisplayID; +use objc2_foundation::NSNumber; use parking_lot::Mutex; use std::collections::HashMap; use std::collections::hash_map::Entry; @@ -40,50 +45,11 @@ pub struct MacosApi; impl MacosApi { #[tracing::instrument(skip_all)] pub fn load_monitor_information(wm: &mut WindowManager) -> Result<(), LibraryError> { + let all_devices = Self::latest_monitor_information()?; + let monitors = &mut wm.monitors; let monitor_usr_idx_map = &mut wm.monitor_usr_idx_map; - let monitor_info = IoReg::query_monitors()?; - - let mut monitor_info_map = HashMap::new(); - for m in monitor_info { - monitor_info_map.insert(m.serial_number, m); - } - - let mut all_devices = vec![]; - - let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); - - for display_id in CoreGraphicsApi::connected_display_ids()? { - let display_bounds = CoreGraphicsApi::display_bounds(display_id); - let serial_number = CoreGraphicsApi::display_serial_number(display_id); - - if let Some(info) = monitor_info_map.get(&serial_number) { - for screen in &screens { - let menu_bar_height = screen.frame().size.height - - screen.visibleFrame().size.height - - screen.visibleFrame().origin.y; - - if screen.frame() == display_bounds { - let size = Rect::from(display_bounds); - let mut work_area_size = Rect::from(display_bounds); - work_area_size.top += menu_bar_height as i32; - work_area_size.bottom = screen.visibleFrame().size.height as i32; - - let monitor = Monitor::new( - display_id, - size, - work_area_size, - &info.product_name, - &info.alphanumeric_serial_number, - ); - - all_devices.push(monitor); - } - } - } - } - 'read: for device in all_devices { for monitor in monitors.elements() { if device.serial_number_id.eq(&monitor.serial_number_id) { @@ -164,36 +130,19 @@ impl MacosApi { Ok(()) } - pub fn update_monitor_work_areas(wm: Arc>) -> eyre::Result<()> { - let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); - - for display_id in CoreGraphicsApi::connected_display_ids()? { - let display_bounds = CoreGraphicsApi::display_bounds(display_id); - - let mut wm = wm.lock(); - - for screen in &screens { - let menu_bar_height = screen.frame().size.height - - screen.visibleFrame().size.height - - screen.visibleFrame().origin.y; - - if screen.frame() == display_bounds { - let size = Rect::from(display_bounds); - let mut work_area_size = Rect::from(display_bounds); - work_area_size.top += menu_bar_height as i32; - work_area_size.bottom = screen.visibleFrame().size.height as i32; - - for monitor in wm.monitors_mut() { - if monitor.id == display_id { - monitor.size = size; - monitor.work_area_size = work_area_size; - } - - tracing::info!( - "updated monitor size and work area for monitor {display_id}" - ) - } + pub fn update_monitor_work_areas(wm: &mut WindowManager) -> eyre::Result<()> { + let all_devices = Self::latest_monitor_information()?; + for device in all_devices { + for monitor in wm.monitors_mut() { + if monitor.id == device.id { + monitor.size = device.size; + monitor.work_area_size = device.work_area_size; } + + tracing::info!( + "updated monitor size and work area for monitor {}", + monitor.serial_number_id + ); } let focus_follows_mouse = wm.mouse_follows_focus; @@ -204,47 +153,102 @@ impl MacosApi { } pub fn latest_monitor_information() -> Result, LibraryError> { - let mut monitors = vec![]; + let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); + let mut network_attached_screens = vec![]; + + for display_id in CoreGraphicsApi::connected_display_ids()? { + let serial_number = CoreGraphicsApi::display_serial_number(display_id); + network_attached_screens.push((serial_number, display_id)); + } let monitor_info = IoReg::query_monitors()?; + let mut monitor_info_map = HashMap::new(); for m in monitor_info { monitor_info_map.insert(m.serial_number, m); } - let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); + // total hackery for iPad second screen stuff over the network + for info in monitor_info_map.values() { + network_attached_screens + .retain(|(serial_number, _)| serial_number != &info.serial_number); + } + + for (serial_number, display_id) in network_attached_screens { + for screen in &screens { + if let Some(did) = screen + .deviceDescription() + .objectForKey(&NSDeviceDescriptionKey::from_str("NSScreenNumber")) + && let Ok(did) = did.downcast::() + && did.as_u32() == display_id + { + monitor_info_map.insert( + serial_number, + MonitorInfo { + alphanumeric_serial_number: serial_number.to_string(), + manufacturer_id: "".to_string(), + product_name: unsafe { screen.localizedName() }.to_string(), + legacy_manufacturer_id: "".to_string(), + product_id: "".to_string(), + serial_number, + week_of_manufacture: "".to_string(), + year_of_manufacture: "".to_string(), + }, + ); + } + } + } + + let mut all_devices = vec![]; for display_id in CoreGraphicsApi::connected_display_ids()? { - let display_bounds = CoreGraphicsApi::display_bounds(display_id); let serial_number = CoreGraphicsApi::display_serial_number(display_id); - if let Some(info) = monitor_info_map.get(&serial_number) { for screen in &screens { - let menu_bar_height = screen.frame().size.height - - screen.visibleFrame().size.height - - screen.visibleFrame().origin.y; + if let Some(did) = screen + .deviceDescription() + .objectForKey(&NSDeviceDescriptionKey::from_str("NSScreenNumber")) + { + let display_bounds = CoreGraphicsApi::display_bounds(display_id); + if let Ok(did) = did.downcast::() + && did.as_u32() == display_id + { + let size = Rect::from(display_bounds); - if screen.frame() == display_bounds { - let size = Rect::from(display_bounds); - let mut work_area_size = Rect::from(display_bounds); - work_area_size.top += menu_bar_height as i32; - work_area_size.bottom = screen.visibleFrame().size.height as i32; + let visible_frame = screen.visibleFrame(); + let primary_display_height = + CoreGraphicsApi::display_bounds(unsafe { CGMainDisplayID() }) + .size + .height; - let monitor = Monitor::new( - display_id, - size, - work_area_size, - &info.product_name, - &info.alphanumeric_serial_number, - ); + let quartz_visible_frame = CGRect::new( + CGPoint::new( + visible_frame.origin.x, + primary_display_height + - visible_frame.origin.y + - visible_frame.size.height, + ), + CGSize::new(visible_frame.size.width, visible_frame.size.height), + ); - monitors.push(monitor); + let work_area_size = Rect::from(quartz_visible_frame); + + let monitor = Monitor::new( + display_id, + size, + work_area_size, + &info.product_name, + &info.alphanumeric_serial_number, + ); + + all_devices.push(monitor); + } } } } } - Ok(monitors) + Ok(all_devices) } pub fn reconile_monitors(wm: Arc>) -> eyre::Result<()> { @@ -252,7 +256,6 @@ impl MacosApi { for display_id in CoreGraphicsApi::connected_display_ids()? { let display_bounds = CoreGraphicsApi::display_bounds(display_id); - let mut wm = wm.lock(); for screen in &screens { diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 7de7467e..1d8256d2 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -7,6 +7,7 @@ use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; use komorebi::HOME_DIR; use komorebi::LATEST_MONITOR_INFORMATION; +use komorebi::LOAD_LATEST_MONITOR_INFORMATION; use komorebi::UPDATE_LATEST_MONITOR_INFORMATION; use komorebi::UPDATE_MONITOR_WORK_AREAS; use komorebi::core::pathext::replace_env_in_path; @@ -138,6 +139,31 @@ fn setup(log_level: LogLevel) -> eyre::Result<(WorkerGuard, WorkerGuard)> { Ok((guard, color_guard)) } +#[cfg(feature = "deadlock_detection")] +#[tracing::instrument] +fn detect_deadlocks() { + // Create a background thread which checks for deadlocks every 10s + std::thread::spawn(move || { + loop { + tracing::info!("running deadlock detector"); + std::thread::sleep(std::time::Duration::from_secs(5)); + let deadlocks = parking_lot::deadlock::check_deadlock(); + if deadlocks.is_empty() { + continue; + } + + tracing::error!("{} deadlocks detected", deadlocks.len()); + for (i, threads) in deadlocks.iter().enumerate() { + tracing::error!("deadlock #{}", i); + for t in threads { + tracing::error!("thread id: {:#?}", t.thread_id()); + tracing::error!("{:#?}", t.backtrace()); + } + } + } + }); +} + #[derive(Default, Deserialize, ValueEnum, Clone)] #[serde(rename_all = "snake_case")] enum LogLevel { @@ -197,6 +223,9 @@ fn main() -> eyre::Result<()> { let run_loop = CFRunLoop::current().ok_or_eyre("couldn't get CFRunLoop::current")?; let _input_listener = InputEventListener::init(&run_loop); + #[cfg(feature = "deadlock_detection")] + detect_deadlocks(); + let static_config = opts.config.map_or_else( || { let komorebi_json = HOME_DIR.join("komorebi.json"); @@ -272,11 +301,13 @@ fn main() -> eyre::Result<()> { if UPDATE_MONITOR_WORK_AREAS.load(Ordering::Relaxed) { // this can only be called on the main thread - if let Err(error) = MacosApi::update_monitor_work_areas(wm.clone()) { - tracing::error!("failed to update montior work areas: {error}"); - } + if let Some(mut wm) = wm.try_lock() { + if let Err(error) = MacosApi::update_monitor_work_areas(&mut wm) { + tracing::error!("failed to update monitor work areas: {error}"); + } - UPDATE_MONITOR_WORK_AREAS.store(false, Ordering::Relaxed); + UPDATE_MONITOR_WORK_AREAS.store(false, Ordering::Relaxed); + } } if UPDATE_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { @@ -285,6 +316,17 @@ fn main() -> eyre::Result<()> { *latest_monitor_information = Some(MacosApi::latest_monitor_information()?); } + if LOAD_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { + // this can only be called on the main thread + if let Some(mut wm) = wm.try_lock() { + if let Err(error) = MacosApi::load_monitor_information(&mut wm) { + tracing::error!("failed to update load monitor information: {error}"); + } + + LOAD_LATEST_MONITOR_INFORMATION.store(false, Ordering::Relaxed); + } + } + // this gets our observer notification callbacks firing autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) }); } diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index 04d69da1..6ec5b0aa 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -1,11 +1,12 @@ use crate::DISPLAY_INDEX_PREFERENCES; use crate::LATEST_MONITOR_INFORMATION; +use crate::LOAD_LATEST_MONITOR_INFORMATION; use crate::Notification; use crate::NotificationEvent; +use crate::UPDATE_LATEST_MONITOR_INFORMATION; use crate::UPDATE_MONITOR_WORK_AREAS; use crate::WORKSPACE_MATCHING_RULES; use crate::core::config_generation::WorkspaceMatchingRule; -use crate::macos_api::MacosApi; use crate::monitor::Monitor; use crate::notify_subscribers; use crate::state::State; @@ -91,13 +92,15 @@ pub fn listen_for_notifications(wm: Arc>) -> color_eyre::Re pub fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> { tracing::info!("listening"); + let arc = wm.clone(); let receiver = event_rx(); 'receiver: for notification in receiver { - let mut wm = wm.lock(); - - let initial_state = State::from(wm.as_ref()); + let initial_state = { + let wm = wm.lock(); + State::from(wm.as_ref()) + }; match notification { MonitorNotification::Resize(_display_id) => { @@ -105,6 +108,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result UPDATE_MONITOR_WORK_AREAS.store(true, Ordering::Relaxed); } MonitorNotification::DisplayConnectionChange(_) => { + let mut wm = wm.lock(); tracing::debug!("handling display connection change notification"); let mut monitor_cache = MONITOR_CACHE .get_or_init(|| Mutex::new(HashMap::new())) @@ -116,10 +120,12 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // TODO: I think because of the way the threading model works on macOS we'll // need to run this on the main thread to get access to info from NSScreen // let attached_devices = attached_display_devices(display_provider)?; - let mut latest_monitor_information = LATEST_MONITOR_INFORMATION.write(); - *latest_monitor_information = None; + { + let mut latest_monitor_information = LATEST_MONITOR_INFORMATION.write(); + *latest_monitor_information = None; + } - UPDATE_MONITOR_WORK_AREAS.store(true, Ordering::Relaxed); + UPDATE_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); let mut attached_devices = vec![]; while attached_devices.is_empty() { @@ -130,9 +136,9 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result std::thread::sleep(std::time::Duration::from_millis(100)); } - UPDATE_MONITOR_WORK_AREAS.store(false, Ordering::Relaxed); + UPDATE_LATEST_MONITOR_INFORMATION.store(false, Ordering::Relaxed); - // Make sure that in our state any attached displays have the latest Win32 data + // Make sure that in our state any attached displays have the latest macOS API data for monitor in wm.monitors_mut() { for attached in &attached_devices { // let serial_number_ids_match = if let (Some(attached_snid), Some(m_snid)) = @@ -326,7 +332,18 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // // Check for and add any new monitors that may have been plugged in // // Monitor and display index preferences get applied in this function - MacosApi::load_monitor_information(&mut wm)?; + // MacosApi::load_monitor_information(&mut wm)?; + + // need to drop here because the main thread needs the lock to load the latest + // monitor info into the wm state + drop(wm); + LOAD_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); + while LOAD_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { + std::thread::sleep(std::time::Duration::from_millis(100)); + tracing::trace!("waiting for latest monitor info to be loaded {}", line!()); + } + + let mut wm = arc.lock(); let post_addition_monitor_count = wm.monitors().len(); @@ -548,13 +565,16 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result } } - notify_subscribers( - Notification { - event: NotificationEvent::Monitor(notification), - state: wm.as_ref().into(), - }, - initial_state.has_been_modified(&wm), - )?; + { + let wm = wm.lock(); + notify_subscribers( + Notification { + event: NotificationEvent::Monitor(notification), + state: wm.as_ref().into(), + }, + initial_state.has_been_modified(&wm), + )?; + } } Ok(()) From 4b0b2f4013d2076481ac1585f6a328ffe49d2af3 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 10:08:32 -0700 Subject: [PATCH 070/305] feat(wm): add cross-monitor focus and moves Forgot that I had hardcoded the window based work area offset lol. --- komorebi/src/monitor.rs | 7 +- komorebi/src/window_manager.rs | 289 ++++++++++++++++++++++++++++++++- 2 files changed, 285 insertions(+), 11 deletions(-) diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 09d80c2a..5b34e55e 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -117,12 +117,7 @@ impl Monitor { size, work_area_offset: None, work_area_size, - window_based_work_area_offset: Some(Rect { - left: 500, - top: 0, - right: 1000, - bottom: 0, - }), + window_based_work_area_offset: None, window_based_work_area_offset_limit: 1, container_padding: None, workspace_padding: None, diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 2eb9dfa3..9d520e40 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -442,20 +442,147 @@ impl WindowManager { &mut self, direction: OperationDirection, ) -> eyre::Result<()> { + self.handle_unmanaged_window_behaviour()?; + let mouse_follows_focus = self.mouse_follows_focus; + let workspace = self.focused_workspace()?; + let workspace_idx = self.focused_workspace_idx()?; tracing::info!("focusing container"); - match workspace.new_idx_for_direction(direction) { - None => {} + let new_idx = + if workspace.maximized_window.is_some() || workspace.monocle_container.is_some() { + None + } else { + workspace.new_idx_for_direction(direction) + }; + + let mut cross_monitor_monocle_or_max = false; + + // this is for when we are scrolling across workspaces like PaperWM + if new_idx.is_none() + && matches!( + self.cross_boundary_behaviour, + CrossBoundaryBehaviour::Workspace + ) + && matches!( + direction, + OperationDirection::Left | OperationDirection::Right + ) + { + let workspace_count = if let Some(monitor) = self.focused_monitor() { + monitor.workspaces().len() + } else { + 1 + }; + + let next_idx = match direction { + OperationDirection::Left => match workspace_idx { + 0 => workspace_count - 1, + n => n - 1, + }, + OperationDirection::Right => match workspace_idx { + n if n == workspace_count - 1 => 0, + n => n + 1, + }, + _ => workspace_idx, + }; + + self.focus_workspace(next_idx)?; + + if let Ok(focused_workspace) = self.focused_workspace_mut() + && focused_workspace.monocle_container.is_none() + { + match direction { + OperationDirection::Left => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = + layout.rightmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + OperationDirection::Right => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = + layout.leftmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + _ => {} + }; + } + + return Ok(()); + } + + // if there is no container in that direction for this workspace + match new_idx { + None => { + let monitor_idx = self + .monitor_idx_in_direction(direction) + .ok_or_eyre("there is no container or monitor in this direction")?; + + self.focus_monitor(monitor_idx)?; + + if let Ok(focused_workspace) = self.focused_workspace_mut() { + if let Some(window) = &focused_workspace.maximized_window { + window.focus(mouse_follows_focus)?; + cross_monitor_monocle_or_max = true; + } else if let Some(monocle) = &focused_workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(mouse_follows_focus)?; + cross_monitor_monocle_or_max = true; + } + } else if focused_workspace.layer == WorkspaceLayer::Tiling { + match direction { + OperationDirection::Left => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = layout + .rightmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + OperationDirection::Right => match focused_workspace.layout { + Layout::Default(layout) => { + let target_index = + layout.leftmost_index(focused_workspace.containers().len()); + focused_workspace.focus_container(target_index); + } + }, + _ => {} + }; + } + } + } Some(idx) => { let workspace = self.focused_workspace_mut()?; workspace.focus_container(idx); } } - if let Ok(focused_window) = self.focused_window() { - focused_window.focus(self.mouse_follows_focus)?; + if !cross_monitor_monocle_or_max { + let ws = self.focused_workspace_mut()?; + if ws.is_empty() { + // TODO: figure out if we need to do this on macOS + // This is to remove focus from the previous monitor + // let desktop_window = Window::from(WindowsApi::desktop_window()?); + // + // match WindowsApi::raise_and_focus_window(desktop_window.hwnd) { + // Ok(()) => {} + // Err(error) => { + // tracing::warn!("{} {}:{}", error, file!(), line!()); + // } + // } + } else if ws.layer == WorkspaceLayer::Floating && !ws.floating_windows().is_empty() { + if let Some(window) = ws.focused_floating_window() { + window.focus(mouse_follows_focus)?; + } + } else { + ws.layer = WorkspaceLayer::Tiling; + if let Ok(focused_window) = self.focused_window() { + focused_window.focus(mouse_follows_focus)?; + } + } } Ok(()) @@ -545,15 +672,167 @@ impl WindowManager { &mut self, direction: OperationDirection, ) -> eyre::Result<()> { + self.handle_unmanaged_window_behaviour()?; + let workspace = self.focused_workspace()?; + let workspace_idx = self.focused_workspace_idx()?; + + // removing this messes up the monitor / container / window index somewhere + // and results in the wrong window getting moved across the monitor boundary + if workspace.is_focused_window_monocle_or_maximized()? { + bail!("ignoring command while active window is in monocle mode or maximized"); + } tracing::info!("moving container"); let origin_container_idx = workspace.focused_container_idx(); + let origin_monitor_idx = self.focused_monitor_idx(); let target_container_idx = workspace.new_idx_for_direction(direction); + // this is for when we are scrolling across workspaces like PaperWM + if target_container_idx.is_none() + && matches!( + self.cross_boundary_behaviour, + CrossBoundaryBehaviour::Workspace + ) + && matches!( + direction, + OperationDirection::Left | OperationDirection::Right + ) + { + let workspace_count = if let Some(monitor) = self.focused_monitor() { + monitor.workspaces().len() + } else { + 1 + }; + + let next_idx = match direction { + OperationDirection::Left => match workspace_idx { + 0 => workspace_count - 1, + n => n - 1, + }, + OperationDirection::Right => match workspace_idx { + n if n == workspace_count - 1 => 0, + n => n + 1, + }, + _ => workspace_idx, + }; + + // passing the direction here is how we handle whether to insert at the front + // or the back of the container vecdeque in the target workspace + self.move_container_to_workspace(next_idx, true, Some(direction))?; + self.update_focused_workspace(self.mouse_follows_focus, true)?; + + return Ok(()); + } + match target_container_idx { - None => {} + // If there is nowhere to move on the current workspace, try to move it onto the monitor + // in that direction if there is one + None => { + // Don't do anything if the user has set the MoveBehaviour to NoOp + if matches!(self.cross_monitor_move_behaviour, MoveBehaviour::NoOp) { + return Ok(()); + } + + let target_monitor_idx = self + .monitor_idx_in_direction(direction) + .ok_or_eyre("there is no container or monitor in this direction")?; + + { + // actually move the container to target monitor using the direction + self.move_container_to_monitor( + target_monitor_idx, + None, + true, + Some(direction), + )?; + + // focus the target monitor + self.focus_monitor(target_monitor_idx)?; + + // unset monocle container on target workspace if there is one + let mut target_workspace_has_monocle = false; + if let Ok(target_workspace) = self.focused_workspace() + && target_workspace.monocle_container.is_some() + { + target_workspace_has_monocle = true; + } + + if target_workspace_has_monocle { + self.toggle_monocle()?; + } + + // get a mutable ref to the focused workspace on the target monitor + let target_workspace = self.focused_workspace_mut()?; + + // if there is only one container on the target workspace after the insertion + // it means that there won't be one swapped back, so we have to decrement the + // focused position + if target_workspace.containers().len() == 1 { + let origin_workspace = + self.focused_workspace_for_monitor_idx_mut(origin_monitor_idx)?; + + origin_workspace.focus_container( + origin_workspace.focused_container_idx().saturating_sub(1), + ); + } + } + + // if our MoveBehaviour is Swap, let's try to send back the window container + // whose position which just took over + if matches!(self.cross_monitor_move_behaviour, MoveBehaviour::Swap) { + { + let target_workspace = self.focused_workspace_mut()?; + + // if the target workspace doesn't have more than one container, this means it + // was previously empty, by only doing the second part of the swap when there is + // more than one container, we can fall back to a "move" if there is nothing to + // swap with on the target monitor + if target_workspace.containers().len() > 1 { + // remove the container from the target monitor workspace + let target_container = target_workspace + // this is now focused_container_idx + 1 because we have inserted our origin container + .remove_container_by_idx( + target_workspace.focused_container_idx() + 1, + ) + .ok_or_eyre("could not remove container at given target index")?; + + let origin_workspace = + self.focused_workspace_for_monitor_idx_mut(origin_monitor_idx)?; + + // insert the container from the target monitor workspace into the origin monitor workspace + // at the same position from which our origin container was removed + origin_workspace + .insert_container_at_idx(origin_container_idx, target_container); + } + } + } + + // make sure to update the origin monitor workspace layout because it is no + // longer focused so it won't get updated at the end of this fn + let offset = self.work_area_offset; + + self.monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .update_focused_workspace(offset)?; + + // TODO: figure out monitor DPI differences on macOS + // let a = self + // .focused_monitor() + // .ok_or_eyre("there is no monitor focused monitor")? + // .id; + // let b = self + // .monitors_mut() + // .get_mut(origin_monitor_idx) + // .ok_or_eyre("there is no monitor at this index")? + // .id; + + // if !WindowsApi::monitors_have_same_dpi(a, b)? { + // self.update_focused_workspace(self.mouse_follows_focus, true)?; + // } + } Some(new_idx) => { let workspace = self.focused_workspace_mut()?; workspace.swap_containers(origin_container_idx, new_idx); From ae0ce4c95d648dc0cf888487b953900aa243d641 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 12:17:04 -0700 Subject: [PATCH 071/305] fix(wm): address more monitor reconciliation bugs This commit fixes another deadlock and a forces the hiding of non-focused workspaces on all monitors after a DisplayConnectionChange event results in a different number of total monitors in the wm state. --- komorebi/src/macos_api.rs | 40 -------------- komorebi/src/monitor_reconciliator.rs | 76 +++++++++++++-------------- komorebi/src/window.rs | 37 +++++++------ 3 files changed, 56 insertions(+), 97 deletions(-) diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 4e6066ad..9abf1247 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -33,12 +33,10 @@ use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; use objc2_core_graphics::CGMainDisplayID; use objc2_foundation::NSNumber; -use parking_lot::Mutex; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::ffi::c_void; use std::ptr::NonNull; -use std::sync::Arc; pub struct MacosApi; @@ -251,44 +249,6 @@ impl MacosApi { Ok(all_devices) } - pub fn reconile_monitors(wm: Arc>) -> eyre::Result<()> { - let screens = NSScreen::screens(MainThreadMarker::new().unwrap()); - - for display_id in CoreGraphicsApi::connected_display_ids()? { - let display_bounds = CoreGraphicsApi::display_bounds(display_id); - let mut wm = wm.lock(); - - for screen in &screens { - let menu_bar_height = screen.frame().size.height - - screen.visibleFrame().size.height - - screen.visibleFrame().origin.y; - - if screen.frame() == display_bounds { - let size = Rect::from(display_bounds); - let mut work_area_size = Rect::from(display_bounds); - work_area_size.top += menu_bar_height as i32; - work_area_size.bottom = screen.visibleFrame().size.height as i32; - - for monitor in wm.monitors_mut() { - if monitor.id == display_id { - monitor.size = size; - monitor.work_area_size = work_area_size; - } - - tracing::info!( - "updated monitor size and work area for monitor {display_id}" - ) - } - } - } - - let focus_follows_mouse = wm.mouse_follows_focus; - wm.update_focused_workspace(focus_follows_mouse, true)?; - } - - Ok(()) - } - #[tracing::instrument(skip_all)] pub fn load_workspace_information(wm: &mut WindowManager) -> Result<(), LibraryError> { let mut monitor_size_map = HashMap::new(); diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index 6ec5b0aa..49f666d2 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -116,17 +116,12 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result let initial_monitor_count = wm.monitors().len(); - // Get the currently attached display devices - // TODO: I think because of the way the threading model works on macOS we'll - // need to run this on the main thread to get access to info from NSScreen - // let attached_devices = attached_display_devices(display_provider)?; { let mut latest_monitor_information = LATEST_MONITOR_INFORMATION.write(); *latest_monitor_information = None; + UPDATE_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); } - UPDATE_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); - let mut attached_devices = vec![]; while attached_devices.is_empty() { if let Some(latest) = &*LATEST_MONITOR_INFORMATION.read() { @@ -141,23 +136,13 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // Make sure that in our state any attached displays have the latest macOS API data for monitor in wm.monitors_mut() { for attached in &attached_devices { - // let serial_number_ids_match = if let (Some(attached_snid), Some(m_snid)) = - // (&attached.serial_number_id, &monitor.serial_number_id) - // { - // attached_snid.eq(m_snid) - // } else { - // false - // }; - let serial_number_ids_match = attached.serial_number_id == monitor.serial_number_id; if serial_number_ids_match { monitor.id = attached.id; monitor.device = attached.device.clone(); - // monitor.device_id = attached.device_id.clone(); monitor.serial_number_id = attached.serial_number_id.clone(); - // monitor.name = attached.name.clone(); monitor.size = attached.size; monitor.work_area_size = attached.work_area_size; } @@ -267,6 +252,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result rules_to_remove.push(i); } } + for i in rules_to_remove { workspace_rules.remove(i); } @@ -286,7 +272,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result } } - // Update known_hwnds + // Update known_window_ids wm.known_window_ids .retain(|i, _| !windows_to_remove.contains(i)); @@ -317,32 +303,32 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result let post_removal_monitor_count = wm.monitors().len(); - // // This is the list of device ids after we have removed detached displays. We can - // // keep this with just the device_ids without the serial numbers since this is used - // // only to check which one is the newly added monitor below if there is a new - // // monitor. Everything done after with said new monitor will again consider both - // // serial number and device ids. - // let post_removal_device_ids = wm - // .monitors() - // .iter() - // .map(|m| &m.device_id) - // .cloned() - // .collect::>(); - let post_removal_serial_ids = []; + // This is the list of device ids after we have removed detached displays. We can + // keep this with just the device_ids without the serial numbers since this is used + // only to check which one is the newly added monitor below if there is a new + // monitor. Everything done after with said new monitor will again consider both + // serial number and device ids. + let post_removal_serial_ids = wm + .monitors() + .iter() + .map(|m| &m.serial_number_id) + .cloned() + .collect::>(); - // // Check for and add any new monitors that may have been plugged in - // // Monitor and display index preferences get applied in this function - // MacosApi::load_monitor_information(&mut wm)?; - - // need to drop here because the main thread needs the lock to load the latest - // monitor info into the wm state - drop(wm); - LOAD_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); - while LOAD_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { - std::thread::sleep(std::time::Duration::from_millis(100)); - tracing::trace!("waiting for latest monitor info to be loaded {}", line!()); + // Check for and add any new monitors that may have been plugged in + // Monitor and display index preferences get applied in this function + { + // need to drop here because the main thread needs the lock to load the latest + // monitor info into the wm state + drop(wm); + LOAD_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); + while LOAD_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { + std::thread::sleep(std::time::Duration::from_millis(50)); + tracing::trace!("waiting for latest monitor info to be loaded {}", line!()); + } } + // regain the lock here once the monitor information has been updated let mut wm = arc.lock(); let post_addition_monitor_count = wm.monitors().len(); @@ -562,6 +548,16 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // Border updates to fix DPI/resolution related jank // border_manager::send_notification(None); } + + let mouse_follows_focus = wm.mouse_follows_focus; + // when a monitor is added/removed some of our "hidden" windows + // get brought back onto the screen, so we wanna make sure unfocused + // workspaces get hidden again + if initial_monitor_count != final_count { + for monitor in wm.monitors_mut() { + monitor.load_focused_workspace(mouse_follows_focus)?; + } + } } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 68869947..bbc48110 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -352,27 +352,30 @@ impl Window { #[tracing::instrument(skip_all)] pub fn hide(&mut self) -> Result<(), AccessibilityError> { + let rect = MacosApi::window_rect(&self.element)?; + let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); - if let Entry::Vacant(entry) = window_restore_positions.entry(self.id) { - let rect = MacosApi::window_rect(&self.element)?; - if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { - entry.insert(rect); - drop(window_restore_positions); + if let Entry::Vacant(entry) = window_restore_positions.entry(self.id) + && CoreGraphicsApi::display_bounds_for_window_rect(rect).is_none() + { + entry.insert(rect); + drop(window_restore_positions); + } - // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API - let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); + if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { + // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API + let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); - tracing::debug!( - "hiding {} and setting restore point to {},{}", - self.title() - .unwrap_or_else(|| String::from("")), - rect.origin.x, - rect.origin.y, - ); + tracing::debug!( + "hiding {} and setting restore point to {},{}", + self.title() + .unwrap_or_else(|| String::from("")), + rect.origin.x, + rect.origin.y, + ); - self.set_point(hidden_rect.origin, true)?; - self.set_size(hidden_rect.size, true)?; - } + self.set_point(hidden_rect.origin, true)?; + self.set_size(hidden_rect.size, true)?; } Ok(()) From 486aecda4c60cf7a27ce8544458ee5ad434b32de Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 12:21:21 -0700 Subject: [PATCH 072/305] fix(wm): respect rules on startup window scan --- komorebi/src/macos_api.rs | 10 +++++++--- komorebi/src/window.rs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 9abf1247..8f981eca 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -15,6 +15,7 @@ use crate::core_graphics::CoreGraphicsApi; use crate::ioreg::IoReg; use crate::monitor::Monitor; use crate::monitor::MonitorInfo; +use crate::window::RuleDebug; use crate::window::WindowInfo; use crate::window_manager::WindowManager; use color_eyre::eyre; @@ -285,9 +286,12 @@ impl MacosApi { }; if let Some(window) = application.window_by_title(&info.name) { - window.observe(&wm.run_loop)?; - entry.push(window); - valid_window_count += 1 + let mut rule_debug = RuleDebug::default(); + if window.should_manage(None, &mut rule_debug)? { + window.observe(&wm.run_loop)?; + entry.push(window); + valid_window_count += 1 + } } } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index bbc48110..06d6a771 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -643,7 +643,7 @@ impl Window { #[tracing::instrument(skip_all)] pub fn should_manage( - self, + &self, event: Option, debug: &mut RuleDebug, ) -> eyre::Result { From 7bb0aaac487b865ae144a47089c736afdfa862a9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 12:49:21 -0700 Subject: [PATCH 073/305] feat(cli): add docgen cmd and jsonschema just target This commit adds a docgen command to generate markdown documentation files of all of the CLI commands, and a justfile target to generate JSONSchema files. --- justfile | 8 ++++++++ komorebic/src/main.rs | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 2df678da..d51aed82 100644 --- a/justfile +++ b/justfile @@ -42,6 +42,14 @@ trace target $RUST_LOG="trace": deadlock $RUST_LOG="trace": cargo +stable run --bin komorebi --locked --no-default-features --features deadlock_detection +docgen: + cargo run --package komorebic -- docgen + find docs/cli -type f -exec sed -i.bak 's/Usage: /Usage: komorebic /g' {} \; && find docs/cli -name "*.bak" -delete + +jsonschema: + cargo run --package komorebic -- static-config-schema > schema.json + cargo run --package komorebic -- application-specific-configuration-schema > schema.asc.json + depgen: cargo deny check cargo deny list --format json | jq 'del(.unlicensed)' > dependencies.json diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 40ef2dce..fccc9084 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1,6 +1,7 @@ #![warn(clippy::all)] use chrono::Utc; +use clap::CommandFactory; use clap::Parser; use clap::ValueEnum; use color_eyre::eyre; @@ -610,8 +611,8 @@ struct Opts { #[derive(Parser)] enum SubCommand { - // #[clap(hide = true)] - // Docgen, + #[clap(hide = true)] + Docgen, // /// Gather example configurations for a new-user quickstart // Quickstart, /// Start komorebi.exe as a background process @@ -1146,6 +1147,36 @@ fn main() -> eyre::Result<()> { let opts: Opts = Opts::parse(); match opts.subcmd { + SubCommand::Docgen => { + let mut cli = Opts::command(); + let subcommands = cli.get_subcommands_mut(); + std::fs::create_dir_all("docs/cli")?; + + let ignore = [ + "docgen", + "alt-focus-hack", + "identify-border-overflow-application", + "load-custom-layout", + "workspace-custom-layout", + "named-workspace-custom-layout", + "workspace-custom-layout-rule", + "named-workspace-custom-layout-rule", + "focus-follows-mouse", + "toggle-focus-follows-mouse", + "format-app-specific-configuration", + ]; + + for cmd in subcommands { + let name = cmd.get_name().to_string(); + if !ignore.contains(&name.as_str()) { + let help_text = cmd.render_long_help().to_string(); + let outpath = format!("docs/cli/{name}.md"); + let markdown = format!("# {name}\n\n```\n{help_text}\n```"); + std::fs::write(outpath, markdown)?; + println!(" - cli/{name}.md"); + } + } + } SubCommand::Start(arg) => { let mut command = &mut Command::new("komorebi"); From f9dd8cf9f1c028ac15d8945bfcb8871687ab5db9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 12:50:17 -0700 Subject: [PATCH 074/305] docs(mkdocs): add generated markdown docs for cli cmds --- docs/cli/adjust-container-padding.md | 19 + docs/cli/adjust-workspace-padding.md | 19 + ...plication-specific-configuration-schema.md | 12 + docs/cli/change-layout.md | 16 + docs/cli/clear-all-workspace-rules.md | 12 + .../cli/clear-named-workspace-layout-rules.md | 16 + docs/cli/clear-named-workspace-rules.md | 16 + docs/cli/clear-session-float-rules.md | 12 + docs/cli/clear-workspace-layout-rules.md | 19 + docs/cli/clear-workspace-rules.md | 19 + docs/cli/close-workspace.md | 12 + docs/cli/close.md | 12 + docs/cli/configuration.md | 12 + docs/cli/container-padding.md | 22 + docs/cli/cross-monitor-move-behaviour.md | 19 + docs/cli/cycle-empty-workspace.md | 16 + docs/cli/cycle-focus.md | 16 + docs/cli/cycle-layout.md | 16 + docs/cli/cycle-monitor.md | 16 + docs/cli/cycle-move-to-monitor.md | 16 + docs/cli/cycle-move-to-workspace.md | 16 + docs/cli/cycle-move-workspace-to-monitor.md | 16 + docs/cli/cycle-move.md | 16 + docs/cli/cycle-send-to-monitor.md | 16 + docs/cli/cycle-send-to-workspace.md | 16 + docs/cli/cycle-stack-index.md | 16 + docs/cli/cycle-stack.md | 16 + docs/cli/cycle-workspace.md | 16 + docs/cli/data-directory.md | 12 + docs/cli/display-index-preference.md | 19 + docs/cli/eager-focus.md | 16 + docs/cli/enforce-workspace-rules.md | 12 + docs/cli/ensure-named-workspaces.md | 19 + docs/cli/ensure-workspaces.md | 19 + docs/cli/fetch-app-specific-configuration.md | 12 + docs/cli/flip-layout.md | 16 + docs/cli/focus-last-workspace.md | 12 + docs/cli/focus-monitor-at-cursor.md | 12 + docs/cli/focus-monitor-workspace.md | 19 + docs/cli/focus-monitor.md | 16 + docs/cli/focus-named-workspace.md | 16 + docs/cli/focus-stack-window.md | 16 + docs/cli/focus-workspace.md | 16 + docs/cli/focus-workspaces.md | 16 + docs/cli/focus.md | 16 + .../focused-workspace-container-padding.md | 16 + docs/cli/focused-workspace-padding.md | 16 + docs/cli/generate-static-config.md | 12 + docs/cli/global-state.md | 12 + docs/cli/global-work-area-offset.md | 25 + docs/cli/ignore-rule.md | 19 + docs/cli/initial-named-workspace-rule.md | 22 + docs/cli/initial-workspace-rule.md | 25 + docs/cli/load-resize.md | 16 + docs/cli/log.md | 12 + docs/cli/manage-rule.md | 19 + docs/cli/manage.md | 12 + docs/cli/minimize.md | 12 + docs/cli/monitor-information.md | 12 + docs/cli/monitor-work-area-offset.md | 28 + docs/cli/mouse-follows-focus.md | 16 + docs/cli/move-to-last-workspace.md | 12 + docs/cli/move-to-monitor-workspace.md | 19 + docs/cli/move-to-monitor.md | 16 + docs/cli/move-to-named-workspace.md | 16 + docs/cli/move-to-workspace.md | 16 + docs/cli/move-workspace-to-monitor.md | 16 + docs/cli/move.md | 16 + docs/cli/named-workspace-container-padding.md | 19 + docs/cli/named-workspace-layout-rule.md | 22 + docs/cli/named-workspace-layout.md | 19 + docs/cli/named-workspace-padding.md | 19 + docs/cli/named-workspace-rule.md | 22 + docs/cli/named-workspace-tiling.md | 19 + docs/cli/new-workspace.md | 12 + docs/cli/notification-schema.md | 12 + docs/cli/promote-focus.md | 12 + docs/cli/promote-window.md | 16 + docs/cli/promote.md | 12 + docs/cli/query.md | 16 + docs/cli/quick-load-resize.md | 12 + docs/cli/quick-save-resize.md | 12 + docs/cli/replace-configuration.md | 16 + docs/cli/resize-axis.md | 19 + docs/cli/resize-delta.md | 16 + docs/cli/resize-edge.md | 19 + docs/cli/retile.md | 12 + docs/cli/save-resize.md | 16 + docs/cli/scrolling-layout-columns.md | 16 + docs/cli/send-to-last-workspace.md | 12 + docs/cli/send-to-monitor-workspace.md | 19 + docs/cli/send-to-monitor.md | 16 + docs/cli/send-to-named-workspace.md | 16 + docs/cli/send-to-workspace.md | 16 + docs/cli/session-float-rule.md | 12 + docs/cli/session-float-rules.md | 12 + docs/cli/socket-schema.md | 12 + docs/cli/stack-all.md | 12 + docs/cli/stack.md | 16 + docs/cli/start.md | 15 + docs/cli/state.md | 12 + docs/cli/static-config-schema.md | 12 + docs/cli/stop.md | 12 + docs/cli/subscribe-socket.md | 16 + docs/cli/swap-workspaces-with-monitor.md | 16 + .../toggle-cross-monitor-move-behaviour.md | 12 + docs/cli/toggle-float-override.md | 12 + docs/cli/toggle-float.md | 12 + docs/cli/toggle-lock.md | 12 + docs/cli/toggle-monocle.md | 12 + docs/cli/toggle-mouse-follows-focus.md | 12 + docs/cli/toggle-pause.md | 12 + docs/cli/toggle-tiling.md | 12 + .../toggle-window-based-work-area-offset.md | 12 + docs/cli/toggle-window-container-behaviour.md | 12 + docs/cli/toggle-workspace-float-override.md | 13 + docs/cli/toggle-workspace-layer.md | 12 + ...le-workspace-window-container-behaviour.md | 12 + docs/cli/unmanage.md | 12 + .../unmanaged-window-operation-behaviour.md | 18 + docs/cli/unstack-all.md | 12 + docs/cli/unstack.md | 12 + docs/cli/unsubscribe-socket.md | 16 + docs/cli/visible-windows.md | 12 + docs/cli/workspace-layout-rule.md | 25 + docs/cli/workspace-layout.md | 22 + docs/cli/workspace-name.md | 22 + docs/cli/workspace-padding.md | 22 + docs/cli/workspace-rule.md | 25 + docs/cli/workspace-tiling.md | 22 + docs/cli/workspace-work-area-offset.md | 31 + schema.asc.json | 168 ++ schema.json | 1384 +++++++++++++++++ 133 files changed, 3618 insertions(+) create mode 100644 docs/cli/adjust-container-padding.md create mode 100644 docs/cli/adjust-workspace-padding.md create mode 100644 docs/cli/application-specific-configuration-schema.md create mode 100644 docs/cli/change-layout.md create mode 100644 docs/cli/clear-all-workspace-rules.md create mode 100644 docs/cli/clear-named-workspace-layout-rules.md create mode 100644 docs/cli/clear-named-workspace-rules.md create mode 100644 docs/cli/clear-session-float-rules.md create mode 100644 docs/cli/clear-workspace-layout-rules.md create mode 100644 docs/cli/clear-workspace-rules.md create mode 100644 docs/cli/close-workspace.md create mode 100644 docs/cli/close.md create mode 100644 docs/cli/configuration.md create mode 100644 docs/cli/container-padding.md create mode 100644 docs/cli/cross-monitor-move-behaviour.md create mode 100644 docs/cli/cycle-empty-workspace.md create mode 100644 docs/cli/cycle-focus.md create mode 100644 docs/cli/cycle-layout.md create mode 100644 docs/cli/cycle-monitor.md create mode 100644 docs/cli/cycle-move-to-monitor.md create mode 100644 docs/cli/cycle-move-to-workspace.md create mode 100644 docs/cli/cycle-move-workspace-to-monitor.md create mode 100644 docs/cli/cycle-move.md create mode 100644 docs/cli/cycle-send-to-monitor.md create mode 100644 docs/cli/cycle-send-to-workspace.md create mode 100644 docs/cli/cycle-stack-index.md create mode 100644 docs/cli/cycle-stack.md create mode 100644 docs/cli/cycle-workspace.md create mode 100644 docs/cli/data-directory.md create mode 100644 docs/cli/display-index-preference.md create mode 100644 docs/cli/eager-focus.md create mode 100644 docs/cli/enforce-workspace-rules.md create mode 100644 docs/cli/ensure-named-workspaces.md create mode 100644 docs/cli/ensure-workspaces.md create mode 100644 docs/cli/fetch-app-specific-configuration.md create mode 100644 docs/cli/flip-layout.md create mode 100644 docs/cli/focus-last-workspace.md create mode 100644 docs/cli/focus-monitor-at-cursor.md create mode 100644 docs/cli/focus-monitor-workspace.md create mode 100644 docs/cli/focus-monitor.md create mode 100644 docs/cli/focus-named-workspace.md create mode 100644 docs/cli/focus-stack-window.md create mode 100644 docs/cli/focus-workspace.md create mode 100644 docs/cli/focus-workspaces.md create mode 100644 docs/cli/focus.md create mode 100644 docs/cli/focused-workspace-container-padding.md create mode 100644 docs/cli/focused-workspace-padding.md create mode 100644 docs/cli/generate-static-config.md create mode 100644 docs/cli/global-state.md create mode 100644 docs/cli/global-work-area-offset.md create mode 100644 docs/cli/ignore-rule.md create mode 100644 docs/cli/initial-named-workspace-rule.md create mode 100644 docs/cli/initial-workspace-rule.md create mode 100644 docs/cli/load-resize.md create mode 100644 docs/cli/log.md create mode 100644 docs/cli/manage-rule.md create mode 100644 docs/cli/manage.md create mode 100644 docs/cli/minimize.md create mode 100644 docs/cli/monitor-information.md create mode 100644 docs/cli/monitor-work-area-offset.md create mode 100644 docs/cli/mouse-follows-focus.md create mode 100644 docs/cli/move-to-last-workspace.md create mode 100644 docs/cli/move-to-monitor-workspace.md create mode 100644 docs/cli/move-to-monitor.md create mode 100644 docs/cli/move-to-named-workspace.md create mode 100644 docs/cli/move-to-workspace.md create mode 100644 docs/cli/move-workspace-to-monitor.md create mode 100644 docs/cli/move.md create mode 100644 docs/cli/named-workspace-container-padding.md create mode 100644 docs/cli/named-workspace-layout-rule.md create mode 100644 docs/cli/named-workspace-layout.md create mode 100644 docs/cli/named-workspace-padding.md create mode 100644 docs/cli/named-workspace-rule.md create mode 100644 docs/cli/named-workspace-tiling.md create mode 100644 docs/cli/new-workspace.md create mode 100644 docs/cli/notification-schema.md create mode 100644 docs/cli/promote-focus.md create mode 100644 docs/cli/promote-window.md create mode 100644 docs/cli/promote.md create mode 100644 docs/cli/query.md create mode 100644 docs/cli/quick-load-resize.md create mode 100644 docs/cli/quick-save-resize.md create mode 100644 docs/cli/replace-configuration.md create mode 100644 docs/cli/resize-axis.md create mode 100644 docs/cli/resize-delta.md create mode 100644 docs/cli/resize-edge.md create mode 100644 docs/cli/retile.md create mode 100644 docs/cli/save-resize.md create mode 100644 docs/cli/scrolling-layout-columns.md create mode 100644 docs/cli/send-to-last-workspace.md create mode 100644 docs/cli/send-to-monitor-workspace.md create mode 100644 docs/cli/send-to-monitor.md create mode 100644 docs/cli/send-to-named-workspace.md create mode 100644 docs/cli/send-to-workspace.md create mode 100644 docs/cli/session-float-rule.md create mode 100644 docs/cli/session-float-rules.md create mode 100644 docs/cli/socket-schema.md create mode 100644 docs/cli/stack-all.md create mode 100644 docs/cli/stack.md create mode 100644 docs/cli/start.md create mode 100644 docs/cli/state.md create mode 100644 docs/cli/static-config-schema.md create mode 100644 docs/cli/stop.md create mode 100644 docs/cli/subscribe-socket.md create mode 100644 docs/cli/swap-workspaces-with-monitor.md create mode 100644 docs/cli/toggle-cross-monitor-move-behaviour.md create mode 100644 docs/cli/toggle-float-override.md create mode 100644 docs/cli/toggle-float.md create mode 100644 docs/cli/toggle-lock.md create mode 100644 docs/cli/toggle-monocle.md create mode 100644 docs/cli/toggle-mouse-follows-focus.md create mode 100644 docs/cli/toggle-pause.md create mode 100644 docs/cli/toggle-tiling.md create mode 100644 docs/cli/toggle-window-based-work-area-offset.md create mode 100644 docs/cli/toggle-window-container-behaviour.md create mode 100644 docs/cli/toggle-workspace-float-override.md create mode 100644 docs/cli/toggle-workspace-layer.md create mode 100644 docs/cli/toggle-workspace-window-container-behaviour.md create mode 100644 docs/cli/unmanage.md create mode 100644 docs/cli/unmanaged-window-operation-behaviour.md create mode 100644 docs/cli/unstack-all.md create mode 100644 docs/cli/unstack.md create mode 100644 docs/cli/unsubscribe-socket.md create mode 100644 docs/cli/visible-windows.md create mode 100644 docs/cli/workspace-layout-rule.md create mode 100644 docs/cli/workspace-layout.md create mode 100644 docs/cli/workspace-name.md create mode 100644 docs/cli/workspace-padding.md create mode 100644 docs/cli/workspace-rule.md create mode 100644 docs/cli/workspace-tiling.md create mode 100644 docs/cli/workspace-work-area-offset.md create mode 100644 schema.asc.json create mode 100644 schema.json diff --git a/docs/cli/adjust-container-padding.md b/docs/cli/adjust-container-padding.md new file mode 100644 index 00000000..f96f1929 --- /dev/null +++ b/docs/cli/adjust-container-padding.md @@ -0,0 +1,19 @@ +# adjust-container-padding + +``` +Adjust container padding on the focused workspace + +Usage: komorebic adjust-container-padding + +Arguments: + + [possible values: increase, decrease] + + + Pixels to adjust by as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/adjust-workspace-padding.md b/docs/cli/adjust-workspace-padding.md new file mode 100644 index 00000000..5045aa95 --- /dev/null +++ b/docs/cli/adjust-workspace-padding.md @@ -0,0 +1,19 @@ +# adjust-workspace-padding + +``` +Adjust workspace padding on the focused workspace + +Usage: komorebic adjust-workspace-padding + +Arguments: + + [possible values: increase, decrease] + + + Pixels to adjust by as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/application-specific-configuration-schema.md b/docs/cli/application-specific-configuration-schema.md new file mode 100644 index 00000000..642b6bb8 --- /dev/null +++ b/docs/cli/application-specific-configuration-schema.md @@ -0,0 +1,12 @@ +# application-specific-configuration-schema + +``` +Generate a JSON Schema for applications.json + +Usage: komorebic application-specific-configuration-schema + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/change-layout.md b/docs/cli/change-layout.md new file mode 100644 index 00000000..5124942b --- /dev/null +++ b/docs/cli/change-layout.md @@ -0,0 +1,16 @@ +# change-layout + +``` +Set the layout on the focused workspace + +Usage: komorebic change-layout + +Arguments: + + [possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/clear-all-workspace-rules.md b/docs/cli/clear-all-workspace-rules.md new file mode 100644 index 00000000..630b1b32 --- /dev/null +++ b/docs/cli/clear-all-workspace-rules.md @@ -0,0 +1,12 @@ +# clear-all-workspace-rules + +``` +Remove all application association rules for all workspaces + +Usage: komorebic clear-all-workspace-rules + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/clear-named-workspace-layout-rules.md b/docs/cli/clear-named-workspace-layout-rules.md new file mode 100644 index 00000000..9c515266 --- /dev/null +++ b/docs/cli/clear-named-workspace-layout-rules.md @@ -0,0 +1,16 @@ +# clear-named-workspace-layout-rules + +``` +Clear all dynamic layout rules for the specified workspace + +Usage: komorebic clear-named-workspace-layout-rules + +Arguments: + + Target workspace name + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/clear-named-workspace-rules.md b/docs/cli/clear-named-workspace-rules.md new file mode 100644 index 00000000..4e60cdef --- /dev/null +++ b/docs/cli/clear-named-workspace-rules.md @@ -0,0 +1,16 @@ +# clear-named-workspace-rules + +``` +Remove all application association rules for a named workspace + +Usage: komorebic clear-named-workspace-rules + +Arguments: + + Name of a workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/clear-session-float-rules.md b/docs/cli/clear-session-float-rules.md new file mode 100644 index 00000000..99d6b036 --- /dev/null +++ b/docs/cli/clear-session-float-rules.md @@ -0,0 +1,12 @@ +# clear-session-float-rules + +``` +Clear all session float rules + +Usage: komorebic clear-session-float-rules + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/clear-workspace-layout-rules.md b/docs/cli/clear-workspace-layout-rules.md new file mode 100644 index 00000000..f3256d45 --- /dev/null +++ b/docs/cli/clear-workspace-layout-rules.md @@ -0,0 +1,19 @@ +# clear-workspace-layout-rules + +``` +Clear all dynamic layout rules for the specified workspace + +Usage: komorebic clear-workspace-layout-rules + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/clear-workspace-rules.md b/docs/cli/clear-workspace-rules.md new file mode 100644 index 00000000..7be02e78 --- /dev/null +++ b/docs/cli/clear-workspace-rules.md @@ -0,0 +1,19 @@ +# clear-workspace-rules + +``` +Remove all application association rules for a workspace by monitor and workspace index + +Usage: komorebic clear-workspace-rules + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/close-workspace.md b/docs/cli/close-workspace.md new file mode 100644 index 00000000..860171f9 --- /dev/null +++ b/docs/cli/close-workspace.md @@ -0,0 +1,12 @@ +# close-workspace + +``` +Close the focused workspace (must be empty and unnamed) + +Usage: komorebic close-workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/close.md b/docs/cli/close.md new file mode 100644 index 00000000..8577f0b9 --- /dev/null +++ b/docs/cli/close.md @@ -0,0 +1,12 @@ +# close + +``` +Close the focused window + +Usage: komorebic close + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/configuration.md b/docs/cli/configuration.md new file mode 100644 index 00000000..d7d1b3b0 --- /dev/null +++ b/docs/cli/configuration.md @@ -0,0 +1,12 @@ +# configuration + +``` +Show the path to komorebi.json + +Usage: komorebic configuration + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/container-padding.md b/docs/cli/container-padding.md new file mode 100644 index 00000000..2096bb43 --- /dev/null +++ b/docs/cli/container-padding.md @@ -0,0 +1,22 @@ +# container-padding + +``` +Set the container padding for the specified workspace + +Usage: komorebic container-padding + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + + + Pixels to pad with as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cross-monitor-move-behaviour.md b/docs/cli/cross-monitor-move-behaviour.md new file mode 100644 index 00000000..719ad4ee --- /dev/null +++ b/docs/cli/cross-monitor-move-behaviour.md @@ -0,0 +1,19 @@ +# cross-monitor-move-behaviour + +``` +Set the behaviour when moving windows across monitor boundaries + +Usage: komorebic cross-monitor-move-behaviour + +Arguments: + + Possible values: + - swap: Swap the window container with the window container at the edge of the adjacent monitor + - insert: Insert the window container into the focused workspace on the adjacent monitor + - no-op: Do nothing if trying to move a window container in the direction of an adjacent monitor + +Options: + -h, --help + Print help (see a summary with '-h') + +``` \ No newline at end of file diff --git a/docs/cli/cycle-empty-workspace.md b/docs/cli/cycle-empty-workspace.md new file mode 100644 index 00000000..029f07d9 --- /dev/null +++ b/docs/cli/cycle-empty-workspace.md @@ -0,0 +1,16 @@ +# cycle-empty-workspace + +``` +Focus the next empty workspace in the given cycle direction (if one exists) + +Usage: komorebic cycle-empty-workspace + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-focus.md b/docs/cli/cycle-focus.md new file mode 100644 index 00000000..c39f188d --- /dev/null +++ b/docs/cli/cycle-focus.md @@ -0,0 +1,16 @@ +# cycle-focus + +``` +Change focus to the window in the specified cycle direction + +Usage: komorebic cycle-focus + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-layout.md b/docs/cli/cycle-layout.md new file mode 100644 index 00000000..e41330ea --- /dev/null +++ b/docs/cli/cycle-layout.md @@ -0,0 +1,16 @@ +# cycle-layout + +``` +Cycle between available layouts + +Usage: komorebic cycle-layout + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-monitor.md b/docs/cli/cycle-monitor.md new file mode 100644 index 00000000..1c080ee0 --- /dev/null +++ b/docs/cli/cycle-monitor.md @@ -0,0 +1,16 @@ +# cycle-monitor + +``` +Focus the monitor in the given cycle direction + +Usage: komorebic cycle-monitor + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-move-to-monitor.md b/docs/cli/cycle-move-to-monitor.md new file mode 100644 index 00000000..c77da7d0 --- /dev/null +++ b/docs/cli/cycle-move-to-monitor.md @@ -0,0 +1,16 @@ +# cycle-move-to-monitor + +``` +Move the focused window to the monitor in the given cycle direction + +Usage: komorebic cycle-move-to-monitor + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-move-to-workspace.md b/docs/cli/cycle-move-to-workspace.md new file mode 100644 index 00000000..80fcc85c --- /dev/null +++ b/docs/cli/cycle-move-to-workspace.md @@ -0,0 +1,16 @@ +# cycle-move-to-workspace + +``` +Move the focused window to the workspace in the given cycle direction + +Usage: komorebic cycle-move-to-workspace + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-move-workspace-to-monitor.md b/docs/cli/cycle-move-workspace-to-monitor.md new file mode 100644 index 00000000..c3ceec2d --- /dev/null +++ b/docs/cli/cycle-move-workspace-to-monitor.md @@ -0,0 +1,16 @@ +# cycle-move-workspace-to-monitor + +``` +Move the focused workspace monitor in the given cycle direction + +Usage: komorebic cycle-move-workspace-to-monitor + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-move.md b/docs/cli/cycle-move.md new file mode 100644 index 00000000..a35abbad --- /dev/null +++ b/docs/cli/cycle-move.md @@ -0,0 +1,16 @@ +# cycle-move + +``` +Move the focused window in the specified cycle direction + +Usage: komorebic cycle-move + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-send-to-monitor.md b/docs/cli/cycle-send-to-monitor.md new file mode 100644 index 00000000..230ea770 --- /dev/null +++ b/docs/cli/cycle-send-to-monitor.md @@ -0,0 +1,16 @@ +# cycle-send-to-monitor + +``` +Send the focused window to the monitor in the given cycle direction + +Usage: komorebic cycle-send-to-monitor + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-send-to-workspace.md b/docs/cli/cycle-send-to-workspace.md new file mode 100644 index 00000000..9226db68 --- /dev/null +++ b/docs/cli/cycle-send-to-workspace.md @@ -0,0 +1,16 @@ +# cycle-send-to-workspace + +``` +Send the focused window to the workspace in the given cycle direction + +Usage: komorebic cycle-send-to-workspace + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-stack-index.md b/docs/cli/cycle-stack-index.md new file mode 100644 index 00000000..0f16a20a --- /dev/null +++ b/docs/cli/cycle-stack-index.md @@ -0,0 +1,16 @@ +# cycle-stack-index + +``` +Cycle the index of the focused window in the focused stack in the specified cycle direction + +Usage: komorebic cycle-stack-index + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-stack.md b/docs/cli/cycle-stack.md new file mode 100644 index 00000000..d3e40e08 --- /dev/null +++ b/docs/cli/cycle-stack.md @@ -0,0 +1,16 @@ +# cycle-stack + +``` +Cycle the focused stack in the specified cycle direction + +Usage: komorebic cycle-stack + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/cycle-workspace.md b/docs/cli/cycle-workspace.md new file mode 100644 index 00000000..be617167 --- /dev/null +++ b/docs/cli/cycle-workspace.md @@ -0,0 +1,16 @@ +# cycle-workspace + +``` +Focus the workspace in the given cycle direction + +Usage: komorebic cycle-workspace + +Arguments: + + [possible values: previous, next] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/data-directory.md b/docs/cli/data-directory.md new file mode 100644 index 00000000..fc9d9336 --- /dev/null +++ b/docs/cli/data-directory.md @@ -0,0 +1,12 @@ +# data-directory + +``` +Show the path to komorebi's data directory in %LOCALAPPDATA% + +Usage: komorebic data-directory + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/display-index-preference.md b/docs/cli/display-index-preference.md new file mode 100644 index 00000000..3acdfc41 --- /dev/null +++ b/docs/cli/display-index-preference.md @@ -0,0 +1,19 @@ +# display-index-preference + +``` +Set the display index preference for a monitor identified using its display name + +Usage: komorebic display-index-preference + +Arguments: + + Preferred monitor index (zero-indexed) + + + Display name as identified in komorebic state + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/eager-focus.md b/docs/cli/eager-focus.md new file mode 100644 index 00000000..271a0ac5 --- /dev/null +++ b/docs/cli/eager-focus.md @@ -0,0 +1,16 @@ +# eager-focus + +``` +Focus the first managed window matching the given exe + +Usage: komorebic eager-focus + +Arguments: + + Case-sensitive exe identifier + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/enforce-workspace-rules.md b/docs/cli/enforce-workspace-rules.md new file mode 100644 index 00000000..546aa1a7 --- /dev/null +++ b/docs/cli/enforce-workspace-rules.md @@ -0,0 +1,12 @@ +# enforce-workspace-rules + +``` +Enforce all workspace rules, including initial workspace rules that have already been applied + +Usage: komorebic enforce-workspace-rules + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/ensure-named-workspaces.md b/docs/cli/ensure-named-workspaces.md new file mode 100644 index 00000000..68663c31 --- /dev/null +++ b/docs/cli/ensure-named-workspaces.md @@ -0,0 +1,19 @@ +# ensure-named-workspaces + +``` +Create these many named workspaces for the specified monitor + +Usage: komorebic ensure-named-workspaces [NAMES]... + +Arguments: + + Monitor index (zero-indexed) + + [NAMES]... + Names of desired workspaces + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/ensure-workspaces.md b/docs/cli/ensure-workspaces.md new file mode 100644 index 00000000..12ea285b --- /dev/null +++ b/docs/cli/ensure-workspaces.md @@ -0,0 +1,19 @@ +# ensure-workspaces + +``` +Create at least this many workspaces for the specified monitor + +Usage: komorebic ensure-workspaces + +Arguments: + + Monitor index (zero-indexed) + + + Number of desired workspaces + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/fetch-app-specific-configuration.md b/docs/cli/fetch-app-specific-configuration.md new file mode 100644 index 00000000..e8f49f41 --- /dev/null +++ b/docs/cli/fetch-app-specific-configuration.md @@ -0,0 +1,12 @@ +# fetch-app-specific-configuration + +``` +Fetch the latest version of applications.json from komorebi-application-specific-configuration + +Usage: komorebic fetch-app-specific-configuration + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/flip-layout.md b/docs/cli/flip-layout.md new file mode 100644 index 00000000..463e2648 --- /dev/null +++ b/docs/cli/flip-layout.md @@ -0,0 +1,16 @@ +# flip-layout + +``` +Flip the layout on the focused workspace + +Usage: komorebic flip-layout + +Arguments: + + [possible values: horizontal, vertical, horizontal-and-vertical] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-last-workspace.md b/docs/cli/focus-last-workspace.md new file mode 100644 index 00000000..8af3ee2c --- /dev/null +++ b/docs/cli/focus-last-workspace.md @@ -0,0 +1,12 @@ +# focus-last-workspace + +``` +Focus the last focused workspace on the focused monitor + +Usage: komorebic focus-last-workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-monitor-at-cursor.md b/docs/cli/focus-monitor-at-cursor.md new file mode 100644 index 00000000..5320c7f6 --- /dev/null +++ b/docs/cli/focus-monitor-at-cursor.md @@ -0,0 +1,12 @@ +# focus-monitor-at-cursor + +``` +Focus the monitor at the current cursor location + +Usage: komorebic focus-monitor-at-cursor + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-monitor-workspace.md b/docs/cli/focus-monitor-workspace.md new file mode 100644 index 00000000..648eb855 --- /dev/null +++ b/docs/cli/focus-monitor-workspace.md @@ -0,0 +1,19 @@ +# focus-monitor-workspace + +``` +Focus the specified workspace on the target monitor + +Usage: komorebic focus-monitor-workspace + +Arguments: + + Target monitor index (zero-indexed) + + + Workspace index on the target monitor (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-monitor.md b/docs/cli/focus-monitor.md new file mode 100644 index 00000000..f97ff091 --- /dev/null +++ b/docs/cli/focus-monitor.md @@ -0,0 +1,16 @@ +# focus-monitor + +``` +Focus the specified monitor + +Usage: komorebic focus-monitor + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-named-workspace.md b/docs/cli/focus-named-workspace.md new file mode 100644 index 00000000..431a8191 --- /dev/null +++ b/docs/cli/focus-named-workspace.md @@ -0,0 +1,16 @@ +# focus-named-workspace + +``` +Focus the specified workspace + +Usage: komorebic focus-named-workspace + +Arguments: + + Target workspace name + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-stack-window.md b/docs/cli/focus-stack-window.md new file mode 100644 index 00000000..1cb84a37 --- /dev/null +++ b/docs/cli/focus-stack-window.md @@ -0,0 +1,16 @@ +# focus-stack-window + +``` +Focus the specified window index in the focused stack + +Usage: komorebic focus-stack-window + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-workspace.md b/docs/cli/focus-workspace.md new file mode 100644 index 00000000..6ad82870 --- /dev/null +++ b/docs/cli/focus-workspace.md @@ -0,0 +1,16 @@ +# focus-workspace + +``` +Focus the specified workspace on the focused monitor + +Usage: komorebic focus-workspace + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus-workspaces.md b/docs/cli/focus-workspaces.md new file mode 100644 index 00000000..e7efee3f --- /dev/null +++ b/docs/cli/focus-workspaces.md @@ -0,0 +1,16 @@ +# focus-workspaces + +``` +Focus the specified workspace on all monitors + +Usage: komorebic focus-workspaces + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focus.md b/docs/cli/focus.md new file mode 100644 index 00000000..1a33b5a0 --- /dev/null +++ b/docs/cli/focus.md @@ -0,0 +1,16 @@ +# focus + +``` +Change focus to the window in the specified direction + +Usage: komorebic focus + +Arguments: + + [possible values: left, right, up, down] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focused-workspace-container-padding.md b/docs/cli/focused-workspace-container-padding.md new file mode 100644 index 00000000..88855c4d --- /dev/null +++ b/docs/cli/focused-workspace-container-padding.md @@ -0,0 +1,16 @@ +# focused-workspace-container-padding + +``` +Set container padding on the focused workspace + +Usage: komorebic focused-workspace-container-padding + +Arguments: + + Pixels size to set as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/focused-workspace-padding.md b/docs/cli/focused-workspace-padding.md new file mode 100644 index 00000000..1ea8bf16 --- /dev/null +++ b/docs/cli/focused-workspace-padding.md @@ -0,0 +1,16 @@ +# focused-workspace-padding + +``` +Set workspace padding on the focused workspace + +Usage: komorebic focused-workspace-padding + +Arguments: + + Pixels size to set as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/generate-static-config.md b/docs/cli/generate-static-config.md new file mode 100644 index 00000000..b4b906ea --- /dev/null +++ b/docs/cli/generate-static-config.md @@ -0,0 +1,12 @@ +# generate-static-config + +``` +Generates a static configuration JSON file based on the current window manager state + +Usage: komorebic generate-static-config + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/global-state.md b/docs/cli/global-state.md new file mode 100644 index 00000000..0ee6ef95 --- /dev/null +++ b/docs/cli/global-state.md @@ -0,0 +1,12 @@ +# global-state + +``` +Show a JSON representation of the current global state + +Usage: komorebic global-state + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/global-work-area-offset.md b/docs/cli/global-work-area-offset.md new file mode 100644 index 00000000..e7ae7153 --- /dev/null +++ b/docs/cli/global-work-area-offset.md @@ -0,0 +1,25 @@ +# global-work-area-offset + +``` +Set offsets to exclude parts of the work area from tiling + +Usage: komorebic global-work-area-offset + +Arguments: + + Size of the left work area offset (set right to left * 2 to maintain right padding) + + + Size of the top work area offset (set bottom to the same value to maintain bottom padding) + + + Size of the right work area offset + + + Size of the bottom work area offset + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/ignore-rule.md b/docs/cli/ignore-rule.md new file mode 100644 index 00000000..55ff1047 --- /dev/null +++ b/docs/cli/ignore-rule.md @@ -0,0 +1,19 @@ +# ignore-rule + +``` +Add a rule to ignore the specified application + +Usage: komorebic ignore-rule + +Arguments: + + [possible values: exe, class, title, path] + + + Identifier as a string + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/initial-named-workspace-rule.md b/docs/cli/initial-named-workspace-rule.md new file mode 100644 index 00000000..430cb561 --- /dev/null +++ b/docs/cli/initial-named-workspace-rule.md @@ -0,0 +1,22 @@ +# initial-named-workspace-rule + +``` +Add a rule to associate an application with a named workspace on first show + +Usage: komorebic initial-named-workspace-rule + +Arguments: + + [possible values: exe, class, title, path] + + + Identifier as a string + + + Name of a workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/initial-workspace-rule.md b/docs/cli/initial-workspace-rule.md new file mode 100644 index 00000000..9e588517 --- /dev/null +++ b/docs/cli/initial-workspace-rule.md @@ -0,0 +1,25 @@ +# initial-workspace-rule + +``` +Add a rule to associate an application with a workspace on first show + +Usage: komorebic initial-workspace-rule + +Arguments: + + [possible values: exe, class, title, path] + + + Identifier as a string + + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/load-resize.md b/docs/cli/load-resize.md new file mode 100644 index 00000000..c133a805 --- /dev/null +++ b/docs/cli/load-resize.md @@ -0,0 +1,16 @@ +# load-resize + +``` +Load the resize layout dimensions from a file + +Usage: komorebic load-resize + +Arguments: + + File from which the resize layout dimensions should be loaded + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/log.md b/docs/cli/log.md new file mode 100644 index 00000000..522aa763 --- /dev/null +++ b/docs/cli/log.md @@ -0,0 +1,12 @@ +# log + +``` +Tail komorebi.exe's process logs (cancel with Ctrl-C) + +Usage: komorebic log + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/manage-rule.md b/docs/cli/manage-rule.md new file mode 100644 index 00000000..11fe3dfa --- /dev/null +++ b/docs/cli/manage-rule.md @@ -0,0 +1,19 @@ +# manage-rule + +``` +Add a rule to always manage the specified application + +Usage: komorebic manage-rule + +Arguments: + + [possible values: exe, class, title, path] + + + Identifier as a string + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/manage.md b/docs/cli/manage.md new file mode 100644 index 00000000..8da10472 --- /dev/null +++ b/docs/cli/manage.md @@ -0,0 +1,12 @@ +# manage + +``` +Force komorebi to manage the focused window + +Usage: komorebic manage + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/minimize.md b/docs/cli/minimize.md new file mode 100644 index 00000000..c814942d --- /dev/null +++ b/docs/cli/minimize.md @@ -0,0 +1,12 @@ +# minimize + +``` +Minimize the focused window + +Usage: komorebic minimize + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/monitor-information.md b/docs/cli/monitor-information.md new file mode 100644 index 00000000..a6b14e70 --- /dev/null +++ b/docs/cli/monitor-information.md @@ -0,0 +1,12 @@ +# monitor-information + +``` +Show information about connected monitors + +Usage: komorebic monitor-information + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/monitor-work-area-offset.md b/docs/cli/monitor-work-area-offset.md new file mode 100644 index 00000000..2a42bff2 --- /dev/null +++ b/docs/cli/monitor-work-area-offset.md @@ -0,0 +1,28 @@ +# monitor-work-area-offset + +``` +Set offsets for a monitor to exclude parts of the work area from tiling + +Usage: komorebic monitor-work-area-offset + +Arguments: + + Monitor index (zero-indexed) + + + Size of the left work area offset (set right to left * 2 to maintain right padding) + + + Size of the top work area offset (set bottom to the same value to maintain bottom padding) + + + Size of the right work area offset + + + Size of the bottom work area offset + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/mouse-follows-focus.md b/docs/cli/mouse-follows-focus.md new file mode 100644 index 00000000..9a38b687 --- /dev/null +++ b/docs/cli/mouse-follows-focus.md @@ -0,0 +1,16 @@ +# mouse-follows-focus + +``` +Enable or disable mouse follows focus on all workspaces + +Usage: komorebic mouse-follows-focus + +Arguments: + + [possible values: enable, disable] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/move-to-last-workspace.md b/docs/cli/move-to-last-workspace.md new file mode 100644 index 00000000..16a08c4c --- /dev/null +++ b/docs/cli/move-to-last-workspace.md @@ -0,0 +1,12 @@ +# move-to-last-workspace + +``` +Move the focused window to the last focused monitor workspace + +Usage: komorebic move-to-last-workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/move-to-monitor-workspace.md b/docs/cli/move-to-monitor-workspace.md new file mode 100644 index 00000000..09217a9a --- /dev/null +++ b/docs/cli/move-to-monitor-workspace.md @@ -0,0 +1,19 @@ +# move-to-monitor-workspace + +``` +Move the focused window to the specified monitor workspace + +Usage: komorebic move-to-monitor-workspace + +Arguments: + + Target monitor index (zero-indexed) + + + Workspace index on the target monitor (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/move-to-monitor.md b/docs/cli/move-to-monitor.md new file mode 100644 index 00000000..1febf73f --- /dev/null +++ b/docs/cli/move-to-monitor.md @@ -0,0 +1,16 @@ +# move-to-monitor + +``` +Move the focused window to the specified monitor + +Usage: komorebic move-to-monitor + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/move-to-named-workspace.md b/docs/cli/move-to-named-workspace.md new file mode 100644 index 00000000..f97635c5 --- /dev/null +++ b/docs/cli/move-to-named-workspace.md @@ -0,0 +1,16 @@ +# move-to-named-workspace + +``` +Move the focused window to the specified workspace + +Usage: komorebic move-to-named-workspace + +Arguments: + + Target workspace name + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/move-to-workspace.md b/docs/cli/move-to-workspace.md new file mode 100644 index 00000000..12ee6670 --- /dev/null +++ b/docs/cli/move-to-workspace.md @@ -0,0 +1,16 @@ +# move-to-workspace + +``` +Move the focused window to the specified workspace + +Usage: komorebic move-to-workspace + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/move-workspace-to-monitor.md b/docs/cli/move-workspace-to-monitor.md new file mode 100644 index 00000000..69a02874 --- /dev/null +++ b/docs/cli/move-workspace-to-monitor.md @@ -0,0 +1,16 @@ +# move-workspace-to-monitor + +``` +Move the focused workspace to the specified monitor + +Usage: komorebic move-workspace-to-monitor + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/move.md b/docs/cli/move.md new file mode 100644 index 00000000..913701bc --- /dev/null +++ b/docs/cli/move.md @@ -0,0 +1,16 @@ +# move + +``` +Move the focused window in the specified direction + +Usage: komorebic move + +Arguments: + + [possible values: left, right, up, down] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/named-workspace-container-padding.md b/docs/cli/named-workspace-container-padding.md new file mode 100644 index 00000000..8432c8a8 --- /dev/null +++ b/docs/cli/named-workspace-container-padding.md @@ -0,0 +1,19 @@ +# named-workspace-container-padding + +``` +Set the container padding for the specified workspace + +Usage: komorebic named-workspace-container-padding + +Arguments: + + Target workspace name + + + Pixels to pad with as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/named-workspace-layout-rule.md b/docs/cli/named-workspace-layout-rule.md new file mode 100644 index 00000000..4e37e06a --- /dev/null +++ b/docs/cli/named-workspace-layout-rule.md @@ -0,0 +1,22 @@ +# named-workspace-layout-rule + +``` +Add a dynamic layout rule for the specified workspace + +Usage: komorebic named-workspace-layout-rule + +Arguments: + + Target workspace name + + + The number of window containers on-screen required to trigger this layout rule + + + [possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/named-workspace-layout.md b/docs/cli/named-workspace-layout.md new file mode 100644 index 00000000..15095e7e --- /dev/null +++ b/docs/cli/named-workspace-layout.md @@ -0,0 +1,19 @@ +# named-workspace-layout + +``` +Set the layout for the specified workspace + +Usage: komorebic named-workspace-layout + +Arguments: + + Target workspace name + + + [possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/named-workspace-padding.md b/docs/cli/named-workspace-padding.md new file mode 100644 index 00000000..35182bc4 --- /dev/null +++ b/docs/cli/named-workspace-padding.md @@ -0,0 +1,19 @@ +# named-workspace-padding + +``` +Set the workspace padding for the specified workspace + +Usage: komorebic named-workspace-padding + +Arguments: + + Target workspace name + + + Pixels to pad with as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/named-workspace-rule.md b/docs/cli/named-workspace-rule.md new file mode 100644 index 00000000..72e11eea --- /dev/null +++ b/docs/cli/named-workspace-rule.md @@ -0,0 +1,22 @@ +# named-workspace-rule + +``` +Add a rule to associate an application with a named workspace + +Usage: komorebic named-workspace-rule + +Arguments: + + [possible values: exe, class, title, path] + + + Identifier as a string + + + Name of a workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/named-workspace-tiling.md b/docs/cli/named-workspace-tiling.md new file mode 100644 index 00000000..9dfb2b4a --- /dev/null +++ b/docs/cli/named-workspace-tiling.md @@ -0,0 +1,19 @@ +# named-workspace-tiling + +``` +Enable or disable window tiling for the specified workspace + +Usage: komorebic named-workspace-tiling + +Arguments: + + Target workspace name + + + [possible values: enable, disable] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/new-workspace.md b/docs/cli/new-workspace.md new file mode 100644 index 00000000..166dfa8b --- /dev/null +++ b/docs/cli/new-workspace.md @@ -0,0 +1,12 @@ +# new-workspace + +``` +Create and append a new workspace on the focused monitor + +Usage: komorebic new-workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/notification-schema.md b/docs/cli/notification-schema.md new file mode 100644 index 00000000..ea480035 --- /dev/null +++ b/docs/cli/notification-schema.md @@ -0,0 +1,12 @@ +# notification-schema + +``` +Generate a JSON Schema of subscription notifications + +Usage: komorebic notification-schema + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/promote-focus.md b/docs/cli/promote-focus.md new file mode 100644 index 00000000..dcbd198d --- /dev/null +++ b/docs/cli/promote-focus.md @@ -0,0 +1,12 @@ +# promote-focus + +``` +Promote the user focus to the top of the tree + +Usage: komorebic promote-focus + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/promote-window.md b/docs/cli/promote-window.md new file mode 100644 index 00000000..e59e293b --- /dev/null +++ b/docs/cli/promote-window.md @@ -0,0 +1,16 @@ +# promote-window + +``` +Promote the window in the specified direction + +Usage: komorebic promote-window + +Arguments: + + [possible values: left, right, up, down] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/promote.md b/docs/cli/promote.md new file mode 100644 index 00000000..ddf40bde --- /dev/null +++ b/docs/cli/promote.md @@ -0,0 +1,12 @@ +# promote + +``` +Promote the focused window to the top of the tree + +Usage: komorebic promote + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/query.md b/docs/cli/query.md new file mode 100644 index 00000000..5b8b4bb8 --- /dev/null +++ b/docs/cli/query.md @@ -0,0 +1,16 @@ +# query + +``` +Query the current window manager state + +Usage: komorebic query + +Arguments: + + [possible values: focused-monitor-index, focused-workspace-index, focused-container-index, focused-window-index, focused-workspace-name, focused-workspace-layout, focused-container-kind, version] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/quick-load-resize.md b/docs/cli/quick-load-resize.md new file mode 100644 index 00000000..11ead3af --- /dev/null +++ b/docs/cli/quick-load-resize.md @@ -0,0 +1,12 @@ +# quick-load-resize + +``` +Load the last quicksaved resize layout dimensions + +Usage: komorebic quick-load-resize + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/quick-save-resize.md b/docs/cli/quick-save-resize.md new file mode 100644 index 00000000..d9ba4d7c --- /dev/null +++ b/docs/cli/quick-save-resize.md @@ -0,0 +1,12 @@ +# quick-save-resize + +``` +Quicksave the current resize layout dimensions + +Usage: komorebic quick-save-resize + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/replace-configuration.md b/docs/cli/replace-configuration.md new file mode 100644 index 00000000..4ebad87d --- /dev/null +++ b/docs/cli/replace-configuration.md @@ -0,0 +1,16 @@ +# replace-configuration + +``` +Replace the configuration of a running instance of komorebi from a static configuration file + +Usage: komorebic replace-configuration + +Arguments: + + Static configuration JSON file from which the configuration should be loaded + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/resize-axis.md b/docs/cli/resize-axis.md new file mode 100644 index 00000000..a3757729 --- /dev/null +++ b/docs/cli/resize-axis.md @@ -0,0 +1,19 @@ +# resize-axis + +``` +Resize the focused window or primary column along the specified axis + +Usage: komorebic resize-axis + +Arguments: + + [possible values: horizontal, vertical, horizontal-and-vertical] + + + [possible values: increase, decrease] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/resize-delta.md b/docs/cli/resize-delta.md new file mode 100644 index 00000000..cb91eb48 --- /dev/null +++ b/docs/cli/resize-delta.md @@ -0,0 +1,16 @@ +# resize-delta + +``` +Set the resize delta (used by resize-edge and resize-axis) + +Usage: komorebic resize-delta + +Arguments: + + The delta of pixels by which to increase or decrease window dimensions when resizing + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/resize-edge.md b/docs/cli/resize-edge.md new file mode 100644 index 00000000..4819d819 --- /dev/null +++ b/docs/cli/resize-edge.md @@ -0,0 +1,19 @@ +# resize-edge + +``` +Resize the focused window in the specified direction + +Usage: komorebic resize-edge + +Arguments: + + [possible values: left, right, up, down] + + + [possible values: increase, decrease] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/retile.md b/docs/cli/retile.md new file mode 100644 index 00000000..2336b013 --- /dev/null +++ b/docs/cli/retile.md @@ -0,0 +1,12 @@ +# retile + +``` +Force the retiling of all managed windows + +Usage: komorebic retile + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/save-resize.md b/docs/cli/save-resize.md new file mode 100644 index 00000000..8eb1918c --- /dev/null +++ b/docs/cli/save-resize.md @@ -0,0 +1,16 @@ +# save-resize + +``` +Save the current resize layout dimensions to a file + +Usage: komorebic save-resize + +Arguments: + + File to which the resize layout dimensions should be saved + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/scrolling-layout-columns.md b/docs/cli/scrolling-layout-columns.md new file mode 100644 index 00000000..d417c279 --- /dev/null +++ b/docs/cli/scrolling-layout-columns.md @@ -0,0 +1,16 @@ +# scrolling-layout-columns + +``` +Set the number of visible columns for the Scrolling layout on the focused workspace + +Usage: komorebic scrolling-layout-columns + +Arguments: + + Desired number of visible columns + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/send-to-last-workspace.md b/docs/cli/send-to-last-workspace.md new file mode 100644 index 00000000..65c43c62 --- /dev/null +++ b/docs/cli/send-to-last-workspace.md @@ -0,0 +1,12 @@ +# send-to-last-workspace + +``` +Send the focused window to the last focused monitor workspace + +Usage: komorebic send-to-last-workspace + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/send-to-monitor-workspace.md b/docs/cli/send-to-monitor-workspace.md new file mode 100644 index 00000000..6cd22746 --- /dev/null +++ b/docs/cli/send-to-monitor-workspace.md @@ -0,0 +1,19 @@ +# send-to-monitor-workspace + +``` +Send the focused window to the specified monitor workspace + +Usage: komorebic send-to-monitor-workspace + +Arguments: + + Target monitor index (zero-indexed) + + + Workspace index on the target monitor (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/send-to-monitor.md b/docs/cli/send-to-monitor.md new file mode 100644 index 00000000..adb6ab90 --- /dev/null +++ b/docs/cli/send-to-monitor.md @@ -0,0 +1,16 @@ +# send-to-monitor + +``` +Send the focused window to the specified monitor + +Usage: komorebic send-to-monitor + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/send-to-named-workspace.md b/docs/cli/send-to-named-workspace.md new file mode 100644 index 00000000..b824ff52 --- /dev/null +++ b/docs/cli/send-to-named-workspace.md @@ -0,0 +1,16 @@ +# send-to-named-workspace + +``` +Send the focused window to the specified workspace + +Usage: komorebic send-to-named-workspace + +Arguments: + + Target workspace name + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/send-to-workspace.md b/docs/cli/send-to-workspace.md new file mode 100644 index 00000000..3d69d1d7 --- /dev/null +++ b/docs/cli/send-to-workspace.md @@ -0,0 +1,16 @@ +# send-to-workspace + +``` +Send the focused window to the specified workspace + +Usage: komorebic send-to-workspace + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/session-float-rule.md b/docs/cli/session-float-rule.md new file mode 100644 index 00000000..5161f45e --- /dev/null +++ b/docs/cli/session-float-rule.md @@ -0,0 +1,12 @@ +# session-float-rule + +``` +Add a rule to float the foreground window for the rest of this session + +Usage: komorebic session-float-rule + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/session-float-rules.md b/docs/cli/session-float-rules.md new file mode 100644 index 00000000..65f8251f --- /dev/null +++ b/docs/cli/session-float-rules.md @@ -0,0 +1,12 @@ +# session-float-rules + +``` +Show all session float rules + +Usage: komorebic session-float-rules + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/socket-schema.md b/docs/cli/socket-schema.md new file mode 100644 index 00000000..5712e391 --- /dev/null +++ b/docs/cli/socket-schema.md @@ -0,0 +1,12 @@ +# socket-schema + +``` +Generate a JSON Schema of socket messages + +Usage: komorebic socket-schema + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/stack-all.md b/docs/cli/stack-all.md new file mode 100644 index 00000000..adfb58ef --- /dev/null +++ b/docs/cli/stack-all.md @@ -0,0 +1,12 @@ +# stack-all + +``` +Stack all windows on the focused workspace + +Usage: komorebic stack-all + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/stack.md b/docs/cli/stack.md new file mode 100644 index 00000000..b1fc6626 --- /dev/null +++ b/docs/cli/stack.md @@ -0,0 +1,16 @@ +# stack + +``` +Stack the focused window in the specified direction + +Usage: komorebic stack + +Arguments: + + [possible values: left, right, up, down] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/start.md b/docs/cli/start.md new file mode 100644 index 00000000..28714e45 --- /dev/null +++ b/docs/cli/start.md @@ -0,0 +1,15 @@ +# start + +``` +Start komorebi.exe as a background process + +Usage: komorebic start [OPTIONS] + +Options: + -c, --config + Path to a static configuration JSON file + + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/state.md b/docs/cli/state.md new file mode 100644 index 00000000..fd6ec1d2 --- /dev/null +++ b/docs/cli/state.md @@ -0,0 +1,12 @@ +# state + +``` +Show a JSON representation of the current window manager state + +Usage: komorebic state + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/static-config-schema.md b/docs/cli/static-config-schema.md new file mode 100644 index 00000000..d44c4e0e --- /dev/null +++ b/docs/cli/static-config-schema.md @@ -0,0 +1,12 @@ +# static-config-schema + +``` +Generate a JSON Schema of the static configuration file + +Usage: komorebic static-config-schema + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/stop.md b/docs/cli/stop.md new file mode 100644 index 00000000..e35f982c --- /dev/null +++ b/docs/cli/stop.md @@ -0,0 +1,12 @@ +# stop + +``` +Stop the komorebi.exe process and restore all hidden windows + +Usage: komorebic stop + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/subscribe-socket.md b/docs/cli/subscribe-socket.md new file mode 100644 index 00000000..96a70068 --- /dev/null +++ b/docs/cli/subscribe-socket.md @@ -0,0 +1,16 @@ +# subscribe-socket + +``` +Subscribe to komorebi events using a Unix Domain Socket + +Usage: komorebic subscribe-socket + +Arguments: + + Name of the socket to send event notifications to + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/swap-workspaces-with-monitor.md b/docs/cli/swap-workspaces-with-monitor.md new file mode 100644 index 00000000..cf84aac6 --- /dev/null +++ b/docs/cli/swap-workspaces-with-monitor.md @@ -0,0 +1,16 @@ +# swap-workspaces-with-monitor + +``` +Swap focused monitor workspaces with specified monitor + +Usage: komorebic swap-workspaces-with-monitor + +Arguments: + + Target index (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-cross-monitor-move-behaviour.md b/docs/cli/toggle-cross-monitor-move-behaviour.md new file mode 100644 index 00000000..237a7173 --- /dev/null +++ b/docs/cli/toggle-cross-monitor-move-behaviour.md @@ -0,0 +1,12 @@ +# toggle-cross-monitor-move-behaviour + +``` +Toggle the behaviour when moving windows across monitor boundaries + +Usage: komorebic toggle-cross-monitor-move-behaviour + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-float-override.md b/docs/cli/toggle-float-override.md new file mode 100644 index 00000000..203dc53f --- /dev/null +++ b/docs/cli/toggle-float-override.md @@ -0,0 +1,12 @@ +# toggle-float-override + +``` +Enable or disable float override, which makes it so every new window opens in floating mode + +Usage: komorebic toggle-float-override + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-float.md b/docs/cli/toggle-float.md new file mode 100644 index 00000000..15ceab84 --- /dev/null +++ b/docs/cli/toggle-float.md @@ -0,0 +1,12 @@ +# toggle-float + +``` +Toggle floating mode for the focused window + +Usage: komorebic toggle-float + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-lock.md b/docs/cli/toggle-lock.md new file mode 100644 index 00000000..d7165d51 --- /dev/null +++ b/docs/cli/toggle-lock.md @@ -0,0 +1,12 @@ +# toggle-lock + +``` +Toggle a lock for the focused container, ensuring it will not be displaced by any new windows + +Usage: komorebic toggle-lock + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-monocle.md b/docs/cli/toggle-monocle.md new file mode 100644 index 00000000..1b3f8af7 --- /dev/null +++ b/docs/cli/toggle-monocle.md @@ -0,0 +1,12 @@ +# toggle-monocle + +``` +Toggle monocle mode for the focused container + +Usage: komorebic toggle-monocle + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-mouse-follows-focus.md b/docs/cli/toggle-mouse-follows-focus.md new file mode 100644 index 00000000..58cdf6a0 --- /dev/null +++ b/docs/cli/toggle-mouse-follows-focus.md @@ -0,0 +1,12 @@ +# toggle-mouse-follows-focus + +``` +Toggle mouse follows focus on all workspaces + +Usage: komorebic toggle-mouse-follows-focus + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-pause.md b/docs/cli/toggle-pause.md new file mode 100644 index 00000000..55618219 --- /dev/null +++ b/docs/cli/toggle-pause.md @@ -0,0 +1,12 @@ +# toggle-pause + +``` +Toggle the paused state for all window tiling + +Usage: komorebic toggle-pause + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-tiling.md b/docs/cli/toggle-tiling.md new file mode 100644 index 00000000..e029bfc8 --- /dev/null +++ b/docs/cli/toggle-tiling.md @@ -0,0 +1,12 @@ +# toggle-tiling + +``` +Toggle window tiling on the focused workspace + +Usage: komorebic toggle-tiling + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-window-based-work-area-offset.md b/docs/cli/toggle-window-based-work-area-offset.md new file mode 100644 index 00000000..426896cd --- /dev/null +++ b/docs/cli/toggle-window-based-work-area-offset.md @@ -0,0 +1,12 @@ +# toggle-window-based-work-area-offset + +``` +Toggle application of the window-based work area offset for the focused workspace + +Usage: komorebic toggle-window-based-work-area-offset + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-window-container-behaviour.md b/docs/cli/toggle-window-container-behaviour.md new file mode 100644 index 00000000..449e1197 --- /dev/null +++ b/docs/cli/toggle-window-container-behaviour.md @@ -0,0 +1,12 @@ +# toggle-window-container-behaviour + +``` +Toggle the behaviour for new windows (stacking or dynamic tiling) + +Usage: komorebic toggle-window-container-behaviour + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-workspace-float-override.md b/docs/cli/toggle-workspace-float-override.md new file mode 100644 index 00000000..497630a9 --- /dev/null +++ b/docs/cli/toggle-workspace-float-override.md @@ -0,0 +1,13 @@ +# toggle-workspace-float-override + +``` +Enable or disable float override, which makes it so every new window opens in floating mode, for the currently focused workspace. If there was no override value set for the workspace previously it takes the opposite of the +global value + +Usage: komorebic toggle-workspace-float-override + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-workspace-layer.md b/docs/cli/toggle-workspace-layer.md new file mode 100644 index 00000000..fca30422 --- /dev/null +++ b/docs/cli/toggle-workspace-layer.md @@ -0,0 +1,12 @@ +# toggle-workspace-layer + +``` +Toggle between the Tiling and Floating layers on the focused workspace + +Usage: komorebic toggle-workspace-layer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/toggle-workspace-window-container-behaviour.md b/docs/cli/toggle-workspace-window-container-behaviour.md new file mode 100644 index 00000000..df02d57c --- /dev/null +++ b/docs/cli/toggle-workspace-window-container-behaviour.md @@ -0,0 +1,12 @@ +# toggle-workspace-window-container-behaviour + +``` +Toggle the behaviour for new windows (stacking or dynamic tiling) for currently focused workspace. If there was no behaviour set for the workspace previously it takes the opposite of the global value + +Usage: komorebic toggle-workspace-window-container-behaviour + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/unmanage.md b/docs/cli/unmanage.md new file mode 100644 index 00000000..e76f89a0 --- /dev/null +++ b/docs/cli/unmanage.md @@ -0,0 +1,12 @@ +# unmanage + +``` +Unmanage a window that was forcibly managed + +Usage: komorebic unmanage + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/unmanaged-window-operation-behaviour.md b/docs/cli/unmanaged-window-operation-behaviour.md new file mode 100644 index 00000000..1afefb4c --- /dev/null +++ b/docs/cli/unmanaged-window-operation-behaviour.md @@ -0,0 +1,18 @@ +# unmanaged-window-operation-behaviour + +``` +Set the operation behaviour when the focused window is not managed + +Usage: komorebic unmanaged-window-operation-behaviour + +Arguments: + + Possible values: + - op: Process komorebic commands on temporarily unmanaged/floated windows + - no-op: Ignore komorebic commands on temporarily unmanaged/floated windows + +Options: + -h, --help + Print help (see a summary with '-h') + +``` \ No newline at end of file diff --git a/docs/cli/unstack-all.md b/docs/cli/unstack-all.md new file mode 100644 index 00000000..ea74a184 --- /dev/null +++ b/docs/cli/unstack-all.md @@ -0,0 +1,12 @@ +# unstack-all + +``` +Unstack all windows in the focused container + +Usage: komorebic unstack-all + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/unstack.md b/docs/cli/unstack.md new file mode 100644 index 00000000..7175fb46 --- /dev/null +++ b/docs/cli/unstack.md @@ -0,0 +1,12 @@ +# unstack + +``` +Unstack the focused window + +Usage: komorebic unstack + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/unsubscribe-socket.md b/docs/cli/unsubscribe-socket.md new file mode 100644 index 00000000..ba0e983e --- /dev/null +++ b/docs/cli/unsubscribe-socket.md @@ -0,0 +1,16 @@ +# unsubscribe-socket + +``` +Unsubscribe from komorebi events + +Usage: komorebic unsubscribe-socket + +Arguments: + + Name of the socket to stop sending event notifications to + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/visible-windows.md b/docs/cli/visible-windows.md new file mode 100644 index 00000000..f8fdbf5d --- /dev/null +++ b/docs/cli/visible-windows.md @@ -0,0 +1,12 @@ +# visible-windows + +``` +Show a JSON representation of visible windows + +Usage: komorebic visible-windows + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/workspace-layout-rule.md b/docs/cli/workspace-layout-rule.md new file mode 100644 index 00000000..b7294e0c --- /dev/null +++ b/docs/cli/workspace-layout-rule.md @@ -0,0 +1,25 @@ +# workspace-layout-rule + +``` +Add a dynamic layout rule for the specified workspace + +Usage: komorebic workspace-layout-rule + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + + + The number of window containers on-screen required to trigger this layout rule + + + [possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/workspace-layout.md b/docs/cli/workspace-layout.md new file mode 100644 index 00000000..62bf3c1f --- /dev/null +++ b/docs/cli/workspace-layout.md @@ -0,0 +1,22 @@ +# workspace-layout + +``` +Set the layout for the specified workspace + +Usage: komorebic workspace-layout + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + + + [possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/workspace-name.md b/docs/cli/workspace-name.md new file mode 100644 index 00000000..bc0ed92f --- /dev/null +++ b/docs/cli/workspace-name.md @@ -0,0 +1,22 @@ +# workspace-name + +``` +Set the workspace name for the specified workspace + +Usage: komorebic workspace-name + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + + + Name of the workspace as a String + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/workspace-padding.md b/docs/cli/workspace-padding.md new file mode 100644 index 00000000..dfe6e475 --- /dev/null +++ b/docs/cli/workspace-padding.md @@ -0,0 +1,22 @@ +# workspace-padding + +``` +Set the workspace padding for the specified workspace + +Usage: komorebic workspace-padding + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + + + Pixels to pad with as an integer + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/workspace-rule.md b/docs/cli/workspace-rule.md new file mode 100644 index 00000000..ed8c97e5 --- /dev/null +++ b/docs/cli/workspace-rule.md @@ -0,0 +1,25 @@ +# workspace-rule + +``` +Add a rule to associate an application with a workspace + +Usage: komorebic workspace-rule + +Arguments: + + [possible values: exe, class, title, path] + + + Identifier as a string + + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/workspace-tiling.md b/docs/cli/workspace-tiling.md new file mode 100644 index 00000000..fbb62efc --- /dev/null +++ b/docs/cli/workspace-tiling.md @@ -0,0 +1,22 @@ +# workspace-tiling + +``` +Enable or disable window tiling for the specified workspace + +Usage: komorebic workspace-tiling + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index on the specified monitor (zero-indexed) + + + [possible values: enable, disable] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/workspace-work-area-offset.md b/docs/cli/workspace-work-area-offset.md new file mode 100644 index 00000000..0fe448db --- /dev/null +++ b/docs/cli/workspace-work-area-offset.md @@ -0,0 +1,31 @@ +# workspace-work-area-offset + +``` +Set offsets for a workspace to exclude parts of the work area from tiling + +Usage: komorebic workspace-work-area-offset + +Arguments: + + Monitor index (zero-indexed) + + + Workspace index (zero-indexed) + + + Size of the left work area offset (set right to left * 2 to maintain right padding) + + + Size of the top work area offset (set bottom to the same value to maintain bottom padding) + + + Size of the right work area offset + + + Size of the bottom work area offset + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/schema.asc.json b/schema.asc.json new file mode 100644 index 00000000..d39fec39 --- /dev/null +++ b/schema.asc.json @@ -0,0 +1,168 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ApplicationSpecificConfiguration", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/AscApplicationRulesOrSchema" + }, + "definitions": { + "ApplicationIdentifier": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "AscApplicationRules": { + "description": "Rules that determine how an application is handled", + "type": "object", + "properties": { + "floating": { + "description": "Rules to manage specific windows as floating windows", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + }, + "ignore": { + "description": "Rules to ignore specific windows", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + }, + "layered": { + "description": "Rules to identify applications which have the `WS_EX_LAYERED` Extended Window Style", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + }, + "manage": { + "description": "Rules to forcibly manage specific windows", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + }, + "object_name_change": { + "description": "Rules to identify applications which send the `EVENT_OBJECT_NAMECHANGE` event on launch", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + }, + "slow_application": { + "description": "Rules to identify applications which are slow to send initial event notifications", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + }, + "transparency_ignore": { + "description": "Rules to ignore specific windows from the transparency feature", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + }, + "tray_and_multi_window": { + "description": "Rules to identify applications which minimize to the tray or have multiple windows", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/MatchingRule" + } + } + } + }, + "AscApplicationRulesOrSchema": { + "anyOf": [ + { + "$ref": "#/definitions/AscApplicationRules" + }, + { + "type": "string" + } + ] + }, + "IdWithIdentifier": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "$ref": "#/definitions/ApplicationIdentifier" + }, + "matching_strategy": { + "anyOf": [ + { + "$ref": "#/definitions/MatchingStrategy" + }, + { + "type": "null" + } + ] + } + } + }, + "MatchingRule": { + "anyOf": [ + { + "$ref": "#/definitions/IdWithIdentifier" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/IdWithIdentifier" + } + } + ] + }, + "MatchingStrategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } +} diff --git a/schema.json b/schema.json new file mode 100644 index 00000000..953fcb04 --- /dev/null +++ b/schema.json @@ -0,0 +1,1384 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "StaticConfig", + "description": "The `komorebi.json` static configuration file reference for `v0.1.39`", + "type": "object", + "properties": { + "app_specific_configuration_path": { + "description": "Path to applications.json from komorebi-application-specific-configurations (default: None)", + "anyOf": [ + { + "description": "A single applications.json file", + "type": "string" + }, + { + "description": "Multiple applications.json files", + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "border_overflow_applications": { + "description": "Identify border overflow applications", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "cross_boundary_behaviour": { + "description": "Determine what happens when an action is called on a window at a monitor boundary (default: Monitor)", + "oneOf": [ + { + "description": "Attempt to perform actions across a workspace boundary", + "type": "string", + "enum": [ + "Workspace" + ] + }, + { + "description": "Attempt to perform actions across a monitor boundary", + "type": "string", + "enum": [ + "Monitor" + ] + } + ] + }, + "cross_monitor_move_behaviour": { + "description": "Determine what happens when a window is moved across a monitor boundary (default: Swap)", + "oneOf": [ + { + "description": "Swap the window container with the window container at the edge of the adjacent monitor", + "type": "string", + "enum": [ + "Swap" + ] + }, + { + "description": "Insert the window container into the focused workspace on the adjacent monitor", + "type": "string", + "enum": [ + "Insert" + ] + }, + { + "description": "Do nothing if trying to move a window container in the direction of an adjacent monitor", + "type": "string", + "enum": [ + "NoOp" + ] + } + ] + }, + "default_container_padding": { + "description": "Global default container padding (default: 10)", + "type": "integer", + "format": "int32" + }, + "default_workspace_padding": { + "description": "Add transparency to unfocused windows (default: false) Global default workspace padding (default: 10)", + "type": "integer", + "format": "int32" + }, + "display_index_preferences": { + "description": "Set display index preferences", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "float_override": { + "description": "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)", + "type": "boolean" + }, + "float_override_placement": { + "description": "Determines the `Placement` to be used when spawning a window with float override active (default: None)", + "oneOf": [ + { + "description": "Does not change the size or position of the window", + "type": "string", + "enum": [ + "None" + ] + }, + { + "description": "Center the window without changing the size", + "type": "string", + "enum": [ + "Center" + ] + }, + { + "description": "Center the window and resize it according to the `AspectRatio`", + "type": "string", + "enum": [ + "CenterAndResize" + ] + } + ] + }, + "float_rule_placement": { + "description": "Determines the `Placement` to be used when spawning a window that matches a 'floating_applications' rule (default: None)", + "oneOf": [ + { + "description": "Does not change the size or position of the window", + "type": "string", + "enum": [ + "None" + ] + }, + { + "description": "Center the window without changing the size", + "type": "string", + "enum": [ + "Center" + ] + }, + { + "description": "Center the window and resize it according to the `AspectRatio`", + "type": "string", + "enum": [ + "CenterAndResize" + ] + } + ] + }, + "floating_applications": { + "description": "Identify applications which should be managed as floating windows", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "floating_layer_behaviour": { + "description": "Determines what happens on a new window when on the `FloatingLayer` (default: Tile)", + "oneOf": [ + { + "description": "Tile new windows (unless they match a float rule or float override is active)", + "type": "string", + "enum": [ + "Tile" + ] + }, + { + "description": "Float new windows", + "type": "string", + "enum": [ + "Float" + ] + } + ] + }, + "floating_layer_placement": { + "description": "Determines the `Placement` to be used when spawning a window on the floating layer with the `FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float` (default: Center)", + "oneOf": [ + { + "description": "Does not change the size or position of the window", + "type": "string", + "enum": [ + "None" + ] + }, + { + "description": "Center the window without changing the size", + "type": "string", + "enum": [ + "Center" + ] + }, + { + "description": "Center the window and resize it according to the `AspectRatio`", + "type": "string", + "enum": [ + "CenterAndResize" + ] + } + ] + }, + "floating_window_aspect_ratio": { + "description": "Identify applications which are slow to send initial event notifications Aspect ratio to resize with when toggling floating mode for a window", + "anyOf": [ + { + "description": "A predefined aspect ratio", + "oneOf": [ + { + "description": "21:9", + "type": "string", + "enum": [ + "Ultrawide" + ] + }, + { + "description": "16:9", + "type": "string", + "enum": [ + "Widescreen" + ] + }, + { + "description": "4:3", + "type": "string", + "enum": [ + "Standard" + ] + } + ] + }, + { + "description": "A custom W:H aspect ratio", + "type": "array", + "items": [ + { + "type": "integer", + "format": "int32" + }, + { + "type": "integer", + "format": "int32" + } + ], + "maxItems": 2, + "minItems": 2 + } + ] + }, + "global_work_area_offset": { + "description": "Global work area (space used for tiling) offset (default: None)", + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "type": "integer", + "format": "int32" + }, + "left": { + "type": "integer", + "format": "int32" + }, + "right": { + "type": "integer", + "format": "int32" + }, + "top": { + "type": "integer", + "format": "int32" + } + } + }, + "ignore_rules": { + "description": "Individual window floating rules", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "layered_applications": { + "description": "Identify applications that have the WS_EX_LAYERED extended window style", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "manage_rules": { + "description": "Individual window force-manage rules", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "monitors": { + "description": "Monitor and workspace configurations", + "type": "array", + "items": { + "type": "object", + "required": [ + "workspaces" + ], + "properties": { + "container_padding": { + "description": "Container padding (default: global)", + "type": "integer", + "format": "int32" + }, + "floating_layer_behaviour": { + "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", + "oneOf": [ + { + "description": "Tile new windows (unless they match a float rule or float override is active)", + "type": "string", + "enum": [ + "Tile" + ] + }, + { + "description": "Float new windows", + "type": "string", + "enum": [ + "Float" + ] + } + ] + }, + "window_based_work_area_offset": { + "description": "Window based work area offset (default: None)", + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "type": "integer", + "format": "int32" + }, + "left": { + "type": "integer", + "format": "int32" + }, + "right": { + "type": "integer", + "format": "int32" + }, + "top": { + "type": "integer", + "format": "int32" + } + } + }, + "window_based_work_area_offset_limit": { + "description": "Open window limit after which the window based work area offset will no longer be applied (default: 1)", + "type": "integer", + "format": "int" + }, + "work_area_offset": { + "description": "Monitor-specific work area offset (default: None)", + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "type": "integer", + "format": "int32" + }, + "left": { + "type": "integer", + "format": "int32" + }, + "right": { + "type": "integer", + "format": "int32" + }, + "top": { + "type": "integer", + "format": "int32" + } + } + }, + "workspace_padding": { + "description": "Workspace padding (default: global)", + "type": "integer", + "format": "int32" + }, + "workspaces": { + "description": "Workspace configurations", + "type": "array", + "items": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "apply_window_based_work_area_offset": { + "description": "Apply this monitor's window-based work area offset (default: true)", + "type": "boolean" + }, + "container_padding": { + "description": "Container padding (default: global)", + "type": "integer", + "format": "int32" + }, + "custom_layout": { + "description": "END OF LIFE FEATURE: Custom Layout (default: None)", + "type": "string" + }, + "float_override": { + "description": "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)", + "type": "boolean" + }, + "floating_layer_behaviour": { + "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", + "oneOf": [ + { + "description": "Tile new windows (unless they match a float rule or float override is active)", + "type": "string", + "enum": [ + "Tile" + ] + }, + { + "description": "Float new windows", + "type": "string", + "enum": [ + "Float" + ] + } + ] + }, + "initial_workspace_rules": { + "description": "Initial workspace application rules", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "layout": { + "description": "Layout (default: BSP)", + "type": "string", + "enum": [ + "BSP", + "Columns", + "Rows", + "VerticalStack", + "HorizontalStack", + "UltrawideVerticalStack", + "Grid", + "RightMainVerticalStack", + "Scrolling" + ] + }, + "layout_flip": { + "description": "Specify an axis on which to flip the selected layout (default: None)", + "type": "string", + "enum": [ + "Horizontal", + "Vertical", + "HorizontalAndVertical" + ] + }, + "layout_options": { + "description": "Layout-specific options (default: None)", + "type": "object", + "properties": { + "scrolling": { + "description": "Options related to the Scrolling layout", + "type": "object", + "required": [ + "columns" + ], + "properties": { + "columns": { + "description": "Desired number of visible columns (default: 3)", + "type": "integer", + "format": "uint", + "minimum": 0.0 + } + } + } + } + }, + "layout_rules": { + "description": "Layout rules in the format of threshold => layout (default: None)", + "type": "object", + "additionalProperties": { + "type": "string", + "enum": [ + "BSP", + "Columns", + "Rows", + "VerticalStack", + "HorizontalStack", + "UltrawideVerticalStack", + "Grid", + "RightMainVerticalStack", + "Scrolling" + ] + } + }, + "name": { + "description": "Name", + "type": "string" + }, + "tile": { + "description": "Enable or disable tiling for the workspace (default: true)", + "type": "boolean" + }, + "window_container_behaviour": { + "description": "Determine what happens when a new window is opened (default: Create)", + "oneOf": [ + { + "description": "Create a new container for each new window", + "type": "string", + "enum": [ + "Create" + ] + }, + { + "description": "Append new windows to the focused window container", + "type": "string", + "enum": [ + "Append" + ] + } + ] + }, + "window_container_behaviour_rules": { + "description": "Window container behaviour rules in the format of threshold => behaviour (default: None)", + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "description": "Create a new container for each new window", + "type": "string", + "enum": [ + "Create" + ] + }, + { + "description": "Append new windows to the focused window container", + "type": "string", + "enum": [ + "Append" + ] + } + ] + } + }, + "work_area_offset": { + "description": "Workspace specific work area offset (default: None)", + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "type": "integer", + "format": "int32" + }, + "left": { + "type": "integer", + "format": "int32" + }, + "right": { + "type": "integer", + "format": "int32" + }, + "top": { + "type": "integer", + "format": "int32" + } + } + }, + "workspace_padding": { + "description": "Workspace padding (default: global)", + "type": "integer", + "format": "int32" + }, + "workspace_rules": { + "description": "Permanent workspace application rules", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + } + } + } + } + } + } + }, + "mouse_follows_focus": { + "description": "Enable or disable mouse follows focus (default: true)", + "type": "boolean" + }, + "object_name_change_applications": { + "description": "Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare)", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "object_name_change_title_ignore_list": { + "description": "Do not process EVENT_OBJECT_NAMECHANGE events as Show events for identified applications matching these title regexes", + "type": "array", + "items": { + "type": "string" + } + }, + "resize_delta": { + "description": "Delta to resize windows by (default 50)", + "type": "integer", + "format": "int32" + }, + "toggle_float_placement": { + "description": "Determines the placement of a new window when toggling to float (default: CenterAndResize)", + "oneOf": [ + { + "description": "Does not change the size or position of the window", + "type": "string", + "enum": [ + "None" + ] + }, + { + "description": "Center the window without changing the size", + "type": "string", + "enum": [ + "Center" + ] + }, + { + "description": "Center the window and resize it according to the `AspectRatio`", + "type": "string", + "enum": [ + "CenterAndResize" + ] + } + ] + }, + "tray_and_multi_window_applications": { + "description": "Identify tray and multi-window applications", + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + }, + { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "kind" + ], + "properties": { + "id": { + "type": "string" + }, + "kind": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "matching_strategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + } + } + } + } + ] + } + }, + "unmanaged_window_operation_behaviour": { + "description": "Determine what happens when commands are sent while an unmanaged window is in the foreground (default: Op)", + "oneOf": [ + { + "description": "Process komorebic commands on temporarily unmanaged/floated windows", + "type": "string", + "enum": [ + "Op" + ] + }, + { + "description": "Ignore komorebic commands on temporarily unmanaged/floated windows", + "type": "string", + "enum": [ + "NoOp" + ] + } + ] + }, + "window_container_behaviour": { + "description": "Determine what happens when a new window is opened (default: Create)", + "oneOf": [ + { + "description": "Create a new container for each new window", + "type": "string", + "enum": [ + "Create" + ] + }, + { + "description": "Append new windows to the focused window container", + "type": "string", + "enum": [ + "Append" + ] + } + ] + } + } +} From 33c319ef61f8cde98aaddf3eacef914acb0b625c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 14:33:49 -0700 Subject: [PATCH 075/305] fix(wm): ensure floating layer behaviour is respected This commit ensures that the floating layer behaviour configured by the user at the top level of the config is propagated properly, and also that it is respected during FocusChange events. --- komorebi/src/process_event.rs | 6 +- komorebi/src/static_config.rs | 107 ++++++++++++++-------------------- 2 files changed, 48 insertions(+), 65 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 9cad66b2..e86cca7d 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -132,6 +132,7 @@ impl WindowManager { WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; let application_name = application.name().unwrap_or_default().clone(); + let mut should_switch_workspace_layer_to_tiling = true; let mut tabbed_window = false; if let Some(window_id) = application.main_window_id() @@ -284,13 +285,16 @@ impl WindowManager { window_manager_event_listener::send_notification( event, ); + should_switch_workspace_layer_to_tiling = false; } } } else if is_on_current_workspace { workspace.focus_container_by_window(window_id)?; } - workspace.layer = WorkspaceLayer::Tiling; + if should_switch_workspace_layer_to_tiling { + workspace.layer = WorkspaceLayer::Tiling; + } if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) && !self.focused_workspace()?.containers().is_empty() { diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 0fb87c49..268b17a5 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -1135,7 +1135,7 @@ impl StaticConfig { .unwrap_or(WindowContainerBehaviour::Create), float_override: value.float_override.unwrap_or_default(), floating_layer_override: false, // this value is always automatically calculated - floating_layer_behaviour: FloatingLayerBehaviour::default(), + floating_layer_behaviour: value.floating_layer_behaviour.unwrap_or_default(), toggle_float_placement: value .toggle_float_placement .unwrap_or(Placement::CenterAndResize), @@ -1155,28 +1155,14 @@ impl StaticConfig { .unmanaged_window_operation_behaviour .unwrap_or(OperationBehaviour::Op), resize_delta: value.resize_delta.unwrap_or(50), - // focus_follows_mouse: value.focus_follows_mouse, mouse_follows_focus: value.mouse_follows_focus.unwrap_or(true), hotwatch: Hotwatch::new()?, - // has_pending_raise_op: false, - // pending_move_op: Arc::new(None), - // already_moved_window_handles: Arc::new(Mutex::new(HashSet::new())), - // uncloack_to_ignore: 0, - // known_hwnds: HashMap::new(), run_loop: CoreFoundationRunLoop(run_loop.clone()), - minimized_windows: Default::default(), + minimized_windows: HashMap::new(), already_moved_window_handles: Default::default(), - known_window_ids: Default::default(), + known_window_ids: HashMap::new(), }; - // match value.focus_follows_mouse { - // None => WindowsApi::disable_focus_follows_mouse()?, - // Some(FocusFollowsMouseImplementation::Windows) => { - // WindowsApi::enable_focus_follows_mouse()?; - // } - // Some(FocusFollowsMouseImplementation::Komorebi) => {} - // }; - let bytes = SocketMessage::ReloadStaticConfiguration(path.clone()).as_bytes()?; wm.hotwatch.watch(path, move |event| match event.kind { @@ -1473,53 +1459,46 @@ impl StaticConfig { // Check for configs that should be tied to a specific display that isn't loaded right now // and cache a monitor with those configs with the specific `serial_number_id` so that when // those devices are connected later we can use the correct config from the cache. - // if configs_with_preference.len() > configs_used.len() { - // for i in configs_with_preference - // .iter() - // .filter(|i| !configs_used.contains(i)) - // { - // let id = { - // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); - // display_index_preferences.get(i).cloned() - // }; - // if let (Some(id), Some(monitor_config)) = - // (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) - // { - // // The name, device, device_id and serial_number_id can be empty here since - // // once the monitor with this preferred index actually connects the - // // `load_monitor_information` function will update these fields. - // let mut m = monitor::new( - // 0, - // Rect::default(), - // Rect::default(), - // "".into(), - // "".into(), - // "".into(), - // None, - // ); - // - // m.ensure_workspace_count(monitor_config.workspaces.len()); - // m.work_area_offset = monitor_config.work_area_offset; - // m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; - // m.window_based_work_area_offset_limit = monitor_config - // .window_based_work_area_offset_limit - // .unwrap_or(1); - // m.container_padding = monitor_config.container_padding; - // m.workspace_padding = monitor_config.workspace_padding; - // m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; - // - // m.update_workspaces_globals(offset); - // - // for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { - // if let Some(workspace_config) = monitor_config.workspaces.get(j) { - // ws.load_static_config(workspace_config)?; - // } - // } - // - // monitor_reconciliator::insert_in_monitor_cache(&id, m); - // } - // } - // } + if configs_with_preference.len() > configs_used.len() { + for i in configs_with_preference + .iter() + .filter(|i| !configs_used.contains(i)) + { + let id = { + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + display_index_preferences.get(i).cloned() + }; + if let (Some(id), Some(monitor_config)) = + (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) + { + // The name, device, device_id and serial_number_id can be empty here since + // once the monitor with this preferred index actually connects the + // `load_monitor_information` function will update these fields. + let mut m = + monitor::new(0, Rect::default(), Rect::default(), "".into(), "".into()); + + m.ensure_workspace_count(monitor_config.workspaces.len()); + m.work_area_offset = monitor_config.work_area_offset; + m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; + m.window_based_work_area_offset_limit = monitor_config + .window_based_work_area_offset_limit + .unwrap_or(1); + m.container_padding = monitor_config.container_padding; + m.workspace_padding = monitor_config.workspace_padding; + m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + + m.update_workspaces_globals(offset); + + for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { + if let Some(workspace_config) = monitor_config.workspaces.get(j) { + ws.load_static_config(workspace_config)?; + } + } + + monitor_reconciliator::insert_in_monitor_cache(&id, m); + } + } + } wm.enforce_workspace_rules()?; From 3792da1bb36eb12a02b2c1cb56166b90bf38b42c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 15:09:26 -0700 Subject: [PATCH 076/305] feat(cli): impl quickstart and update config dir This commit implements the komorebic quickstart command, adds a sample komorebi.json and a sample skhdrc file which get built into the komorebic binary, and updates the default config path on macOS to $HOME/.config/komorebi --- docs/komorebi.example.json | 58 ++++++++++++++++++++++++++++ docs/skhdrc.sample | 69 +++++++++++++++++++++++++++++++++ komorebi/src/lib.rs | 25 +++++++----- komorebi/src/workspace.rs | 2 +- komorebic/src/main.rs | 78 +++++++++++++++++++++++++++++++++++--- 5 files changed, 216 insertions(+), 16 deletions(-) create mode 100644 docs/komorebi.example.json create mode 100644 docs/skhdrc.sample diff --git a/docs/komorebi.example.json b/docs/komorebi.example.json new file mode 100644 index 00000000..6efb278a --- /dev/null +++ b/docs/komorebi.example.json @@ -0,0 +1,58 @@ +{ + "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.39/schema.json", + "app_specific_configuration_path": "$HOME/.config/komorebi/applications.json", + "cross_monitor_move_behaviour": "Insert", + "default_workspace_padding": 15, + "default_container_padding": 15, + "floating_window_aspect_ratio": "Widescreen", + "floating_layer_behaviour": "Float", + "resize_delta": 100, + "ignore_rules": [], + "floating_applications": [], + "manage_rules": [], + "monitors": [ + { + "workspaces": [ + { + "name": "I", + "layout": "BSP", + "initial_workspace_rules": [ +// { +// "kind": "Exe", +// "id": "Zen", +// "matching_strategy": "Equals" +// } + ] + }, + { + "name": "II", + "layout": "VerticalStack" + }, + { + "name": "III", + "layout": "HorizontalStack" + }, + { + "name": "IV", + "layout": "UltrawideVerticalStack" + }, + { + "name": "V", + "layout": "Rows" + }, + { + "name": "VI", + "layout": "Grid" + }, + { + "name": "VII", + "layout": "RightMainVerticalStack" + }, + { + "name": "VIII", + "layout": "Scrolling" + } + ] + } + ] +} \ No newline at end of file diff --git a/docs/skhdrc.sample b/docs/skhdrc.sample new file mode 100644 index 00000000..f8fb45f3 --- /dev/null +++ b/docs/skhdrc.sample @@ -0,0 +1,69 @@ +# Focus windows +alt - h : komorebic focus left +alt - j : komorebic focus down +alt - k : komorebic focus up +alt - l : komorebic focus right +alt + shift - 0x21 : komorebic cycle-focus previous # 0x21 is [ +alt + shift - 0x1E : komorebic cycle-focus next # 0x1E is ] + +# Move windows +alt + shift - h : komorebic move left +alt + shift - j : komorebic move down +alt + shift - k : komorebic move up +alt + shift - l : komorebic move right +alt + shift - return : komorebic promote + +# Stack windows +ctrl - left : komorebic stack left +ctrl - down : komorebic stack down +ctrl - up : komorebic stack up +ctrl - right : komorebic stack right +alt - 0x29 : komorebic unstack # 0x29 is ; +alt - 0x21 : komorebic cycle-stack previous # 0x21 is [ +alt - 0x1E : komorebic cycle-stack next # 0x1E is ] + +# Workspace layer +alt + shift - 0x29 : komorebic toggle-workspace-layer # 0x29 is ; + +# Resize +alt - 0x18 : komorebic resize-axis horizontal increase # 0x18 is + +alt - 0x1B : komorebic resize-axis horizontal decrease # 0x1B is - +alt + shift - 0x18 : komorebic resize-axis vertical increase +alt + shift - 0x1B : komorebic resize-axis vertical decrease + +# Manipulate windows +alt - t : komorebic toggle-float +alt + shift - t : komorebic toggle-workspace-float-override +alt + shift - f : komorebic toggle-monocle + +# Window manager options +alt + shift - r : komorebic retile +alt - p : komorebic toggle-pause +alt - 0 : komorebic toggle-window-container-behaviour + +# Layouts +alt - x : komorebic flip-layout horizontal +alt - y : komorebic flip-layout vertical +alt + shift - x : komorebic session-float-rule + +# Workspaces +alt - 1 : komorebic focus-workspace 0 +alt - 2 : komorebic focus-workspace 1 +alt - 3 : komorebic focus-workspace 2 +alt - 4 : komorebic focus-workspace 3 +alt - 5 : komorebic focus-workspace 4 +alt - 6 : komorebic focus-workspace 5 +alt - 7 : komorebic focus-workspace 6 +alt - 8 : komorebic focus-workspace 7 +alt - 9 : komorebic focus-workspace 8 + +# Move windows across workspaces +alt + shift - 1 : komorebic move-to-workspace 0 +alt + shift - 2 : komorebic move-to-workspace 1 +alt + shift - 3 : komorebic move-to-workspace 2 +alt + shift - 4 : komorebic move-to-workspace 3 +alt + shift - 5 : komorebic move-to-workspace 4 +alt + shift - 6 : komorebic move-to-workspace 5 +alt + shift - 7 : komorebic move-to-workspace 6 +alt + shift - 8 : komorebic move-to-workspace 7 +alt + shift - 9 : komorebic move-to-workspace 8 \ No newline at end of file diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 844d7d26..d3b86b06 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -74,17 +74,24 @@ pub mod workspace; lazy_static! { pub static ref HOME_DIR: PathBuf = { - std::env::var("KOMOREBI_CONFIG_HOME").map_or_else(|_| dirs::home_dir().expect("there is no home directory"), |home_path| { - let home = home_path.replace_env(); + std::env::var("KOMOREBI_CONFIG_HOME").map_or_else( + |_| { + dirs::home_dir() + .expect("there is no home directory") + .join(".config") + .join("komorebi") + }, + |home_path| { + let home = home_path.replace_env(); - assert!( - home.is_dir(), - "$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory" - ); + assert!( + home.is_dir(), + "$KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory" + ); - - home - }) + home + }, + ) }; pub static ref DATA_DIR: PathBuf = dirs::data_local_dir() .expect("there is no local data directory") diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index c1cae466..fc709cb3 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -89,7 +89,7 @@ impl Default for Workspace { workspace_padding: None, container_padding: None, resize_dimensions: vec![], - layout: Layout::Default(DefaultLayout::UltrawideVerticalStack), + layout: Layout::Default(DefaultLayout::BSP), work_area_offset: None, latest_layout: vec![], layout_flip: None, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index fccc9084..63dd7e75 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -39,7 +39,7 @@ lazy_static! { static ref HAS_CUSTOM_CONFIG_HOME: AtomicBool = AtomicBool::new(false); static ref HOME_DIR: PathBuf = { std::env::var("KOMOREBI_CONFIG_HOME").map_or_else( - |_| dirs::home_dir().expect("there is no home directory"), + |_| dirs::home_dir().expect("there is no home directory").join(".config").join("komorebi"), |home_path| { let home = home_path.replace_env(); if home.as_path().is_dir() { @@ -47,7 +47,7 @@ lazy_static! { home } else { panic!( - "$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory", + "$KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory", ); } }, @@ -613,13 +613,11 @@ struct Opts { enum SubCommand { #[clap(hide = true)] Docgen, - // /// Gather example configurations for a new-user quickstart - // Quickstart, + /// Gather example configurations for a new-user quickstart + Quickstart, /// Start komorebi.exe as a background process Start(Start), /// Stop the komorebi.exe process and restore all hidden windows - // komorebi for Windows signature - // Stop(Stop), Stop(Stop), // /// Kill background processes started by komorebic // Kill(Kill), @@ -1177,6 +1175,74 @@ fn main() -> eyre::Result<()> { } } } + SubCommand::Quickstart => { + fn write_file_with_prompt( + path: &PathBuf, + content: &str, + created_files: &mut Vec, + ) -> eyre::Result<()> { + if path.exists() { + print!( + "{} will be overwritten, do you want to continue? (y/N): ", + path.display() + ); + std::io::stdout().flush()?; + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + let trimmed = input.trim().to_lowercase(); + if trimmed == "y" || trimmed == "yes" { + std::fs::write(path, content)?; + created_files.push(path.display().to_string()); + } else { + println!("Skipping {}", path.display()); + } + } else { + std::fs::write(path, content)?; + created_files.push(path.display().to_string()); + } + Ok(()) + } + + let local_appdata_dir = dirs::data_local_dir().expect("could not find localdata dir"); + let data_dir = local_appdata_dir.join("komorebi"); + std::fs::create_dir_all(&*HOME_DIR)?; + std::fs::create_dir_all(data_dir)?; + + let mut komorebi_json = include_str!("../../docs/komorebi.example.json").to_string(); + + if std::env::var("KOMOREBI_CONFIG_HOME").is_ok() { + komorebi_json = + komorebi_json.replace("Env:USERPROFILE", "Env:KOMOREBI_CONFIG_HOME"); + } + + let komorebi_path = HOME_DIR.join("komorebi.json"); + let applications_path = HOME_DIR.join("applications.json"); + let skhdrc_path = HOME_DIR.join("skhdrc"); + + let mut written_files = Vec::new(); + + write_file_with_prompt(&komorebi_path, &komorebi_json, &mut written_files)?; + + let applications_json = include_str!("../applications.json"); + write_file_with_prompt(&applications_path, applications_json, &mut written_files)?; + + let whkdrc = include_str!("../../docs/skhdrc.sample"); + write_file_with_prompt(&skhdrc_path, whkdrc, &mut written_files)?; + if written_files.is_empty() { + println!("\nNo files were written.") + } else { + println!( + "\nThe following example files were written:\n{}", + written_files.join("\n") + ); + } + println!("\nYou can now run: komorebic start"); + println!( + "\nIf you have skhd hotkey daemon installed, you can also run: skhd --config {}", + skhdrc_path.display() + ); + } + SubCommand::Start(arg) => { let mut command = &mut Command::new("komorebi"); From d0121815ea74a3817d7d371cb6a94dd9eafa75c1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 15:47:59 -0700 Subject: [PATCH 077/305] feat(cli): add enable and disable autostart cmds --- docs/cli/disable-autostart.md | 12 ++++ docs/cli/enable-autostart.md | 15 +++++ docs/cli/quickstart.md | 12 ++++ komorebic/src/main.rs | 108 ++++++++++++++++++++++++++++++++-- 4 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 docs/cli/disable-autostart.md create mode 100644 docs/cli/enable-autostart.md create mode 100644 docs/cli/quickstart.md diff --git a/docs/cli/disable-autostart.md b/docs/cli/disable-autostart.md new file mode 100644 index 00000000..32d0bf88 --- /dev/null +++ b/docs/cli/disable-autostart.md @@ -0,0 +1,12 @@ +# disable-autostart + +``` +Unloads and deletes the com.lgug2z.komorebi.plist file in $HOME/Library/LaunchAgents + +Usage: komorebic disable-autostart + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/enable-autostart.md b/docs/cli/enable-autostart.md new file mode 100644 index 00000000..355a62dd --- /dev/null +++ b/docs/cli/enable-autostart.md @@ -0,0 +1,15 @@ +# enable-autostart + +``` +Generates and loads the com.lgug2z.komorebi.plist file in $HOME/Library/LaunchAgents + +Usage: komorebic enable-autostart [OPTIONS] + +Options: + -c, --config + Path to a static configuration JSON file + + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/quickstart.md b/docs/cli/quickstart.md new file mode 100644 index 00000000..b296dfea --- /dev/null +++ b/docs/cli/quickstart.md @@ -0,0 +1,12 @@ +# quickstart + +``` +Gather example configurations for a new-user quickstart + +Usage: komorebic quickstart + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 63dd7e75..57bd0e70 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -590,6 +590,14 @@ struct ReplaceConfiguration { path: PathBuf, } +#[derive(Parser)] +struct EnableAutostart { + /// Path to a static configuration JSON file + #[clap(action, short, long)] + #[clap(value_parser = replace_env_in_path)] + config: Option, +} + #[derive(Parser)] struct EagerFocus { /// Case-sensitive exe identifier @@ -1128,10 +1136,10 @@ enum SubCommand { StaticConfigSchema, /// Generates a static configuration JSON file based on the current window manager state GenerateStaticConfig, - // /// Generates the komorebi.lnk shortcut in shell:startup to autostart komorebi - // EnableAutostart(EnableAutostart), - // /// Deletes the komorebi.lnk shortcut in shell:startup to disable autostart - // DisableAutostart, + /// Generates and loads the com.lgug2z.komorebi.plist file in $HOME/Library/LaunchAgents + EnableAutostart(EnableAutostart), + /// Unloads and deletes the com.lgug2z.komorebi.plist file in $HOME/Library/LaunchAgents + DisableAutostart, } fn print_query(message: &SocketMessage) { @@ -1242,7 +1250,99 @@ fn main() -> eyre::Result<()> { skhdrc_path.display() ); } + SubCommand::EnableAutostart(args) => { + let mut current_exe = std::env::current_exe().expect("unable to get exec path"); + current_exe.pop(); + let komorebic_exe = current_exe.join("komorebi"); + let plist = match args.config { + None => { + format!( + r#" + + + + + EnvironmentVariables + + PATH + $HOME/.nix-profile/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin + + KeepAlive + + Label + com.lgug2z.komorebi + ProcessType + Interactive + ProgramArguments + + {} + + +"#, + komorebic_exe.to_string_lossy() + ) + } + Some(config) => { + format!( + r#" + + + + + EnvironmentVariables + + PATH + $HOME/.nix-profile/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin + + KeepAlive + + Label + com.lgug2z.komorebi + ProcessType + Interactive + ProgramArguments + + {} + --config + {} + + +"#, + komorebic_exe.to_string_lossy(), + config.to_string_lossy() + ) + } + }; + + let target = dirs::home_dir() + .expect("no $HOME dir") + .join("Library") + .join("LaunchAgents") + .join("com.lgug2z.komorebi.plist"); + + std::fs::write(&target, &plist)?; + + println!("Created com.lgug2z.komorebi.plist at {}", target.display()); + Command::new("launchctl") + .args(["load", &*target.to_string_lossy()]) + .output()?; + println!("Ran 'launchctl load {}'", target.display()); + } + SubCommand::DisableAutostart => { + let target = dirs::home_dir() + .expect("no $HOME dir") + .join("Library") + .join("LaunchAgents") + .join("com.lgug2z.komorebi.plist"); + + Command::new("launchctl") + .args(["unload", &*target.to_string_lossy()]) + .output()?; + println!("Ran 'launchctl unload {}'", target.display()); + std::fs::remove_file(&target)?; + println!("Deleted {}", target.display()); + } SubCommand::Start(arg) => { let mut command = &mut Command::new("komorebi"); From 6a194f7e6c79993d6e5e76513d3c55ac296fdeb0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 16:41:38 -0700 Subject: [PATCH 078/305] docs(mkdocs): initial outline of documentation website --- docs/cli/data-directory.md | 2 +- docs/cli/eager-focus.md | 2 +- docs/cli/log.md | 2 +- docs/cli/start.md | 2 +- docs/cli/stop.md | 2 +- docs/cli/toggle-workspace-float-override.md | 3 +- docs/design.md | 42 ++++ docs/example-configurations.md | 166 +++++++++++++++ docs/index.md | 76 +++++++ docs/installation.md | 60 ++++++ docs/known-issues.md | 8 + docs/usage/focusing-windows.md | 46 ++++ docs/usage/focusing-workspaces.md | 59 +++++ .../usage/moving-windows-across-workspaces.md | 59 +++++ docs/usage/moving-windows.md | 50 +++++ docs/usage/stacking-windows.md | 52 +++++ komorebic/src/main.rs | 10 +- mkdocs.yml | 201 ++++++++++++++++++ shell.nix | 19 +- 19 files changed, 842 insertions(+), 19 deletions(-) create mode 100644 docs/design.md create mode 100644 docs/example-configurations.md create mode 100644 docs/index.md create mode 100644 docs/installation.md create mode 100644 docs/known-issues.md create mode 100644 docs/usage/focusing-windows.md create mode 100644 docs/usage/focusing-workspaces.md create mode 100644 docs/usage/moving-windows-across-workspaces.md create mode 100644 docs/usage/moving-windows.md create mode 100644 docs/usage/stacking-windows.md create mode 100644 mkdocs.yml diff --git a/docs/cli/data-directory.md b/docs/cli/data-directory.md index fc9d9336..9a1303f8 100644 --- a/docs/cli/data-directory.md +++ b/docs/cli/data-directory.md @@ -1,7 +1,7 @@ # data-directory ``` -Show the path to komorebi's data directory in %LOCALAPPDATA% +Show the path to komorebi's data directory in $HOME/Library/Application Support Usage: komorebic data-directory diff --git a/docs/cli/eager-focus.md b/docs/cli/eager-focus.md index 271a0ac5..77cdf664 100644 --- a/docs/cli/eager-focus.md +++ b/docs/cli/eager-focus.md @@ -1,7 +1,7 @@ # eager-focus ``` -Focus the first managed window matching the given exe +Focus the first managed window matching the given executable Usage: komorebic eager-focus diff --git a/docs/cli/log.md b/docs/cli/log.md index 522aa763..bb66ab70 100644 --- a/docs/cli/log.md +++ b/docs/cli/log.md @@ -1,7 +1,7 @@ # log ``` -Tail komorebi.exe's process logs (cancel with Ctrl-C) +Tail komorebi's process logs (cancel with Ctrl-C) Usage: komorebic log diff --git a/docs/cli/start.md b/docs/cli/start.md index 28714e45..144873d1 100644 --- a/docs/cli/start.md +++ b/docs/cli/start.md @@ -1,7 +1,7 @@ # start ``` -Start komorebi.exe as a background process +Start komorebi as a background process Usage: komorebic start [OPTIONS] diff --git a/docs/cli/stop.md b/docs/cli/stop.md index e35f982c..29a02cd4 100644 --- a/docs/cli/stop.md +++ b/docs/cli/stop.md @@ -1,7 +1,7 @@ # stop ``` -Stop the komorebi.exe process and restore all hidden windows +Stop the komorebi process and restore all hidden windows Usage: komorebic stop diff --git a/docs/cli/toggle-workspace-float-override.md b/docs/cli/toggle-workspace-float-override.md index 497630a9..a1a5b9ff 100644 --- a/docs/cli/toggle-workspace-float-override.md +++ b/docs/cli/toggle-workspace-float-override.md @@ -1,8 +1,7 @@ # toggle-workspace-float-override ``` -Enable or disable float override, which makes it so every new window opens in floating mode, for the currently focused workspace. If there was no override value set for the workspace previously it takes the opposite of the -global value +Enable or disable float override, which makes it so every new window opens in floating mode, for the currently focused workspace. If there was no override value set for the workspace previously it takes the opposite of the global value Usage: komorebic toggle-workspace-float-override diff --git a/docs/design.md b/docs/design.md new file mode 100644 index 00000000..f8ede5a9 --- /dev/null +++ b/docs/design.md @@ -0,0 +1,42 @@ +--- +hide: + - toc +--- + +## Description + +_komorebi_ only responds to operating system events and the messages it receives +on a dedicated socket. + +_komorebic_ is a CLI that writes messages on _komorebi_'s socket. + +_komorebi_ doesn't handle any keyboard or mouse inputs; a third party program ( +e.g. +[skhd](https://github.com/koekeishiya/skhd)) is needed in order to translate +keyboard and mouse events to _komorebic_ commands. + +This architecture, popularised by [_bspwm_](https://github.com/baskerville/bspwm) on Linux and +[_yabai_](https://github.com/koekeishiya/yabai) on macOS, is outlined as follows: + + +``` + PROCESS SOCKET +skhd --------> komorebic <------> komorebi +``` + +## Data Model + +_komorebi_ holds a list of physical monitors. + +A monitor is just a rectangle of the available work area which contains one or more virtual workspaces. + +A workspace holds a list of containers. + +A container is just a rectangle where one or more application windows can be displayed. + +This means that: + +- Every monitor has its own collection of virtual workspaces +- Workspaces only know about containers and their dimensions, not about individual application windows +- Every application window must belong to a container, even if that container only contains one application window +- Many application windows can be stacked and cycled through in the same container within a workspace diff --git a/docs/example-configurations.md b/docs/example-configurations.md new file mode 100644 index 00000000..f1562ac8 --- /dev/null +++ b/docs/example-configurations.md @@ -0,0 +1,166 @@ +`komorebi`, and tiling window managers in general, are very complex pieces of +software. + +In an attempt to reduce some of the initial configuration burden for users who +are looking to try out the software for the first time, example configurations +are provided and updated whenever appropriate. + +## Downloading example configurations + +Run the following command to download example configuration files for +`komorebi` and `skhd`. Pay attention to the output of the command to see where +the example files have been downloaded. For most new users this will be in the +`$HOME/.config/komorebi` directory. + +```bash +komorebic quickstart +``` + +With the example configurations downloaded, you can now start `komorebi` + +```powershell +komorebic start +``` + +## komorebi.json + +The example window manager configuration sets some sane defaults and provides +seven preconfigured workspaces on the primary monitor each with a different +layout. + +```json +{% include "./komorebi.example.json" %} +``` + +### Application-specific configuration + +There is a [community-maintained +repository](https://github.com/LGUG2Z/komorebi-application-specific-configuration) +of "apps behaving badly" that do not conform to macOS application development +guidelines and behave erratically when used with `komorebi` without additional +configuration. + +You can always download the latest version of these configurations by running +`komorebic fetch-asc`. The output of this command will also provide a line that +you can paste into `komorebi.json` to ensure that the window manager looks for +the file in the correction location. + +When installing and running `komorebi` for the first time, the `komorebic +quickstart` command will usually download this file to the `$HOME/.config/komorebi` +directory. + +### Padding + +While you can set the workspace padding (the space between the outer edges of +the windows and the bezel of your monitor) and the container padding (the space +between each of the tiled windows) for each workspace independently, you can +also set a default for both of these values that will apply to all workspaces +using `default_workspace_padding` and `default_container_padding`. + +### Layouts + +#### BSP + +``` ++-------+-----+ +| | | +| +--+--+ +| | |--| ++-------+--+--+ +``` + +#### Vertical Stack + +``` ++-------+-----+ +| | | +| +-----+ +| | | ++-------+-----+ +``` + +#### RightMainVerticalStack + +``` ++-----+-------+ +| | | ++-----+ | +| | | ++-----+-------+ +``` + +#### Horizontal Stack + +``` ++------+------+ +| | +|------+------+ +| | | ++------+------+ +``` + +#### Columns + +``` ++--+--+--+--+ +| | | | | +| | | | | +| | | | | ++--+--+--+--+ +``` + +#### Rows + +If you have a vertical monitor, I recommend using this layout. + +``` ++-----------+ +|-----------| +|-----------| +|-----------| ++-----------+ +``` + +#### Ultrawide Vertical Stack + +If you have an ultrawide monitor, I recommend using this layout. + +``` ++-----+-----------+-----+ +| | | | +| | +-----+ +| | | | +| | +-----+ +| | | | ++-----+-----------+-----+ +``` + +### Grid + +If you like the `grid` layout in [LeftWM](https://github.com/leftwm/leftwm-layouts) this is almost exactly the same! + +The `grid` layout does not support resizing windows tiles. + +``` ++-----+-----+ +---+---+---+ +---+---+---+ +---+---+---+ +| | | | | | | | | | | | | | | +| | | | | | | | | | | | | +---+ ++-----+-----+ | +---+---+ +---+---+---+ +---+---| | +| | | | | | | | | | | | | +---+ +| | | | | | | | | | | | | | | ++-----+-----+ +---+---+---+ +---+---+---+ +---+---+---+ + 4 windows 5 windows 6 windows 7 windows +``` + +## skhdrc + +`skhd` is a fairly basic piece of software with a simple configuration format: +key bindings go to the left of the colon, and shell commands go to the right of the +colon. + +``` +{% include "./skhdrc.sample" %} +``` + +You can try the example komorebi configuration by running +`skhd --config ~/.config/komorebi/skhdrc`. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..9992b799 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,76 @@ +![screenshot](https://user-images.githubusercontent.com/13164844/184027064-f5a6cec2-2865-4d65-a549-a1f1da589abf.png) + +## Overview + +`komorebi` is a tiling window manager that works as an extension to macOS. + +`komorebi` allows you to control application windows, virtual workspaces and +display monitors with a CLI which can be used with third-party software such as +[skhd](https://github.com/koekeishiya/skhd) to set user-defined +keyboard shortcuts. + +`komorebi` aims to make _as few modifications as possible_ to the operating +system and desktop environment by default. Users are free to make such +modifications in their own configuration files for `komorebi`, but these will +always remain opt-in and off-by-default. + +## Community + +There is a [Discord server](https://discord.gg/mGkn66PHkx) available for +`komorebi`-related discussion, help, troubleshooting etc. + +There is a [YouTube +channel](https://www.youtube.com/channel/UCeai3-do-9O4MNy9_xjO6mg) where I post +`komorebi` development videos, feature previews and release overviews. Subscribing +to the channel (which is monetized as part of the YouTube Partner Program) and +watching videos is a really simple and passive way to contribute financially to +the development and maintenance of `komorebi`. + +There is an [Awesome List](https://github.com/LGUG2Z/awesome-komorebi) which +showcases the many awesome projects that exist in the `komorebi` ecosystem. + +## Licensing for Personal Use + +`komorebi` is licensed under the [Komorebi 2.0.0 license](https://github.com/LGUG2Z/komorebi-license), which is a fork +of the [PolyForm Strict 1.0.0 license](https://polyformproject.org/licenses/strict/1.0.0). On a high level this means +that you are free to do whatever you want with `komorebi` for personal use other than redistribution, or distribution of +new works (i.e. hard-forks) based on the software. + +Anyone is free to make their own fork of `komorebi` with changes intended either for personal use or for integration +back upstream via pull requests. + +The [Komorebi 2.0.0 License](https://github.com/LGUG2Z/komorebi-license) does not permit any kind of commercial use ( +i.e. using `komorebi` at work). + +## Sponsorship for Personal Use + +`komorebi` is a free and educational source project, and one that encourages you +to make charitable donations if you find the software to be useful and have the +financial means. + +I encourage you to make a charitable donation to the [Palestine Children's +Relief Fund](https://pcrf1.app.neoncrm.com/forms/gaza-recovery) or to contribute +to a [Gaza Funds campaign](https://gazafunds.com) before you consider sponsoring +me on GitHub. + +[GitHub Sponsors is enabled for this +project](https://github.com/sponsors/LGUG2Z). Sponsors can claim custom roles on +the Discord server, get shout-outs at the end of _komorebi_-related videos on +YouTube, and gain the ability to submit feature requests on the issue tracker. + +If you would like to tip or sponsor the project but are unable to use GitHub +Sponsors, you may also sponsor through [Ko-fi](https://ko-fi.com/lgug2z), or +make an anonymous Bitcoin donation to `bc1qv73wzspc77k46uty4vp85x8sdp24mphvm58f6q`. + +## Licensing for Commercial Use + +A dedicated Individual Commercial Use License is available for those who want to +use `komorebi` at work. + +The Individual Commerical Use License adds “Commercial Use” as a “Permitted Use” +for the licensed individual only, for the duration of a valid paid license +subscription only. All provisions and restrictions enumerated in the [Komorebi +License](https://github.com/LGUG2Z/komorebi-license) continue to apply. + +More information, pricing and purchase links for Individual Commercial Use +Licenses [can be found here](https://lgug2z.com/software/komorebi). diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 00000000..14075266 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,60 @@ +# Getting started + +`komorebi` is a tiling window manager for macOS that is comprised of two +main binaries, `komorebi`, which contains the window manager itself, +and `komorebic`, which is the main way to send commands to the tiling +window manager. + +It is important to note that neither `komorebi` nor `komorebic` handle +key bindings, because `komorebi` is a tiling window manager and not a hotkey +daemon. + +This getting started guide suggests the installation of +[`skhd`](https://github.com/koekeishiya/skhd) to allow you to bind `komorebic` +commands to hotkeys to allow you to communicate with the tiling window manager +using keyboard shortcuts. + +## Installation + +At this time users must compile `komorebi` from source. + +## Building from source + +Make sure you have installed [`rustup`](https://rustup.rs), and a stable `rust` +compiler toolchain. + +Clone the git repository, enter the directory, and build the following binaries: + +```powershell +cargo +stable install --path komorebi --locked --target-dir ~/.cargo/bin +cargo +stable install --path komorebic --locked --target-dir ~/.cargo/bin +``` + +If the binaries have been built and added to your `$PATH` correctly, you should +see some output when running `komorebi --help` and `komorebic --help` + +## Granting Permissions + +Users will need to manually add `~/.cargo/bin/komorebi` to: + +* Settings -> Privacy & Security -> Accessibility +* Settings -> Privacy & Security -> Screen & System Audio Recording + +Once komorebi is installed, and these permissions have been granted, proceed to +get the [example +configurations](example-configurations.md). + +## Uninstallation + +Before uninstalling, first run `komorebic stop` to make sure that +the `komorebi` processes have been stopped. + +Finally, you can run the following commands to clean up files created by the +`quickstart` command and any other runtime files: + +```powershell +rm -rf ~/.cargo/bin/komorebi +rm -rf ~/.cargo/bin/komorebic +rm -rf ~/.config/komorebi +rm -rf "~/Library/Application Support/komorebi" +``` diff --git a/docs/known-issues.md b/docs/known-issues.md new file mode 100644 index 00000000..fc89afcc --- /dev/null +++ b/docs/known-issues.md @@ -0,0 +1,8 @@ +* The flow for manually adding Accessibility and Screen Recording permissions + sucks +* Mouse resizing is not implemented +* Swapping window containers via mouse dragging is not implemented +* Fullscreen windows aren't supported (and probably won't be) and break the + state (probably shouldn't) +* Application hiding isn't supported (and probably won't be) and breaks the + state (probably shouldn't) diff --git a/docs/usage/focusing-windows.md b/docs/usage/focusing-windows.md new file mode 100644 index 00000000..f16d9cf8 --- /dev/null +++ b/docs/usage/focusing-windows.md @@ -0,0 +1,46 @@ +# Focusing Windows + +Windows can be focused in a direction (left, down, up, right) using the [`komorebic focus`](../cli/focus.md) command. + +``` +# example showing how you might bind this command + +alt + h : komorebic focus left +alt + j : komorebic focus down +alt + k : komorebic focus up +alt + l : komorebic focus right +``` + +Windows can be focused in a cycle direction (previous, next) using the [`komorebic cycle-focus`](../cli/cycle-focus.md) +command. + +``` +# example showing you might bind this command + +alt + shift + oem_4 : komorebic cycle-focus previous # oem_4 is [ +alt + shift + oem_6 : komorebic cycle-focus next # oem_6 is ] +``` + +It is possible to attempt to focus the first window, on any workspace, matching an exe using the [ +`komorebic eager-focus`](../cli/eager-focus.md) command. + +``` +# example showing how you might bind this command + +win + 1 : komorebic eager-focus firefox.exe +``` + +The window at the largest tile can be focused using the [`komorebic promote-focus`](../cli/promote-focus.md) command. + +``` +# example showing how you might bind this command + +alt + return : komorebic promote-focus +``` + +The behaviour when attempting to call `komorebic focus` when at the left or right edge of a monitor is determined by +the [`cross_boundary_behaviour`](https://komorebi.lgug2z.com/schema#cross_boundary_behaviour) configuration option. + +When set to `Workspace`, the next workspace on the same monitor will be focused. + +When set to `Monitor`, the focused workspace on the next monitor in the given direction will be focused. \ No newline at end of file diff --git a/docs/usage/focusing-workspaces.md b/docs/usage/focusing-workspaces.md new file mode 100644 index 00000000..26bceaef --- /dev/null +++ b/docs/usage/focusing-workspaces.md @@ -0,0 +1,59 @@ +# Focusing Workspaces + +Workspaces on the focused monitor can be focused by their index using the [ +`komorebic focus-workspace`](../cli/focus-workspace.md) command. + +If this command is called with an index for a workspace which does not exist, that workspace, and all workspace indexes +required to get to that workspace, will be created. + +``` +# example showing how you might bind this command + +alt + 1 : komorebic focus-workspace 0 +alt + 2 : komorebic focus-workspace 1 +alt + 3 : komorebic focus-workspace 2 +``` + +Workspaces on the focused monitor can be focused in a cycle direction (previous, next) using the [ +`komorebic cycle-workspace`](../cli/cycle-workspace.md) command. + +``` +# example showing how you might bind this command + +alt + shift + oem_4 : komorebic cycle-workspace previous # oem_4 is [ +alt + shift + oem_6 : komorebic cycle-workspace next # oem_6 is ] +``` + +Workspaces on other monitors can be focused by both the monitor index and the workspace index using the [ +`komorebic focus-monitor-workspace`](../cli/focus-monitor-workspace.md) command. + +``` +# example showing how you might bind this command + +alt + 1 : komorebic focus-monitor-workspace 0 0 +alt + 2 : komorebic focus-monitor-workspace 0 1 +alt + 3 : komorebic focus-monitor-workspace 1 0 +``` + +Workspaces on any monitor can be focused by their name (given that all workspace names across all monitors are unique) +using the [`komorebic focus-named-workspace`](../cli/focus-named-workspace.md) command. + +``` +# example showing how you might bind this command + +alt + c : komorebic focus-named-workspace coding +``` + +Workspaces on all monitors can be set to the same index (emulating single workspaces which span across all monitors) +using the [`komorebic focus-workspaces`](../cli/focus-workspaces.md) command. + +``` +# example showing how you might bind this command + +alt + 1 : komorebic focus-workspaces 0 +alt + 2 : komorebic focus-workspaces 1 +alt + 3 : komorebic focus-workspaces 2 +``` + +The last focused workspace on the focused monitor can be re-focused using the [ +`komorebic focus-last-workspace`](../cli/focus-last-workspace.md) command. diff --git a/docs/usage/moving-windows-across-workspaces.md b/docs/usage/moving-windows-across-workspaces.md new file mode 100644 index 00000000..31249517 --- /dev/null +++ b/docs/usage/moving-windows-across-workspaces.md @@ -0,0 +1,59 @@ +# Moving Windows Across Workspaces + +Windows can be moved to another workspace on the focused monitor using the [ +`komorebic move-to-workspace`](../cli/move-to-workspace.md) command. This command will also move your focus to the +target workspace. + +``` +# example showing how you might bind this command + +alt + shift + 1 : komorebic move-to-workspace 0 +alt + shift + 2 : komorebic move-to-workspace 1 +alt + shift + 3 : komorebic move-to-workspace 2 +``` + +Windows can be sent to another workspace on the focused monitor using the [ +`komorebic send-to-workspace`](../cli/send-to-workspace.md) command. This command will keep your focus on the origin +workspace. + +``` +# example showing how you might bind this command + +alt + shift + 1 : komorebic send-to-workspace 0 +alt + shift + 2 : komorebic send-to-workspace 1 +alt + shift + 3 : komorebic send-to-workspace 2 +``` + +Windows can be moved to another workspace on the focused monitor in a cycle direction (previous, next) using the [ +`komorebic cycle-move-to-workspace`](../cli/cycle-move-to-workspace.md) command. This command will also move your focus +to the target workspace. + +``` +# example showing how you might bind this command + +alt + shift + oem_4 : komorebic cycle-move-to-workspace previous # oem_4 is [ +alt + shift + oem_6 : komorebic cycle-move-to-workspace next # oem_6 is ] +``` + +Windows can be sent to another workspace on the focused monitor in a cycle direction (previous, next) using the [ +`komorebic cycle-move-to-workspace`](../cli/cycle-move-to-workspace.md) command. This command will keep your focus on +the origin workspace. + +``` +# example showing how you might bind this command + +alt + shift + oem_4 : komorebic cycle-send-to-workspace previous # oem_4 is [ +alt + shift + oem_6 : komorebic cycle-send-to-workspace next # oem_6 is ] +``` + +Windows can be moved or sent to the focused workspace on a another monitor using the [ +`komorebic move-to-monitor`](../cli/move-to-monitor.md) and [`komorebic send-to-monitor`](../cli/send-to-monitor.md) +commands. + +Windows can be moved or sent to the focused workspace on a monitor in a cycle direction (previous, next) using the [ +`komorebic cycle-move-to-monitor`](../cli/cycle-move-to-monitor.md) and [ +`komorebic cycle-send-to-monitor`](../cli/cycle-send-to-monitor.md) commands. + +Windows can be moved or sent to a named workspace on any monitor (given that all workspace names across all monitors are +unique) using the [`komorebic move-to-named-workspace`](../cli/move-to-named-workspace.md) and [ +`komorebic send-to-named-workspace`](../cli/send-to-named-workspace.md) commands diff --git a/docs/usage/moving-windows.md b/docs/usage/moving-windows.md new file mode 100644 index 00000000..1ca5e816 --- /dev/null +++ b/docs/usage/moving-windows.md @@ -0,0 +1,50 @@ +# Moving Windows + +Windows can be moved in a direction (left, down, up, right) using the [`komorebic move`](../cli/move.md) command. + +``` +# example showing how you might bind this command + +alt + shift + h : komorebic move left +alt + shift + j : komorebic move down +alt + shift + k : komorebic move up +alt + shift + l : komorebic move right +``` + +Windows can be moved in a cycle direction (previous, next) using the [`komorebic cycle-move`](../cli/cycle-move.md) +command. + +``` +# example showing how you might bind this command + +alt + shift + oem_4 : komorebic cycle-move previous # oem_4 is [ +alt + shift + oem_6 : komorebic cycle-move next # oem_6 is ] +``` + +The focused window can be moved to the largest tile using the [`komorebic promote`](../cli/promote.md) command. + +``` +# example showing how you might bind this command + +alt + shift + return : komorebic promote +``` + +The behaviour when attempting to call `komorebic move` when at the left or right edge of a monitor is determined by +the [`cross_boundary_behaviour`](https://komorebi.lgug2z.com/schema#cross_boundary_behaviour) configuration option. + +When set to `Workspace`, the focused window will be moved to the next workspace on the focused monitor in the given +direction + +When set to `Monitor`, the focused window will be moved to the focused workspace on the next monitor in the given +direction. + +The behaviour when calling `komorebic move` with `cross_boundary_behaviour` set to `Monitor` can be further refined with +the [`cross_monitor_move_behaviour`](https://komorebi.lgug2z.com/schema#cross_monitor_move_behaviour) configuration +option. + +When set to `Swap`, the focused window will be swapped with the window at the corresponding edge of the adjacent monitor + +When set to `Insert`, the focused window will be inserted into the focused workspace on the adjacent monitor. + +When set to `NoOp`, the focused window will not be moved across a monitor boundary, though focusing across monitor +boundaries will continue to function. \ No newline at end of file diff --git a/docs/usage/stacking-windows.md b/docs/usage/stacking-windows.md new file mode 100644 index 00000000..7d689981 --- /dev/null +++ b/docs/usage/stacking-windows.md @@ -0,0 +1,52 @@ +# Stacking Windows + +Windows can be stacked in a direction (left, down, up, right) using the [`komorebic stack`](../cli/stack.md) command. + +``` +# example showing how you might bind this command + +alt + left : komorebic stack left +alt + down : komorebic stack down +alt + up : komorebic stack up +alt + right : komorebic stack right +``` + +Windows can be popped from a stack using the [`komorebic unstack`](../cli/unstack.md) command. + +``` +# example showing how you might bind this command + +alt + oem_1 : komorebic unstack # oem_1 is ; +``` + +Windows in a stack can be focused in a cycle direction (previous, next) using the [ +`komorebic cycle-stack`](../cli/cycle-stack.md) command. + +``` +# example showing how you might bind this command + +alt + oem_4 : komorebic cycle-stack previous # oem_4 is [ +alt + oem_6 : komorebic cycle-stack next # oem_6 is ] +``` + +Windows in a stack can have their positions in the stack moved in a cycle direction (previous, next) using the [ +`komorebic cycle-stack-index`](../cli/cycle-stack-index.md) command. + +``` +# example showing how you might bind this command + +alt + shift + oem_4 : komorebic cycle-stack-index previous # oem_4 is [ +alt + shift + oem_6 : komorebic cycle-stack-index next # oem_6 is ] +``` + +Windows in a stack can be focused by their index in the stack using the [ +`komorebic focus-stack-window`](../cli/focus-stack-window.md) command. + +All windows on the focused workspace can be combined into a single stack using the [ +`komorebic stack-all`](../cli/stack-all.md) command. + +All windows in a focused stack can be popped using the [`komorebic unstack-all`](../cli/unstack-all.md) command. + +It is possible to tell the window manager to stack the next opened window on top of the currently focused window by +using the [ +`komorebic toggle-workspace-window-container-behaviour`](../cli/toggle-workspace-window-container-behaviour.md) command. diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 57bd0e70..5e219889 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -623,9 +623,9 @@ enum SubCommand { Docgen, /// Gather example configurations for a new-user quickstart Quickstart, - /// Start komorebi.exe as a background process + /// Start komorebi as a background process Start(Start), - /// Stop the komorebi.exe process and restore all hidden windows + /// Stop the komorebi process and restore all hidden windows Stop(Stop), // /// Kill background processes started by komorebic // Kill(Kill), @@ -641,7 +641,7 @@ enum SubCommand { // /// Show the path to whkdrc // #[clap(alias = "whkd")] // Whkdrc, - /// Show the path to komorebi's data directory in %LOCALAPPDATA% + /// Show the path to komorebi's data directory in $HOME/Library/Application Support #[clap(alias = "datadir")] DataDirectory, /// Show a JSON representation of the current window manager state @@ -674,7 +674,7 @@ enum SubCommand { // #[clap(arg_required_else_help = true)] // #[clap(alias = "unsubscribe")] // UnsubscribePipe(UnsubscribePipe), - /// Tail komorebi.exe's process logs (cancel with Ctrl-C) + /// Tail komorebi's process logs (cancel with Ctrl-C) Log, /// Quicksave the current resize layout dimensions #[clap(alias = "quick-save")] @@ -708,7 +708,7 @@ enum SubCommand { /// Move the focused window in the specified cycle direction #[clap(arg_required_else_help = true)] CycleMove(CycleMove), - /// Focus the first managed window matching the given exe + /// Focus the first managed window matching the given executable #[clap(arg_required_else_help = true)] EagerFocus(EagerFocus), /// Stack the focused window in the specified direction diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..5c01fb8e --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,201 @@ +copyright: Copyright © 2020-Present LGUG2Z +use_directory_urls: false +site_name: Komorebi for macOS +site_description: The Tiling Window Manager for macOS +repo_url: https://github.com/LGUG2Z/komorebi-for-mac +repo_name: LGUG2Z/komorebi-for-mac +docs_dir: docs +theme: + name: material + palette: + - media: "(prefers-color-scheme: light)" + scheme: default + primary: deep purple + accent: deep purple + toggle: + icon: material/weather-sunny + name: Switch to dark mode + + # Palette toggle for dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: deep purple + accent: purple + toggle: + icon: material/weather-night + name: Switch to light mode + features: + - content.action.edit + - content.action.view + - content.code.copy + - content.tabs.link + - navigation.footer + - navigation.indexes + - navigation.sections + - navigation.tabs + - navigation.top + - navigation.tracking + - search.highlight + - search.share + - search.suggest + - toc.follow +markdown_extensions: + - admonition + - pymdownx.highlight + - pymdownx.superfences +plugins: + - macros + - search + +nav: + - Komorebi: + - About: + - index.md + - design.md + - Getting started: + - Installation: installation.md + - Example configurations: example-configurations.md + - Known issues: known-issues.md + - Usage: + - usage/focusing-windows.md + - usage/moving-windows.md + - usage/stacking-windows.md + - usage/focusing-workspaces.md + - usage/moving-windows-across-workspaces.md + - Komorebi Configuration: + - Schema: https://komorebi.lgug2z.com/schema + - CLI reference: + - cli/quickstart.md + - cli/start.md + - cli/stop.md + - cli/configuration.md + - cli/data-directory.md + - cli/state.md + - cli/global-state.md + - cli/visible-windows.md + - cli/monitor-information.md + - cli/query.md + - cli/subscribe-socket.md + - cli/unsubscribe-socket.md + - cli/log.md + - cli/quick-save-resize.md + - cli/quick-load-resize.md + - cli/save-resize.md + - cli/load-resize.md + - cli/focus.md + - cli/move.md + - cli/minimize.md + - cli/close.md + - cli/cycle-focus.md + - cli/cycle-move.md + - cli/eager-focus.md + - cli/stack.md + - cli/unstack.md + - cli/cycle-stack.md + - cli/cycle-stack-index.md + - cli/focus-stack-window.md + - cli/stack-all.md + - cli/unstack-all.md + - cli/resize-edge.md + - cli/resize-axis.md + - cli/move-to-monitor.md + - cli/cycle-move-to-monitor.md + - cli/move-to-workspace.md + - cli/move-to-named-workspace.md + - cli/cycle-move-to-workspace.md + - cli/send-to-monitor.md + - cli/cycle-send-to-monitor.md + - cli/send-to-workspace.md + - cli/send-to-named-workspace.md + - cli/cycle-send-to-workspace.md + - cli/send-to-monitor-workspace.md + - cli/move-to-monitor-workspace.md + - cli/send-to-last-workspace.md + - cli/move-to-last-workspace.md + - cli/focus-monitor.md + - cli/focus-monitor-at-cursor.md + - cli/focus-last-workspace.md + - cli/focus-workspace.md + - cli/focus-workspaces.md + - cli/focus-monitor-workspace.md + - cli/focus-named-workspace.md + - cli/close-workspace.md + - cli/cycle-monitor.md + - cli/cycle-workspace.md + - cli/cycle-empty-workspace.md + - cli/move-workspace-to-monitor.md + - cli/cycle-move-workspace-to-monitor.md + - cli/swap-workspaces-with-monitor.md + - cli/new-workspace.md + - cli/resize-delta.md + - cli/global-work-area-offset.md + - cli/monitor-work-area-offset.md + - cli/workspace-work-area-offset.md + - cli/toggle-window-based-work-area-offset.md + - cli/focused-workspace-container-padding.md + - cli/focused-workspace-padding.md + - cli/adjust-container-padding.md + - cli/adjust-workspace-padding.md + - cli/change-layout.md + - cli/cycle-layout.md + - cli/scrolling-layout-columns.md + - cli/flip-layout.md + - cli/promote.md + - cli/promote-focus.md + - cli/promote-window.md + - cli/retile.md + - cli/display-index-preference.md + - cli/ensure-workspaces.md + - cli/ensure-named-workspaces.md + - cli/container-padding.md + - cli/named-workspace-container-padding.md + - cli/workspace-padding.md + - cli/named-workspace-padding.md + - cli/workspace-layout.md + - cli/named-workspace-layout.md + - cli/workspace-layout-rule.md + - cli/named-workspace-layout-rule.md + - cli/clear-workspace-layout-rules.md + - cli/clear-named-workspace-layout-rules.md + - cli/workspace-tiling.md + - cli/named-workspace-tiling.md + - cli/workspace-name.md + - cli/toggle-window-container-behaviour.md + - cli/toggle-float-override.md + - cli/toggle-workspace-window-container-behaviour.md + - cli/toggle-workspace-float-override.md + - cli/toggle-workspace-layer.md + - cli/toggle-pause.md + - cli/toggle-tiling.md + - cli/toggle-float.md + - cli/toggle-monocle.md + - cli/toggle-lock.md + - cli/manage.md + - cli/unmanage.md + - cli/replace-configuration.md + - cli/cross-monitor-move-behaviour.md + - cli/toggle-cross-monitor-move-behaviour.md + - cli/unmanaged-window-operation-behaviour.md + - cli/session-float-rule.md + - cli/session-float-rules.md + - cli/clear-session-float-rules.md + - cli/ignore-rule.md + - cli/manage-rule.md + - cli/initial-workspace-rule.md + - cli/initial-named-workspace-rule.md + - cli/workspace-rule.md + - cli/named-workspace-rule.md + - cli/clear-workspace-rules.md + - cli/clear-named-workspace-rules.md + - cli/clear-all-workspace-rules.md + - cli/enforce-workspace-rules.md + - cli/mouse-follows-focus.md + - cli/toggle-mouse-follows-focus.md + - cli/fetch-app-specific-configuration.md + - cli/application-specific-configuration-schema.md + - cli/notification-schema.md + - cli/socket-schema.md + - cli/static-config-schema.md + - cli/generate-static-config.md + - cli/enable-autostart.md + - cli/disable-autostart.md \ No newline at end of file diff --git a/shell.nix b/shell.nix index 110aaf91..f0cd3500 100644 --- a/shell.nix +++ b/shell.nix @@ -6,13 +6,18 @@ with pkgs; RUST_BACKTRACE = "full"; buildInputs = [ - just - gcc - libiconv - cargo-deny - jq - prettier - cargo-udeps alejandra + cargo-deny + cargo-udeps + gcc + jq + just + libiconv + prettier + + python311Packages.mkdocs-material + python311Packages.mkdocs-macros + python311Packages.setuptools + python311Packages.json-schema-for-humans ]; } From 69909df2f59a5712cec492df0f18a972ac7b6a96 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 09:22:32 -0700 Subject: [PATCH 079/305] fix(wm): avoid display notification spam Looks like macOS spams every single possible CGDisplayChangeSummaryFlag whenever a display is added or removed, which ends up with a lot of calls to the monitor reconciliator and a lot of locks on the wm state. To better handle the spam this commit ensures we only send monitor reconciliation notifications on the DesktopShapeChanged, Add and Remove flags. --- .../src/display_reconfiguration_listener.rs | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/komorebi/src/display_reconfiguration_listener.rs b/komorebi/src/display_reconfiguration_listener.rs index 0056d3a5..acf1f042 100644 --- a/komorebi/src/display_reconfiguration_listener.rs +++ b/komorebi/src/display_reconfiguration_listener.rs @@ -32,27 +32,27 @@ unsafe extern "C-unwind" fn callback( )); } - if flags.contains(CGDisplayChangeSummaryFlags::EnabledFlag) { - tracing::debug!("display: {display_id} enabled"); - monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( - display_id, - )); - } - - if flags.contains(CGDisplayChangeSummaryFlags::DisabledFlag) { - tracing::debug!("display: {display_id} disabled"); - monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( - display_id, - )); - } - - if flags.contains(CGDisplayChangeSummaryFlags::MovedFlag) { - tracing::debug!("display: {display_id} moved"); - monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( - display_id, - )); - } - + // if flags.contains(CGDisplayChangeSummaryFlags::EnabledFlag) { + // tracing::debug!("display: {display_id} enabled"); + // monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + // display_id, + // )); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::DisabledFlag) { + // tracing::debug!("display: {display_id} disabled"); + // monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + // display_id, + // )); + // } + // + // if flags.contains(CGDisplayChangeSummaryFlags::MovedFlag) { + // tracing::debug!("display: {display_id} moved"); + // monitor_reconciliator::send_notification(MonitorNotification::DisplayConnectionChange( + // display_id, + // )); + // } + // // if flags.contains(CGDisplayChangeSummaryFlags::BeginConfigurationFlag) { // tracing::debug!("display: {display_id} configured"); // } From fb416e75fd5ecb0b718df59565e8889da91c63e1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 10:55:04 -0700 Subject: [PATCH 080/305] feat(wm): implement move resizing and moving This commit implements moving and resizing by mouse as it works in komorebi for Windows. We're able to make this a bit nicer here because macOS emits separate events for resizing and movement, so now we have MoveStart/MoveEnd and ResizeStart/ResizeEnd. Resizing is a little janky because the system does not update the position of resized windows quickly enough, so if you do a quick drag and release the left mouse button, sometimes the accessibility attributes for the size and position of that window won't have been updated, and no resize will take place. --- docs/known-issues.md | 2 - komorebi/src/macos_api.rs | 12 +- komorebi/src/process_event.rs | 314 +++++++++++++++++++++++++++ komorebi/src/static_config.rs | 2 + komorebi/src/window_manager.rs | 170 +++++++++++++++ komorebi/src/window_manager_event.rs | 56 ++++- komorebi/src/workspace.rs | 21 ++ 7 files changed, 568 insertions(+), 9 deletions(-) diff --git a/docs/known-issues.md b/docs/known-issues.md index fc89afcc..da251eb0 100644 --- a/docs/known-issues.md +++ b/docs/known-issues.md @@ -1,7 +1,5 @@ * The flow for manually adding Accessibility and Screen Recording permissions sucks -* Mouse resizing is not implemented -* Swapping window containers via mouse dragging is not implemented * Fullscreen windows aren't supported (and probably won't be) and break the state (probably shouldn't) * Application hiding isn't supported (and probably won't be) and breaks the diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 8f981eca..0278e111 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -32,6 +32,9 @@ use objc2_core_foundation::CFString; use objc2_core_foundation::CGPoint; use objc2_core_foundation::CGRect; use objc2_core_foundation::CGSize; +use objc2_core_graphics::CGEvent; +use objc2_core_graphics::CGEventSource; +use objc2_core_graphics::CGEventSourceStateID; use objc2_core_graphics::CGMainDisplayID; use objc2_foundation::NSNumber; use std::collections::HashMap; @@ -398,12 +401,17 @@ impl MacosApi { pub fn cursor_pos() -> CGPoint { unsafe { - let point = NSEvent::mouseLocation(); - CGPoint::new(point.x, point.y) + let source = CGEventSource::new(CGEventSourceStateID::HIDSystemState); + let event = CGEvent::new(source.as_deref()); + CGEvent::location(event.as_deref()) } } pub fn monitor_from_point(point: CGPoint) -> Option { CoreGraphicsApi::display_with_point(point) } + + pub fn left_mouse_button_is_pressed() -> bool { + (unsafe { NSEvent::pressedMouseButtons() } & 0x1 != 0) + } } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index e86cca7d..cb6b0418 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -10,10 +10,13 @@ use crate::accessibility::error::AccessibilityApiError; use crate::accessibility::error::AccessibilityError; use crate::accessibility::notification_constants::AccessibilityNotification; use crate::app_kit_notification_constants::AppKitWorkspaceNotification; +use crate::core::Sizing; use crate::core::WindowContainerBehaviour; use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; +use crate::core::operation_direction::OperationDirection; +use crate::core::rect::Rect; use crate::macos_api::MacosApi; use crate::notify_subscribers; use crate::state::State; @@ -594,6 +597,317 @@ impl WindowManager { } } } + WindowManagerEvent::MoveStart(_, _, window_id) => { + if self.pending_move_op.is_none() && self.pending_resize_op.is_none() { + let monitor_idx = self.focused_monitor_idx(); + let workspace_idx = self + .focused_monitor() + .ok_or_eyre("there is no monitor with this idx")? + .focused_workspace_idx(); + + let pending_move_op = Arc::make_mut(&mut self.pending_move_op); + *pending_move_op = Option::from((monitor_idx, workspace_idx, window_id)); + } + } + WindowManagerEvent::MoveEnd(_, _, window_id) => { + // We need this because if the event ends on a different monitor, + // that monitor will already have been focused and updated in the state + let pending = *self.pending_move_op; + // Always consume the pending move op whenever this event is handled + let pending_move_op = Arc::make_mut(&mut self.pending_move_op); + *pending_move_op = None; + + if let Some((origin_monitor_idx, origin_workspace_idx, wid)) = pending { + // If the window handles don't match then something went wrong and the pending move + // is not related to this current move, if so abort this operation. + if wid != window_id { + eyre::bail!( + "window handles for move operation don't match: {} != {}", + wid, + window_id + ); + } + let known_window_ids = self.known_window_ids.clone(); + + let target_monitor_idx = self + .monitor_idx_from_current_pos() + .ok_or_eyre("cannot get monitor idx from current position")?; + + let focused_monitor_idx = self.focused_monitor_idx(); + let focused_workspace_idx = self.focused_workspace_idx().unwrap_or_default(); + let window_management_behaviour = self + .window_management_behaviour(focused_monitor_idx, focused_workspace_idx); + + let workspace = self.focused_workspace_mut()?; + let focused_container_idx = workspace.focused_container_idx(); + + if let Some(container) = workspace.focused_container() + && let Some(window) = container.focused_window() + { + // TODO: not sure about this clone + let window = window.clone(); + let new_position = Rect::from(MacosApi::window_rect(&window.element)?); + let old_position = *workspace + .latest_layout + .get(focused_container_idx) + // If the move was to another monitor with an empty workspace, the + // workspace here will refer to that empty workspace, which won't + // have any latest layout set. We fall back to a Default for Rect + // which allows us to make a reasonable guess that the drag has taken + // place across a monitor boundary to an empty workspace + .unwrap_or(&Rect::default()); + + // This will be true if we have moved to another monitor + let mut moved_across_monitors = false; + + if let Some((m_idx, _)) = known_window_ids.get(&window_id) + && *m_idx != target_monitor_idx + { + moved_across_monitors = true; + } + + // If we didn't move to another monitor with an empty workspace, it is + // still possible that we moved to another monitor with a populated workspace + if !moved_across_monitors { + // So we'll check if the origin monitor index and the target monitor index + // are different, if they are, we can set the override + moved_across_monitors = origin_monitor_idx != target_monitor_idx; + + if moved_across_monitors { + // Want to make sure that we exclude unmanaged windows from cross-monitor + // moves with a mouse, otherwise the currently focused idx container will + // be moved when we just want to drag an unmanaged window + let origin_workspace = self + .monitors() + .get(origin_monitor_idx) + .ok_or_eyre("cannot get monitor idx")? + .workspaces() + .get(origin_workspace_idx) + .ok_or_eyre("cannot get workspace idx")?; + + let managed_window = origin_workspace.contains_window(window_id); + + if !managed_window { + moved_across_monitors = false; + } + } + } + + let workspace = self.focused_workspace_mut()?; + if (workspace.tile && workspace.contains_managed_window(window_id)) + || moved_across_monitors + { + let resize = Rect { + left: new_position.left - old_position.left, + top: new_position.top - old_position.top, + right: new_position.right - old_position.right, + bottom: new_position.bottom - old_position.bottom, + }; + + // If we have moved across the monitors, use that override, otherwise determine + // if a move has taken place by ruling out a resize + let right_bottom_constant = 0; + + let is_move = moved_across_monitors + || resize.right.abs() == right_bottom_constant + && resize.bottom.abs() == right_bottom_constant; + + if is_move { + tracing::info!("moving with mouse"); + + if moved_across_monitors { + if let Some(( + origin_monitor_idx, + origin_workspace_idx, + w_hwnd, + )) = pending + { + let target_workspace_idx = self + .monitors() + .get(target_monitor_idx) + .ok_or_eyre("there is no monitor at this idx")? + .focused_workspace_idx(); + + let target_container_idx = self + .monitors() + .get(target_monitor_idx) + .ok_or_eyre("there is no monitor at this idx")? + .focused_workspace() + .ok_or_eyre( + "there is no focused workspace for this monitor", + )? + .container_idx_from_current_point() + // Default to 0 in the case of an empty workspace + .unwrap_or(0); + + let origin = + (origin_monitor_idx, origin_workspace_idx, w_hwnd); + let target = ( + target_monitor_idx, + target_workspace_idx, + target_container_idx, + ); + self.transfer_window(origin, target)?; + + // We want to make sure both the origin and target monitors are updated, + // so that we don't have ghost tiles until we force an interaction on + // the origin monitor's focused workspace + self.focus_monitor(origin_monitor_idx)?; + let origin_monitor = self + .monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("there is no monitor at this idx")?; + origin_monitor.focus_workspace(origin_workspace_idx)?; + self.update_focused_workspace(false, false)?; + + self.focus_monitor(target_monitor_idx)?; + let target_monitor = self + .monitors_mut() + .get_mut(target_monitor_idx) + .ok_or_eyre("there is no monitor at this idx")?; + target_monitor.focus_workspace(target_workspace_idx)?; + self.update_focused_workspace(false, false)?; + + // Make sure to give focus to the moved window again + window.focus(self.mouse_follows_focus)?; + } + } else if window_management_behaviour.float_override { + // TODO: unsure of this clone + workspace.floating_windows_mut().push_back(window); + self.update_focused_workspace(false, false)?; + } else { + match window_management_behaviour.current_behaviour { + WindowContainerBehaviour::Create => { + match workspace.container_idx_from_current_point() { + Some(target_idx) => { + workspace.swap_containers( + focused_container_idx, + target_idx, + ); + self.update_focused_workspace(false, false)?; + } + None => { + self.update_focused_workspace( + self.mouse_follows_focus, + false, + )?; + } + } + } + WindowContainerBehaviour::Append => { + match workspace.container_idx_from_current_point() { + Some(target_idx) => { + workspace + .move_window_to_container(target_idx)?; + self.update_focused_workspace(false, false)?; + } + None => { + self.update_focused_workspace( + self.mouse_follows_focus, + false, + )?; + } + } + } + } + } + } + } + } + } + } + WindowManagerEvent::ResizeStart(_, _, window_id) => { + let workspace = self.focused_workspace_mut()?; + if let Some(container) = workspace.focused_container() + && let Some(window) = container.focused_window() + { + let window = window.clone(); + let new_position = Rect::from(MacosApi::window_rect(&window.element)?); + + let pending_resize_op = Arc::make_mut(&mut self.pending_resize_op); + *pending_resize_op = Option::from((window_id, Some(new_position))); + } + } + WindowManagerEvent::ResizeEnd(_, _, window_id) => { + let pending = *self.pending_resize_op; + // Always consume the pending resize op whenever this event is handled + let pending_resize_op = Arc::make_mut(&mut self.pending_resize_op); + *pending_resize_op = None; + + if let Some((wid, Some(new_position))) = pending { + // If the window handles don't match then something went wrong and the pending resize + // is not related to this current resize, if so abort this operation. + if wid != window_id { + eyre::bail!( + "window handles for resize operation don't match: {} != {}", + wid, + window_id + ); + } + + let workspace = self.focused_workspace_mut()?; + let focused_container_idx = workspace.focused_container_idx(); + + if let Some(container) = workspace.focused_container() + && let Some(window) = container.focused_window() + { + let window = window.clone(); + + let old_position = *workspace + .latest_layout + .get(focused_container_idx) + .unwrap_or(&Rect::default()); + + let workspace = self.focused_workspace_mut()?; + if workspace.tile && workspace.contains_managed_window(window.id) { + let resize = Rect { + left: new_position.left - old_position.left, + top: new_position.top - old_position.top, + right: new_position.right - old_position.right, + bottom: new_position.bottom - old_position.bottom, + }; + + tracing::info!("resizing with mouse"); + let mut ops = vec![]; + + macro_rules! resize_op { + ($coordinate:expr, $comparator:tt, $direction:expr) => {{ + let adjusted = $coordinate * 2; + let sizing = if adjusted $comparator 0 { + Sizing::Decrease + } else { + Sizing::Increase + }; + + ($direction, sizing, adjusted.abs()) + }}; + } + + if resize.left != 0 { + ops.push(resize_op!(resize.left, >, OperationDirection::Left)); + } + + if resize.top != 0 { + ops.push(resize_op!(resize.top, >, OperationDirection::Up)); + } + + if resize.right != 0 && (resize.left == 0) { + ops.push(resize_op!(resize.right, <, OperationDirection::Right)); + } + + if resize.bottom != 0 && (resize.top == 0) { + ops.push(resize_op!(resize.bottom, <, OperationDirection::Down)); + } + + for (edge, sizing, delta) in ops { + self.resize_window(edge, sizing, delta, true)?; + } + + self.update_focused_workspace(false, false)?; + } + } + } + } } self.update_known_window_ids(); diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 268b17a5..b4eff49f 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -1159,6 +1159,8 @@ impl StaticConfig { hotwatch: Hotwatch::new()?, run_loop: CoreFoundationRunLoop(run_loop.clone()), minimized_windows: HashMap::new(), + pending_move_op: Arc::new(None), + pending_resize_op: Arc::new(None), already_moved_window_handles: Default::default(), known_window_ids: HashMap::new(), }; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 9d520e40..22ed3bdc 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -74,6 +74,8 @@ pub struct WindowManager { pub work_area_offset: Option, pub incoming_events: Receiver, pub minimized_windows: HashMap, + pub pending_move_op: Arc>, + pub pending_resize_op: Arc)>>, pub already_moved_window_handles: Arc>>, /// Maps each known window id to the (monitor, workspace) index pair managing it pub known_window_ids: HashMap, @@ -154,6 +156,8 @@ impl WindowManager { work_area_offset: None, incoming_events: incoming, minimized_windows: HashMap::new(), + pending_move_op: Arc::new(None), + pending_resize_op: Arc::new(None), already_moved_window_handles: Default::default(), known_window_ids: Default::default(), }) @@ -2959,4 +2963,170 @@ impl WindowManager { Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn transfer_window( + &mut self, + origin: (usize, usize, u32), + target: (usize, usize, usize), + ) -> eyre::Result<()> { + let (origin_monitor_idx, origin_workspace_idx, window_id) = origin; + let (target_monitor_idx, target_workspace_idx, target_container_idx) = target; + + let origin_workspace = self + .monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("cannot get monitor idx")? + .workspaces_mut() + .get_mut(origin_workspace_idx) + .ok_or_eyre("cannot get workspace idx")?; + + let origin_container_idx = origin_workspace + .container_for_window(window_id) + .and_then(|c| origin_workspace.containers().iter().position(|cc| cc == c)); + + if let Some(origin_container_idx) = origin_container_idx { + // Moving normal container window + self.transfer_container( + ( + origin_monitor_idx, + origin_workspace_idx, + origin_container_idx, + ), + ( + target_monitor_idx, + target_workspace_idx, + target_container_idx, + ), + )?; + } else if let Some(idx) = origin_workspace + .floating_windows() + .iter() + .position(|w| w.id == window_id) + { + // Moving floating window + // There is no need to physically move the floating window between areas with + // `move_to_area` because the user already did that, so we only need to transfer the + // window to the target `floating_windows` + if let Some(floating_window) = origin_workspace.floating_windows_mut().remove(idx) { + let target_workspace = self + .monitors_mut() + .get_mut(target_monitor_idx) + .ok_or_eyre("there is no monitor at this idx")? + .focused_workspace_mut() + .ok_or_eyre("there is no focused workspace for this monitor")?; + + target_workspace + .floating_windows_mut() + .push_back(floating_window); + } + } else if origin_workspace + .monocle_container + .as_ref() + .and_then(|monocle| monocle.focused_window().map(|w| w.id == window_id)) + .unwrap_or_default() + { + // Moving monocle container + if let Some(monocle_idx) = origin_workspace.monocle_container_restore_idx { + let origin_workspace = self + .monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("there is no monitor at this idx")? + .workspaces_mut() + .get_mut(origin_workspace_idx) + .ok_or_eyre("there is no workspace for this monitor")?; + + for container in origin_workspace.containers_mut() { + container.restore()?; + } + + origin_workspace.reintegrate_monocle_container()?; + + self.transfer_container( + (origin_monitor_idx, origin_workspace_idx, monocle_idx), + ( + target_monitor_idx, + target_workspace_idx, + target_container_idx, + ), + )?; + // TODO: don't think this is needed on macOS + // After we restore the origin workspace, some windows that were cloacked + // by the monocle might now be uncloacked which would trigger a workspace + // reconciliation since the focused monitor would be different from origin. + // That workspace reconciliation would focus the window on the origin monitor. + // So we need to ignore the uncloak events produced by the origin workspace + // restore to avoid that issue. + // self.uncloack_to_ignore = uncloack_amount; + } + // TODO: this probably won't be used on macOS + } else if origin_workspace + .maximized_window + .as_ref() + .map(|max| max.id == window_id) + .unwrap_or_default() + { + // Moving maximized_window + // TODO: not sure if we'll support maximized windows on macOS + // if let Some(maximized_idx) = origin_workspace.maximized_window_restore_idx { + // self.focus_monitor(origin_monitor_idx)?; + // let origin_monitor = self + // .focused_monitor_mut() + // .ok_or_eyre("there is no origin monitor")?; + // origin_monitor.focus_workspace(origin_workspace_idx)?; + // self.unmaximize_window()?; + // self.focus_monitor(target_monitor_idx)?; + // let target_monitor = self + // .focused_monitor_mut() + // .ok_or_eyre("there is no target monitor")?; + // target_monitor.focus_workspace(target_workspace_idx)?; + // + // self.transfer_container( + // (origin_monitor_idx, origin_workspace_idx, maximized_idx), + // ( + // target_monitor_idx, + // target_workspace_idx, + // target_container_idx, + // ), + // )?; + // } + } + Ok(()) + } + + #[tracing::instrument(skip(self))] + pub fn transfer_container( + &mut self, + origin: (usize, usize, usize), + target: (usize, usize, usize), + ) -> eyre::Result<()> { + let (origin_monitor_idx, origin_workspace_idx, origin_container_idx) = origin; + let (target_monitor_idx, target_workspace_idx, target_container_idx) = target; + + let origin_container = self + .monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(origin_workspace_idx) + .ok_or_eyre("there is no workspace at this index")? + .remove_container(origin_container_idx) + .ok_or_eyre("there is no container at this index")?; + + let target_workspace = self + .monitors_mut() + .get_mut(target_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(target_workspace_idx) + .ok_or_eyre("there is no workspace at this index")?; + + target_workspace + .containers_mut() + .insert(target_container_idx, origin_container); + + target_workspace.focus_container(target_container_idx); + + Ok(()) + } } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index f8948dad..eb00cbfa 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -2,6 +2,7 @@ use crate::accessibility::notification_constants::AccessibilityNotification; use crate::app_kit_notification_constants::AppKitWorkspaceNotification; +use crate::macos_api::MacosApi; use serde::Deserialize; use serde::Serialize; use strum::Display; @@ -37,6 +38,10 @@ pub enum WindowManagerEvent { Restore(SystemNotification, i32, u32), Manage(SystemNotification, i32, u32), Unmanage(SystemNotification, i32, u32), + MoveStart(SystemNotification, i32, u32), + MoveEnd(SystemNotification, i32, u32), + ResizeStart(SystemNotification, i32, u32), + ResizeEnd(SystemNotification, i32, u32), } impl WindowManagerEvent { @@ -87,11 +92,40 @@ impl WindowManagerEvent { .map(|window_id| WindowManagerEvent::Manage(notification, process_id, window_id)), SystemNotification::Manual(ManualNotification::Unmanage) => window_id .map(|window_id| WindowManagerEvent::Unmanage(notification, process_id, window_id)), - // kAXWindowMovedNotification => {} - // kAXWindowResizedNotification => {} - // kAXTitleChangedNotification => {} - // kAXApplicationDeactivatedNotification => {} - _ => None, + SystemNotification::Accessibility(AccessibilityNotification::AXWindowMoved) => { + if MacosApi::left_mouse_button_is_pressed() { + window_id.map(|window_id| { + WindowManagerEvent::MoveStart(notification, process_id, window_id) + }) + } else { + window_id.map(|window_id| { + WindowManagerEvent::MoveEnd(notification, process_id, window_id) + }) + } + } + SystemNotification::Accessibility(AccessibilityNotification::AXWindowResized) => { + if MacosApi::left_mouse_button_is_pressed() { + window_id.map(|window_id| { + WindowManagerEvent::ResizeStart(notification, process_id, window_id) + }) + } else { + window_id.map(|window_id| { + WindowManagerEvent::ResizeEnd(notification, process_id, window_id) + }) + } + } + notification => { + let notification_string = match notification { + SystemNotification::Accessibility(n) => n.to_string(), + SystemNotification::AppKitWorkspace(n) => n.to_string(), + SystemNotification::Manual(n) => n.to_string(), + }; + + tracing::trace!( + "ignoring system notification: {notification_string} (pid: {process_id}, window id: {window_id:?})" + ); + None + } } } @@ -103,6 +137,10 @@ impl WindowManagerEvent { | WindowManagerEvent::Minimize(_, process_id, _) | WindowManagerEvent::Manage(_, process_id, _) | WindowManagerEvent::Unmanage(_, process_id, _) + | WindowManagerEvent::MoveStart(_, process_id, _) + | WindowManagerEvent::MoveEnd(_, process_id, _) + | WindowManagerEvent::ResizeStart(_, process_id, _) + | WindowManagerEvent::ResizeEnd(_, process_id, _) | WindowManagerEvent::Restore(_, process_id, _) => *process_id, } } @@ -114,6 +152,10 @@ impl WindowManagerEvent { | WindowManagerEvent::Destroy(n, _) | WindowManagerEvent::Minimize(n, _, _) | WindowManagerEvent::Manage(n, _, _) + | WindowManagerEvent::MoveStart(n, _, _) + | WindowManagerEvent::MoveEnd(n, _, _) + | WindowManagerEvent::ResizeStart(n, _, _) + | WindowManagerEvent::ResizeEnd(n, _, _) | WindowManagerEvent::Unmanage(n, _, _) | WindowManagerEvent::Restore(n, _, _) => match n { SystemNotification::Accessibility(a) => a.to_string(), @@ -130,6 +172,10 @@ impl WindowManagerEvent { WindowManagerEvent::Minimize(_, _, window_id) | WindowManagerEvent::Manage(_, _, window_id) | WindowManagerEvent::Unmanage(_, _, window_id) + | WindowManagerEvent::MoveStart(_, _, window_id) + | WindowManagerEvent::MoveEnd(_, _, window_id) + | WindowManagerEvent::ResizeStart(_, _, window_id) + | WindowManagerEvent::ResizeEnd(_, _, window_id) | WindowManagerEvent::Restore(_, _, window_id) => Some(*window_id), } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index fc709cb3..49d8298b 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1128,6 +1128,27 @@ impl Workspace { Ok(()) } + + pub fn container_idx_from_current_point(&self) -> Option { + let mut idx = None; + + let point = MacosApi::cursor_pos(); + + for (i, _container) in self.containers().iter().enumerate() { + if let Some(rect) = self.latest_layout.get(i) + && rect.contains_point((point.x as i32, point.y as i32)) + { + idx = Option::from(i); + } + } + + idx + } + + pub fn container_for_window(&self, window_id: u32) -> Option<&Container> { + self.containers() + .get(self.container_idx_for_window(window_id)?) + } } impl Workspace { From 400cb63c6aae52bd6c95f0f549d90dbb04c4288f Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 11:05:44 -0700 Subject: [PATCH 081/305] fix(wm): ensure window restore positions get updated --- komorebi/src/window.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 06d6a771..91197956 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -355,9 +355,7 @@ impl Window { let rect = MacosApi::window_rect(&self.element)?; let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); - if let Entry::Vacant(entry) = window_restore_positions.entry(self.id) - && CoreGraphicsApi::display_bounds_for_window_rect(rect).is_none() - { + if let Entry::Vacant(entry) = window_restore_positions.entry(self.id) { entry.insert(rect); drop(window_restore_positions); } From cd5f660455a10a86c6c6d95279817d6570db6933 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 13:04:21 -0700 Subject: [PATCH 082/305] feat(cli): add permissions prompts to quickstart --- docs/example-configurations.md | 12 +++++++++++- docs/installation.md | 12 ++---------- komorebi/src/lib.rs | 2 +- komorebic/src/main.rs | 27 +++++++++++++++++++++++++-- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/docs/example-configurations.md b/docs/example-configurations.md index f1562ac8..9c861faf 100644 --- a/docs/example-configurations.md +++ b/docs/example-configurations.md @@ -16,7 +16,17 @@ the example files have been downloaded. For most new users this will be in the komorebic quickstart ``` -With the example configurations downloaded, you can now start `komorebi` + +### Granting Permissions + +The `quickstart` command will also prompt you to grant komorebi the permissions +it requires to run, and will open the following System Settings tabs for you: + +* Settings -> Privacy & Security -> Accessibility +* Settings -> Privacy & Security -> Screen & System Audio Recording + +With the example configurations downloaded and permissions granted, you can now +start `komorebi` ```powershell komorebic start diff --git a/docs/installation.md b/docs/installation.md index 14075266..d0db4ded 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -33,16 +33,8 @@ cargo +stable install --path komorebic --locked --target-dir ~/.cargo/bin If the binaries have been built and added to your `$PATH` correctly, you should see some output when running `komorebi --help` and `komorebic --help` -## Granting Permissions - -Users will need to manually add `~/.cargo/bin/komorebi` to: - -* Settings -> Privacy & Security -> Accessibility -* Settings -> Privacy & Security -> Screen & System Audio Recording - -Once komorebi is installed, and these permissions have been granted, proceed to -get the [example -configurations](example-configurations.md). +Once komorebi is installed, proceed to get +the [example configurations](example-configurations.md). ## Uninstallation diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index d3b86b06..58118b10 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -86,7 +86,7 @@ lazy_static! { assert!( home.is_dir(), - "$KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory" + "$KOMOREBI_CONFIG_HOME is set to \"{home_path}\", which is not a valid directory" ); home diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 5e219889..7223a45f 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -47,7 +47,7 @@ lazy_static! { home } else { panic!( - "$KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory", + "$KOMOREBI_CONFIG_HOME is set to \"{home_path}\", which is not a valid directory", ); } }, @@ -1244,7 +1244,30 @@ fn main() -> eyre::Result<()> { written_files.join("\n") ); } - println!("\nYou can now run: komorebic start"); + + let mut current_exe = std::env::current_exe().expect("unable to get exec path"); + current_exe.pop(); + let komorebi_exe = current_exe.join("komorebi"); + + println!("\nPlease grant Accessibility permissions to \"{}\"", komorebi_exe.display()); + println!("Accessibility permissions are required for komorebi to to manage windows"); + Command::new("open").arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility").spawn()?; + + println!("\nHit return when done..."); + std::io::stdout().flush()?; + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + + println!("Please grant Screen Recording permissions to \"{}\"", komorebi_exe.display()); + println!("Screen Recording permissions are required to for komorebi to read window titles"); + Command::new("open").arg("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture").spawn()?; + + println!("\nHit return when done..."); + std::io::stdout().flush()?; + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + + println!("You can now run: komorebic start"); println!( "\nIf you have skhd hotkey daemon installed, you can also run: skhd --config {}", skhdrc_path.display() From e5468dc0362aaaaab672739f641f575da96db4b1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 13:26:30 -0700 Subject: [PATCH 083/305] feat(wm): ignore events on other spaces This commit ensures that events and commands on spaces other than the one that komorebi was started on will be ignored. --- komorebi/src/accessibility/private.rs | 2 +- komorebi/src/lib.rs | 8 ++++++++ komorebi/src/main.rs | 5 ----- komorebi/src/process_command.rs | 9 +++++++++ komorebi/src/process_event.rs | 9 +++++++++ komorebi/src/skylight.rs | 6 ++++++ komorebi/src/static_config.rs | 2 ++ komorebi/src/window_manager.rs | 5 ++++- komorebic/src/main.rs | 26 +++++++++++++++++++++----- 9 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 komorebi/src/skylight.rs diff --git a/komorebi/src/accessibility/private.rs b/komorebi/src/accessibility/private.rs index 5e1eab7c..2c6318d5 100644 --- a/komorebi/src/accessibility/private.rs +++ b/komorebi/src/accessibility/private.rs @@ -6,5 +6,5 @@ use objc2_core_graphics::CGWindowID; // https://github.com/nikitabobko/AeroSpace?tab=readme-ov-file#project-values unsafe extern "C" { /// Extract `window_id` from an AXUIElement. - pub(crate) fn _AXUIElementGetWindow(elem: &AXUIElement, window_id: *mut CGWindowID) -> AXError; + pub fn _AXUIElementGetWindow(elem: &AXUIElement, window_id: *mut CGWindowID) -> AXError; } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 58118b10..6c58f538 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -38,6 +38,7 @@ use std::collections::HashMap; use std::io::Write; use std::ops::Deref; use std::os::unix::net::UnixStream; +use std::panic; use std::path::PathBuf; use std::ptr::NonNull; use std::sync::Arc; @@ -64,6 +65,7 @@ pub mod notification_center_listener; pub mod process_command; pub mod process_event; pub mod reaper; +pub mod skylight; pub mod state; pub mod static_config; pub mod window; @@ -149,6 +151,12 @@ shadow_rs::shadow!(build); pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(5); +#[must_use] +pub fn current_space_id() -> Option { + panic::catch_unwind(|| unsafe { skylight::CGSGetActiveSpace(skylight::CGSMainConnectionID()) }) + .ok() +} + #[derive(Clone, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[serde(untagged)] diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 1d8256d2..faa6b574 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -26,8 +26,6 @@ use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::kCFRunLoopDefaultMode; -use objc2_core_graphics::CGDisplayBounds; -use objc2_core_graphics::CGMainDisplayID; use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; use parking_lot::Mutex; @@ -217,9 +215,6 @@ fn main() -> eyre::Result<()> { let _notification_center_listener = NotificationCenterListener::init(); let _display_reconfiguration_listener = DisplayReconfigurationListener::init(); - let display_size = unsafe { CGDisplayBounds(CGMainDisplayID()) }; - tracing::info!("display size for main display is: {:?}", display_size); - let run_loop = CFRunLoop::current().ok_or_eyre("couldn't get CFRunLoop::current")?; let _input_listener = InputEventListener::init(&run_loop); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7e4a3746..8389d2fe 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -29,6 +29,7 @@ use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; +use crate::current_space_id; use crate::macos_api::MacosApi; use crate::monitor::MonitorInformation; use crate::notify_subscribers; @@ -107,6 +108,14 @@ impl WindowManager { message: SocketMessage, mut reply: impl std::io::Write, ) -> eyre::Result<()> { + if let Some(space_id) = &self.space_id + && let Some(current_space_id) = current_space_id() + && *space_id != current_space_id + { + tracing::trace!("ignoring events and commands while not on space {space_id}"); + return Ok(()); + } + tracing::info!("processing command: {message}"); #[allow(clippy::useless_asref)] diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index cb6b0418..7322c25d 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -17,6 +17,7 @@ use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use crate::current_space_id; use crate::macos_api::MacosApi; use crate::notify_subscribers; use crate::state::State; @@ -68,6 +69,14 @@ impl WindowManager { return Ok(()); } + if let Some(space_id) = &self.space_id + && let Some(current_space_id) = current_space_id() + && *space_id != current_space_id + { + tracing::trace!("ignoring events and commands while not on space {space_id}"); + return Ok(()); + } + let mut rule_debug = RuleDebug::default(); let mut should_manage = true; diff --git a/komorebi/src/skylight.rs b/komorebi/src/skylight.rs new file mode 100644 index 00000000..7d9c423f --- /dev/null +++ b/komorebi/src/skylight.rs @@ -0,0 +1,6 @@ +// Only read operations are permitted, and their usage and potential failure must +// never disrupt the window manager +unsafe extern "C" { + pub fn CGSMainConnectionID() -> i32; + pub fn CGSGetActiveSpace(cid: i32) -> u64; +} diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index b4eff49f..5f1f331a 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -28,6 +28,7 @@ use crate::core::default_layout::LayoutOptions; use crate::core::layout::Layout; use crate::core::pathext::ResolvedPathBuf; use crate::core::rect::Rect; +use crate::current_space_id; use crate::monitor; use crate::monitor::Monitor; use crate::monitor_reconciliator; @@ -1126,6 +1127,7 @@ impl StaticConfig { applications: Default::default(), incoming_events: incoming, command_listener: listener, + space_id: current_space_id(), is_paused: false, // virtual_desktop_id: current_virtual_desktop(), work_area_offset: value.global_work_area_offset, diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 22ed3bdc..6e6ea273 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -23,6 +23,7 @@ use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; +use crate::current_space_id; use crate::lockable_sequence::Lockable; use crate::macos_api::MacosApi; use crate::monitor::Monitor; @@ -63,6 +64,7 @@ pub struct WindowManager { pub applications: HashMap, pub run_loop: CoreFoundationRunLoop, pub command_listener: UnixListener, + pub space_id: Option, pub is_paused: bool, pub resize_delta: i32, pub hotwatch: Hotwatch, @@ -145,6 +147,7 @@ impl WindowManager { applications: Default::default(), run_loop: CoreFoundationRunLoop(run_loop.clone()), command_listener: listener, + space_id: current_space_id(), is_paused: false, resize_delta: 50, hotwatch: Hotwatch::new()?, @@ -1136,7 +1139,7 @@ impl WindowManager { tracing::info!("removing window"); if self.focused_container()?.windows().len() == 1 { - eyre::bail!("a container must have at least one window"); + bail!("a container must have at least one window"); } let workspace = self.focused_workspace_mut()?; diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 7223a45f..05062699 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1249,18 +1249,34 @@ fn main() -> eyre::Result<()> { current_exe.pop(); let komorebi_exe = current_exe.join("komorebi"); - println!("\nPlease grant Accessibility permissions to \"{}\"", komorebi_exe.display()); + println!( + "\nPlease grant Accessibility permissions to \"{}\"", + komorebi_exe.display() + ); println!("Accessibility permissions are required for komorebi to to manage windows"); - Command::new("open").arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility").spawn()?; + Command::new("open") + .arg( + "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility", + ) + .spawn()?; println!("\nHit return when done..."); std::io::stdout().flush()?; let mut input = String::new(); std::io::stdin().read_line(&mut input)?; - println!("Please grant Screen Recording permissions to \"{}\"", komorebi_exe.display()); - println!("Screen Recording permissions are required to for komorebi to read window titles"); - Command::new("open").arg("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture").spawn()?; + println!( + "Please grant Screen Recording permissions to \"{}\"", + komorebi_exe.display() + ); + println!( + "Screen Recording permissions are required to for komorebi to read window titles" + ); + Command::new("open") + .arg( + "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture", + ) + .spawn()?; println!("\nHit return when done..."); std::io::stdout().flush()?; From 7aea35dff1526ed1a9aee686998779a34c1c2986 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 13:33:07 -0700 Subject: [PATCH 084/305] docs(examples): ensure skhdrc samples don't conflict with mission control --- docs/skhdrc.sample | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/skhdrc.sample b/docs/skhdrc.sample index f8fb45f3..6b38ae8c 100644 --- a/docs/skhdrc.sample +++ b/docs/skhdrc.sample @@ -14,10 +14,10 @@ alt + shift - l : komorebic move right alt + shift - return : komorebic promote # Stack windows -ctrl - left : komorebic stack left -ctrl - down : komorebic stack down -ctrl - up : komorebic stack up -ctrl - right : komorebic stack right +ctrl + alt - left : komorebic stack left +ctrl + alt - down : komorebic stack down +ctrl + alt - up : komorebic stack up +ctrl + alt - right : komorebic stack right alt - 0x29 : komorebic unstack # 0x29 is ; alt - 0x21 : komorebic cycle-stack previous # 0x21 is [ alt - 0x1E : komorebic cycle-stack next # 0x1E is ] From 9b9c96a89d20af6f7fcf0cb528013ab391c9c014 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 17:01:59 -0700 Subject: [PATCH 085/305] fix(wm): don't duplicate windows on empty workspaces This commit fixes a subtle boolean logic bug that I think was introduced by a "cargo clippy --fix" to apply some new boolean chaining stuff in Rust 2024. Gotta be more careful. --- komorebi/src/process_event.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 7322c25d..1b659e2b 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -405,12 +405,8 @@ impl WindowManager { } if let Some((m_idx, w_idx)) = self.known_window_ids.get(&window_id) - && let Some(focused_workspace_idx) = self - .monitors() - .get(*m_idx) - .map(|m| m.focused_workspace_idx()) - && *m_idx != self.focused_monitor_idx() - && *w_idx != focused_workspace_idx + && let Ok(focused_workspace_idx) = self.focused_workspace_idx() + && (*m_idx != self.focused_monitor_idx() || *w_idx != focused_workspace_idx) { tracing::debug!( "ignoring show event for window already associated with another workspace" From a398609071b18af087f77c5ab8659702f860a064 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 29 Sep 2025 10:35:24 -0700 Subject: [PATCH 086/305] refactor(wm): start using gcd dispatch This commit switches from executing things which need a MainThreadMarker in our main loop in main.rs to executing them via Grand Central Dispatch using the dispatch2 crate. All the monitor reconciliator stuff is now much faster. --- Cargo.lock | 3 ++ komorebi/Cargo.toml | 1 + komorebi/src/lib.rs | 9 ----- komorebi/src/main.rs | 33 ----------------- komorebi/src/monitor_reconciliator.rs | 53 ++++++++++++--------------- 5 files changed, 28 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a0abddb..22f2e922 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,6 +404,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" dependencies = [ "bitflags 2.9.4", + "block2", + "libc", "objc2", ] @@ -1072,6 +1074,7 @@ dependencies = [ "crossbeam-channel", "ctrlc", "dirs", + "dispatch2", "hotwatch", "lazy_static", "nanoid", diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index d7b9b651..c49a9fb2 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -9,6 +9,7 @@ clap = { workspace = true } color-eyre = { workspace = true } crossbeam-channel = "0.5" ctrlc = { version = "3", features = ["termination"] } +dispatch2 = "0.3" dirs = { workspace = true } hotwatch = "0.5" lazy_static = { workspace = true } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 6c58f538..85bb7068 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -10,7 +10,6 @@ use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; use crate::core::config_generation::WorkspaceMatchingRule; use crate::core_graphics::error::CoreGraphicsError; -use crate::monitor::Monitor; use crate::monitor_reconciliator::MonitorNotification; use crate::state::State; use crate::window::AspectRatio; @@ -42,7 +41,6 @@ use std::panic; use std::path::PathBuf; use std::ptr::NonNull; use std::sync::Arc; -use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicI32; #[macro_use] @@ -109,13 +107,6 @@ lazy_static! { Arc::new(RwLock::new(HashMap::new())); static ref WINDOW_RESTORE_POSITIONS: Arc>> = Arc::new(Mutex::new(HashMap::new())); - pub static ref UPDATE_MONITOR_WORK_AREAS: Arc = Arc::new(AtomicBool::new(false)); - pub static ref UPDATE_LATEST_MONITOR_INFORMATION: Arc = - Arc::new(AtomicBool::new(false)); - pub static ref LOAD_LATEST_MONITOR_INFORMATION: Arc = - Arc::new(AtomicBool::new(false)); - pub static ref LATEST_MONITOR_INFORMATION: Arc>>> = - Arc::new(RwLock::new(None)); static ref WORKSPACE_MATCHING_RULES: Arc>> = Arc::new(Mutex::new(Vec::new())); static ref REGEX_IDENTIFIERS: Arc>> = diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index faa6b574..8ef4e568 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -6,14 +6,9 @@ use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi::DATA_DIR; use komorebi::HOME_DIR; -use komorebi::LATEST_MONITOR_INFORMATION; -use komorebi::LOAD_LATEST_MONITOR_INFORMATION; -use komorebi::UPDATE_LATEST_MONITOR_INFORMATION; -use komorebi::UPDATE_MONITOR_WORK_AREAS; use komorebi::core::pathext::replace_env_in_path; use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; use komorebi::input_event_listener::InputEventListener; -use komorebi::macos_api::MacosApi; use komorebi::monitor_reconciliator; use komorebi::notification_center_listener::NotificationCenterListener; use komorebi::process_command::listen_for_commands; @@ -294,34 +289,6 @@ fn main() -> eyre::Result<()> { break; } - if UPDATE_MONITOR_WORK_AREAS.load(Ordering::Relaxed) { - // this can only be called on the main thread - if let Some(mut wm) = wm.try_lock() { - if let Err(error) = MacosApi::update_monitor_work_areas(&mut wm) { - tracing::error!("failed to update monitor work areas: {error}"); - } - - UPDATE_MONITOR_WORK_AREAS.store(false, Ordering::Relaxed); - } - } - - if UPDATE_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { - let mut latest_monitor_information = LATEST_MONITOR_INFORMATION.write(); - // this can only be called on the main thread - *latest_monitor_information = Some(MacosApi::latest_monitor_information()?); - } - - if LOAD_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { - // this can only be called on the main thread - if let Some(mut wm) = wm.try_lock() { - if let Err(error) = MacosApi::load_monitor_information(&mut wm) { - tracing::error!("failed to update load monitor information: {error}"); - } - - LOAD_LATEST_MONITOR_INFORMATION.store(false, Ordering::Relaxed); - } - } - // this gets our observer notification callbacks firing autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) }); } diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index 49f666d2..f407214a 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -1,18 +1,16 @@ use crate::DISPLAY_INDEX_PREFERENCES; -use crate::LATEST_MONITOR_INFORMATION; -use crate::LOAD_LATEST_MONITOR_INFORMATION; use crate::Notification; use crate::NotificationEvent; -use crate::UPDATE_LATEST_MONITOR_INFORMATION; -use crate::UPDATE_MONITOR_WORK_AREAS; use crate::WORKSPACE_MATCHING_RULES; use crate::core::config_generation::WorkspaceMatchingRule; +use crate::macos_api::MacosApi; use crate::monitor::Monitor; use crate::notify_subscribers; use crate::state::State; use crate::window_manager::WindowManager; use crossbeam_channel::Receiver; use crossbeam_channel::Sender; +use dispatch2::DispatchQueue; use objc2_core_graphics::CGDirectDisplayID; use parking_lot::Mutex; use serde::Deserialize; @@ -20,7 +18,6 @@ use serde::Serialize; use std::collections::HashMap; use std::sync::Arc; use std::sync::OnceLock; -use std::sync::atomic::Ordering; use strum::Display; #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] @@ -105,34 +102,30 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result match notification { MonitorNotification::Resize(_display_id) => { tracing::debug!("handling resize notification"); - UPDATE_MONITOR_WORK_AREAS.store(true, Ordering::Relaxed); + DispatchQueue::main().exec_sync(|| { + let mut wm = wm.lock(); + if let Err(error) = MacosApi::update_monitor_work_areas(&mut wm) { + tracing::error!("failed to update monitor work areas: {error}"); + } + }); } MonitorNotification::DisplayConnectionChange(_) => { - let mut wm = wm.lock(); tracing::debug!("handling display connection change notification"); + + let mut attached_devices = vec![]; + DispatchQueue::main().exec_sync(|| { + if let Ok(latest) = MacosApi::latest_monitor_information() { + attached_devices = latest.clone(); + } + }); + + let mut wm = wm.lock(); let mut monitor_cache = MONITOR_CACHE .get_or_init(|| Mutex::new(HashMap::new())) .lock(); let initial_monitor_count = wm.monitors().len(); - { - let mut latest_monitor_information = LATEST_MONITOR_INFORMATION.write(); - *latest_monitor_information = None; - UPDATE_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); - } - - let mut attached_devices = vec![]; - while attached_devices.is_empty() { - if let Some(latest) = &*LATEST_MONITOR_INFORMATION.read() { - attached_devices = latest.clone(); - } - - std::thread::sleep(std::time::Duration::from_millis(100)); - } - - UPDATE_LATEST_MONITOR_INFORMATION.store(false, Ordering::Relaxed); - // Make sure that in our state any attached displays have the latest macOS API data for monitor in wm.monitors_mut() { for attached in &attached_devices { @@ -321,11 +314,13 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // need to drop here because the main thread needs the lock to load the latest // monitor info into the wm state drop(wm); - LOAD_LATEST_MONITOR_INFORMATION.store(true, Ordering::Relaxed); - while LOAD_LATEST_MONITOR_INFORMATION.load(Ordering::Relaxed) { - std::thread::sleep(std::time::Duration::from_millis(50)); - tracing::trace!("waiting for latest monitor info to be loaded {}", line!()); - } + + DispatchQueue::main().exec_sync(|| { + let mut wm = arc.lock(); + if let Err(error) = MacosApi::load_monitor_information(&mut wm) { + tracing::error!("failed to update load monitor information: {error}"); + } + }); } // regain the lock here once the monitor information has been updated From 28e0a2b75d710f9a56d107667be869b70daab23c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 29 Sep 2025 16:35:01 -0700 Subject: [PATCH 087/305] feat(wm): impl first pass of border manager This commit introduces a very introductory attempt at a border manager. All of the colors work, from some brief usage it seems to behave as expected based on windows, with some caveats. There are issues with the window layering and popups which are annoyng - the borders always stay drawn on top of RustRover popups, for example. Also, the window tracking is incredibly slow and laggy when you try to move or resize using the mouse. Probably because the implementation uses NSWindow under the hood which according to Google is notoriously unperformant. None of the config options have been brought over yet. The border manager is defaulting to off for now in the absence of config - anyone at this commit who really wants to try it out should set BORDER_ENABLED in border_manager/mod.rs to "true". --- Cargo.lock | 3760 +++++++++++++++++++++- deny.toml | 27 +- dependencies.json | 366 ++- komorebi/Cargo.toml | 7 + komorebi/src/accessibility/mod.rs | 7 +- komorebi/src/application.rs | 3 +- komorebi/src/border_manager/border.rs | 161 + komorebi/src/border_manager/mod.rs | 550 ++++ komorebi/src/border_manager/ns_window.rs | 159 + komorebi/src/core/mod.rs | 25 + komorebi/src/lib.rs | 3 +- komorebi/src/macos_api.rs | 4 +- komorebi/src/main.rs | 5 +- komorebi/src/monitor_reconciliator.rs | 3 + komorebi/src/process_command.rs | 16 +- komorebi/src/process_event.rs | 20 +- komorebi/src/reaper.rs | 2 + komorebi/src/window.rs | 7 +- komorebi/src/window_manager.rs | 2 +- komorebi/src/workspace.rs | 6 + 20 files changed, 4917 insertions(+), 216 deletions(-) create mode 100644 komorebi/src/border_manager/border.rs create mode 100644 komorebi/src/border_manager/mod.rs create mode 100644 komorebi/src/border_manager/ns_window.rs diff --git a/Cargo.lock b/Cargo.lock index 22f2e922..f322b8d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,20 +3,153 @@ version = 4 [[package]] -name = "addr2line" -version = "0.24.2" +name = "ab_glyph" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" + +[[package]] +name = "accesskit" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3d3b8f9bae46a948369bc4a03e815d4ed6d616bd00de4051133a5019dc31c5a" + +[[package]] +name = "accesskit_atspi_common" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c5dd55e6e94949498698daf4d48fb5659e824d7abec0d394089656ceaf99d4f" +dependencies = [ + "accesskit", + "accesskit_consumer", + "atspi-common", + "serde", + "thiserror 1.0.69", + "zvariant", +] + +[[package]] +name = "accesskit_consumer" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f47983a1084940ba9a39c077a8c63e55c619388be5476ac04c804cfbd1e63459" +dependencies = [ + "accesskit", + "hashbrown 0.15.5", + "immutable-chunkmap", +] + +[[package]] +name = "accesskit_macos" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7329821f3bd1101e03a7d2e03bd339e3ac0dc64c70b4c9f9ae1949e3ba8dece1" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.15.5", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "accesskit_unix" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcee751cc20d88678c33edaf9c07e8b693cd02819fe89053776f5313492273f5" +dependencies = [ + "accesskit", + "accesskit_atspi_common", + "async-channel", + "async-executor", + "async-task", + "atspi", + "futures-lite", + "futures-util", + "serde", + "zbus", +] + +[[package]] +name = "accesskit_windows" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24fcd5d23d70670992b823e735e859374d694a3d12bfd8dd32bd3bd8bedb5d81" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.15.5", + "paste", + "static_assertions", + "windows 0.58.0", + "windows-core 0.58.0", +] + +[[package]] +name = "accesskit_winit" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6a48dad5530b6deb9fc7a52cc6c3bf72cdd9eb8157ac9d32d69f2427a5e879" +dependencies = [ + "accesskit", + "accesskit_macos", + "accesskit_unix", + "accesskit_windows", + "raw-window-handle", + "winit", +] + +[[package]] +name = "addr2line" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" dependencies = [ "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "adler2" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.3", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -26,6 +159,33 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-activity" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" +dependencies = [ + "android-properties", + "bitflags 2.9.4", + "cc", + "cesu8", + "jni", + "jni-sys", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys 0.6.0+11769913", + "num_enum", + "thiserror 1.0.69", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -52,9 +212,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anstyle-parse" @@ -85,12 +245,267 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arboard" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf" +dependencies = [ + "clipboard-win", + "image 0.25.8", + "log", + "objc2 0.6.2", + "objc2-app-kit 0.3.1", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.1", + "parking_lot", + "percent-encoding", + "windows-sys 0.60.2", + "x11rb", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + +[[package]] +name = "ash" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" +dependencies = [ + "libloading", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497c00e0fd83a72a79a39fcbd8e3e2f055d6f6c7e025f3b3d91f4f8e76527fb8" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-fs" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5" +dependencies = [ + "async-lock", + "blocking", + "futures-lite", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix 1.1.2", + "slab", + "windows-sys 0.61.1", +] + +[[package]] +name = "async-lock" +version = "3.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix 1.1.2", +] + +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "async-signal" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c070bbf59cd3570b6b2dd54cd772527c7c3620fce8be898406dd3ed6adc64c" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 1.1.2", + "signal-hook-registry", + "slab", + "windows-sys 0.61.1", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atspi" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be534b16650e35237bb1ed189ba2aab86ce65e88cc84c66f4935ba38575cecbf" +dependencies = [ + "atspi-common", + "atspi-connection", + "atspi-proxies", +] + +[[package]] +name = "atspi-common" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1909ed2dc01d0a17505d89311d192518507e8a056a48148e3598fef5e7bb6ba7" +dependencies = [ + "enumflags2", + "serde", + "static_assertions", + "zbus", + "zbus-lockstep", + "zbus-lockstep-macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "atspi-connection" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "430c5960624a4baaa511c9c0fcc2218e3b58f5dbcc47e6190cafee344b873333" +dependencies = [ + "atspi-common", + "atspi-proxies", + "futures-lite", + "zbus", +] + +[[package]] +name = "atspi-proxies" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e6c5de3e524cf967569722446bcd458d5032348554d9a17d7d72b041ab7496" +dependencies = [ + "atspi-common", + "serde", + "zbus", + "zvariant", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -99,17 +514,40 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backtrace" -version = "0.3.75" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" dependencies = [ "addr2line", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.8.9", "object", "rustc-demangle", - "windows-targets 0.52.6", + "windows-link 0.2.0", +] + +[[package]] +name = "base16-egui-themes" +version = "0.1.0" +source = "git+https://github.com/LGUG2Z/base16-egui-themes?rev=96f26c88d83781f234d42222293ec73d23a39ad8#96f26c88d83781f234d42222293ec73d23a39ad8" +dependencies = [ + "egui", + "schemars 0.8.22", + "serde", + "strum 0.27.2", + "strum_macros 0.27.2", +] + +[[package]] +name = "base16_color_scheme" +version = "0.3.2" +source = "git+https://github.com/LGUG2Z/base16_color_scheme#c32a9e290f0997eacba3e74bba2442667b5fc478" +dependencies = [ + "hex", + "nom", + "ramhorns", + "serde", ] [[package]] @@ -118,6 +556,27 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + [[package]] name = "bitflags" version = "1.3.2" @@ -129,6 +588,52 @@ name = "bitflags" version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +dependencies = [ + "serde", +] + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" +dependencies = [ + "objc-sys", +] + +[[package]] +name = "block2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" +dependencies = [ + "block-sys", + "objc2 0.4.1", +] + +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2 0.5.2", +] [[package]] name = "block2" @@ -136,7 +641,20 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2" dependencies = [ - "objc2", + "objc2 0.6.2", +] + +[[package]] +name = "blocking" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", ] [[package]] @@ -145,6 +663,38 @@ version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +[[package]] +name = "bytemuck" +version = "1.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f154e572231cb6ba2bd1176980827e3d5dc04cc183a75dea38109fbdd672d29" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + [[package]] name = "bytes" version = "1.10.1" @@ -152,10 +702,63 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] -name = "cc" -version = "1.2.38" +name = "calloop" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f41ae168f955c12fb8960b057d70d0ca153fb83182b57d86380443527be7e9" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" +dependencies = [ + "bitflags 2.9.4", + "log", + "polling", + "rustix 0.38.44", + "slab", + "thiserror 1.0.69", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" +dependencies = [ + "calloop", + "rustix 0.38.44", + "wayland-backend", + "wayland-client", +] + +[[package]] +name = "calm_io" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea0608700fe42d90ec17ad0f86335cf229b67df2e34e7f463e8241ce7b8fa5f" +dependencies = [ + "calmio_filters", +] + +[[package]] +name = "calmio_filters" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "846501f4575cd66766a40bb7ab6d8e960adc7eb49f753c8232bd8e0e09cf6ca2" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "catppuccin-egui" +version = "5.3.1" +source = "git+https://github.com/LGUG2Z/catppuccin-egui?rev=bdaff30959512c4f7ee7304117076a48633d777f#bdaff30959512c4f7ee7304117076a48633d777f" +dependencies = [ + "egui", +] + +[[package]] +name = "cc" +version = "1.2.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f" dependencies = [ "find-msvc-tools", "jobserver", @@ -163,6 +766,12 @@ dependencies = [ "shlex", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.3" @@ -175,6 +784,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + [[package]] name = "chrono" version = "0.4.42" @@ -221,7 +839,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -230,6 +848,25 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +[[package]] +name = "clipboard-win" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4" +dependencies = [ + "error-code", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "color-eyre" version = "0.6.5" @@ -257,12 +894,46 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "color-thief" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6460d760cf38ce67c9e0318f896538820acc54f2d0a3bfc5b2c557211066c98" +dependencies = [ + "rgb", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "colorchoice" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "const_format" version = "0.2.34" @@ -293,12 +964,64 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core-graphics" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "core-graphics-types", + "foreign-types 0.5.0", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -308,12 +1031,47 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "ctrlc" version = "3.5.0" @@ -321,10 +1079,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881c5d0a13b2f1498e2306e82cbada78390e152d4b1378fb28a84f4dcd0dc4f3" dependencies = [ "dispatch", - "nix", - "windows-sys 0.61.0", + "nix 0.30.1", + "windows-sys 0.61.1", ] +[[package]] +name = "cursor-icon" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" + [[package]] name = "darling" version = "0.21.3" @@ -346,7 +1110,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.106", ] [[package]] @@ -357,7 +1121,17 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.106", +] + +[[package]] +name = "deflate" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" +dependencies = [ + "adler32", + "byteorder", ] [[package]] @@ -370,13 +1144,52 @@ dependencies = [ "serde_core", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +dependencies = [ + "dirs-sys 0.3.7", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys 0.3.7", +] + [[package]] name = "dirs" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" dependencies = [ - "dirs-sys", + "dirs-sys 0.5.0", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users 0.4.6", + "winapi", ] [[package]] @@ -387,8 +1200,8 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" dependencies = [ "libc", "option-ext", - "redox_users", - "windows-sys 0.61.0", + "redox_users 0.5.2", + "windows-sys 0.61.1", ] [[package]] @@ -404,9 +1217,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" dependencies = [ "bitflags 2.9.4", - "block2", + "block2 0.6.1", "libc", - "objc2", + "objc2 0.6.2", ] [[package]] @@ -417,15 +1230,180 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] +[[package]] +name = "dlib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" +dependencies = [ + "libloading", +] + +[[package]] +name = "document-features" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +dependencies = [ + "litrs", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dpi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" + [[package]] name = "dyn-clone" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" +[[package]] +name = "ecolor" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc4feb366740ded31a004a0e4452fbf84e80ef432ecf8314c485210229672fd1" +dependencies = [ + "bytemuck", + "emath", +] + +[[package]] +name = "eframe" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0dfe0859f3fb1bc6424c57d41e10e9093fe938f426b691e42272c2f336d915c" +dependencies = [ + "ahash", + "bytemuck", + "document-features", + "egui", + "egui-wgpu", + "egui-winit", + "egui_glow", + "glow", + "glutin", + "glutin-winit", + "image 0.25.8", + "js-sys", + "log", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", + "parking_lot", + "percent-encoding", + "profiling", + "raw-window-handle", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "web-time", + "winapi", + "windows-sys 0.59.0", + "winit", +] + +[[package]] +name = "egui" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd34cec49ab55d85ebf70139cb1ccd29c977ef6b6ba4fe85489d6877ee9ef3" +dependencies = [ + "accesskit", + "ahash", + "bitflags 2.9.4", + "emath", + "epaint", + "log", + "nohash-hasher", + "profiling", +] + +[[package]] +name = "egui-wgpu" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d319dfef570f699b6e9114e235e862a2ddcf75f0d1a061de9e1328d92146d820" +dependencies = [ + "ahash", + "bytemuck", + "document-features", + "egui", + "epaint", + "log", + "profiling", + "thiserror 1.0.69", + "type-map", + "web-time", + "wgpu", + "winit", +] + +[[package]] +name = "egui-winit" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9dfbb78fe4eb9c3a39ad528b90ee5915c252e77bbab9d4ebc576541ab67e13" +dependencies = [ + "accesskit_winit", + "ahash", + "arboard", + "bytemuck", + "egui", + "log", + "profiling", + "raw-window-handle", + "smithay-clipboard", + "web-time", + "webbrowser", + "winit", +] + +[[package]] +name = "egui_glow" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "910906e3f042ea6d2378ec12a6fd07698e14ddae68aed2d819ffe944a73aab9e" +dependencies = [ + "ahash", + "bytemuck", + "egui", + "glow", + "log", + "memoffset", + "profiling", + "wasm-bindgen", + "web-sys", + "winit", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "emath" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e4cadcff7a5353ba72b7fea76bf2122b5ebdbc68e8155aa56dfdea90083fe1b" +dependencies = [ + "bytemuck", +] + [[package]] name = "encoding_rs" version = "0.8.35" @@ -435,6 +1413,57 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "endi" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" + +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "epaint" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fcc0f5a7c613afd2dee5e4b30c3e6acafb8ad6f0edb06068811f708a67c562" +dependencies = [ + "ab_glyph", + "ahash", + "bytemuck", + "ecolor", + "emath", + "epaint_default_fonts", + "log", + "nohash-hasher", + "parking_lot", + "profiling", +] + +[[package]] +name = "epaint_default_fonts" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7e7a64c02cf7a5b51e745a9e45f60660a286f151c238b9d397b3e923f5082f" + [[package]] name = "equivalent" version = "1.0.2" @@ -448,7 +1477,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.0", + "windows-sys 0.61.1", +] + +[[package]] +name = "error-code" +version = "3.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" + +[[package]] +name = "event-listener" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", ] [[package]] @@ -467,6 +1523,35 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +[[package]] +name = "fax" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05de7d48f37cd6730705cbca900770cab77a89f413d23e100ad7fad7795a0ab" +dependencies = [ + "fax_derive", +] + +[[package]] +name = "fax_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + [[package]] name = "file-id" version = "0.1.0" @@ -500,19 +1585,78 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +dependencies = [ + "crc32fast", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "flavours" +version = "0.7.2" +source = "git+https://github.com/LGUG2Z/flavours#84da76ccf16e795360e556711fd68edb06f67011" +dependencies = [ + "anyhow", + "base16_color_scheme", + "calm_io", + "color-thief", + "dirs 3.0.2", + "glob", + "hex", + "image 0.23.14", + "palette", + "rand 0.7.3", + "serde", + "serde_yaml", + "shell-words", + "shellexpand", + "toml", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foreign-types" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared", + "foreign-types-shared 0.1.1", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared 0.3.1", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", ] [[package]] @@ -521,6 +1665,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -570,6 +1720,30 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "futures-sink" version = "0.3.31" @@ -590,6 +1764,7 @@ checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-io", + "futures-macro", "futures-sink", "futures-task", "memchr", @@ -598,6 +1773,37 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "gethostname" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc257fdb4038301ce4b9cd1b3b51704509692bb3ff716a410cbd07925d9dae55" +dependencies = [ + "rustix 1.1.2", + "windows-targets 0.52.6", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.16" @@ -622,10 +1828,20 @@ dependencies = [ ] [[package]] -name = "gimli" -version = "0.31.1" +name = "gif" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "gimli" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" [[package]] name = "git2" @@ -640,6 +1856,140 @@ dependencies = [ "url", ] +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "glow" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" +dependencies = [ + "bitflags 2.9.4", + "cfg_aliases", + "cgl", + "dispatch2", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "libloading", + "objc2 0.6.2", + "objc2-app-kit 0.3.1", + "objc2-core-foundation", + "objc2-foundation 0.3.1", + "once_cell", + "raw-window-handle", + "wayland-sys", + "windows-sys 0.52.0", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85edca7075f8fc728f28cb8fbb111a96c3b89e930574369e3e9c27eb75d3788f" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2" +dependencies = [ + "gl_generator", + "windows-sys 0.52.0", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gpu-alloc" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" +dependencies = [ + "bitflags 2.9.4", + "gpu-alloc-types", +] + +[[package]] +name = "gpu-alloc-types" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" +dependencies = [ + "bitflags 2.9.4", +] + +[[package]] +name = "gpu-descriptor" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca" +dependencies = [ + "bitflags 2.9.4", + "gpu-descriptor-types", + "hashbrown 0.15.5", +] + +[[package]] +name = "gpu-descriptor-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" +dependencies = [ + "bitflags 2.9.4", +] + [[package]] name = "h2" version = "0.4.12" @@ -659,12 +2009,31 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + [[package]] name = "hashbrown" version = "0.16.0" @@ -677,11 +2046,37 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "hex_color" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d37f101bf4c633f7ca2e4b5e136050314503dd198e78e325ea602c327c484ef0" +dependencies = [ + "arrayvec", + "rand 0.8.5", + "serde", +] + +[[package]] +name = "hexf-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" [[package]] name = "hotwatch" @@ -826,7 +2221,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.62.0", + "windows-core 0.62.1", ] [[package]] @@ -951,6 +2346,48 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "image" +version = "0.23.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "gif", + "jpeg-decoder", + "num-iter", + "num-rational", + "num-traits", + "png 0.16.8", + "scoped_threadpool", + "tiff 0.6.1", +] + +[[package]] +name = "image" +version = "0.25.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "529feb3e6769d234375c4cf1ee2ce713682b8e76538cb13f9fc23e1400a591e7" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "png 0.18.0", + "tiff 0.10.3", +] + +[[package]] +name = "immutable-chunkmap" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3e98b1520e49e252237edc238a39869da9f3241f2ec19dc788c1d24694d1e4" +dependencies = [ + "arrayvec", +] + [[package]] name = "indenter" version = "0.3.4" @@ -1045,6 +2482,28 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.34" @@ -1055,6 +2514,15 @@ dependencies = [ "libc", ] +[[package]] +name = "jpeg-decoder" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" +dependencies = [ + "rayon", +] + [[package]] name = "js-sys" version = "0.3.81" @@ -1065,25 +2533,48 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "khronos-egl" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" +dependencies = [ + "libc", + "libloading", + "pkg-config", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + [[package]] name = "komorebi" version = "0.1.0" dependencies = [ + "block2 0.3.0", "clap", "color-eyre", "crossbeam-channel", + "crossbeam-utils", "ctrlc", - "dirs", + "dirs 6.0.0", "dispatch2", "hotwatch", + "komorebi-themes", "lazy_static", "nanoid", - "objc2", - "objc2-app-kit", + "objc2 0.6.2", + "objc2-app-kit 0.3.1", "objc2-application-services", "objc2-core-foundation", "objc2-core-graphics", - "objc2-foundation", + "objc2-core-services", + "objc2-core-video", + "objc2-foundation 0.3.1", + "objc2-quartz-core 0.3.1", "parking_lot", "pastey", "quick-xml 0.38.3", @@ -1094,9 +2585,9 @@ dependencies = [ "serde_json_lenient", "serde_with", "shadow-rs", - "strum", + "strum 0.27.2", "sysinfo", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "tracing-appender", "tracing-subscriber", @@ -1110,6 +2601,22 @@ dependencies = [ "serde_json_lenient", ] +[[package]] +name = "komorebi-themes" +version = "0.1.39" +source = "git+https://github.com/LGUG2Z/komorebi#52a745d0a355f4eeeba468bea5174610a2ebf30f" +dependencies = [ + "base16-egui-themes", + "catppuccin-egui", + "eframe", + "flavours", + "hex_color", + "schemars 0.8.22", + "serde", + "serde_variant", + "strum 0.27.2", +] + [[package]] name = "komorebic" version = "0.1.0" @@ -1117,7 +2624,7 @@ dependencies = [ "chrono", "clap", "color-eyre", - "dirs", + "dirs 6.0.0", "fs-tail", "komorebi-client", "lazy_static", @@ -1173,6 +2680,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link 0.2.0", +] + [[package]] name = "libredox" version = "0.1.10" @@ -1181,7 +2698,7 @@ checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ "bitflags 2.9.4", "libc", - "redox_syscall", + "redox_syscall 0.5.17", ] [[package]] @@ -1196,6 +2713,18 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "linux-raw-sys" version = "0.11.0" @@ -1208,6 +2737,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" +[[package]] +name = "litrs" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" + [[package]] name = "lock_api" version = "0.4.13" @@ -1224,6 +2759,48 @@ version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +[[package]] +name = "logos" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7251356ef8cb7aec833ddf598c6cb24d17b689d20b993f9d11a3d764e34e6458" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-codegen" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f80069600c0d66734f5ff52cc42f2dabd6b29d205f333d61fd7832e9e9963f" +dependencies = [ + "beef", + "fnv", + "lazy_static", + "proc-macro2", + "quote", + "regex-syntax", + "syn 2.0.106", +] + +[[package]] +name = "logos-derive" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24fb722b06a9dc12adb0963ed585f19fc61dc5413e6a9be9422ef92c091e731d" +dependencies = [ + "logos-codegen", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + [[package]] name = "matchers" version = "0.2.0" @@ -1235,9 +2812,42 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "memmap2" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843a98750cd611cc2965a8213b53b43e715f13c37a9e096c6408e69990961db7" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "metal" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e" +dependencies = [ + "bitflags 2.9.4", + "block", + "core-graphics-types", + "foreign-types 0.5.0", + "log", + "objc", + "paste", +] [[package]] name = "mime" @@ -1254,6 +2864,31 @@ dependencies = [ "quick-xml 0.17.2", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" +dependencies = [ + "adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -1261,6 +2896,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -1286,13 +2922,45 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "moxcms" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd32fa8935aeadb8a8a6b6b351e40225570a37c43de67690383d87ef170cd08" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "naga" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e380993072e52eef724eddfcde0ed013b0c023c3f0417336ed041aa9f076994e" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.9.4", + "cfg_aliases", + "codespan-reporting", + "hexf-parse", + "indexmap 2.11.4", + "log", + "rustc-hash 1.1.0", + "spirv", + "strum 0.26.3", + "termcolor", + "thiserror 2.0.17", + "unicode-xid", +] + [[package]] name = "nanoid" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" dependencies = [ - "rand", + "rand 0.8.5", ] [[package]] @@ -1312,6 +2980,58 @@ dependencies = [ "tempfile", ] +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.9.4", + "jni-sys", + "log", + "ndk-sys 0.6.0+11769913", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys", +] + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys", +] + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.9.4", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + [[package]] name = "nix" version = "0.30.1" @@ -1324,6 +3044,22 @@ dependencies = [ "libc", ] +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "notify" version = "6.1.1" @@ -1380,6 +3116,37 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1389,6 +3156,28 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_enum" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "num_threads" version = "0.1.7" @@ -1398,13 +3187,64 @@ dependencies = [ "libc", ] +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" +dependencies = [ + "objc-sys", + "objc2-encode 3.0.0", +] + +[[package]] +name = "objc2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +dependencies = [ + "objc-sys", + "objc2-encode 4.1.0", +] + [[package]] name = "objc2" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "561f357ba7f3a2a61563a186a163d0a3a5247e1089524a3981d49adb775078bc" dependencies = [ - "objc2-encode", + "objc2-encode 4.1.0", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "libc", + "objc2 0.5.2", + "objc2-core-data 0.2.2", + "objc2-core-image 0.2.2", + "objc2-foundation 0.2.2", + "objc2-quartz-core 0.2.2", ] [[package]] @@ -1414,16 +3254,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc" dependencies = [ "bitflags 2.9.4", - "block2", + "block2 0.6.1", "libc", - "objc2", - "objc2-cloud-kit", - "objc2-core-data", + "objc2 0.6.2", + "objc2-cloud-kit 0.3.1", + "objc2-core-data 0.3.1", "objc2-core-foundation", "objc2-core-graphics", - "objc2-core-image", - "objc2-foundation", - "objc2-quartz-core", + "objc2-core-image 0.3.1", + "objc2-foundation 0.3.1", + "objc2-quartz-core 0.3.1", ] [[package]] @@ -1434,11 +3274,24 @@ checksum = "c9abc05b1f757ebfbd72f4f3f9a515662c67dfe66b26e71b37d818f56a1c2f17" dependencies = [ "bitflags 2.9.4", "libc", - "objc2", + "objc2 0.6.2", "objc2-core-foundation", "objc2-core-graphics", "objc2-core-services", - "objc2-foundation", + "objc2-foundation 0.3.1", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-core-location", + "objc2-foundation 0.2.2", ] [[package]] @@ -1448,8 +3301,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17614fdcd9b411e6ff1117dfb1d0150f908ba83a7df81b1f118005fe0a8ea15d" dependencies = [ "bitflags 2.9.4", - "objc2", - "objc2-foundation", + "objc2 0.6.2", + "objc2-foundation 0.3.1", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -1459,8 +3335,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291fbbf7d29287518e8686417cf7239c74700fd4b607623140a7d4a3c834329d" dependencies = [ "bitflags 2.9.4", - "objc2", - "objc2-foundation", + "objc2 0.6.2", + "objc2-foundation 0.3.1", ] [[package]] @@ -1470,10 +3346,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166" dependencies = [ "bitflags 2.9.4", - "block2", + "block2 0.6.1", "dispatch2", "libc", - "objc2", + "objc2 0.6.2", ] [[package]] @@ -1483,13 +3359,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4" dependencies = [ "bitflags 2.9.4", - "block2", + "block2 0.6.1", "dispatch2", "libc", - "objc2", + "objc2 0.6.2", "objc2-core-foundation", "objc2-io-surface", - "objc2-metal", + "objc2-metal 0.3.1", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", ] [[package]] @@ -1498,8 +3386,20 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79b3dc0cc4386b6ccf21c157591b34a7f44c8e75b064f85502901ab2188c007e" dependencies = [ - "objc2", - "objc2-foundation", + "objc2 0.6.2", + "objc2-foundation 0.3.1", +] + +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-contacts", + "objc2-foundation 0.2.2", ] [[package]] @@ -1508,18 +3408,55 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "159be6e4cd366c7d236d798daa2aa71855230e5691cde045a0670ce01a06d664" dependencies = [ + "bitflags 2.9.4", + "block2 0.6.1", "dispatch2", - "objc2", + "libc", + "objc2 0.6.2", "objc2-core-foundation", "objc2-security", ] +[[package]] +name = "objc2-core-video" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1989c3e76c7e978cab0ba9e6f4961cd00ed14ca21121444cc26877403bfb6303" +dependencies = [ + "bitflags 2.9.4", + "block2 0.6.1", + "objc2 0.6.2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-io-surface", + "objc2-metal 0.3.1", +] + +[[package]] +name = "objc2-encode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" + [[package]] name = "objc2-encode" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "dispatch", + "libc", + "objc2 0.5.2", +] + [[package]] name = "objc2-foundation" version = "0.3.1" @@ -1527,9 +3464,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c" dependencies = [ "bitflags 2.9.4", - "block2", + "block2 0.6.1", "libc", - "objc2", + "objc2 0.6.2", "objc2-core-foundation", ] @@ -1550,10 +3487,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c" dependencies = [ "bitflags 2.9.4", - "objc2", + "objc2 0.6.2", "objc2-core-foundation", ] +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + [[package]] name = "objc2-metal" version = "0.3.1" @@ -1561,8 +3522,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f246c183239540aab1782457b35ab2040d4259175bd1d0c58e46ada7b47a874" dependencies = [ "bitflags 2.9.4", - "objc2", - "objc2-foundation", + "objc2 0.6.2", + "objc2-foundation 0.3.1", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", ] [[package]] @@ -1572,8 +3546,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ffb6a0cd5f182dc964334388560b12a57f7b74b3e2dec5e2722aa2dfb2ccd5" dependencies = [ "bitflags 2.9.4", - "objc2", - "objc2-foundation", + "block2 0.6.1", + "libc", + "objc2 0.6.2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-video", + "objc2-foundation 0.3.1", + "objc2-metal 0.3.1", ] [[package]] @@ -1583,15 +3563,70 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1f8e0ef3ab66b08c42644dcb34dba6ec0a574bbd8adbb8bdbdc7a2779731a44" dependencies = [ "bitflags 2.9.4", - "objc2", + "objc2 0.6.2", "objc2-core-foundation", ] [[package]] -name = "object" -version = "0.36.7" +name = "objc2-symbols" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-cloud-kit 0.2.2", + "objc2-core-data 0.2.2", + "objc2-core-image 0.2.2", + "objc2-core-location", + "objc2-foundation 0.2.2", + "objc2-link-presentation", + "objc2-quartz-core 0.2.2", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.9.4", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" dependencies = [ "memchr", ] @@ -1616,7 +3651,7 @@ checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" dependencies = [ "bitflags 2.9.4", "cfg-if", - "foreign-types", + "foreign-types 0.3.2", "libc", "once_cell", "openssl-macros", @@ -1631,7 +3666,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -1659,10 +3694,77 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] -name = "owo-colors" -version = "4.2.2" +name = "orbclient" +version = "0.3.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" +checksum = "ba0b26cec2e24f08ed8bb31519a9333140a6599b867dac464bb150bdb796fd43" +dependencies = [ + "libredox", +] + +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "owo-colors" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" + +[[package]] +name = "palette" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05c0334468e62a4dfbda34b29110aa7d70d58c7fdb2c9857b5874dd9827cc59" +dependencies = [ + "approx", + "num-traits", + "palette_derive", + "phf", + "phf_codegen", +] + +[[package]] +name = "palette_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b4b5f600e60dd3a147fb57b4547033d382d1979eb087af310e91cb45a63b1f4" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" @@ -1684,12 +3786,18 @@ dependencies = [ "cfg-if", "libc", "petgraph", - "redox_syscall", + "redox_syscall 0.5.17", "smallvec", "thread-id", "windows-targets 0.52.6", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pastey" version = "0.1.1" @@ -1712,6 +3820,64 @@ dependencies = [ "indexmap 2.11.4", ] +[[package]] +name = "phf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +dependencies = [ + "phf_shared", + "rand 0.7.3", +] + +[[package]] +name = "phf_shared" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1724,12 +3890,62 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + [[package]] name = "pkg-config" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "png" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "deflate", + "miniz_oxide 0.3.7", +] + +[[package]] +name = "png" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97baced388464909d42d89643fe4361939af9b7ce7a31ee32a168f832a70f2a0" +dependencies = [ + "bitflags 2.9.4", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.1.2", + "windows-sys 0.61.1", +] + [[package]] name = "potential_utf" version = "0.1.3" @@ -1754,6 +3970,15 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "proc-macro-crate" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.101" @@ -1763,6 +3988,27 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "profiling" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" + +[[package]] +name = "pxfm" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83f9b339b02259ada5c0f4a389b7fb472f933aa17ce176fd2ad98f28bb401fde" +dependencies = [ + "num-traits", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quick-xml" version = "0.17.2" @@ -1772,6 +4018,25 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quick-xml" +version = "0.37.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb" +dependencies = [ + "memchr", +] + [[package]] name = "quick-xml" version = "0.38.3" @@ -1796,9 +4061,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -1809,6 +4074,32 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "ramhorns" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d64e28e1069d26c22d4f085ca7f9e2e2eaee16f9d6f80e5fdce62cbf8670f" +dependencies = [ + "arrayvec", + "beef", + "fnv", + "logos", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + [[package]] name = "rand" version = "0.8.5" @@ -1816,8 +4107,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -1827,7 +4128,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -1839,6 +4149,59 @@ dependencies = [ "getrandom 0.2.16", ] +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.17" @@ -1848,6 +4211,17 @@ dependencies = [ "bitflags 2.9.4", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom 0.2.16", + "libredox", + "thiserror 1.0.69", +] + [[package]] name = "redox_users" version = "0.5.2" @@ -1856,34 +4230,34 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] name = "ref-cast" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] name = "regex" -version = "1.11.2" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" +checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c" dependencies = [ "aho-corasick", "memchr", @@ -1893,9 +4267,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" +checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad" dependencies = [ "aho-corasick", "memchr", @@ -1908,6 +4282,12 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + [[package]] name = "reqwest" version = "0.12.23" @@ -1950,6 +4330,15 @@ dependencies = [ "web-sys", ] +[[package]] +name = "rgb" +version = "0.8.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce" +dependencies = [ + "bytemuck", +] + [[package]] name = "ring" version = "0.17.14" @@ -1970,6 +4359,31 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.9.4", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + [[package]] name = "rustix" version = "1.1.2" @@ -1979,8 +4393,8 @@ dependencies = [ "bitflags 2.9.4", "errno", "libc", - "linux-raw-sys", - "windows-sys 0.61.0", + "linux-raw-sys 0.11.0", + "windows-sys 0.61.1", ] [[package]] @@ -2043,7 +4457,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.61.0", + "windows-sys 0.61.1", ] [[package]] @@ -2091,15 +4505,40 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 2.0.106", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scoped_threadpool" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sctk-adwaita" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit", + "tiny-skia", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -2107,7 +4546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.9.4", - "core-foundation", + "core-foundation 0.9.4", "core-foundation-sys", "libc", "security-framework-sys", @@ -2125,9 +4564,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.226" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", @@ -2135,22 +4574,22 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.226" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.226" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2161,7 +4600,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2189,6 +4628,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2201,6 +4651,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_variant" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0068df419f9d9b6488fdded3f1c818522cdea328e02ce9d9f147380265a432" +dependencies = [ + "serde", +] + [[package]] name = "serde_with" version = "3.14.1" @@ -2231,7 +4690,30 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.106", +] + +[[package]] +name = "serde_yaml" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +dependencies = [ + "indexmap 1.9.3", + "ryu", + "serde", + "yaml-rust", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", ] [[package]] @@ -2256,24 +4738,114 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + +[[package]] +name = "shellexpand" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" +dependencies = [ + "dirs 4.0.0", +] + [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook-registry" +version = "1.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +dependencies = [ + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +dependencies = [ + "version_check", +] + [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "smithay-client-toolkit" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" +dependencies = [ + "bitflags 2.9.4", + "calloop", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 0.38.44", + "thiserror 1.0.69", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-clipboard" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc8216eec463674a0e90f29e0ae41a4db573ec5b56b1c6c1c71615d249b6d846" +dependencies = [ + "libc", + "smithay-client-toolkit", + "wayland-backend", +] + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + [[package]] name = "socket2" version = "0.6.0" @@ -2284,25 +4856,68 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "spirv" +version = "0.3.0+sdk-1.3.268.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" +dependencies = [ + "bitflags 2.9.4", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" + [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros 0.26.4", +] + [[package]] name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ - "strum_macros", + "strum_macros 0.27.2", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.106", ] [[package]] @@ -2314,7 +4929,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2323,6 +4938,17 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.106" @@ -2351,21 +4977,21 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] name = "sysinfo" -version = "0.37.0" +version = "0.37.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cec4dc2d2e357ca1e610cfb07de2fa7a10fc3e9fe89f72545f3d244ea87753" +checksum = "3bddd368fda2f82ead69c03d46d351987cfa0c2a57abfa37a017f3aa3e9bf69a" dependencies = [ "libc", "memchr", "ntapi", "objc2-core-foundation", "objc2-io-kit", - "windows", + "windows 0.61.3", ] [[package]] @@ -2375,7 +5001,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags 2.9.4", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -2398,8 +5024,17 @@ dependencies = [ "fastrand", "getrandom 0.3.3", "once_cell", - "rustix", - "windows-sys 0.61.0", + "rustix 1.1.2", + "windows-sys 0.61.1", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", ] [[package]] @@ -2408,7 +5043,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b8cb979cb11c32ce1603f8137b22262a9d131aaa5c37b5678025f22b8becd0" dependencies = [ - "rustix", + "rustix 1.1.2", "windows-sys 0.60.2", ] @@ -2423,11 +5058,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl 2.0.16", + "thiserror-impl 2.0.17", ] [[package]] @@ -2438,18 +5073,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2471,6 +5106,31 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "tiff" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437" +dependencies = [ + "jpeg-decoder", + "miniz_oxide 0.4.4", + "weezl", +] + +[[package]] +name = "tiff" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af9605de7fee8d9551863fd692cce7637f548dbd9db9180fcc07ccc6d26c336f" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + [[package]] name = "time" version = "0.3.44" @@ -2504,6 +5164,31 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + [[package]] name = "tinystr" version = "0.8.1" @@ -2543,9 +5228,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f63835928ca123f1bef57abbcd23bb2ba0ac9ae1235f1e65bda0d06e7786bd" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ "rustls", "tokio", @@ -2564,6 +5249,45 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.23.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b" +dependencies = [ + "indexmap 2.11.4", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627" +dependencies = [ + "winnow", +] + [[package]] name = "tower" version = "0.5.2" @@ -2640,7 +5364,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2698,6 +5422,27 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" + +[[package]] +name = "type-map" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90" +dependencies = [ + "rustc-hash 2.1.1", +] + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + [[package]] name = "tz-rs" version = "0.7.0" @@ -2724,12 +5469,35 @@ dependencies = [ "tz-rs", ] +[[package]] +name = "uds_windows" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" +dependencies = [ + "memoffset", + "tempfile", + "winapi", +] + [[package]] name = "unicode-ident" version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -2778,6 +5546,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "walkdir" version = "2.5.0" @@ -2797,6 +5571,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -2844,7 +5624,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 2.0.106", "wasm-bindgen-shared", ] @@ -2879,7 +5659,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2893,6 +5673,115 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wayland-backend" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673a33c33048a5ade91a6b139580fa174e19fb0d23f396dca9fa15f2e1e49b35" +dependencies = [ + "cc", + "downcast-rs", + "rustix 1.1.2", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66a47e840dc20793f2264eb4b3e4ecb4b75d91c0dd4af04b456128e0bdd449d" +dependencies = [ + "bitflags 2.9.4", + "rustix 1.1.2", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.9.4", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447ccc440a881271b19e9989f75726d60faa09b95b0200a9b7eb5cc47c3eeb29" +dependencies = [ + "rustix 1.1.2", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efa790ed75fbfd71283bd2521a1cfdc022aabcc28bdcff00851f9e4ae88d9901" +dependencies = [ + "bitflags 2.9.4", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a07a14257c077ab3279987c4f8bb987851bf57081b93710381daea94f2c2c032" +dependencies = [ + "bitflags 2.9.4", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd94963ed43cf9938a090ca4f7da58eb55325ec8200c3848963e98dc25b78ec" +dependencies = [ + "bitflags 2.9.4", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54cb1e9dc49da91950bdfd8b848c49330536d9d1fb03d4bfec8cae50caa50ae3" +dependencies = [ + "proc-macro2", + "quick-xml 0.37.5", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34949b42822155826b41db8e5d0c1be3a2bd296c747577a43a3e6daefc296142" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + [[package]] name = "web-sys" version = "0.3.81" @@ -2903,6 +5792,141 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf4f3c0ba838e82b4e5ccc4157003fb8c324ee24c058470ffb82820becbde98" +dependencies = [ + "core-foundation 0.10.1", + "jni", + "log", + "ndk-context", + "objc2 0.6.2", + "objc2-foundation 0.3.1", + "url", + "web-sys", +] + +[[package]] +name = "weezl" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a751b3277700db47d3e574514de2eced5e54dc8a5436a3bf7a0b248b2cee16f3" + +[[package]] +name = "wgpu" +version = "24.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0b3436f0729f6cdf2e6e9201f3d39dc95813fad61d826c1ed07918b4539353" +dependencies = [ + "arrayvec", + "bitflags 2.9.4", + "cfg_aliases", + "document-features", + "js-sys", + "log", + "parking_lot", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "24.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f0aa306497a238d169b9dc70659105b4a096859a34894544ca81719242e1499" +dependencies = [ + "arrayvec", + "bit-vec", + "bitflags 2.9.4", + "cfg_aliases", + "document-features", + "indexmap 2.11.4", + "log", + "naga", + "once_cell", + "parking_lot", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.17", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-hal" +version = "24.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f112f464674ca69f3533248508ee30cb84c67cf06c25ff6800685f5e0294e259" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bitflags 2.9.4", + "bytemuck", + "cfg_aliases", + "core-graphics-types", + "glow", + "glutin_wgl_sys", + "gpu-alloc", + "gpu-descriptor", + "js-sys", + "khronos-egl", + "libc", + "libloading", + "log", + "metal", + "naga", + "ndk-sys 0.5.0+25.2.9519653", + "objc", + "once_cell", + "ordered-float", + "parking_lot", + "profiling", + "raw-window-handle", + "renderdoc-sys", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.17", + "wasm-bindgen", + "web-sys", + "wgpu-types", + "windows 0.58.0", +] + +[[package]] +name = "wgpu-types" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50ac044c0e76c03a0378e7786ac505d010a873665e2d51383dcff8dd227dc69c" +dependencies = [ + "bitflags 2.9.4", + "js-sys", + "log", + "web-sys", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2925,7 +5949,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.0", + "windows-sys 0.61.1", ] [[package]] @@ -2934,6 +5958,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core 0.58.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.61.3" @@ -2956,14 +5990,27 @@ dependencies = [ "windows-core 0.61.2", ] +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement", - "windows-interface", + "windows-implement 0.60.1", + "windows-interface 0.59.2", "windows-link 0.1.3", "windows-result 0.3.4", "windows-strings 0.4.2", @@ -2971,12 +6018,12 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.62.0" +version = "0.62.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" +checksum = "6844ee5416b285084d3d3fffd743b925a6c9385455f64f6d4fa3031c4c2749a9" dependencies = [ - "windows-implement", - "windows-interface", + "windows-implement 0.60.1", + "windows-interface 0.59.2", "windows-link 0.2.0", "windows-result 0.4.0", "windows-strings 0.5.0", @@ -2995,24 +6042,46 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.60.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", +] + +[[package]] +name = "windows-implement" +version = "0.60.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edb307e42a74fb6de9bf3a02d9712678b22399c87e6fa869d6dfcd8c1b7754e0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", ] [[package]] name = "windows-interface" -version = "0.59.1" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", +] + +[[package]] +name = "windows-interface" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", ] [[package]] @@ -3048,6 +6117,15 @@ dependencies = [ "windows-strings 0.4.2", ] +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.3.4" @@ -3066,6 +6144,16 @@ dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows-strings" version = "0.4.2" @@ -3084,6 +6172,15 @@ dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -3117,18 +6214,33 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.3", + "windows-targets 0.53.4", ] [[package]] name = "windows-sys" -version = "0.61.0" +version = "0.61.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa" +checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f" dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -3162,11 +6274,11 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.3" +version = "0.53.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b" dependencies = [ - "windows-link 0.1.3", + "windows-link 0.2.0", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", @@ -3186,6 +6298,12 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -3204,6 +6322,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -3222,6 +6346,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -3252,6 +6382,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -3270,6 +6406,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -3288,6 +6430,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -3306,6 +6454,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -3324,6 +6478,67 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +[[package]] +name = "winit" +version = "0.30.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66d4b9ed69c4009f6321f762d6e61ad8a2389cd431b97cb1e146812e9e6c732" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.9.4", + "block2 0.5.1", + "bytemuck", + "calloop", + "cfg_aliases", + "concurrent-queue", + "core-foundation 0.9.4", + "core-graphics", + "cursor-icon", + "dpi", + "js-sys", + "libc", + "memmap2", + "ndk", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", + "objc2-ui-kit", + "orbclient", + "percent-encoding", + "pin-project", + "raw-window-handle", + "redox_syscall 0.4.1", + "rustix 0.38.44", + "sctk-adwaita", + "smithay-client-toolkit", + "smol_str", + "tracing", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.52.0", + "x11-dl", + "x11rb", + "xkbcommon-dl", +] + +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +dependencies = [ + "memchr", +] + [[package]] name = "wit-bindgen" version = "0.46.0" @@ -3336,6 +6551,88 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "x11rb" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" +dependencies = [ + "as-raw-xcb-connection", + "gethostname", + "libc", + "libloading", + "once_cell", + "rustix 1.1.2", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + +[[package]] +name = "xcursor" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b" + +[[package]] +name = "xdg-home" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.9.4", + "dlib", + "log", + "once_cell", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "xml-rs" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fd8403733700263c6eb89f192880191f1b83e332f7a20371ddcf421c4a337c7" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yoke" version = "0.8.0" @@ -3356,10 +6653,109 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", "synstructure", ] +[[package]] +name = "zbus" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" +dependencies = [ + "async-broadcast", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix 0.29.0", + "ordered-stream", + "rand 0.8.5", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tracing", + "uds_windows", + "windows-sys 0.52.0", + "xdg-home", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus-lockstep" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca2c5dceb099bddaade154055c926bb8ae507a18756ba1d8963fd7b51d8ed1d" +dependencies = [ + "zbus_xml", + "zvariant", +] + +[[package]] +name = "zbus-lockstep-macros" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709ab20fc57cb22af85be7b360239563209258430bccf38d8b979c5a2ae3ecce" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", + "zbus-lockstep", + "zbus_xml", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.106", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + +[[package]] +name = "zbus_xml" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3f374552b954f6abb4bd6ce979e6c9b38fb9d0cd7cc68a7d796e70c9f3a233" +dependencies = [ + "quick-xml 0.30.0", + "serde", + "static_assertions", + "zbus_names", + "zvariant", +] + [[package]] name = "zerocopy" version = "0.8.27" @@ -3377,7 +6773,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -3397,15 +6793,15 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", "synstructure", ] [[package]] name = "zeroize" -version = "1.8.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" [[package]] name = "zerotrie" @@ -3437,5 +6833,57 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", +] + +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-jpeg" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ce2c8a9384ad323cf564b67da86e21d3cfdff87908bc1223ed5c99bc792713" +dependencies = [ + "zune-core", +] + +[[package]] +name = "zvariant" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" +dependencies = [ + "endi", + "enumflags2", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.106", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", ] diff --git a/deny.toml b/deny.toml index c22b2f35..fc814d68 100644 --- a/deny.toml +++ b/deny.toml @@ -9,7 +9,10 @@ no-default-features = false feature-depth = 1 [advisories] -ignore = [] +ignore = [ + { id = "RUSTSEC-2024-0320", reason = "not using any yaml features from this library" }, + { id = "RUSTSEC-2025-0056", reason = "only used for colour palette generation" } +] [licenses] allow = [ @@ -18,8 +21,11 @@ allow = [ "Artistic-2.0", "BSD-3-Clause", "CC0-1.0", + "ISC", "MIT", "MPL-2.0", + "OFL-1.1", + "Ubuntu-font-1.0", "Unicode-3.0", "Zlib", @@ -28,10 +34,7 @@ allow = [ # "BSD-2-Clause", # "BSL-1.0", - # "ISC", # "MIT-0", - # "OFL-1.1", - # "Ubuntu-font-1.0", ] confidence-threshold = 0.8 @@ -50,6 +53,16 @@ crate = "komorebic" expression = "LicenseRef-Komorebi-2.0" license-files = [] +[[licenses.clarify]] +crate = "komorebi-themes" +expression = "LicenseRef-Komorebi-2.0" +license-files = [] + +[[licenses.clarify]] +crate = "base16-egui-themes" +expression = "MIT" +license-files = [] + [bans] multiple-versions = "allow" wildcards = "allow" @@ -63,4 +76,10 @@ unknown-git = "deny" allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-git = [ "https://github.com/LGUG2Z/quickxml_to_serde", + "https://github.com/LGUG2Z/base16-egui-themes", + "https://github.com/LGUG2Z/catppuccin-egui", + "https://github.com/LGUG2Z/flavours", + "https://github.com/LGUG2Z/komorebi", + "https://github.com/LGUG2Z/base16_color_scheme", + ] \ No newline at end of file diff --git a/dependencies.json b/dependencies.json index 1140615e..63745539 100644 --- a/dependencies.json +++ b/dependencies.json @@ -3,25 +3,44 @@ [ "0BSD", [ + "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "Apache-2.0", [ - "addr2line 0.24.2 registry+https://github.com/rust-lang/crates.io-index", + "ab_glyph 0.2.32 registry+https://github.com/rust-lang/crates.io-index", + "ab_glyph_rasterizer 0.1.10 registry+https://github.com/rust-lang/crates.io-index", + "accesskit 0.17.1 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_consumer 0.26.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_macos 0.18.1 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_winit 0.23.1 registry+https://github.com/rust-lang/crates.io-index", + "addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index", + "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", - "anstyle 1.0.11 registry+https://github.com/rust-lang/crates.io-index", + "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "anyhow 1.0.100 registry+https://github.com/rust-lang/crates.io-index", + "approx 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "arboard 3.6.1 registry+https://github.com/rust-lang/crates.io-index", + "arrayvec 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "atomic-waker 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", + "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", + "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", + "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", + "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.38 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.39 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", + "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", @@ -30,36 +49,74 @@ "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "colorchoice 1.0.4 registry+https://github.com/rust-lang/crates.io-index", + "core-foundation 0.10.1 registry+https://github.com/rust-lang/crates.io-index", "core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index", "core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index", + "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", + "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", - "deranged 0.5.3 registry+https://github.com/rust-lang/crates.io-index", + "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "deflate 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "deranged 0.5.4 registry+https://github.com/rust-lang/crates.io-index", + "dirs 3.0.2 registry+https://github.com/rust-lang/crates.io-index", + "dirs 4.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", + "dirs-sys 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index", + "document-features 0.2.11 registry+https://github.com/rust-lang/crates.io-index", + "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", + "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "egui-winit 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", + "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "find-msvc-tools 0.1.2 registry+https://github.com/rust-lang/crates.io-index", + "flate2 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types-macros 0.2.3 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types-shared 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", "futures-channel 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-core 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-sink 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-task 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-util 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.1.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", - "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", + "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", + "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", + "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", + "glutin 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "half 2.6.0 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "hex 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "hex_color 3.0.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "http 1.3.1 registry+https://github.com/rust-lang/crates.io-index", "httparse 1.10.1 registry+https://github.com/rust-lang/crates.io-index", @@ -68,7 +125,10 @@ "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", + "image 0.25.8 registry+https://github.com/rust-lang/crates.io-index", + "immutable-chunkmap 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", @@ -76,16 +136,29 @@ "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", + "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.176 registry+https://github.com/rust-lang/crates.io-index", "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", + "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", + "litrs 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", + "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", + "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", + "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", + "minimal-lexical 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", + "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "num-integer 0.1.46 registry+https://github.com/rust-lang/crates.io-index", + "num-iter 0.1.45 registry+https://github.com/rust-lang/crates.io-index", + "num-rational 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -96,11 +169,16 @@ "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-video 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", + "objc2-security 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "object 0.37.3 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", + "owned_ttf_parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", + "palette 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "palette_derive 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", @@ -108,15 +186,27 @@ "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "pkg-config 0.3.32 registry+https://github.com/rust-lang/crates.io-index", + "png 0.16.8 registry+https://github.com/rust-lang/crates.io-index", + "png 0.18.0 registry+https://github.com/rust-lang/crates.io-index", "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", - "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", + "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index", + "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", + "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", + "rand_chacha 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "rand_chacha 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "rand_core 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "rand_core 0.6.4 registry+https://github.com/rust-lang/crates.io-index", - "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", - "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", + "rand_pcg 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", + "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", + "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.11.3 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.11 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", @@ -126,31 +216,43 @@ "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", "security-framework-sys 2.15.0 registry+https://github.com/rust-lang/crates.io-index", - "serde 1.0.226 registry+https://github.com/rust-lang/crates.io-index", - "serde_core 1.0.226 registry+https://github.com/rust-lang/crates.io-index", - "serde_derive 1.0.226 registry+https://github.com/rust-lang/crates.io-index", + "serde 1.0.228 registry+https://github.com/rust-lang/crates.io-index", + "serde_core 1.0.228 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive 1.0.228 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive_internals 0.29.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_json 1.0.145 registry+https://github.com/rust-lang/crates.io-index", "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", "shadow-rs 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "siphasher 0.3.11 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", + "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "stable_deref_trait 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", "sync_wrapper 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", - "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", + "tempfile 3.23.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", - "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 2.0.17 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", - "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 2.0.17 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", "time 0.3.44 registry+https://github.com/rust-lang/crates.io-index", "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", + "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", + "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", @@ -160,8 +262,16 @@ "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "vcpkg 0.2.15 registry+https://github.com/rust-lang/crates.io-index", + "version_check 0.9.5 registry+https://github.com/rust-lang/crates.io-index", + "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "webbrowser 1.0.5 registry+https://github.com/rust-lang/crates.io-index", + "weezl 0.1.10 registry+https://github.com/rust-lang/crates.io-index", + "winit 0.30.12 registry+https://github.com/rust-lang/crates.io-index", + "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", - "zeroize 1.8.1 registry+https://github.com/rust-lang/crates.io-index" + "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", + "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -186,7 +296,9 @@ [ "BSD-3-Clause", [ - "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index" + "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.5 registry+https://github.com/rust-lang/crates.io-index", + "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -203,26 +315,54 @@ "notify-debouncer-full 0.1.0 registry+https://github.com/rust-lang/crates.io-index" ] ], + [ + "ISC", + [ + "libloading 0.8.9 registry+https://github.com/rust-lang/crates.io-index" + ] + ], [ "MIT", [ - "addr2line 0.24.2 registry+https://github.com/rust-lang/crates.io-index", + "accesskit 0.17.1 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_consumer 0.26.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_macos 0.18.1 registry+https://github.com/rust-lang/crates.io-index", + "addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index", + "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", + "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", - "anstyle 1.0.11 registry+https://github.com/rust-lang/crates.io-index", + "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "anyhow 1.0.100 registry+https://github.com/rust-lang/crates.io-index", + "arboard 3.6.1 registry+https://github.com/rust-lang/crates.io-index", + "arrayvec 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "atomic-waker 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "backtrace 0.3.75 registry+https://github.com/rust-lang/crates.io-index", + "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", + "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", + "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", + "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "block-sys 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "block2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "block2 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", + "byteorder 1.5.0 registry+https://github.com/rust-lang/crates.io-index", + "byteorder-lite 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.38 registry+https://github.com/rust-lang/crates.io-index", + "calm_io 0.1.1 registry+https://github.com/rust-lang/crates.io-index", + "calmio_filters 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "catppuccin-egui 5.3.1 git+https://github.com/LGUG2Z/catppuccin-egui?rev=bdaff30959512c4f7ee7304117076a48633d777f", + "cc 1.2.39 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", @@ -230,29 +370,62 @@ "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "color-thief 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "color_quant 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "colorchoice 1.0.4 registry+https://github.com/rust-lang/crates.io-index", + "core-foundation 0.10.1 registry+https://github.com/rust-lang/crates.io-index", "core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index", "core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index", + "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", + "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "darling 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "darling_core 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "darling_macro 0.21.3 registry+https://github.com/rust-lang/crates.io-index", - "deranged 0.5.3 registry+https://github.com/rust-lang/crates.io-index", + "deflate 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "deranged 0.5.4 registry+https://github.com/rust-lang/crates.io-index", + "dirs 3.0.2 registry+https://github.com/rust-lang/crates.io-index", + "dirs 4.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", + "dirs-sys 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index", + "document-features 0.2.11 registry+https://github.com/rust-lang/crates.io-index", + "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", + "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "egui-winit 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", + "fax 0.2.6 registry+https://github.com/rust-lang/crates.io-index", + "fax_derive 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "find-msvc-tools 0.1.2 registry+https://github.com/rust-lang/crates.io-index", + "flate2 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "flavours 0.7.2 git+https://github.com/LGUG2Z/flavours", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types-macros 0.2.3 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types-shared 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", "fs-tail 0.1.4 registry+https://github.com/rust-lang/crates.io-index", "fsevent-sys 4.1.0 registry+https://github.com/rust-lang/crates.io-index", @@ -261,13 +434,23 @@ "futures-sink 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-task 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-util 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.1.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", - "gimli 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", + "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", + "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", + "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", + "glutin-winit 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "h2 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "half 2.6.0 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "hex 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "hex_color 3.0.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "http 1.3.1 registry+https://github.com/rust-lang/crates.io-index", "http-body 1.0.1 registry+https://github.com/rust-lang/crates.io-index", @@ -280,7 +463,11 @@ "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", + "image 0.23.14 registry+https://github.com/rust-lang/crates.io-index", + "image 0.25.8 registry+https://github.com/rust-lang/crates.io-index", + "immutable-chunkmap 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", @@ -288,25 +475,44 @@ "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", + "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "libc 0.2.175 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.176 registry+https://github.com/rust-lang/crates.io-index", "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", + "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", + "litrs 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", + "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", + "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", + "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", - "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index", + "memchr 2.7.6 registry+https://github.com/rust-lang/crates.io-index", + "memoffset 0.9.1 registry+https://github.com/rust-lang/crates.io-index", "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", + "minimal-lexical 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "miniz_oxide 0.3.7 registry+https://github.com/rust-lang/crates.io-index", + "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", "mio 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "nanoid 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", + "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "nom 7.1.3 registry+https://github.com/rust-lang/crates.io-index", "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "num-integer 0.1.46 registry+https://github.com/rust-lang/crates.io-index", + "num-iter 0.1.45 registry+https://github.com/rust-lang/crates.io-index", + "num-rational 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", + "objc-sys 0.3.5 registry+https://github.com/rust-lang/crates.io-index", + "objc2 0.4.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-app-kit 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -315,76 +521,115 @@ "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-video 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-encode 3.0.0 registry+https://github.com/rust-lang/crates.io-index", "objc2-encode 4.1.0 registry+https://github.com/rust-lang/crates.io-index", + "objc2-foundation 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "object 0.36.7 registry+https://github.com/rust-lang/crates.io-index", + "objc2-security 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "object 0.37.3 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", - "owo-colors 4.2.2 registry+https://github.com/rust-lang/crates.io-index", + "owo-colors 4.2.3 registry+https://github.com/rust-lang/crates.io-index", + "palette 0.5.0 registry+https://github.com/rust-lang/crates.io-index", + "palette_derive 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", + "phf 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "phf_codegen 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "phf_generator 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "phf_shared 0.8.0 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "pkg-config 0.3.32 registry+https://github.com/rust-lang/crates.io-index", + "png 0.16.8 registry+https://github.com/rust-lang/crates.io-index", + "png 0.18.0 registry+https://github.com/rust-lang/crates.io-index", "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", + "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", + "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.38.3 registry+https://github.com/rust-lang/crates.io-index", "quickxml_to_serde 0.6.1 git+https://github.com/LGUG2Z/quickxml_to_serde.git", - "quote 1.0.40 registry+https://github.com/rust-lang/crates.io-index", + "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", + "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", + "rand_chacha 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "rand_chacha 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "rand_core 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "rand_core 0.6.4 registry+https://github.com/rust-lang/crates.io-index", - "regex 1.11.2 registry+https://github.com/rust-lang/crates.io-index", - "regex-automata 0.4.10 registry+https://github.com/rust-lang/crates.io-index", + "rand_pcg 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", + "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", + "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.11.3 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.11 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", + "rgb 0.8.52 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "rustls-pki-types 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", + "schemars 0.8.22 registry+https://github.com/rust-lang/crates.io-index", + "schemars_derive 0.8.22 registry+https://github.com/rust-lang/crates.io-index", + "scoped_threadpool 0.1.9 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", "security-framework-sys 2.15.0 registry+https://github.com/rust-lang/crates.io-index", - "serde 1.0.226 registry+https://github.com/rust-lang/crates.io-index", - "serde_core 1.0.226 registry+https://github.com/rust-lang/crates.io-index", - "serde_derive 1.0.226 registry+https://github.com/rust-lang/crates.io-index", + "serde 1.0.228 registry+https://github.com/rust-lang/crates.io-index", + "serde_core 1.0.228 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive 1.0.228 registry+https://github.com/rust-lang/crates.io-index", + "serde_derive_internals 0.29.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_json 1.0.145 registry+https://github.com/rust-lang/crates.io-index", "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", "shadow-rs 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", + "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "simd-adler32 0.3.7 registry+https://github.com/rust-lang/crates.io-index", + "siphasher 0.3.11 registry+https://github.com/rust-lang/crates.io-index", "slab 0.4.11 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", + "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "stable_deref_trait 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "strsim 0.11.1 registry+https://github.com/rust-lang/crates.io-index", "strum 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", + "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", - "sysinfo 0.37.0 registry+https://github.com/rust-lang/crates.io-index", + "sysinfo 0.37.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", - "tempfile 3.22.0 registry+https://github.com/rust-lang/crates.io-index", + "tempfile 3.23.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", - "thiserror 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror 2.0.17 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", - "thiserror-impl 2.0.16 registry+https://github.com/rust-lang/crates.io-index", + "thiserror-impl 2.0.17 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", + "tiff 0.10.3 registry+https://github.com/rust-lang/crates.io-index", + "tiff 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "time 0.3.44 registry+https://github.com/rust-lang/crates.io-index", "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "tokio 1.47.1 registry+https://github.com/rust-lang/crates.io-index", "tokio-native-tls 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "tokio-util 0.7.16 registry+https://github.com/rust-lang/crates.io-index", + "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", "tower 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "tower-http 0.6.6 registry+https://github.com/rust-lang/crates.io-index", "tower-layer 0.3.3 registry+https://github.com/rust-lang/crates.io-index", @@ -397,6 +642,7 @@ "tracing-log 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", "try-lock 0.2.5 registry+https://github.com/rust-lang/crates.io-index", + "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", @@ -405,10 +651,17 @@ "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "vcpkg 0.2.15 registry+https://github.com/rust-lang/crates.io-index", + "version_check 0.9.5 registry+https://github.com/rust-lang/crates.io-index", "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index", "want 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "webbrowser 1.0.5 registry+https://github.com/rust-lang/crates.io-index", + "weezl 0.1.10 registry+https://github.com/rust-lang/crates.io-index", + "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", - "zeroize 1.8.1 registry+https://github.com/rust-lang/crates.io-index" + "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", + "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -421,7 +674,20 @@ "MPL-2.0", [ "minidom 0.12.0 registry+https://github.com/rust-lang/crates.io-index", - "option-ext 0.2.0 registry+https://github.com/rust-lang/crates.io-index" + "option-ext 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "ramhorns 1.0.1 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "OFL-1.1", + [ + "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index" + ] + ], + [ + "Ubuntu-font-1.0", + [ + "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -452,7 +718,9 @@ "Unlicense", [ "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", - "memchr 2.7.5 registry+https://github.com/rust-lang/crates.io-index", + "byteorder 1.5.0 registry+https://github.com/rust-lang/crates.io-index", + "byteorder-lite 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "memchr 2.7.6 registry+https://github.com/rust-lang/crates.io-index", "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index" ] @@ -460,9 +728,16 @@ [ "Zlib", [ + "adler32 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "const_format 0.2.34 registry+https://github.com/rust-lang/crates.io-index", "const_format_proc_macros 0.2.34 registry+https://github.com/rust-lang/crates.io-index", + "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "foldhash 0.1.5 registry+https://github.com/rust-lang/crates.io-index", + "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", + "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -472,9 +747,14 @@ "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-video 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index" + "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-security 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", + "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" ] ] ] diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index c49a9fb2..a6d960fd 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -5,18 +5,25 @@ description = "A tiling window manager for macOS" edition = "2024" [dependencies] +komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", version = "0.1.38"} + clap = { workspace = true } color-eyre = { workspace = true } crossbeam-channel = "0.5" +crossbeam-utils = "0.8" ctrlc = { version = "3", features = ["termination"] } dispatch2 = "0.3" dirs = { workspace = true } hotwatch = "0.5" lazy_static = { workspace = true } nanoid = "0.4" +block2 = "0.3" objc2 = "0.6" +objc2-core-services = "0.3" objc2-app-kit = "0.3" objc2-application-services = "0.3" +objc2-quartz-core = "0.3" +objc2-core-video = "0.3" objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } objc2-foundation = "0.3" diff --git a/komorebi/src/accessibility/mod.rs b/komorebi/src/accessibility/mod.rs index 0a799709..4cbfa4fc 100644 --- a/komorebi/src/accessibility/mod.rs +++ b/komorebi/src/accessibility/mod.rs @@ -15,6 +15,7 @@ use objc2_core_foundation::CFString; use objc2_core_foundation::CFType; use objc2_core_foundation::kCFRunLoopDefaultMode; use objc2_core_graphics::CGWindowID; +use std::ffi::c_void; use std::ptr::NonNull; pub mod action_constants; @@ -141,6 +142,7 @@ impl AccessibilityApi { observer: &AXObserver, element: &AXUIElement, notifications: &[&'static str], + refcon: Option<*mut c_void>, ) -> Result<(), AccessibilityError> { for notification in notifications { unsafe { @@ -148,7 +150,7 @@ impl AccessibilityApi { observer, element, &CFString::from_str(notification), - std::ptr::null_mut(), + refcon.unwrap_or_default(), )) { // we don't want to return until all the notifications have been added AccessibilityError::Api(AccessibilityApiError::Success) => {} @@ -175,8 +177,9 @@ impl AccessibilityApi { element: &AXUIElement, notifications: &[&'static str], run_loop: &CFRunLoop, + refcon: Option<*mut c_void>, ) -> Result<(), AccessibilityError> { - AccessibilityApi::add_notifications_to_observer(observer, element, notifications)?; + AccessibilityApi::add_notifications_to_observer(observer, element, notifications, refcon)?; unsafe { CFRunLoop::add_source( diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index d9cc66df..8656c715 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -121,7 +121,7 @@ impl Application { } #[tracing::instrument(skip_all)] - pub fn observe(&mut self, run_loop: &CFRunLoop) { + pub fn observe(&mut self, run_loop: &CFRunLoop, refcon: Option<*mut c_void>) { tracing::info!( "registering observer for process: {}, name: {}", self.process_id, @@ -137,6 +137,7 @@ impl Application { &self.element, NOTIFICATIONS, run_loop, + refcon, ) { Ok(_) => { self.is_observable = true; diff --git a/komorebi/src/border_manager/border.rs b/komorebi/src/border_manager/border.rs new file mode 100644 index 00000000..3d5d05ef --- /dev/null +++ b/komorebi/src/border_manager/border.rs @@ -0,0 +1,161 @@ +use crate::AccessibilityObserver; +use crate::AccessibilityUiElement; +use crate::CoreFoundationRunLoop; +use crate::accessibility::AccessibilityApi; +use crate::accessibility::notification_constants::kAXMainWindowChangedNotification; +use crate::accessibility::notification_constants::kAXWindowMovedNotification; +use crate::accessibility::notification_constants::kAXWindowResizedNotification; +use crate::border_manager::BORDER_OFFSET; +use crate::border_manager::BORDER_WIDTH; +use crate::border_manager::ns_window::NsWindow; +use crate::border_manager::window_kind_colour; +use crate::core::WindowKind; +use crate::core::rect::Rect; +use crate::core_graphics::CoreGraphicsApi; +use crate::macos_api::MacosApi; +use color_eyre::eyre; +use dispatch2::DispatchQueue; +use komorebi_themes::colour::Rgb; +use objc2_application_services::AXObserver; +use objc2_application_services::AXUIElement; +use objc2_core_foundation::CFString; +use objc2_core_foundation::CGFloat; +use objc2_core_graphics::CGMainDisplayID; +use objc2_foundation::NSPoint; +use objc2_foundation::NSRect; +use objc2_quartz_core::CATransaction; +use std::ffi::c_void; +use std::ptr::NonNull; +use std::sync::atomic::Ordering; +use tracing::instrument; + +#[instrument(skip_all)] +unsafe extern "C-unwind" fn border_observer_callback( + _observer: NonNull, + _element: NonNull, + _notification: NonNull, + context: *mut c_void, +) { + unsafe { + if !context.is_null() { + let border = &*context.cast::(); + if !border.ns_window.window.isVisible() { + return; + } + + if let Ok(rect) = MacosApi::window_rect(&border.tracking_element) { + let frame = Rect::from(CoreGraphicsApi::display_bounds(CGMainDisplayID())); + let mut ns_rect = NSRect::new( + NSPoint::new( + rect.origin.x, + frame.bottom as CGFloat - rect.origin.y - rect.size.height, + ), + rect.size, + ); + + let offset = BORDER_OFFSET.load(Ordering::Relaxed) as f64; + + ns_rect.origin.x -= offset; + ns_rect.origin.y -= offset; + ns_rect.size.width += offset * 2.0; + ns_rect.size.height += offset * 2.0; + + border.update(); + border + .ns_window + .window + .setFrame_display_animate(ns_rect, false, false); + } + } + } +} + +#[derive(Debug)] +pub struct Border { + pub id: String, + #[allow(dead_code)] + // we need to keep a reference to this so it stays alive + pub observer: AccessibilityObserver, + pub tracking_element: AccessibilityUiElement, + pub tracking_window_id: u32, + pub monitor_idx: Option, + pub ns_window: NsWindow, + pub window_kind: WindowKind, +} + +unsafe impl Send for Border {} + +impl Border { + pub fn create( + id: &str, + tracking_window_id: u32, + process_id: i32, + element: AccessibilityUiElement, + monitor_idx: Option, + run_loop: CoreFoundationRunLoop, + ) -> eyre::Result> { + let observer = AccessibilityObserver(AccessibilityApi::create_observer( + process_id, + Some(border_observer_callback), + )?); + + let rect = MacosApi::window_rect(&element).unwrap_or_default(); + + let frame = Rect::from(CoreGraphicsApi::display_bounds(unsafe { + CGMainDisplayID() + })); + let ns_rect = NSRect::new( + NSPoint::new( + rect.origin.x, + frame.bottom as CGFloat - rect.origin.y - rect.size.height, + ), + rect.size, + ); + + let mut border = Box::new(Self { + id: id.to_string(), + tracking_window_id, + monitor_idx, + observer: observer.clone(), + tracking_element: element.clone(), + ns_window: NsWindow::new(ns_rect)?, + window_kind: WindowKind::Unfocused, + }); + + DispatchQueue::main().exec_sync(|| { + let border_ptr = std::ptr::addr_of_mut!(*border).cast::(); + if let Err(error) = AccessibilityApi::add_observer_to_run_loop( + &observer, + &element, + &[ + kAXWindowMovedNotification, + kAXWindowResizedNotification, + kAXMainWindowChangedNotification, + ], + &run_loop, + Some(border_ptr), + ) { + tracing::warn!("failed to create border observer: {error}") + } + }); + + Ok(border) + } + + pub fn update(&self) { + let colour = Rgb::from(window_kind_colour(self.window_kind)); + + CATransaction::begin(); + CATransaction::setDisableActions(true); + self.ns_window.set_border_color(colour); + self.ns_window + .set_border_width(BORDER_WIDTH.load(Ordering::Relaxed) as f64); + // TODO: why does this crash? + // self.ns_window.window.setFrame_display(ns_rect, true); + CATransaction::commit(); + } + + pub fn destroy(&self) { + self.ns_window.window.close(); + } +} diff --git a/komorebi/src/border_manager/mod.rs b/komorebi/src/border_manager/mod.rs new file mode 100644 index 00000000..dd913d54 --- /dev/null +++ b/komorebi/src/border_manager/mod.rs @@ -0,0 +1,550 @@ +mod border; +mod ns_window; + +use crate::AccessibilityUiElement; +use crate::CoreFoundationRunLoop; +use crate::accessibility::AccessibilityApi; +use crate::border_manager::border::Border; +use crate::core::WindowKind; +use crate::macos_api::MacosApi; +use crate::ring::Ring; +use crate::window_manager::WindowManager; +use crate::workspace::Workspace; +use crate::workspace::WorkspaceLayer; +use color_eyre::eyre; +use crossbeam_channel::Receiver; +use crossbeam_channel::Sender; +use crossbeam_utils::atomic::AtomicConsume; +use dispatch2::DispatchQueue; +use komorebi_themes::colour::Colour; +use komorebi_themes::colour::Rgb; +use lazy_static::lazy_static; +use parking_lot::Mutex; +use std::collections::HashMap; +use std::collections::hash_map::Entry; +use std::sync::Arc; +use std::sync::OnceLock; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::AtomicI32; +use std::sync::atomic::AtomicU32; +use std::sync::atomic::Ordering; + +pub static BORDER_WIDTH: AtomicI32 = AtomicI32::new(6); +pub static BORDER_OFFSET: AtomicI32 = AtomicI32::new(5); +pub static BORDER_RADIUS: AtomicI32 = AtomicI32::new(10); +pub static BORDER_ENABLED: AtomicBool = AtomicBool::new(true); + +lazy_static! { + pub static ref FOCUSED: AtomicU32 = + AtomicU32::new(u32::from(Colour::Rgb(Rgb::new(66, 165, 245)))); + pub static ref UNFOCUSED: AtomicU32 = + AtomicU32::new(u32::from(Colour::Rgb(Rgb::new(128, 128, 128)))); + pub static ref UNFOCUSED_LOCKED: AtomicU32 = + AtomicU32::new(u32::from(Colour::Rgb(Rgb::new(158, 8, 8)))); + pub static ref MONOCLE: AtomicU32 = + AtomicU32::new(u32::from(Colour::Rgb(Rgb::new(255, 51, 153)))); + pub static ref STACK: AtomicU32 = AtomicU32::new(u32::from(Colour::Rgb(Rgb::new(0, 165, 66)))); + pub static ref FLOATING: AtomicU32 = + AtomicU32::new(u32::from(Colour::Rgb(Rgb::new(245, 245, 165)))); +} + +lazy_static! { + static ref BORDER_STATE: Mutex>> = Mutex::new(HashMap::new()); + static ref WINDOWS_BORDERS: Mutex> = Mutex::new(HashMap::new()); +} + +pub enum Notification { + Update(Option, Option), + ForceUpdate, +} + +static CHANNEL: OnceLock<(Sender, Receiver)> = OnceLock::new(); + +pub fn channel() -> &'static (Sender, Receiver) { + CHANNEL.get_or_init(|| crossbeam_channel::bounded(50)) +} + +fn event_tx() -> Sender { + channel().0.clone() +} + +fn event_rx() -> Receiver { + channel().1.clone() +} + +#[derive(Debug, Default, Clone, PartialEq)] +pub struct BorderInfo { + pub border_id: String, + pub window_kind: WindowKind, +} + +pub fn window_border(window_id: u32) -> Option { + let id = WINDOWS_BORDERS.lock().get(&window_id)?.clone(); + BORDER_STATE.lock().get(&id).map(|b| BorderInfo { + border_id: b.id.clone(), + window_kind: b.window_kind, + }) +} + +pub fn send_notification(element: Option, window_id: Option) { + if event_tx() + .try_send(Notification::Update(element, window_id)) + .is_err() + { + tracing::warn!("channel is full; dropping notification") + } +} + +pub fn destroy_all_borders() -> eyre::Result<()> { + let mut borders = BORDER_STATE.lock(); + tracing::info!( + "purging known borders: {:?}", + borders.iter().map(|b| b.1.id.clone()).collect::>() + ); + + for (_, border) in borders.drain() { + let _ = destroy_border(border); + } + + drop(borders); + + WINDOWS_BORDERS.lock().clear(); + + Ok(()) +} + +fn window_kind_colour(focus_kind: WindowKind) -> u32 { + match focus_kind { + WindowKind::Unfocused => UNFOCUSED.load(Ordering::Relaxed), + WindowKind::UnfocusedLocked => UNFOCUSED_LOCKED.load(Ordering::Relaxed), + WindowKind::Single => FOCUSED.load(Ordering::Relaxed), + WindowKind::Stack => STACK.load(Ordering::Relaxed), + WindowKind::Monocle => MONOCLE.load(Ordering::Relaxed), + WindowKind::Floating => FLOATING.load(Ordering::Relaxed), + } +} + +fn remove_borders( + borders: &mut HashMap>, + windows_borders: &mut HashMap, + monitor_idx: usize, + condition: impl Fn(&String, &Border) -> bool, +) -> color_eyre::Result<()> { + let mut to_remove = vec![]; + for (id, border) in borders.iter() { + // if border is on this monitor + if border.monitor_idx.is_some_and(|idx| idx == monitor_idx) + // and the condition applies + && condition(id, border) + { + // we mark it to be removed + to_remove.push(id.clone()); + } + } + + for id in &to_remove { + remove_border(id, borders, windows_borders)?; + } + + Ok(()) +} + +fn remove_border( + id: &str, + borders: &mut HashMap>, + windows_borders: &mut HashMap, +) -> color_eyre::Result<()> { + if let Some(removed_border) = borders.remove(id) { + windows_borders.remove(&removed_border.tracking_window_id); + destroy_border(removed_border)?; + } + + Ok(()) +} + +fn destroy_border(border: Box) -> color_eyre::Result<()> { + DispatchQueue::main().exec_sync(|| { + tracing::info!("invalidating border observer"); + AccessibilityApi::invalidate_observer(&border.observer); + }); + + std::thread::sleep(std::time::Duration::from_millis(10)); + + let raw_pointer = Box::into_raw(border); + unsafe { + (*raw_pointer).destroy(); + } + + Ok(()) +} + +pub fn listen_for_notifications(wm: Arc>, run_loop: CoreFoundationRunLoop) { + std::thread::spawn(move || { + loop { + match handle_notifications(wm.clone(), run_loop.clone()) { + Ok(()) => { + tracing::warn!("restarting finished thread"); + } + Err(error) => { + tracing::warn!("restarting failed thread: {}", error); + } + } + } + }); +} + +fn handle_notifications( + wm: Arc>, + run_loop: CoreFoundationRunLoop, +) -> color_eyre::Result<()> { + tracing::info!("listening"); + + let receiver = event_rx(); + event_tx().send(Notification::Update(None, None))?; + + let mut previous_snapshot = Ring::default(); + let mut previous_pending_move_op = None; + let mut previous_is_paused = false; + let mut previous_notification: Option = None; + let mut previous_layer = WorkspaceLayer::default(); + + 'receiver: for notification in receiver { + let state = wm.lock(); + let is_paused = state.is_paused; + let focused_monitor_idx = state.focused_monitor_idx(); + let focused_workspace_idx = + state.monitors.elements()[focused_monitor_idx].focused_workspace_idx(); + let monitors = state.monitors.clone(); + let pending_move_op = *state.pending_move_op; + let floating_window_hwnds = state.monitors.elements()[focused_monitor_idx].workspaces() + [focused_workspace_idx] + .floating_windows() + .iter() + .map(|w| w.id) + .collect::>(); + let workspace_layer = state.monitors.elements()[focused_monitor_idx].workspaces() + [focused_workspace_idx] + .layer; + let foreground_window = MacosApi::foreground_window_id().unwrap_or_default(); + let _layer_changed = previous_layer != workspace_layer; + let _forced_update = matches!(notification, Notification::ForceUpdate); + + drop(state); + + let should_process_notification = match notification { + Notification::Update(_, notification_window_id) => { + let mut should_process_notification = true; + + if monitors == previous_snapshot + // handle the window dragging edge case + && pending_move_op == previous_pending_move_op + { + should_process_notification = false; + } + + // handle the pause edge case + if is_paused && !previous_is_paused { + should_process_notification = true; + } + + // handle the unpause edge case + if previous_is_paused && !is_paused { + should_process_notification = true; + } + + // handle the retile edge case + if !should_process_notification && BORDER_STATE.lock().is_empty() { + should_process_notification = true; + } + + // when we switch focus to/from a floating window + let switch_focus_to_from_floating_window = floating_window_hwnds.iter().any(|fw| { + // if we switch focus to a floating window + fw == ¬ification_window_id.unwrap_or_default() || + // if there is any floating window with a `WindowKind::Floating` border + // that no longer is the foreground window then we need to update that + // border. + (fw != &foreground_window + && window_border(*fw) + .is_some_and(|b| b.window_kind == WindowKind::Floating)) + }); + + // when the focused window has an `Unfocused` border kind, usually this happens if + // we focus an admin window and then refocus the previously focused window. For + // komorebi it will have the same state has before, however the previously focused + // window changed its border to unfocused so now we need to update it again. + if !should_process_notification + && window_border(notification_window_id.unwrap_or_default()) + .is_some_and(|b| b.window_kind == WindowKind::Unfocused) + { + should_process_notification = true; + } + + if !should_process_notification && switch_focus_to_from_floating_window { + should_process_notification = true; + } + + if !should_process_notification + && let Some(Notification::Update(_, ref previous_window_id)) = + previous_notification + && previous_window_id.unwrap_or_default() + != notification_window_id.unwrap_or_default() + { + should_process_notification = true; + } + + should_process_notification + } + Notification::ForceUpdate => true, + }; + + if !should_process_notification { + // tracing::debug!("monitor state matches latest snapshot, skipping notification"); + continue 'receiver; + } + + let mut borders = BORDER_STATE.lock(); + let mut windows_borders = WINDOWS_BORDERS.lock(); + + // If borders are disabled + if !BORDER_ENABLED.load_consume() + // Or if the wm is paused + || is_paused + { + // Destroy the borders we know about + for (_, border) in borders.drain() { + destroy_border(border)?; + } + + windows_borders.clear(); + + previous_is_paused = is_paused; + continue 'receiver; + } + + 'monitors: for (monitor_idx, m) in monitors.elements().iter().enumerate() { + if let Some(ws) = m.focused_workspace() { + if !ws.tile { + remove_borders(&mut borders, &mut windows_borders, monitor_idx, |_, _| true)?; + continue 'monitors; + } + + if let Some(monocle) = &ws.monocle_container + && let Some(window) = monocle.focused_window() + { + let focused_window_id = + monocle.focused_window().map(|w| w.id).unwrap_or_default(); + let id = monocle.id.clone(); + let border = match borders.entry(id.clone()) { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => { + if let Ok(border) = Border::create( + &monocle.id, + window.id, + window.application.process_id, + window.element.clone(), + Some(monitor_idx), + run_loop.clone(), + ) { + entry.insert(border) + } else { + continue 'monitors; + } + } + }; + + let new_focus_state = if monitor_idx != focused_monitor_idx { + WindowKind::Unfocused + } else { + WindowKind::Monocle + }; + + border.window_kind = new_focus_state; + + // Update the borders tracking_hwnd in case it changed and remove the + // old `tracking_hwnd` from `WINDOWS_BORDERS` if needed. + if border.tracking_window_id != focused_window_id { + if let Some(previous) = windows_borders.get(&border.tracking_window_id) { + // Only remove the border from `windows_borders` if it + // still corresponds to the same border, if doesn't then + // it means it was already updated by another border for + // that window and in that case we don't want to remove it. + if previous == &id { + windows_borders.remove(&border.tracking_window_id); + } + } + border.tracking_window_id = focused_window_id; + } + + // Update the border's monitor idx in case it changed + border.monitor_idx = Some(monitor_idx); + border.update(); + + windows_borders.insert(focused_window_id, id); + + let border_id = border.id.clone(); + + if ws.layer == WorkspaceLayer::Floating { + handle_floating_borders( + &mut borders, + &mut windows_borders, + ws, + monitor_idx, + foreground_window, + run_loop.clone(), + )?; + + // Remove all borders on this monitor except monocle and floating borders + remove_borders(&mut borders, &mut windows_borders, monitor_idx, |_, b| { + border_id != b.id + && !ws + .floating_windows() + .iter() + .any(|w| w.id == b.tracking_window_id) + })?; + } else { + // Remove all borders on this monitor except monocle + remove_borders(&mut borders, &mut windows_borders, monitor_idx, |_, b| { + border_id != b.id + })?; + } + continue 'monitors; + } + + // Collect focused workspace container and floating windows ID's + let container_and_floating_window_ids = ws + .containers() + .iter() + .map(|c| c.id.clone()) + .collect::>(); + + remove_borders(&mut borders, &mut windows_borders, monitor_idx, |id, _| { + !container_and_floating_window_ids.contains(id) + })?; + + for (idx, c) in ws.containers().iter().enumerate() { + if let Some(window) = c.focused_window() { + let id = c.id.clone(); + + let border = match borders.entry(id.clone()) { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => { + if let Ok(border) = Border::create( + &c.id, + window.id, + window.application.process_id, + window.element.clone(), + Some(monitor_idx), + run_loop.clone(), + ) { + entry.insert(border) + } else { + continue 'monitors; + } + } + }; + + let new_focus_state = if idx != ws.focused_container_idx() + || monitor_idx != focused_monitor_idx + || window.id != foreground_window + { + if c.locked { + WindowKind::UnfocusedLocked + } else { + WindowKind::Unfocused + } + } else if c.windows().len() > 1 { + WindowKind::Stack + } else { + WindowKind::Single + }; + + border.window_kind = new_focus_state; + + if border.tracking_window_id != window.id { + if let Some(previous) = windows_borders.get(&border.tracking_window_id) + { + // Only remove the border from `windows_borders` if it + // still corresponds to the same border, if doesn't then + // it means it was already updated by another border for + // that window and in that case we don't want to remove it. + if previous == &id { + windows_borders.remove(&border.tracking_window_id); + } + } + border.tracking_window_id = window.id; + } + + border.monitor_idx = Some(monitor_idx); + border.update(); + + windows_borders.insert(window.id, id); + } + + handle_floating_borders( + &mut borders, + &mut windows_borders, + ws, + monitor_idx, + foreground_window, + run_loop.clone(), + )?; + } + } + } + + previous_snapshot = monitors; + previous_pending_move_op = pending_move_op; + previous_is_paused = is_paused; + previous_notification = Some(notification); + previous_layer = workspace_layer; + } + + Ok(()) +} + +fn handle_floating_borders( + borders: &mut HashMap>, + windows_borders: &mut HashMap, + ws: &Workspace, + monitor_idx: usize, + foreground_window: u32, + run_loop: CoreFoundationRunLoop, +) -> color_eyre::Result<()> { + for window in ws.floating_windows() { + let id = window.id.to_string(); + let border = match borders.entry(id.clone()) { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => { + if let Ok(border) = Border::create( + &window.id.to_string(), + window.id, + window.application.process_id, + window.element.clone(), + Some(monitor_idx), + run_loop.clone(), + ) { + entry.insert(border) + } else { + return Ok(()); + } + } + }; + + let new_focus_state = if foreground_window == window.id { + WindowKind::Floating + } else { + WindowKind::Unfocused + }; + + border.window_kind = new_focus_state; + // Update the border's monitor idx in case it changed + border.monitor_idx = Some(monitor_idx); + + border.update(); + + windows_borders.insert(window.id, id); + } + + Ok(()) +} diff --git a/komorebi/src/border_manager/ns_window.rs b/komorebi/src/border_manager/ns_window.rs new file mode 100644 index 00000000..6a506052 --- /dev/null +++ b/komorebi/src/border_manager/ns_window.rs @@ -0,0 +1,159 @@ +use crate::border_manager::BORDER_OFFSET; +use crate::border_manager::BORDER_RADIUS; +use crate::border_manager::BORDER_WIDTH; +use color_eyre::eyre; +use color_eyre::eyre::OptionExt; +use dispatch2::DispatchQueue; +use komorebi_themes::colour::Rgb; +use objc2::MainThreadMarker; +use objc2::MainThreadOnly; +use objc2::msg_send; +use objc2::rc::Retained; +use objc2_app_kit::NSBackingStoreType; +use objc2_app_kit::NSColor; +use objc2_app_kit::NSNormalWindowLevel; +use objc2_app_kit::NSView; +use objc2_app_kit::NSWindow; +use objc2_app_kit::NSWindowAnimationBehavior; +use objc2_app_kit::NSWindowCollectionBehavior; +use objc2_app_kit::NSWindowStyleMask; +use objc2_core_graphics::CGColor; +use objc2_foundation::NSDictionary; +use objc2_foundation::NSRect; +use objc2_quartz_core::CALayer; +use std::ops::Deref; +use std::sync::atomic::Ordering; +use std::sync::mpsc; + +#[derive(Debug)] +pub struct NsWindow { + pub window: Retained, + pub layer: Retained, +} + +unsafe impl Send for NsWindow {} + +impl NsWindow { + pub fn new(ns_rect: NSRect) -> eyre::Result { + let offset = BORDER_OFFSET.load(Ordering::Relaxed) as f64; + + let mut ns_rect = ns_rect; + + ns_rect.origin.x -= offset; + ns_rect.origin.y -= offset; + ns_rect.size.width += offset * 2.0; + ns_rect.size.height += offset * 2.0; + + let (tx, rx) = mpsc::channel(); + + DispatchQueue::main().exec_async(move || { + let mtm = unsafe { MainThreadMarker::new_unchecked() }; + + // Create window + let window_frame = ns_rect; + + let window = unsafe { + let window = NSWindow::alloc(mtm); + NSWindow::initWithContentRect_styleMask_backing_defer( + window, + window_frame, + NSWindowStyleMask::Borderless, + NSBackingStoreType::Buffered, + false, + ) + }; + + // Make transparent + unsafe { + window.setBackgroundColor(Some(&NSColor::clearColor())); + window.setAnimationBehavior(NSWindowAnimationBehavior::None); + window.disableSnapshotRestoration(); + window.setPreservesContentDuringLiveResize(false); + window.setRestorable(false); + } + + window.setHasShadow(false); + window.setOpaque(false); + window.setLevel(NSNormalWindowLevel); + window.setIgnoresMouseEvents(true); + + unsafe { + window.setCollectionBehavior( + NSWindowCollectionBehavior::CanJoinAllSpaces | + NSWindowCollectionBehavior::Stationary | + NSWindowCollectionBehavior::IgnoresCycle | + NSWindowCollectionBehavior::Transient + ); + } + + let content_view = { + let view = NSView::alloc(mtm); + unsafe { NSView::initWithFrame(view, window_frame) } + }; + + content_view.setWantsLayer(true); + unsafe { + content_view.setAutoresizesSubviews(false); + } + + // Create and configure the layer for the border + let layer = { + let layer = CALayer::new(); + layer.setFrame(ns_rect); + layer.setActions(Some(&NSDictionary::new())); + + unsafe { + // transparent + let clear = CGColor::new_generic_rgb(0.0, 0.0, 0.0, 0.0); + let clear_ptr = clear.deref() as *const _; + let _: () = msg_send![&layer, setBackgroundColor: clear_ptr]; + + let red = CGColor::new_generic_rgb(1.0, 0.0, 0.0, 1.0); + let red_ptr = red.deref() as *const _; + let _: () = msg_send![&layer, setBorderColor: red_ptr]; + let _: () = msg_send![&layer, setBorderWidth: BORDER_WIDTH.load(Ordering::Relaxed) as f64]; + + let corner_radius: f64 = BORDER_RADIUS.load(Ordering::Relaxed) as f64; + let _: () = msg_send![&layer, setCornerRadius: corner_radius]; + + layer + } + }; + + unsafe { + content_view.setLayer(Some(&layer)); + } + + window.setContentView(Some(&content_view)); + window.setMovableByWindowBackground(false); + window.makeKeyAndOrderFront(None); + if let Err(error) = tx.send(NsWindow { window, layer }) { + tracing::error!("could not send NSWindow created for border: {error}") + } + }); + + rx.recv() + .ok() + .ok_or_eyre("could not create a border NSWindow") + } + + pub fn set_border_color(&self, rgb: Rgb) { + unsafe { + // this is ass + let color = CGColor::new_generic_rgb( + rgb.r as f64 / 255.0, + rgb.g as f64 / 255.0, + rgb.b as f64 / 255.0, + 1.0, + ); + let color_ptr = color.deref() as *const _; + let _: () = msg_send![&self.layer, setBorderColor: color_ptr]; + } + } + + pub fn set_border_width(&self, width: f64) { + unsafe { + let _: () = msg_send![&self.layer, setBorderWidth: width]; + } + } +} diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 1a1944d7..7d5f584c 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -189,6 +189,31 @@ pub enum ApplicationIdentifier { Path, } +#[derive( + Copy, + Clone, + Debug, + Default, + Serialize, + Deserialize, + Display, + EnumString, + ValueEnum, + PartialEq, + Eq, + Hash, +)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum WindowKind { + Single, + Stack, + Monocle, + #[default] + Unfocused, + UnfocusedLocked, + Floating, +} + #[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum StateQuery { diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 85bb7068..d945a15b 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -49,6 +49,7 @@ pub mod ring; pub mod accessibility; pub mod app_kit_notification_constants; pub mod application; +pub mod border_manager; pub mod container; pub mod core; pub mod core_graphics; @@ -228,7 +229,7 @@ pub fn notify_subscribers( Ok(()) } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct CoreFoundationRunLoop(pub CFRetained); unsafe impl Sync for CoreFoundationRunLoop {} unsafe impl Send for CoreFoundationRunLoop {} diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 0278e111..99ecde20 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -283,7 +283,7 @@ impl MacosApi { Entry::Vacant(vacant) => { let mut application = Application::new(info.owner_pid)?; // TODO: this ain't great, fix this OBS workaround - application.observe(&wm.run_loop); + application.observe(&wm.run_loop, None); vacant.insert(application) } }; @@ -291,7 +291,7 @@ impl MacosApi { if let Some(window) = application.window_by_title(&info.name) { let mut rule_debug = RuleDebug::default(); if window.should_manage(None, &mut rule_debug)? { - window.observe(&wm.run_loop)?; + window.observe(&wm.run_loop, None)?; entry.push(window); valid_window_count += 1 } diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 8ef4e568..07854bbf 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -4,8 +4,10 @@ use clap::Parser; use clap::ValueEnum; use color_eyre::eyre; use color_eyre::eyre::OptionExt; +use komorebi::CoreFoundationRunLoop; use komorebi::DATA_DIR; use komorebi::HOME_DIR; +use komorebi::border_manager; use komorebi::core::pathext::replace_env_in_path; use komorebi::display_reconfiguration_listener::DisplayReconfigurationListener; use komorebi::input_event_listener::InputEventListener; @@ -256,6 +258,7 @@ fn main() -> eyre::Result<()> { wm.lock().update_focused_workspace(true, true)?; + border_manager::listen_for_notifications(wm.clone(), CoreFoundationRunLoop(run_loop)); listen_for_commands(wm.clone()); listen_for_events(wm.clone()); monitor_reconciliator::listen_for_notifications(wm.clone())?; @@ -290,7 +293,7 @@ fn main() -> eyre::Result<()> { } // this gets our observer notification callbacks firing - autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 2.0, false) }); + autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 0.1, false) }); } wm.lock().restore_all_windows(false)?; diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index f407214a..cfa49d82 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -2,6 +2,7 @@ use crate::DISPLAY_INDEX_PREFERENCES; use crate::Notification; use crate::NotificationEvent; use crate::WORKSPACE_MATCHING_RULES; +use crate::border_manager; use crate::core::config_generation::WorkspaceMatchingRule; use crate::macos_api::MacosApi; use crate::monitor::Monitor; @@ -566,6 +567,8 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result initial_state.has_been_modified(&wm), )?; } + + border_manager::send_notification(None, None); } Ok(()) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 8389d2fe..a84c7265 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -11,6 +11,7 @@ use crate::SUBSCRIPTION_SOCKETS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::application::Application; +use crate::border_manager; use crate::build; use crate::cf_array_as; use crate::core::ApplicationIdentifier; @@ -731,8 +732,14 @@ impl WindowManager { self.update_focused_workspace(false, false)?; } - SocketMessage::Retile => self.retile_all(false)?, - SocketMessage::RetileWithResizeDimensions => self.retile_all(true)?, + SocketMessage::Retile => { + border_manager::destroy_all_borders()?; + self.retile_all(false)? + } + SocketMessage::RetileWithResizeDimensions => { + border_manager::destroy_all_borders()?; + self.retile_all(true)? + } SocketMessage::ToggleWorkspaceWindowContainerBehaviour => { let current_global_behaviour = self.window_management_behaviour.current_behaviour; if let Some(behaviour) = @@ -1670,6 +1677,9 @@ impl WindowManager { } } } + + self.update_known_window_ids(); + notify_subscribers( Notification { event: NotificationEvent::Socket(message.clone()), @@ -1678,7 +1688,7 @@ impl WindowManager { initial_state.has_been_modified(self.as_ref()), )?; - self.update_known_window_ids(); + border_manager::send_notification(None, None); tracing::info!("processed"); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 1b659e2b..0f2efb46 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -1,3 +1,4 @@ +use crate::AccessibilityUiElement; use crate::FLOATING_APPLICATIONS; use crate::Notification; use crate::NotificationEvent; @@ -10,6 +11,7 @@ use crate::accessibility::error::AccessibilityApiError; use crate::accessibility::error::AccessibilityError; use crate::accessibility::notification_constants::AccessibilityNotification; use crate::app_kit_notification_constants::AppKitWorkspaceNotification; +use crate::border_manager; use crate::core::Sizing; use crate::core::WindowContainerBehaviour; use crate::core::config_generation::MatchingRule; @@ -74,6 +76,7 @@ impl WindowManager { && *space_id != current_space_id { tracing::trace!("ignoring events and commands while not on space {space_id}"); + border_manager::destroy_all_borders()?; return Ok(()); } @@ -105,6 +108,19 @@ impl WindowManager { return Ok(()); } + let mut window_id = None; + let mut window_element = None; + + { + let application = self.application(event.process_id())?; + if let Some(element) = application.main_window() + && let Ok(wid) = AccessibilityApi::window_id(&element) + { + window_id = Some(wid); + window_element = Some(AccessibilityUiElement(element.clone())); + } + } + // don't want to spam logs for manually triggered hacks triggered // from the input listener if !matches!( @@ -432,7 +448,7 @@ impl WindowManager { && let Some(element) = window_element && let Ok(mut window) = Window::new(element, application.clone()) { - window.observe(&self.run_loop)?; + window.observe(&self.run_loop, None)?; let behaviour = self .window_management_behaviour(focused_monitor_idx, focused_workspace_idx); @@ -925,6 +941,8 @@ impl WindowManager { initial_state.has_been_modified(self.as_ref()), )?; + border_manager::send_notification(window_element, window_id); + Ok(()) } } diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs index a2fc3fc4..c8301331 100644 --- a/komorebi/src/reaper.rs +++ b/komorebi/src/reaper.rs @@ -1,5 +1,6 @@ use crate::TABBED_APPLICATIONS; use crate::accessibility::error::AccessibilityError; +use crate::border_manager; use crate::window::Window; use crate::window_manager::WindowManager; use crossbeam_channel::Receiver; @@ -86,6 +87,7 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> // If an invalid window was cleaned up, we update the workspace wm.update_focused_workspace(false, false)?; + border_manager::send_notification(None, Some(window_id)); } ReaperNotification::MouseUpKeyUp => { // this first one will do a "nothing" update to check if any windows failed diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 91197956..d75d732a 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -339,7 +339,11 @@ impl Window { } #[tracing::instrument(skip_all)] - pub fn observe(&self, run_loop: &CFRunLoop) -> Result<(), AccessibilityError> { + pub fn observe( + &self, + run_loop: &CFRunLoop, + refcon: Option<*mut c_void>, + ) -> Result<(), AccessibilityError> { tracing::info!("registering observer for {self}"); AccessibilityApi::add_observer_to_run_loop( @@ -347,6 +351,7 @@ impl Window { &self.element, NOTIFICATIONS, run_loop, + refcon, ) } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 6e6ea273..4425e426 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -178,7 +178,7 @@ impl WindowManager { Entry::Occupied(entry) => Ok(entry.into_mut()), Entry::Vacant(vacant) => { let mut application = Application::new(process_id)?; - application.observe(&self.run_loop); + application.observe(&self.run_loop, None); Ok(vacant.insert(application)) } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 49d8298b..b0ffc544 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -993,8 +993,14 @@ impl Workspace { pub fn update(&mut self) -> eyre::Result<()> { // make sure we are never holding on to empty containers self.prune_duplicate_windows()?; + let focused_container_idx = self.focused_container_idx(); self.containers_mut().retain(|c| !c.windows().is_empty()); + // make sure we are never focused on a no longer existent final empty container + if focused_container_idx >= self.containers().len() { + self.focus_container(focused_container_idx.saturating_sub(1)); + } + let container_padding = self .container_padding .or(self.globals.container_padding) From 0cbf02b604c06e93ab77f81d1515740d309d89e0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 09:34:12 -0700 Subject: [PATCH 088/305] feat(config): implement border manager options This commit enables the border, border_width, border_offset and border_colours options in StaticConfig, and hooks them up to the relevant variables in the border manager module. --- docs/komorebi.example.json | 5 +- komorebi/src/process_command.rs | 10 +- komorebi/src/static_config.rs | 207 ++++++++++++++++---------------- komorebi/src/window_manager.rs | 3 + 4 files changed, 114 insertions(+), 111 deletions(-) diff --git a/docs/komorebi.example.json b/docs/komorebi.example.json index 6efb278a..8b0ec992 100644 --- a/docs/komorebi.example.json +++ b/docs/komorebi.example.json @@ -1,9 +1,12 @@ { - "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.39/schema.json", + "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.38/schema.json", "app_specific_configuration_path": "$HOME/.config/komorebi/applications.json", "cross_monitor_move_behaviour": "Insert", "default_workspace_padding": 15, "default_container_padding": 15, + "border": true, + "border_width": 6, + "border_offset": 5, "floating_window_aspect_ratio": "Widescreen", "floating_layer_behaviour": "Float", "resize_delta": 100, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index a84c7265..f293d26d 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -732,14 +732,8 @@ impl WindowManager { self.update_focused_workspace(false, false)?; } - SocketMessage::Retile => { - border_manager::destroy_all_borders()?; - self.retile_all(false)? - } - SocketMessage::RetileWithResizeDimensions => { - border_manager::destroy_all_borders()?; - self.retile_all(true)? - } + SocketMessage::Retile => self.retile_all(false)?, + SocketMessage::RetileWithResizeDimensions => self.retile_all(true)?, SocketMessage::ToggleWorkspaceWindowContainerBehaviour => { let current_global_behaviour = self.window_management_behaviour.current_behaviour; if let Some(behaviour) = diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 5f1f331a..785466ec 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -9,6 +9,7 @@ use crate::IGNORE_IDENTIFIERS; use crate::MANAGE_IDENTIFIERS; use crate::REGEX_IDENTIFIERS; use crate::WORKSPACE_MATCHING_RULES; +use crate::border_manager; use crate::core::CrossBoundaryBehaviour; use crate::core::FloatingLayerBehaviour; use crate::core::MoveBehaviour; @@ -42,6 +43,7 @@ use color_eyre::eyre; use crossbeam_channel::Receiver; use hotwatch::EventKind; use hotwatch::Hotwatch; +use komorebi_themes::colour::Colour; use objc2_core_foundation::CFRetained; use objc2_core_foundation::CFRunLoop; use parking_lot::Mutex; @@ -57,28 +59,28 @@ use std::path::PathBuf; use std::sync::Arc; use std::sync::atomic::Ordering; -// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -// pub struct BorderColours { -// /// Border colour when the container contains a single window -// #[serde(skip_serializing_if = "Option::is_none")] -// pub single: Option, -// /// Border colour when the container contains multiple windows -// #[serde(skip_serializing_if = "Option::is_none")] -// pub stack: Option, -// /// Border colour when the container is in monocle mode -// #[serde(skip_serializing_if = "Option::is_none")] -// pub monocle: Option, -// /// Border colour when the container is in floating mode -// #[serde(skip_serializing_if = "Option::is_none")] -// pub floating: Option, -// /// Border colour when the container is unfocused -// #[serde(skip_serializing_if = "Option::is_none")] -// pub unfocused: Option, -// /// Border colour when the container is unfocused and locked -// #[serde(skip_serializing_if = "Option::is_none")] -// pub unfocused_locked: Option, -// } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct BorderColours { + /// Border colour when the container contains a single window + #[serde(skip_serializing_if = "Option::is_none")] + pub single: Option, + /// Border colour when the container contains multiple windows + #[serde(skip_serializing_if = "Option::is_none")] + pub stack: Option, + /// Border colour when the container is in monocle mode + #[serde(skip_serializing_if = "Option::is_none")] + pub monocle: Option, + /// Border colour when the container is in floating mode + #[serde(skip_serializing_if = "Option::is_none")] + pub floating: Option, + /// Border colour when the container is unfocused + #[serde(skip_serializing_if = "Option::is_none")] + pub unfocused: Option, + /// Border colour when the container is unfocused and locked + #[serde(skip_serializing_if = "Option::is_none")] + pub unfocused_locked: Option, +} // #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] // #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] @@ -409,22 +411,22 @@ pub struct StaticConfig { /// Path to applications.json from komorebi-application-specific-configurations (default: None) #[serde(skip_serializing_if = "Option::is_none")] pub app_specific_configuration_path: Option, - // /// Width of the window border (default: 8) - // #[serde(skip_serializing_if = "Option::is_none")] - // #[serde(alias = "active_window_border_width")] - // pub border_width: Option, - // /// Offset of the window border (default: -1) - // #[serde(skip_serializing_if = "Option::is_none")] - // #[serde(alias = "active_window_border_offset")] - // pub border_offset: Option, - // /// Display an active window border (default: true) - // #[serde(skip_serializing_if = "Option::is_none")] - // #[serde(alias = "active_window_border")] - // pub border: Option, - // /// Active window border colours for different container types - // #[serde(skip_serializing_if = "Option::is_none")] - // #[serde(alias = "active_window_border_colours")] - // pub border_colours: Option, + /// Width of the window border (default: 6) + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(alias = "active_window_border_width")] + pub border_width: Option, + /// Offset of the window border (default: 5) + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(alias = "active_window_border_offset")] + pub border_offset: Option, + /// Display an active window border (default: true) + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(alias = "active_window_border")] + pub border: Option, + /// Active window border colours for different container types + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(alias = "active_window_border_colours")] + pub border_colours: Option, // /// Active window border style (default: System) // #[serde(skip_serializing_if = "Option::is_none")] // #[serde(alias = "active_window_border_style")] @@ -693,24 +695,24 @@ impl From<&WindowManager> for StaticConfig { monitors.push(MonitorConfig::from(m)); } - // let border_colours = if border_manager::FOCUSED.load(Ordering::SeqCst) == 0 { - // None - // } else { - // Option::from(BorderColours { - // single: Option::from(Colour::from(border_manager::FOCUSED.load(Ordering::SeqCst))), - // stack: Option::from(Colour::from(border_manager::STACK.load(Ordering::SeqCst))), - // monocle: Option::from(Colour::from(border_manager::MONOCLE.load(Ordering::SeqCst))), - // floating: Option::from(Colour::from( - // border_manager::FLOATING.load(Ordering::SeqCst), - // )), - // unfocused: Option::from(Colour::from( - // border_manager::UNFOCUSED.load(Ordering::SeqCst), - // )), - // unfocused_locked: Option::from(Colour::from( - // border_manager::UNFOCUSED_LOCKED.load(Ordering::SeqCst), - // )), - // }) - // }; + let border_colours = if border_manager::FOCUSED.load(Ordering::SeqCst) == 0 { + None + } else { + Option::from(BorderColours { + single: Option::from(Colour::from(border_manager::FOCUSED.load(Ordering::SeqCst))), + stack: Option::from(Colour::from(border_manager::STACK.load(Ordering::SeqCst))), + monocle: Option::from(Colour::from(border_manager::MONOCLE.load(Ordering::SeqCst))), + floating: Option::from(Colour::from( + border_manager::FLOATING.load(Ordering::SeqCst), + )), + unfocused: Option::from(Colour::from( + border_manager::UNFOCUSED.load(Ordering::SeqCst), + )), + unfocused_locked: Option::from(Colour::from( + border_manager::UNFOCUSED_LOCKED.load(Ordering::SeqCst), + )), + }) + }; Self { // invisible_borders: None, @@ -744,10 +746,10 @@ impl From<&WindowManager> for StaticConfig { // focus_follows_mouse: value.focus_follows_mouse, mouse_follows_focus: Option::from(value.mouse_follows_focus), app_specific_configuration_path: None, - // border_width: Option::from(border_manager::BORDER_WIDTH.load(Ordering::SeqCst)), - // border_offset: Option::from(border_manager::BORDER_OFFSET.load(Ordering::SeqCst)), - // border: Option::from(border_manager::BORDER_ENABLED.load(Ordering::SeqCst)), - // border_colours, + border_width: Option::from(border_manager::BORDER_WIDTH.load(Ordering::SeqCst)), + border_offset: Option::from(border_manager::BORDER_OFFSET.load(Ordering::SeqCst)), + border: Option::from(border_manager::BORDER_ENABLED.load(Ordering::SeqCst)), + border_colours, // transparency: Option::from( // transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst), // ), @@ -804,6 +806,7 @@ impl StaticConfig { // preferences.clone_from(monitor_index_preferences); // } // + if let Some(display_index_preferences) = &self.display_index_preferences { let mut preferences = DISPLAY_INDEX_PREFERENCES.write(); preferences.clone_from(display_index_preferences); @@ -870,37 +873,37 @@ impl StaticConfig { DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst); } - // border_manager::BORDER_WIDTH.store(self.border_width.unwrap_or(8), Ordering::SeqCst); - // border_manager::BORDER_OFFSET.store(self.border_offset.unwrap_or(-1), Ordering::SeqCst); - // border_manager::BORDER_ENABLED.store(self.border.unwrap_or(true), Ordering::SeqCst); - // - // if let Some(colours) = &self.border_colours { - // if let Some(single) = colours.single { - // border_manager::FOCUSED.store(u32::from(single), Ordering::SeqCst); - // } - // - // if let Some(stack) = colours.stack { - // border_manager::STACK.store(u32::from(stack), Ordering::SeqCst); - // } - // - // if let Some(monocle) = colours.monocle { - // border_manager::MONOCLE.store(u32::from(monocle), Ordering::SeqCst); - // } - // - // if let Some(floating) = colours.floating { - // border_manager::FLOATING.store(u32::from(floating), Ordering::SeqCst); - // } - // - // if let Some(unfocused) = colours.unfocused { - // border_manager::UNFOCUSED.store(u32::from(unfocused), Ordering::SeqCst); - // } - // - // if let Some(unfocused_locked) = colours.unfocused_locked { - // border_manager::UNFOCUSED_LOCKED - // .store(u32::from(unfocused_locked), Ordering::SeqCst); - // } - // } - // + border_manager::BORDER_WIDTH.store(self.border_width.unwrap_or(6), Ordering::SeqCst); + border_manager::BORDER_OFFSET.store(self.border_offset.unwrap_or(5), Ordering::SeqCst); + border_manager::BORDER_ENABLED.store(self.border.unwrap_or(true), Ordering::SeqCst); + + if let Some(colours) = &self.border_colours { + if let Some(single) = colours.single { + border_manager::FOCUSED.store(u32::from(single), Ordering::SeqCst); + } + + if let Some(stack) = colours.stack { + border_manager::STACK.store(u32::from(stack), Ordering::SeqCst); + } + + if let Some(monocle) = colours.monocle { + border_manager::MONOCLE.store(u32::from(monocle), Ordering::SeqCst); + } + + if let Some(floating) = colours.floating { + border_manager::FLOATING.store(u32::from(floating), Ordering::SeqCst); + } + + if let Some(unfocused) = colours.unfocused { + border_manager::UNFOCUSED.store(u32::from(unfocused), Ordering::SeqCst); + } + + if let Some(unfocused_locked) = colours.unfocused_locked { + border_manager::UNFOCUSED_LOCKED + .store(u32::from(unfocused_locked), Ordering::SeqCst); + } + } + // STYLE.store(self.border_style.unwrap_or_default()); // // if !*WINDOWS_11 @@ -1345,9 +1348,9 @@ impl StaticConfig { wm.enforce_workspace_rules()?; - // if value.border == Some(true) { - // border_manager::BORDER_ENABLED.store(true, Ordering::SeqCst); - // } + if value.border == Some(true) { + border_manager::BORDER_ENABLED.store(true, Ordering::SeqCst); + } Ok(()) } @@ -1425,13 +1428,10 @@ impl StaticConfig { // Check if this monitor config is the preferred config for this monitor and store // a copy of the monitor itself on the monitor cache if it is. - // if idx == preferred_config_idx { - // let id = monitor - // .serial_number_id - // .as_ref() - // .map_or(&monitor.device_id, |sn| sn); - // monitor_reconciliator::insert_in_monitor_cache(id, monitor.clone()); - // } + if idx == preferred_config_idx { + let id = monitor.serial_number_id.clone(); + monitor_reconciliator::insert_in_monitor_cache(&id, monitor.clone()); + } let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock(); for (j, ws) in monitor_config.workspaces.iter().enumerate() { @@ -1506,7 +1506,7 @@ impl StaticConfig { wm.enforce_workspace_rules()?; - // border_manager::BORDER_ENABLED.store(value.border.unwrap_or(true), Ordering::SeqCst); + border_manager::BORDER_ENABLED.store(value.border.unwrap_or(true), Ordering::SeqCst); wm.window_management_behaviour.current_behaviour = value.window_container_behaviour.unwrap_or_default(); wm.window_management_behaviour.float_override = value.float_override.unwrap_or_default(); @@ -1547,6 +1547,9 @@ impl StaticConfig { // wm.apply_wallpaper_for_monitor_workspace(i, ws_idx)?; } + // to update the borders + wm.retile_all(true)?; + Ok(()) } } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 4425e426..a1064a78 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -7,6 +7,7 @@ use crate::UNMANAGED_WINDOW_IDS; use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::application::Application; +use crate::border_manager; use crate::container::Container; use crate::core::CrossBoundaryBehaviour; use crate::core::MoveBehaviour; @@ -1571,6 +1572,8 @@ impl WindowManager { workspace.update()?; } + border_manager::destroy_all_borders()?; + Ok(()) } From 8950a32bbb47f3a7d41d19028312b5ab74523b03 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 09:42:02 -0700 Subject: [PATCH 089/305] feat(cli): implement border-related cmds This commit implements the various border-related SocketMessage variants and the komorebic commands to send them. --- komorebi-client/src/lib.rs | 1 + komorebi/src/core/mod.rs | 12 ++--- komorebi/src/process_command.rs | 38 ++++++++++++++++ komorebic/src/main.rs | 80 ++++++++++++++++++++++++++------- 4 files changed, 109 insertions(+), 22 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index dd1104a9..75c45651 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -6,6 +6,7 @@ pub use komorebi::core::OperationBehaviour; pub use komorebi::core::Sizing; pub use komorebi::core::SocketMessage; pub use komorebi::core::StateQuery; +pub use komorebi::core::WindowKind; pub use komorebi::core::arrangement::Axis; pub use komorebi::core::asc::ApplicationSpecificConfiguration; pub use komorebi::core::cycle_direction::CycleDirection; diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 7d5f584c..9a1e0af2 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -366,14 +366,14 @@ pub enum SocketMessage { // AnimationDuration(u64, Option), // AnimationFps(u64), // AnimationStyle(AnimationStyle, Option), - // #[serde(alias = "ActiveWindowBorder")] - // Border(bool), - // #[serde(alias = "ActiveWindowBorderColour")] - // BorderColour(WindowKind, u32, u32, u32), + #[serde(alias = "ActiveWindowBorder")] + Border(bool), + #[serde(alias = "ActiveWindowBorderColour")] + BorderColour(WindowKind, u32, u32, u32), // #[serde(alias = "ActiveWindowBorderStyle")] // BorderStyle(BorderStyle), - // BorderWidth(i32), - // BorderOffset(i32), + BorderWidth(i32), + BorderOffset(i32), // BorderImplementation(BorderImplementation), // Transparency(bool), // ToggleTransparency, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index f293d26d..721a17b1 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -19,6 +19,7 @@ use crate::core::MoveBehaviour; use crate::core::SocketMessage; use crate::core::StateQuery; use crate::core::WindowContainerBehaviour; +use crate::core::WindowKind; use crate::core::arrangement::Axis; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; @@ -48,6 +49,7 @@ use crate::workspace::WorkspaceWindowLocation; use color_eyre::eyre; use color_eyre::eyre::Context; use color_eyre::eyre::OptionExt; +use komorebi_themes::colour::Rgb; use objc2_core_foundation::CFDictionary; use parking_lot::Mutex; use std::collections::HashMap; @@ -59,6 +61,7 @@ use std::num::NonZeroUsize; use std::os::unix::net::UnixStream; use std::str::FromStr; use std::sync::Arc; +use std::sync::atomic::Ordering; use std::time::Duration; #[tracing::instrument] @@ -1670,6 +1673,41 @@ impl WindowManager { *self = wm; } } + SocketMessage::Border(enable) => { + border_manager::BORDER_ENABLED.store(enable, Ordering::SeqCst); + if !enable { + border_manager::destroy_all_borders()?; + } + } + SocketMessage::BorderColour(kind, r, g, b) => match kind { + WindowKind::Single => { + border_manager::FOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst); + } + WindowKind::Stack => { + border_manager::STACK.store(Rgb::new(r, g, b).into(), Ordering::SeqCst); + } + WindowKind::Monocle => { + border_manager::MONOCLE.store(Rgb::new(r, g, b).into(), Ordering::SeqCst); + } + WindowKind::Unfocused => { + border_manager::UNFOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst); + } + WindowKind::UnfocusedLocked => { + border_manager::UNFOCUSED_LOCKED + .store(Rgb::new(r, g, b).into(), Ordering::SeqCst); + } + WindowKind::Floating => { + border_manager::FLOATING.store(Rgb::new(r, g, b).into(), Ordering::SeqCst); + } + }, + SocketMessage::BorderWidth(width) => { + border_manager::BORDER_WIDTH.store(width, Ordering::SeqCst); + border_manager::destroy_all_borders()?; + } + SocketMessage::BorderOffset(offset) => { + border_manager::BORDER_OFFSET.store(offset, Ordering::SeqCst); + border_manager::destroy_all_borders()?; + } } self.update_known_window_ids(); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 05062699..c411e5c1 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -18,6 +18,7 @@ use komorebi_client::Rect; use komorebi_client::Sizing; use komorebi_client::SocketMessage; use komorebi_client::StateQuery; +use komorebi_client::WindowKind; use komorebi_client::replace_env_in_path; use komorebi_client::send_message; use komorebi_client::send_query; @@ -610,6 +611,36 @@ struct ScrollingLayoutColumns { count: NonZeroUsize, } +#[derive(Parser)] +struct Border { + #[clap(value_enum)] + boolean_state: BooleanState, +} + +#[derive(Parser)] +struct BorderColour { + #[clap(value_enum, short, long, default_value = "single")] + window_kind: WindowKind, + /// Red + r: u32, + /// Green + g: u32, + /// Blue + b: u32, +} + +#[derive(Parser)] +struct BorderWidth { + /// Desired width of the window border + width: i32, +} + +#[derive(Parser)] +struct BorderOffset { + /// Desired offset of the window border + offset: i32, +} + #[derive(Parser)] #[clap(author, about, version = build::CLAP_LONG_VERSION)] struct Opts { @@ -1047,22 +1078,22 @@ enum SubCommand { // #[clap(hide = true)] // #[clap(alias = "identify-border-overflow")] // IdentifyBorderOverflowApplication(IdentifyBorderOverflowApplication), - // /// Enable or disable borders - // #[clap(arg_required_else_help = true)] - // #[clap(alias = "active-window-border")] - // Border(Border), - // /// Set the colour for a window border kind - // #[clap(arg_required_else_help = true)] - // #[clap(alias = "active-window-border-colour")] - // BorderColour(BorderColour), - // /// Set the border width - // #[clap(arg_required_else_help = true)] - // #[clap(alias = "active-window-border-width")] - // BorderWidth(BorderWidth), - // /// Set the border offset - // #[clap(arg_required_else_help = true)] - // #[clap(alias = "active-window-border-offset")] - // BorderOffset(BorderOffset), + /// Enable or disable borders + #[clap(arg_required_else_help = true)] + #[clap(alias = "active-window-border")] + Border(Border), + /// Set the colour for a window border kind + #[clap(arg_required_else_help = true)] + #[clap(alias = "active-window-border-colour")] + BorderColour(BorderColour), + /// Set the border width + #[clap(arg_required_else_help = true)] + #[clap(alias = "active-window-border-width")] + BorderWidth(BorderWidth), + /// Set the border offset + #[clap(arg_required_else_help = true)] + #[clap(alias = "active-window-border-offset")] + BorderOffset(BorderOffset), // /// Set the border style // #[clap(arg_required_else_help = true)] // BorderStyle(BorderStyle), @@ -2062,6 +2093,23 @@ fn main() -> eyre::Result<()> { SubCommand::ReplaceConfiguration(arg) => { send_message(&SocketMessage::ReplaceConfiguration(arg.path))?; } + SubCommand::Border(arg) => { + send_message(&SocketMessage::Border(arg.boolean_state.into()))?; + } + SubCommand::BorderColour(arg) => { + send_message(&SocketMessage::BorderColour( + arg.window_kind, + arg.r, + arg.g, + arg.b, + ))?; + } + SubCommand::BorderWidth(arg) => { + send_message(&SocketMessage::BorderWidth(arg.width))?; + } + SubCommand::BorderOffset(arg) => { + send_message(&SocketMessage::BorderOffset(arg.offset))?; + } } Ok(()) From f4d9734655c8e62dcf30f7993ce38b751310cc23 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 09:59:24 -0700 Subject: [PATCH 090/305] feat(wm): implement theme manager This commit implements the theme manager from komorebi for Windows. Mostly a lift and shift. Might look into the wallpaper stuff next. --- komorebi/src/lib.rs | 1 + komorebi/src/main.rs | 2 + komorebi/src/static_config.rs | 309 +++++++++++++++++----------------- komorebi/src/theme_manager.rs | 285 +++++++++++++++++++++++++++++++ 4 files changed, 443 insertions(+), 154 deletions(-) create mode 100644 komorebi/src/theme_manager.rs diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index d945a15b..a17d6508 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -67,6 +67,7 @@ pub mod reaper; pub mod skylight; pub mod state; pub mod static_config; +pub mod theme_manager; pub mod window; pub mod window_manager; pub mod window_manager_event; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 07854bbf..6c3550bc 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -17,6 +17,7 @@ use komorebi::process_command::listen_for_commands; use komorebi::process_event::listen_for_events; use komorebi::reaper; use komorebi::static_config::StaticConfig; +use komorebi::theme_manager; use komorebi::window_manager::WindowManager; use komorebi::window_manager_event_listener; use objc2::rc::autoreleasepool; @@ -259,6 +260,7 @@ fn main() -> eyre::Result<()> { wm.lock().update_focused_workspace(true, true)?; border_manager::listen_for_notifications(wm.clone(), CoreFoundationRunLoop(run_loop)); + theme_manager::listen_for_notifications(); listen_for_commands(wm.clone()); listen_for_events(wm.clone()); monitor_reconciliator::listen_for_notifications(wm.clone())?; diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 785466ec..baae7867 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -34,6 +34,7 @@ use crate::monitor; use crate::monitor::Monitor; use crate::monitor_reconciliator; use crate::ring::Ring; +use crate::theme_manager; use crate::window::AspectRatio; use crate::window::PredefinedAspectRatio; use crate::window_manager::WindowManager; @@ -82,43 +83,43 @@ pub struct BorderColours { pub unfocused_locked: Option, } -// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -// pub struct ThemeOptions { -// /// Specify Light or Dark variant for theme generation (default: Dark) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub theme_variant: Option, -// /// Border colour when the container contains a single window (default: Base0D) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub single_border: Option, -// /// Border colour when the container contains multiple windows (default: Base0B) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub stack_border: Option, -// /// Border colour when the container is in monocle mode (default: Base0F) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub monocle_border: Option, -// /// Border colour when the window is floating (default: Base09) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub floating_border: Option, -// /// Border colour when the container is unfocused (default: Base01) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub unfocused_border: Option, -// /// Border colour when the container is unfocused and locked (default: Base08) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub unfocused_locked_border: Option, -// /// Stackbar focused tab text colour (default: Base0B) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub stackbar_focused_text: Option, -// /// Stackbar unfocused tab text colour (default: Base05) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub stackbar_unfocused_text: Option, -// /// Stackbar tab background colour (default: Base01) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub stackbar_background: Option, -// /// Komorebi status bar accent (default: Base0D) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub bar_accent: Option, -// } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct ThemeOptions { + /// Specify Light or Dark variant for theme generation (default: Dark) + #[serde(skip_serializing_if = "Option::is_none")] + pub theme_variant: Option, + /// Border colour when the container contains a single window (default: Base0D) + #[serde(skip_serializing_if = "Option::is_none")] + pub single_border: Option, + /// Border colour when the container contains multiple windows (default: Base0B) + #[serde(skip_serializing_if = "Option::is_none")] + pub stack_border: Option, + /// Border colour when the container is in monocle mode (default: Base0F) + #[serde(skip_serializing_if = "Option::is_none")] + pub monocle_border: Option, + /// Border colour when the window is floating (default: Base09) + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_border: Option, + /// Border colour when the container is unfocused (default: Base01) + #[serde(skip_serializing_if = "Option::is_none")] + pub unfocused_border: Option, + /// Border colour when the container is unfocused and locked (default: Base08) + #[serde(skip_serializing_if = "Option::is_none")] + pub unfocused_locked_border: Option, + /// Stackbar focused tab text colour (default: Base0B) + #[serde(skip_serializing_if = "Option::is_none")] + pub stackbar_focused_text: Option, + /// Stackbar unfocused tab text colour (default: Base05) + #[serde(skip_serializing_if = "Option::is_none")] + pub stackbar_unfocused_text: Option, + /// Stackbar tab background colour (default: Base01) + #[serde(skip_serializing_if = "Option::is_none")] + pub stackbar_background: Option, + /// Komorebi status bar accent (default: Base0D) + #[serde(skip_serializing_if = "Option::is_none")] + pub bar_accent: Option, +} // #[serde_with::serde_as] // #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] @@ -495,9 +496,9 @@ pub struct StaticConfig { // /// Animations configuration options // #[serde(skip_serializing_if = "Option::is_none")] // pub animation: Option, - // /// Theme configuration options - // #[serde(skip_serializing_if = "Option::is_none")] - // pub theme: Option, + /// Theme configuration options + #[serde(skip_serializing_if = "Option::is_none")] + pub theme: Option, /// Identify applications which are slow to send initial event notifications // #[serde(skip_serializing_if = "Option::is_none")] // pub slow_application_identifiers: Option>, @@ -536,116 +537,116 @@ pub struct StaticConfig { // pub fps: Option, // } -// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -// #[serde(tag = "palette")] -// pub enum KomorebiTheme { -// /// A theme from catppuccin-egui -// Catppuccin { -// /// Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin) -// name: komorebi_themes::Catppuccin, -// /// Border colour when the container contains a single window (default: Blue) -// #[serde(skip_serializing_if = "Option::is_none")] -// single_border: Option, -// /// Border colour when the container contains multiple windows (default: Green) -// #[serde(skip_serializing_if = "Option::is_none")] -// stack_border: Option, -// /// Border colour when the container is in monocle mode (default: Pink) -// #[serde(skip_serializing_if = "Option::is_none")] -// monocle_border: Option, -// /// Border colour when the window is floating (default: Yellow) -// #[serde(skip_serializing_if = "Option::is_none")] -// floating_border: Option, -// /// Border colour when the container is unfocused (default: Base) -// #[serde(skip_serializing_if = "Option::is_none")] -// unfocused_border: Option, -// /// Border colour when the container is unfocused and locked (default: Red) -// #[serde(skip_serializing_if = "Option::is_none")] -// unfocused_locked_border: Option, -// /// Stackbar focused tab text colour (default: Green) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_focused_text: Option, -// /// Stackbar unfocused tab text colour (default: Text) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_unfocused_text: Option, -// /// Stackbar tab background colour (default: Base) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_background: Option, -// /// Komorebi status bar accent (default: Blue) -// #[serde(skip_serializing_if = "Option::is_none")] -// bar_accent: Option, -// }, -// /// A theme from base16-egui-themes -// Base16 { -// /// Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/) -// name: komorebi_themes::Base16, -// /// Border colour when the container contains a single window (default: Base0D) -// #[serde(skip_serializing_if = "Option::is_none")] -// single_border: Option, -// /// Border colour when the container contains multiple windows (default: Base0B) -// #[serde(skip_serializing_if = "Option::is_none")] -// stack_border: Option, -// /// Border colour when the container is in monocle mode (default: Base0F) -// #[serde(skip_serializing_if = "Option::is_none")] -// monocle_border: Option, -// /// Border colour when the window is floating (default: Base09) -// #[serde(skip_serializing_if = "Option::is_none")] -// floating_border: Option, -// /// Border colour when the container is unfocused (default: Base01) -// #[serde(skip_serializing_if = "Option::is_none")] -// unfocused_border: Option, -// /// Border colour when the container is unfocused and locked (default: Base08) -// #[serde(skip_serializing_if = "Option::is_none")] -// unfocused_locked_border: Option, -// /// Stackbar focused tab text colour (default: Base0B) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_focused_text: Option, -// /// Stackbar unfocused tab text colour (default: Base05) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_unfocused_text: Option, -// /// Stackbar tab background colour (default: Base01) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_background: Option, -// /// Komorebi status bar accent (default: Base0D) -// #[serde(skip_serializing_if = "Option::is_none")] -// bar_accent: Option, -// }, -// /// A custom Base16 theme -// Custom { -// /// Colours of the custom Base16 theme palette -// colours: Box, -// /// Border colour when the container contains a single window (default: Base0D) -// #[serde(skip_serializing_if = "Option::is_none")] -// single_border: Option, -// /// Border colour when the container contains multiple windows (default: Base0B) -// #[serde(skip_serializing_if = "Option::is_none")] -// stack_border: Option, -// /// Border colour when the container is in monocle mode (default: Base0F) -// #[serde(skip_serializing_if = "Option::is_none")] -// monocle_border: Option, -// /// Border colour when the window is floating (default: Base09) -// #[serde(skip_serializing_if = "Option::is_none")] -// floating_border: Option, -// /// Border colour when the container is unfocused (default: Base01) -// #[serde(skip_serializing_if = "Option::is_none")] -// unfocused_border: Option, -// /// Border colour when the container is unfocused and locked (default: Base08) -// #[serde(skip_serializing_if = "Option::is_none")] -// unfocused_locked_border: Option, -// /// Stackbar focused tab text colour (default: Base0B) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_focused_text: Option, -// /// Stackbar unfocused tab text colour (default: Base05) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_unfocused_text: Option, -// /// Stackbar tab background colour (default: Base01) -// #[serde(skip_serializing_if = "Option::is_none")] -// stackbar_background: Option, -// /// Komorebi status bar accent (default: Base0D) -// #[serde(skip_serializing_if = "Option::is_none")] -// bar_accent: Option, -// }, -// } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(tag = "palette")] +pub enum KomorebiTheme { + /// A theme from catppuccin-egui + Catppuccin { + /// Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin) + name: komorebi_themes::Catppuccin, + /// Border colour when the container contains a single window (default: Blue) + #[serde(skip_serializing_if = "Option::is_none")] + single_border: Option, + /// Border colour when the container contains multiple windows (default: Green) + #[serde(skip_serializing_if = "Option::is_none")] + stack_border: Option, + /// Border colour when the container is in monocle mode (default: Pink) + #[serde(skip_serializing_if = "Option::is_none")] + monocle_border: Option, + /// Border colour when the window is floating (default: Yellow) + #[serde(skip_serializing_if = "Option::is_none")] + floating_border: Option, + /// Border colour when the container is unfocused (default: Base) + #[serde(skip_serializing_if = "Option::is_none")] + unfocused_border: Option, + /// Border colour when the container is unfocused and locked (default: Red) + #[serde(skip_serializing_if = "Option::is_none")] + unfocused_locked_border: Option, + /// Stackbar focused tab text colour (default: Green) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_focused_text: Option, + /// Stackbar unfocused tab text colour (default: Text) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_unfocused_text: Option, + /// Stackbar tab background colour (default: Base) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_background: Option, + /// Komorebi status bar accent (default: Blue) + #[serde(skip_serializing_if = "Option::is_none")] + bar_accent: Option, + }, + /// A theme from base16-egui-themes + Base16 { + /// Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/) + name: komorebi_themes::Base16, + /// Border colour when the container contains a single window (default: Base0D) + #[serde(skip_serializing_if = "Option::is_none")] + single_border: Option, + /// Border colour when the container contains multiple windows (default: Base0B) + #[serde(skip_serializing_if = "Option::is_none")] + stack_border: Option, + /// Border colour when the container is in monocle mode (default: Base0F) + #[serde(skip_serializing_if = "Option::is_none")] + monocle_border: Option, + /// Border colour when the window is floating (default: Base09) + #[serde(skip_serializing_if = "Option::is_none")] + floating_border: Option, + /// Border colour when the container is unfocused (default: Base01) + #[serde(skip_serializing_if = "Option::is_none")] + unfocused_border: Option, + /// Border colour when the container is unfocused and locked (default: Base08) + #[serde(skip_serializing_if = "Option::is_none")] + unfocused_locked_border: Option, + /// Stackbar focused tab text colour (default: Base0B) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_focused_text: Option, + /// Stackbar unfocused tab text colour (default: Base05) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_unfocused_text: Option, + /// Stackbar tab background colour (default: Base01) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_background: Option, + /// Komorebi status bar accent (default: Base0D) + #[serde(skip_serializing_if = "Option::is_none")] + bar_accent: Option, + }, + /// A custom Base16 theme + Custom { + /// Colours of the custom Base16 theme palette + colours: Box, + /// Border colour when the container contains a single window (default: Base0D) + #[serde(skip_serializing_if = "Option::is_none")] + single_border: Option, + /// Border colour when the container contains multiple windows (default: Base0B) + #[serde(skip_serializing_if = "Option::is_none")] + stack_border: Option, + /// Border colour when the container is in monocle mode (default: Base0F) + #[serde(skip_serializing_if = "Option::is_none")] + monocle_border: Option, + /// Border colour when the window is floating (default: Base09) + #[serde(skip_serializing_if = "Option::is_none")] + floating_border: Option, + /// Border colour when the container is unfocused (default: Base01) + #[serde(skip_serializing_if = "Option::is_none")] + unfocused_border: Option, + /// Border colour when the container is unfocused and locked (default: Base08) + #[serde(skip_serializing_if = "Option::is_none")] + unfocused_locked_border: Option, + /// Stackbar focused tab text colour (default: Base0B) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_focused_text: Option, + /// Stackbar unfocused tab text colour (default: Base05) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_unfocused_text: Option, + /// Stackbar tab background colour (default: Base01) + #[serde(skip_serializing_if = "Option::is_none")] + stackbar_background: Option, + /// Komorebi status bar accent (default: Base0D) + #[serde(skip_serializing_if = "Option::is_none")] + bar_accent: Option, + }, +} // #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] // #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] @@ -781,7 +782,7 @@ impl From<&WindowManager> for StaticConfig { display_index_preferences: Option::from(DISPLAY_INDEX_PREFERENCES.read().clone()), // stackbar: None, // animation: None, - // theme: None, + theme: None, // slow_application_compensation_time: Option::from( // SLOW_APPLICATION_COMPENSATION_TIME.load(Ordering::SeqCst), // ), @@ -1041,9 +1042,9 @@ impl StaticConfig { // } // } // - // if let Some(theme) = &self.theme { - // theme_manager::send_notification(theme.clone()); - // } + if let Some(theme) = &self.theme { + theme_manager::send_notification(theme.clone()); + } if let Some(path) = &self.app_specific_configuration_path { match path { diff --git a/komorebi/src/theme_manager.rs b/komorebi/src/theme_manager.rs new file mode 100644 index 00000000..7e2626ad --- /dev/null +++ b/komorebi/src/theme_manager.rs @@ -0,0 +1,285 @@ +#![deny(clippy::unwrap_used, clippy::expect_used)] + +use crate::border_manager; +use crate::static_config::KomorebiTheme; +use crossbeam_channel::Receiver; +use crossbeam_channel::Sender; +use crossbeam_utils::atomic::AtomicCell; +use komorebi_themes::Base16Wrapper; +use komorebi_themes::colour::Colour; +use std::ops::Deref; +use std::sync::OnceLock; +use std::sync::atomic::Ordering; + +pub struct Notification(KomorebiTheme); + +pub static CURRENT_THEME: AtomicCell> = AtomicCell::new(None); + +impl Deref for Notification { + type Target = KomorebiTheme; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +static CHANNEL: OnceLock<(Sender, Receiver)> = OnceLock::new(); + +pub fn channel() -> &'static (Sender, Receiver) { + CHANNEL.get_or_init(|| crossbeam_channel::bounded(20)) +} + +fn event_tx() -> Sender { + channel().0.clone() +} + +fn event_rx() -> Receiver { + channel().1.clone() +} + +// Currently this should only be used for async focus updates, such as +// when an animation finishes and we need to focus to set the cursor +// position if the user has mouse follows focus enabled +pub fn send_notification(theme: KomorebiTheme) { + if event_tx().try_send(Notification(theme)).is_err() { + tracing::warn!("channel is full; dropping notification") + } +} + +pub fn listen_for_notifications() { + std::thread::spawn(move || { + loop { + match handle_notifications() { + Ok(()) => { + tracing::warn!("restarting finished thread"); + } + Err(error) => { + tracing::warn!("restarting failed thread: {}", error); + } + } + } + }); +} + +pub fn handle_notifications() -> color_eyre::Result<()> { + tracing::info!("listening"); + + let receiver = event_rx(); + + for notification in receiver { + let theme = ¬ification.0; + + let ( + single_border, + stack_border, + monocle_border, + floating_border, + unfocused_border, + unfocused_locked_border, + _stackbar_focused_text, + _stackbar_unfocused_text, + _stackbar_background, + ) = match theme { + KomorebiTheme::Catppuccin { + name, + single_border, + stack_border, + monocle_border, + floating_border, + unfocused_border, + unfocused_locked_border, + stackbar_focused_text, + stackbar_unfocused_text, + stackbar_background, + .. + } => { + let single_border = single_border + .unwrap_or(komorebi_themes::CatppuccinValue::Blue) + .color32(name.as_theme()); + + let stack_border = stack_border + .unwrap_or(komorebi_themes::CatppuccinValue::Green) + .color32(name.as_theme()); + + let monocle_border = monocle_border + .unwrap_or(komorebi_themes::CatppuccinValue::Pink) + .color32(name.as_theme()); + + let floating_border = floating_border + .unwrap_or(komorebi_themes::CatppuccinValue::Yellow) + .color32(name.as_theme()); + + let unfocused_border = unfocused_border + .unwrap_or(komorebi_themes::CatppuccinValue::Base) + .color32(name.as_theme()); + + let unfocused_locked_border = unfocused_locked_border + .unwrap_or(komorebi_themes::CatppuccinValue::Red) + .color32(name.as_theme()); + + let stackbar_focused_text = stackbar_focused_text + .unwrap_or(komorebi_themes::CatppuccinValue::Green) + .color32(name.as_theme()); + + let stackbar_unfocused_text = stackbar_unfocused_text + .unwrap_or(komorebi_themes::CatppuccinValue::Text) + .color32(name.as_theme()); + + let stackbar_background = stackbar_background + .unwrap_or(komorebi_themes::CatppuccinValue::Base) + .color32(name.as_theme()); + + ( + single_border, + stack_border, + monocle_border, + floating_border, + unfocused_border, + unfocused_locked_border, + stackbar_focused_text, + stackbar_unfocused_text, + stackbar_background, + ) + } + KomorebiTheme::Base16 { + name, + single_border, + stack_border, + monocle_border, + floating_border, + unfocused_border, + unfocused_locked_border, + stackbar_focused_text, + stackbar_unfocused_text, + stackbar_background, + .. + } => { + let single_border = single_border + .unwrap_or(komorebi_themes::Base16Value::Base0D) + .color32(Base16Wrapper::Base16(*name)); + + let stack_border = stack_border + .unwrap_or(komorebi_themes::Base16Value::Base0B) + .color32(Base16Wrapper::Base16(*name)); + + let monocle_border = monocle_border + .unwrap_or(komorebi_themes::Base16Value::Base0F) + .color32(Base16Wrapper::Base16(*name)); + + let unfocused_border = unfocused_border + .unwrap_or(komorebi_themes::Base16Value::Base01) + .color32(Base16Wrapper::Base16(*name)); + + let unfocused_locked_border = unfocused_locked_border + .unwrap_or(komorebi_themes::Base16Value::Base08) + .color32(Base16Wrapper::Base16(*name)); + + let floating_border = floating_border + .unwrap_or(komorebi_themes::Base16Value::Base09) + .color32(Base16Wrapper::Base16(*name)); + + let stackbar_focused_text = stackbar_focused_text + .unwrap_or(komorebi_themes::Base16Value::Base0B) + .color32(Base16Wrapper::Base16(*name)); + + let stackbar_unfocused_text = stackbar_unfocused_text + .unwrap_or(komorebi_themes::Base16Value::Base05) + .color32(Base16Wrapper::Base16(*name)); + + let stackbar_background = stackbar_background + .unwrap_or(komorebi_themes::Base16Value::Base01) + .color32(Base16Wrapper::Base16(*name)); + + ( + single_border, + stack_border, + monocle_border, + floating_border, + unfocused_border, + unfocused_locked_border, + stackbar_focused_text, + stackbar_unfocused_text, + stackbar_background, + ) + } + KomorebiTheme::Custom { + colours, + single_border, + stack_border, + monocle_border, + floating_border, + unfocused_border, + unfocused_locked_border, + stackbar_focused_text, + stackbar_unfocused_text, + stackbar_background, + .. + } => { + let single_border = single_border + .unwrap_or(komorebi_themes::Base16Value::Base0D) + .color32(Base16Wrapper::Custom(colours.clone())); + + let stack_border = stack_border + .unwrap_or(komorebi_themes::Base16Value::Base0B) + .color32(Base16Wrapper::Custom(colours.clone())); + + let monocle_border = monocle_border + .unwrap_or(komorebi_themes::Base16Value::Base0F) + .color32(Base16Wrapper::Custom(colours.clone())); + + let unfocused_border = unfocused_border + .unwrap_or(komorebi_themes::Base16Value::Base01) + .color32(Base16Wrapper::Custom(colours.clone())); + + let unfocused_locked_border = unfocused_locked_border + .unwrap_or(komorebi_themes::Base16Value::Base08) + .color32(Base16Wrapper::Custom(colours.clone())); + + let floating_border = floating_border + .unwrap_or(komorebi_themes::Base16Value::Base09) + .color32(Base16Wrapper::Custom(colours.clone())); + + let stackbar_focused_text = stackbar_focused_text + .unwrap_or(komorebi_themes::Base16Value::Base0B) + .color32(Base16Wrapper::Custom(colours.clone())); + + let stackbar_unfocused_text = stackbar_unfocused_text + .unwrap_or(komorebi_themes::Base16Value::Base05) + .color32(Base16Wrapper::Custom(colours.clone())); + + let stackbar_background = stackbar_background + .unwrap_or(komorebi_themes::Base16Value::Base01) + .color32(Base16Wrapper::Custom(colours.clone())); + + ( + single_border, + stack_border, + monocle_border, + floating_border, + unfocused_border, + unfocused_locked_border, + stackbar_focused_text, + stackbar_unfocused_text, + stackbar_background, + ) + } + }; + + border_manager::FOCUSED.store(u32::from(Colour::from(single_border)), Ordering::SeqCst); + border_manager::MONOCLE.store(u32::from(Colour::from(monocle_border)), Ordering::SeqCst); + border_manager::STACK.store(u32::from(Colour::from(stack_border)), Ordering::SeqCst); + border_manager::FLOATING.store(u32::from(Colour::from(floating_border)), Ordering::SeqCst); + border_manager::UNFOCUSED + .store(u32::from(Colour::from(unfocused_border)), Ordering::SeqCst); + border_manager::UNFOCUSED_LOCKED.store( + u32::from(Colour::from(unfocused_locked_border)), + Ordering::SeqCst, + ); + + CURRENT_THEME.store(Some(notification.0)); + + border_manager::destroy_all_borders()?; + } + + Ok(()) +} From 801be9150810803229a97bfe0c08324e6119dfbe Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 11:02:37 -0700 Subject: [PATCH 091/305] feat(wm): implement monitor/ws wallpapers This commit implements per-monitor and per-workspace wallpapers and integrates with the theme manager to optionally generate themes based on the palette of the wallpaper image. Mostly a lift-and-shift from komorebi for Windows. --- komorebi/src/core/mod.rs | 3 +- komorebi/src/macos_api.rs | 43 ++++++++ komorebi/src/monitor.rs | 9 +- komorebi/src/monitor_reconciliator.rs | 2 +- komorebi/src/process_command.rs | 4 + komorebi/src/state.rs | 4 +- komorebi/src/static_config.rs | 52 +++++----- komorebi/src/window_manager.rs | 30 ++++++ komorebi/src/workspace.rs | 143 +++++++++++++++++++++++++- 9 files changed, 256 insertions(+), 34 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 9a1e0af2..87430cb4 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -4,6 +4,7 @@ use crate::core::default_layout::DefaultLayout; use crate::core::operation_direction::OperationDirection; use crate::core::pathext::ResolvedPathBuf; use crate::core::rect::Rect; +use crate::static_config::KomorebiTheme; use clap::ValueEnum; use color_eyre::eyre; use serde::Deserialize; @@ -361,7 +362,7 @@ pub enum SocketMessage { // WatchConfiguration(bool), // CompleteConfiguration, // AltFocusHack(bool), - // Theme(Box), + Theme(Box), // Animation(bool, Option), // AnimationDuration(u64, Option), // AnimationFps(u64), diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index 99ecde20..f4cd7829 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -19,10 +19,13 @@ use crate::window::RuleDebug; use crate::window::WindowInfo; use crate::window_manager::WindowManager; use color_eyre::eyre; +use color_eyre::eyre::OptionExt; +use dispatch2::DispatchQueue; use objc2::MainThreadMarker; use objc2_app_kit::NSDeviceDescriptionKey; use objc2_app_kit::NSEvent; use objc2_app_kit::NSScreen; +use objc2_app_kit::NSWorkspace; use objc2_application_services::AXUIElement; use objc2_application_services::AXValue; use objc2_application_services::AXValueType; @@ -36,14 +39,54 @@ use objc2_core_graphics::CGEvent; use objc2_core_graphics::CGEventSource; use objc2_core_graphics::CGEventSourceStateID; use objc2_core_graphics::CGMainDisplayID; +use objc2_foundation::NSDictionary; use objc2_foundation::NSNumber; +use objc2_foundation::NSString; +use objc2_foundation::NSURL; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::ffi::c_void; +use std::path::Path; use std::ptr::NonNull; pub struct MacosApi; +impl MacosApi { + pub fn set_wallpaper(path: &Path, display_id: u32) -> eyre::Result<()> { + let path_str = path.to_str().ok_or_eyre("Invalid path encoding")?; + + DispatchQueue::main().exec_sync(|| { + let ns_path = NSString::from_str(path_str); + let url = unsafe { NSURL::fileURLWithPath(&ns_path) }; + + let mtm = unsafe { MainThreadMarker::new_unchecked() }; + let screens = NSScreen::screens(mtm); + + for screen in &screens { + if let Some(did) = screen + .deviceDescription() + .objectForKey(&NSDeviceDescriptionKey::from_str("NSScreenNumber")) + && let Ok(did) = did.downcast::() + && did.as_u32() == display_id + { + let workspace = unsafe { NSWorkspace::sharedWorkspace() }; + unsafe { + if let Err(error) = workspace.setDesktopImageURL_forScreen_options_error( + &url, + &screen, + &NSDictionary::new(), + ) { + tracing::warn!("failed to set wallpaper: {error}") + } + } + } + } + }); + + Ok(()) + } +} + impl MacosApi { #[tracing::instrument(skip_all)] pub fn load_monitor_information(wm: &mut WindowManager) -> Result<(), LibraryError> { diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 5b34e55e..b5401174 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -8,6 +8,7 @@ use crate::core::operation_direction::OperationDirection; use crate::core::rect::Rect; use crate::macos_api::MacosApi; use crate::ring::Ring; +use crate::static_config::Wallpaper; use crate::workspace::Workspace; use crate::workspace::WorkspaceGlobals; use crate::workspace::WorkspaceLayer; @@ -67,6 +68,7 @@ pub struct Monitor { pub workspace_padding: Option, #[serde(skip_serializing_if = "Option::is_none")] pub last_focused_workspace: Option, + pub wallpaper: Option, pub floating_layer_behaviour: Option, } @@ -93,6 +95,7 @@ pub fn new( last_focused_workspace: None, container_padding: None, workspace_padding: None, + wallpaper: None, floating_layer_behaviour: None, } } @@ -122,6 +125,7 @@ impl Monitor { container_padding: None, workspace_padding: None, last_focused_workspace: None, + wallpaper: None, floating_layer_behaviour: None, } } @@ -141,6 +145,7 @@ impl Monitor { last_focused_workspace: None, container_padding: None, workspace_padding: None, + wallpaper: None, floating_layer_behaviour: None, } } @@ -211,9 +216,11 @@ impl Monitor { pub fn load_focused_workspace(&mut self, mouse_follows_focus: bool) -> eyre::Result<()> { let focused_idx = self.focused_workspace_idx(); + let monitor_id = self.id; + let monitor_wp = self.wallpaper.clone(); for (i, workspace) in self.workspaces_mut().iter_mut().enumerate() { if i == focused_idx { - workspace.restore(mouse_follows_focus)?; + workspace.restore(mouse_follows_focus, monitor_id, &monitor_wp)?; } else { workspace.hide(None)?; } diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index cfa49d82..f44ceb0e 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -381,7 +381,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // workspace_names: cached.workspace_names.clone(), container_padding: cached.container_padding, workspace_padding: cached.workspace_padding, - // wallpaper: cached.wallpaper.clone(), + wallpaper: cached.wallpaper.clone(), floating_layer_behaviour: cached.floating_layer_behaviour, }; diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 721a17b1..240607e8 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -38,6 +38,7 @@ use crate::notify_subscribers; use crate::state::GlobalState; use crate::state::State; use crate::static_config::StaticConfig; +use crate::theme_manager; use crate::window::AdhocWindow; use crate::window::RuleDebug; use crate::window::Window; @@ -1708,6 +1709,9 @@ impl WindowManager { border_manager::BORDER_OFFSET.store(offset, Ordering::SeqCst); border_manager::destroy_all_borders()?; } + SocketMessage::Theme(ref theme) => { + theme_manager::send_notification(*theme.clone()); + } } self.update_known_window_ids(); diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs index d6627ff4..11c37b17 100644 --- a/komorebi/src/state.rs +++ b/komorebi/src/state.rs @@ -138,7 +138,7 @@ impl From<&WindowManager> for State { layer: workspace.layer, floating_layer_behaviour: workspace.floating_layer_behaviour, globals: workspace.globals, - // wallpaper: workspace.wallpaper.clone(), + wallpaper: workspace.wallpaper.clone(), workspace_config: None, }) .collect::>(); @@ -149,7 +149,7 @@ impl From<&WindowManager> for State { // workspace_names: monitor.workspace_names.clone(), container_padding: monitor.container_padding, workspace_padding: monitor.workspace_padding, - // wallpaper: monitor.wallpaper.clone(), + wallpaper: monitor.wallpaper.clone(), floating_layer_behaviour: monitor.floating_layer_behaviour, }) .collect::>(); diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index baae7867..e7a879be 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -121,20 +121,20 @@ pub struct ThemeOptions { pub bar_accent: Option, } -// #[serde_with::serde_as] -// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -// pub struct Wallpaper { -// /// Path to the wallpaper image file -// #[serde_as(as = "ResolvedPathBuf")] -// pub path: PathBuf, -// /// Generate and apply Base16 theme for this wallpaper (default: true) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub generate_theme: Option, -// /// Specify Light or Dark variant for theme generation (default: Dark) -// #[serde(skip_serializing_if = "Option::is_none")] -// pub theme_options: Option, -// } +#[serde_with::serde_as] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct Wallpaper { + /// Path to the wallpaper image file + #[serde_as(as = "ResolvedPathBuf")] + pub path: PathBuf, + /// Generate and apply Base16 theme for this wallpaper (default: true) + #[serde(skip_serializing_if = "Option::is_none")] + pub generate_theme: Option, + /// Specify Light or Dark variant for theme generation (default: Dark) + #[serde(skip_serializing_if = "Option::is_none")] + pub theme_options: Option, +} // serde_as must be before derive #[serde_with::serde_as] @@ -192,9 +192,9 @@ pub struct WorkspaceConfig { /// Determine what happens to a new window when the Floating workspace layer is active (default: Tile) #[serde(skip_serializing_if = "Option::is_none")] pub floating_layer_behaviour: Option, - // /// Specify a wallpaper for this workspace - // #[serde(skip_serializing_if = "Option::is_none")] - // pub wallpaper: Option, + /// Specify a wallpaper for this workspace + #[serde(skip_serializing_if = "Option::is_none")] + pub wallpaper: Option, } impl From<&Workspace> for WorkspaceConfig { @@ -274,7 +274,7 @@ impl From<&Workspace> for WorkspaceConfig { tile, layout_flip: value.layout_flip, floating_layer_behaviour: value.floating_layer_behaviour, - // wallpaper: None, + wallpaper: None, } } } @@ -299,9 +299,9 @@ pub struct MonitorConfig { /// Workspace padding (default: global) #[serde(skip_serializing_if = "Option::is_none")] pub workspace_padding: Option, - // /// Specify a wallpaper for this monitor - // #[serde(skip_serializing_if = "Option::is_none")] - // pub wallpaper: Option, + /// Specify a wallpaper for this monitor + #[serde(skip_serializing_if = "Option::is_none")] + pub wallpaper: Option, /// Determine what happens to a new window when the Floating workspace layer is active (default: Tile) #[serde(skip_serializing_if = "Option::is_none")] pub floating_layer_behaviour: Option, @@ -340,7 +340,7 @@ impl From<&Monitor> for MonitorConfig { window_based_work_area_offset_limit: Some(value.window_based_work_area_offset_limit), container_padding, workspace_padding, - // wallpaper: value.wallpaper.clone(), + wallpaper: value.wallpaper.clone(), floating_layer_behaviour: value.floating_layer_behaviour, } } @@ -1250,7 +1250,7 @@ impl StaticConfig { .unwrap_or(1); monitor.container_padding = monitor_config.container_padding; monitor.workspace_padding = monitor_config.workspace_padding; - // monitor.wallpaper = monitor_config.wallpaper.clone(); + monitor.wallpaper = monitor_config.wallpaper.clone(); monitor.floating_layer_behaviour = monitor_config.floating_layer_behaviour; monitor.update_workspaces_globals(offset); @@ -1416,7 +1416,7 @@ impl StaticConfig { .unwrap_or(1); monitor.container_padding = monitor_config.container_padding; monitor.workspace_padding = monitor_config.workspace_padding; - // monitor.wallpaper = monitor_config.wallpaper.clone(); + monitor.wallpaper = monitor_config.wallpaper.clone(); monitor.floating_layer_behaviour = monitor_config.floating_layer_behaviour; monitor.update_workspaces_globals(offset); @@ -1544,8 +1544,8 @@ impl StaticConfig { for i in 0..monitor_count { wm.update_focused_workspace_by_monitor_idx(i)?; - // let ws_idx = wm.focused_workspace_idx_for_monitor_idx(i)?; - // wm.apply_wallpaper_for_monitor_workspace(i, ws_idx)?; + let ws_idx = wm.focused_workspace_idx_for_monitor_idx(i)?; + wm.apply_wallpaper_for_monitor_workspace(i, ws_idx)?; } // to update the borders diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index a1064a78..0c11473a 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1558,6 +1558,8 @@ impl WindowManager { let focused_workspace_idx = monitor.focused_workspace_idx(); monitor.update_workspace_globals(focused_workspace_idx, offset); + let monitor_id = monitor.id; + let monitor_wp = monitor.wallpaper.clone(); let workspace = monitor .focused_workspace_mut() .ok_or_eyre("there is no workspace")?; @@ -1569,6 +1571,12 @@ impl WindowManager { } } + if (workspace.wallpaper.is_some() || monitor_wp.is_some()) + && let Err(error) = workspace.apply_wallpaper(monitor_id, &monitor_wp) + { + tracing::error!("failed to apply wallpaper: {}", error); + } + workspace.update()?; } @@ -3135,4 +3143,26 @@ impl WindowManager { Ok(()) } + + #[tracing::instrument(skip(self))] + pub fn apply_wallpaper_for_monitor_workspace( + &mut self, + monitor_idx: usize, + workspace_idx: usize, + ) -> eyre::Result<()> { + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_eyre("there is no monitor")?; + + let monitor_id = monitor.id; + let monitor_wp = monitor.wallpaper.clone(); + + let workspace = monitor + .workspaces() + .get(workspace_idx) + .ok_or_eyre("there is no workspace")?; + + workspace.apply_wallpaper(monitor_id, &monitor_wp) + } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index b0ffc544..fdf974ab 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1,5 +1,7 @@ +use crate::DATA_DIR; use crate::container::Container; use crate::core::FloatingLayerBehaviour; +use crate::core::SocketMessage; use crate::core::WindowContainerBehaviour; use crate::core::arrangement::Axis; use crate::core::cycle_direction::CycleDirection; @@ -11,17 +13,23 @@ use crate::core::rect::Rect; use crate::lockable_sequence::LockableSequence; use crate::macos_api::MacosApi; use crate::ring::Ring; +use crate::static_config::KomorebiTheme; +use crate::static_config::Wallpaper; use crate::static_config::WorkspaceConfig; use crate::window::Window; use crate::window::WindowDetails; use color_eyre::eyre; use color_eyre::eyre::OptionExt; +use komorebi_themes::Base16ColourPalette; use serde::Deserialize; use serde::Serialize; use std::collections::HashMap; +use std::ffi::OsStr; use std::fmt::Display; use std::fmt::Formatter; +use std::io::Write; use std::num::NonZeroUsize; +use std::os::unix::net::UnixStream; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] @@ -53,6 +61,7 @@ pub struct Workspace { pub globals: WorkspaceGlobals, pub layer: WorkspaceLayer, pub floating_layer_behaviour: Option, + pub wallpaper: Option, #[serde(skip_serializing_if = "Option::is_none")] pub workspace_config: Option, } @@ -104,6 +113,7 @@ impl Default for Workspace { floating_windows: Default::default(), float_override: None, floating_layer_behaviour: None, + wallpaper: None, workspace_config: None, } } @@ -185,7 +195,7 @@ impl Workspace { self.float_override = config.float_override; self.layout_flip = config.layout_flip; self.floating_layer_behaviour = config.floating_layer_behaviour; - // self.wallpaper = config.wallpaper.clone(); + self.wallpaper = config.wallpaper.clone(); self.layout_options = config.layout_options; self.workspace_config = Some(config.clone()); @@ -678,13 +688,20 @@ impl Workspace { Ok(()) } - pub fn restore(&mut self, mouse_follows_focus: bool) -> eyre::Result<()> { + pub fn restore( + &mut self, + mouse_follows_focus: bool, + monitor_id: u32, + monitor_wp: &Option, + ) -> eyre::Result<()> { if let Some(container) = &mut self.monocle_container { container.restore()?; if let Some(window) = container.focused_window() { window.focus(mouse_follows_focus)?; } + + return self.apply_wallpaper(monitor_id, monitor_wp); } let idx = self.focused_container_idx(); @@ -730,7 +747,7 @@ impl Workspace { floating_window.focus(mouse_follows_focus)?; } - Ok(()) + self.apply_wallpaper(monitor_id, monitor_wp) } pub fn remove_focused_container(&mut self) -> Option { @@ -1155,6 +1172,126 @@ impl Workspace { self.containers() .get(self.container_idx_for_window(window_id)?) } + + pub fn apply_wallpaper( + &self, + monitor_id: u32, + monitor_wp: &Option, + ) -> eyre::Result<()> { + if let Some(wallpaper) = self.wallpaper.as_ref().or(monitor_wp.as_ref()) { + if let Err(error) = MacosApi::set_wallpaper(&wallpaper.path, monitor_id) { + tracing::error!("failed to set wallpaper: {error}"); + } + + if wallpaper.generate_theme.unwrap_or(true) { + let variant = wallpaper + .theme_options + .as_ref() + .and_then(|t| t.theme_variant) + .unwrap_or_default(); + + let cached_palette = DATA_DIR.join(format!( + "{}.base16.{variant}.json", + wallpaper + .path + .file_name() + .unwrap_or(OsStr::new("tmp")) + .to_string_lossy() + )); + + let mut base16_palette = None; + + if cached_palette.is_file() { + tracing::info!( + "colour palette for wallpaper {} found in cache", + cached_palette.display() + ); + + // this code is VERY slow on debug builds - should only be a one-time issue when loading + // an uncached wallpaper + if let Ok(palette) = serde_json::from_str::( + &std::fs::read_to_string(&cached_palette)?, + ) { + base16_palette = Some(palette); + } + }; + + if base16_palette.is_none() { + base16_palette = + komorebi_themes::generate_base16_palette(&wallpaper.path, variant).ok(); + + std::fs::write( + &cached_palette, + serde_json::to_string_pretty(&base16_palette)?, + )?; + + tracing::info!( + "colour palette for wallpaper {} cached", + cached_palette.display() + ); + } + + if let Some(palette) = base16_palette { + let komorebi_theme = KomorebiTheme::Custom { + colours: Box::new(palette), + single_border: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.single_border), + stack_border: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.stack_border), + monocle_border: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.monocle_border), + floating_border: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.floating_border), + unfocused_border: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.unfocused_border), + unfocused_locked_border: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.unfocused_locked_border), + stackbar_focused_text: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.stackbar_focused_text), + stackbar_unfocused_text: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.stackbar_unfocused_text), + stackbar_background: wallpaper + .theme_options + .as_ref() + .and_then(|o| o.stackbar_background), + bar_accent: wallpaper.theme_options.as_ref().and_then(|o| o.bar_accent), + }; + + let bytes = SocketMessage::Theme(Box::new(komorebi_theme)).as_bytes()?; + + let socket = DATA_DIR.join("komorebi.sock"); + match UnixStream::connect(socket) { + Ok(mut stream) => { + if let Err(error) = stream.write_all(&bytes) { + tracing::error!("failed to send theme update message: {error}") + } + } + Err(error) => { + tracing::error!("{error}") + } + } + } + } + } + + Ok(()) + } } impl Workspace { From ded36d39ee08e85538b35c65bda13d24e055f97c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 11:07:00 -0700 Subject: [PATCH 092/305] docs(schema): update jsonschema files --- schema.json | 2486 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2486 insertions(+) diff --git a/schema.json b/schema.json index 953fcb04..4b0d8399 100644 --- a/schema.json +++ b/schema.json @@ -20,6 +20,255 @@ } ] }, + "border": { + "description": "Display an active window border (default: true)", + "type": "boolean" + }, + "border_colours": { + "description": "Active window border colours for different container types", + "type": "object", + "properties": { + "floating": { + "description": "Border colour when the container is in floating mode", + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "monocle": { + "description": "Border colour when the container is in monocle mode", + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "single": { + "description": "Border colour when the container contains a single window", + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "stack": { + "description": "Border colour when the container contains multiple windows", + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "unfocused": { + "description": "Border colour when the container is unfocused", + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "unfocused_locked": { + "description": "Border colour when the container is unfocused and locked", + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + } + } + }, + "border_offset": { + "description": "Offset of the window border (default: 5)", + "type": "integer", + "format": "int32" + }, "border_overflow_applications": { "description": "Identify border overflow applications", "type": "array", @@ -103,6 +352,11 @@ ] } }, + "border_width": { + "description": "Width of the window border (default: 6)", + "type": "integer", + "format": "int32" + }, "cross_boundary_behaviour": { "description": "Determine what happens when an action is called on a window at a monitor boundary (default: Monitor)", "oneOf": [ @@ -706,6 +960,257 @@ } ] }, + "wallpaper": { + "description": "Specify a wallpaper for this monitor", + "type": "object", + "required": [ + "path" + ], + "properties": { + "generate_theme": { + "description": "Generate and apply Base16 theme for this wallpaper (default: true)", + "type": "boolean" + }, + "path": { + "description": "Path to the wallpaper image file", + "type": "string" + }, + "theme_options": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "theme_variant": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "type": "string", + "enum": [ + "Dark", + "Light" + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + } + } + } + } + }, "window_based_work_area_offset": { "description": "Window based work area offset (default: None)", "type": "object", @@ -971,6 +1476,257 @@ "description": "Enable or disable tiling for the workspace (default: true)", "type": "boolean" }, + "wallpaper": { + "description": "Specify a wallpaper for this workspace", + "type": "object", + "required": [ + "path" + ], + "properties": { + "generate_theme": { + "description": "Generate and apply Base16 theme for this wallpaper (default: true)", + "type": "boolean" + }, + "path": { + "description": "Path to the wallpaper image file", + "type": "string" + }, + "theme_options": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "theme_variant": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "type": "string", + "enum": [ + "Dark", + "Light" + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + } + } + } + } + }, "window_container_behaviour": { "description": "Determine what happens when a new window is opened (default: Create)", "oneOf": [ @@ -1233,6 +1989,1736 @@ "type": "integer", "format": "int32" }, + "theme": { + "description": "Theme configuration options", + "oneOf": [ + { + "description": "A theme from catppuccin-egui", + "type": "object", + "required": [ + "name", + "palette" + ], + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Blue)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Yellow)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Pink)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "name": { + "description": "Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)", + "type": "string", + "enum": [ + "Frappe", + "Latte", + "Macchiato", + "Mocha" + ] + }, + "palette": { + "type": "string", + "enum": [ + "Catppuccin" + ] + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Blue)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Green)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Green)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Text)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Red)", + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + } + } + }, + { + "description": "A theme from base16-egui-themes", + "type": "object", + "required": [ + "name", + "palette" + ], + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "name": { + "description": "Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)", + "type": "string", + "enum": [ + "3024", + "Apathy", + "Apprentice", + "Ashes", + "AtelierCaveLight", + "AtelierCave", + "AtelierDuneLight", + "AtelierDune", + "AtelierEstuaryLight", + "AtelierEstuary", + "AtelierForestLight", + "AtelierForest", + "AtelierHeathLight", + "AtelierHeath", + "AtelierLakesideLight", + "AtelierLakeside", + "AtelierPlateauLight", + "AtelierPlateau", + "AtelierSavannaLight", + "AtelierSavanna", + "AtelierSeasideLight", + "AtelierSeaside", + "AtelierSulphurpoolLight", + "AtelierSulphurpool", + "Atlas", + "AyuDark", + "AyuLight", + "AyuMirage", + "Aztec", + "Bespin", + "BlackMetalBathory", + "BlackMetalBurzum", + "BlackMetalDarkFuneral", + "BlackMetalGorgoroth", + "BlackMetalImmortal", + "BlackMetalKhold", + "BlackMetalMarduk", + "BlackMetalMayhem", + "BlackMetalNile", + "BlackMetalVenom", + "BlackMetal", + "Blueforest", + "Blueish", + "Brewer", + "Bright", + "Brogrammer", + "BrushtreesDark", + "Brushtrees", + "Caroline", + "CatppuccinFrappe", + "CatppuccinLatte", + "CatppuccinMacchiato", + "CatppuccinMocha", + "Chalk", + "Circus", + "ClassicDark", + "ClassicLight", + "Codeschool", + "Colors", + "Cupcake", + "Cupertino", + "DaOneBlack", + "DaOneGray", + "DaOneOcean", + "DaOnePaper", + "DaOneSea", + "DaOneWhite", + "DanqingLight", + "Danqing", + "Darcula", + "Darkmoss", + "Darktooth", + "Darkviolet", + "Decaf", + "DefaultDark", + "DefaultLight", + "Dirtysea", + "Dracula", + "EdgeDark", + "EdgeLight", + "Eighties", + "EmbersLight", + "Embers", + "Emil", + "EquilibriumDark", + "EquilibriumGrayDark", + "EquilibriumGrayLight", + "EquilibriumLight", + "Eris", + "Espresso", + "EvaDim", + "Eva", + "EvenokDark", + "EverforestDarkHard", + "Everforest", + "Flat", + "Framer", + "FruitSoda", + "Gigavolt", + "Github", + "GoogleDark", + "GoogleLight", + "Gotham", + "GrayscaleDark", + "GrayscaleLight", + "Greenscreen", + "Gruber", + "GruvboxDarkHard", + "GruvboxDarkMedium", + "GruvboxDarkPale", + "GruvboxDarkSoft", + "GruvboxLightHard", + "GruvboxLightMedium", + "GruvboxLightSoft", + "GruvboxMaterialDarkHard", + "GruvboxMaterialDarkMedium", + "GruvboxMaterialDarkSoft", + "GruvboxMaterialLightHard", + "GruvboxMaterialLightMedium", + "GruvboxMaterialLightSoft", + "Hardcore", + "Harmonic16Dark", + "Harmonic16Light", + "HeetchLight", + "Heetch", + "Helios", + "Hopscotch", + "HorizonDark", + "HorizonLight", + "HorizonTerminalDark", + "HorizonTerminalLight", + "HumanoidDark", + "HumanoidLight", + "IaDark", + "IaLight", + "Icy", + "Irblack", + "Isotope", + "Jabuti", + "Kanagawa", + "Katy", + "Kimber", + "Lime", + "Macintosh", + "Marrakesh", + "Materia", + "MaterialDarker", + "MaterialLighter", + "MaterialPalenight", + "MaterialVivid", + "Material", + "MeasuredDark", + "MeasuredLight", + "MellowPurple", + "MexicoLight", + "Mocha", + "Monokai", + "Moonlight", + "Mountain", + "Nebula", + "NordLight", + "Nord", + "Nova", + "Ocean", + "Oceanicnext", + "OneLight", + "OnedarkDark", + "Onedark", + "OutrunDark", + "OxocarbonDark", + "OxocarbonLight", + "Pandora", + "PapercolorDark", + "PapercolorLight", + "Paraiso", + "Pasque", + "Phd", + "Pico", + "Pinky", + "Pop", + "Porple", + "PreciousDarkEleven", + "PreciousDarkFifteen", + "PreciousLightWarm", + "PreciousLightWhite", + "PrimerDarkDimmed", + "PrimerDark", + "PrimerLight", + "Purpledream", + "Qualia", + "Railscasts", + "Rebecca", + "RosePineDawn", + "RosePineMoon", + "RosePine", + "Saga", + "Sagelight", + "Sakura", + "Sandcastle", + "SelenizedBlack", + "SelenizedDark", + "SelenizedLight", + "SelenizedWhite", + "Seti", + "ShadesOfPurple", + "ShadesmearDark", + "ShadesmearLight", + "Shapeshifter", + "SilkDark", + "SilkLight", + "Snazzy", + "SolarflareLight", + "Solarflare", + "SolarizedDark", + "SolarizedLight", + "Spaceduck", + "Spacemacs", + "Sparky", + "StandardizedDark", + "StandardizedLight", + "Stella", + "StillAlive", + "Summercamp", + "SummerfruitDark", + "SummerfruitLight", + "SynthMidnightDark", + "SynthMidnightLight", + "Tango", + "Tarot", + "Tender", + "TerracottaDark", + "Terracotta", + "TokyoCityDark", + "TokyoCityLight", + "TokyoCityTerminalDark", + "TokyoCityTerminalLight", + "TokyoNightDark", + "TokyoNightLight", + "TokyoNightMoon", + "TokyoNightStorm", + "TokyoNightTerminalDark", + "TokyoNightTerminalLight", + "TokyoNightTerminalStorm", + "TokyodarkTerminal", + "Tokyodark", + "TomorrowNightEighties", + "TomorrowNight", + "Tomorrow", + "Tube", + "Twilight", + "UnikittyDark", + "UnikittyLight", + "UnikittyReversible", + "Uwunicorn", + "Vesper", + "Vice", + "Vulcan", + "Windows10Light", + "Windows10", + "Windows95Light", + "Windows95", + "WindowsHighcontrastLight", + "WindowsHighcontrast", + "WindowsNtLight", + "WindowsNt", + "Woodland", + "XcodeDusk", + "Zenbones", + "Zenburn" + ] + }, + "palette": { + "type": "string", + "enum": [ + "Base16" + ] + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + } + } + }, + { + "description": "A custom Base16 theme", + "type": "object", + "required": [ + "colours", + "palette" + ], + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "colours": { + "description": "Colours of the custom Base16 theme palette", + "type": "object", + "required": [ + "base_00", + "base_01", + "base_02", + "base_03", + "base_04", + "base_05", + "base_06", + "base_07", + "base_08", + "base_09", + "base_0a", + "base_0b", + "base_0c", + "base_0d", + "base_0e", + "base_0f" + ], + "properties": { + "base_00": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_01": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_02": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_03": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_04": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_05": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_06": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_07": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_08": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_09": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_0a": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_0b": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_0c": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_0d": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_0e": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + }, + "base_0f": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "type": "object", + "required": [ + "b", + "g", + "r" + ], + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + }, + { + "description": "Colour represented as Hex", + "type": "string", + "format": "color-hex" + } + ] + } + } + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "palette": { + "type": "string", + "enum": [ + "Custom" + ] + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + } + } + } + ] + }, "toggle_float_placement": { "description": "Determines the placement of a new window when toggling to float (default: CenterAndResize)", "oneOf": [ From 230acf3547d91f04fbc36b637111cdd4fa2ad72c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 13:03:38 -0700 Subject: [PATCH 093/305] fix(client): wrap axobservers in an option to avoid deser crashes This commit fixes a crash for subscribers who try to deserialize state from notifications. Even though skip_deserializing is used on the AccessibilityObserver, we still need a sane Default, so we wrap the inner AXObserver in an Option and default to None. --- komorebi-client/src/lib.rs | 21 +++++++++++++++++++++ komorebi/src/application.rs | 4 ++-- komorebi/src/border_manager/border.rs | 4 ++-- komorebi/src/lib.rs | 7 +++---- komorebi/src/window.rs | 2 +- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 75c45651..8e63854c 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -21,6 +21,7 @@ use std::io::BufReader; use std::io::Read; use std::io::Write; use std::net::Shutdown; +use std::os::unix::net::UnixListener; use std::os::unix::net::UnixStream; use std::time::Duration; @@ -65,3 +66,23 @@ pub fn send_query(message: &SocketMessage) -> std::io::Result { Ok(response) } + +pub fn subscribe(name: &str) -> std::io::Result { + let socket = DATA_DIR.join(name); + + match std::fs::remove_file(&socket) { + Ok(()) => {} + Err(error) => match error.kind() { + std::io::ErrorKind::NotFound => {} + _ => { + return Err(error); + } + }, + }; + + let listener = UnixListener::bind(&socket)?; + + send_message(&SocketMessage::AddSubscriberSocket(name.to_string()))?; + + Ok(listener) +} diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index 8656c715..be344fdb 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -107,10 +107,10 @@ impl Application { Ok(Self { element: AccessibilityUiElement(AccessibilityApi::create_application(process_id)), process_id, - observer: AccessibilityObserver(AccessibilityApi::create_observer( + observer: AccessibilityObserver(Some(AccessibilityApi::create_observer( process_id, Some(application_observer_callback), - )?), + )?)), is_observable: true, }) } diff --git a/komorebi/src/border_manager/border.rs b/komorebi/src/border_manager/border.rs index 3d5d05ef..260715bf 100644 --- a/komorebi/src/border_manager/border.rs +++ b/komorebi/src/border_manager/border.rs @@ -94,10 +94,10 @@ impl Border { monitor_idx: Option, run_loop: CoreFoundationRunLoop, ) -> eyre::Result> { - let observer = AccessibilityObserver(AccessibilityApi::create_observer( + let observer = AccessibilityObserver(Some(AccessibilityApi::create_observer( process_id, Some(border_observer_callback), - )?); + )?)); let rect = MacosApi::window_rect(&element).unwrap_or_default(); diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index a17d6508..e92a1b7e 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -1,6 +1,5 @@ #![warn(clippy::all)] -use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityError; use crate::core::ApplicationIdentifier; use crate::core::SocketMessage; @@ -261,20 +260,20 @@ impl Default for AccessibilityUiElement { } #[derive(Debug, Clone, PartialEq)] -pub struct AccessibilityObserver(pub CFRetained); +pub struct AccessibilityObserver(pub Option>); unsafe impl Sync for AccessibilityObserver {} unsafe impl Send for AccessibilityObserver {} impl Deref for AccessibilityObserver { type Target = AXObserver; fn deref(&self) -> &Self::Target { - self.0.as_ref() + self.0.as_ref().expect("must have an AXObserver") } } impl Default for AccessibilityObserver { fn default() -> Self { - Self(AccessibilityApi::create_observer(1, None).unwrap()) + Self(None) } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index d75d732a..aca11f61 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -330,7 +330,7 @@ impl Window { id: AccessibilityApi::window_id(&element)?, element: AccessibilityUiElement(element), application, - observer: AccessibilityObserver(observer), + observer: AccessibilityObserver(Some(observer)), }) } From 9777c55a1f12e9c4c742b98a99cc678a6bdffca0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 15:14:28 -0700 Subject: [PATCH 094/305] feat(bar): migrate the komorebi-bar This commit migrates the komorebi-bar from komorebi for Windows. Mostly lifting and shifting code, exposing stuff we need in komorebi-client etc. A few widgets will need to be reworked completely so they have been removed for now. Mouse and command stuff also needs updating a little so that has also been removed for now. --- Cargo.lock | 881 +++++++++++- Cargo.toml | 13 +- docs/komorebi.bar.example.json | 64 + komorebi-bar/Cargo.toml | 47 + komorebi-bar/src/bar.rs | 1347 +++++++++++++++++++ komorebi-bar/src/config.rs | 699 ++++++++++ komorebi-bar/src/main.rs | 373 +++++ komorebi-bar/src/render.rs | 429 ++++++ komorebi-bar/src/selected_frame.rs | 89 ++ komorebi-bar/src/ui.rs | 22 + komorebi-bar/src/widgets/applications.rs | 404 ++++++ komorebi-bar/src/widgets/battery.rs | 189 +++ komorebi-bar/src/widgets/cpu.rs | 132 ++ komorebi-bar/src/widgets/date.rs | 240 ++++ komorebi-bar/src/widgets/keyboard.rs | 177 +++ komorebi-bar/src/widgets/komorebi.rs | 1015 ++++++++++++++ komorebi-bar/src/widgets/komorebi_layout.rs | 323 +++++ komorebi-bar/src/widgets/media.rs | 122 ++ komorebi-bar/src/widgets/memory.rs | 137 ++ komorebi-bar/src/widgets/mod.rs | 173 +++ komorebi-bar/src/widgets/network.rs | 553 ++++++++ komorebi-bar/src/widgets/storage.rs | 171 +++ komorebi-bar/src/widgets/time.rs | 538 ++++++++ komorebi-bar/src/widgets/update.rs | 156 +++ komorebi-bar/src/widgets/widget.rs | 94 ++ komorebi-client/Cargo.toml | 1 + komorebi-client/src/lib.rs | 38 + komorebi/Cargo.toml | 27 +- komorebi/src/lib.rs | 31 +- komorebi/src/macos_api.rs | 9 +- komorebi/src/main.rs | 7 +- komorebi/src/process_command.rs | 3 +- komorebi/src/window.rs | 4 + komorebic/src/main.rs | 21 + 34 files changed, 8478 insertions(+), 51 deletions(-) create mode 100644 docs/komorebi.bar.example.json create mode 100644 komorebi-bar/Cargo.toml create mode 100644 komorebi-bar/src/bar.rs create mode 100644 komorebi-bar/src/config.rs create mode 100644 komorebi-bar/src/main.rs create mode 100644 komorebi-bar/src/render.rs create mode 100644 komorebi-bar/src/selected_frame.rs create mode 100644 komorebi-bar/src/ui.rs create mode 100644 komorebi-bar/src/widgets/applications.rs create mode 100644 komorebi-bar/src/widgets/battery.rs create mode 100644 komorebi-bar/src/widgets/cpu.rs create mode 100644 komorebi-bar/src/widgets/date.rs create mode 100644 komorebi-bar/src/widgets/keyboard.rs create mode 100644 komorebi-bar/src/widgets/komorebi.rs create mode 100644 komorebi-bar/src/widgets/komorebi_layout.rs create mode 100644 komorebi-bar/src/widgets/media.rs create mode 100644 komorebi-bar/src/widgets/memory.rs create mode 100644 komorebi-bar/src/widgets/mod.rs create mode 100644 komorebi-bar/src/widgets/network.rs create mode 100644 komorebi-bar/src/widgets/storage.rs create mode 100644 komorebi-bar/src/widgets/time.rs create mode 100644 komorebi-bar/src/widgets/update.rs create mode 100644 komorebi-bar/src/widgets/widget.rs diff --git a/Cargo.lock b/Cargo.lock index f322b8d2..0b262c34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -159,6 +159,30 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned-vec" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" +dependencies = [ + "equator", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "android-activity" version = "0.6.0" @@ -260,6 +284,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + [[package]] name = "arboard" version = "3.6.1" @@ -280,6 +310,17 @@ dependencies = [ "x11rb", ] +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "arrayref" version = "0.3.9" @@ -512,6 +553,29 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "av1-grain" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3efb2ca85bc610acfa917b5aaa36f3fcbebed5b3182d7f877b02531c4b80c8" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational 0.4.2", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c8fbc0f831f4519fe8b810b6a7a91410ec83031b8233f730a0480029f6a23f" +dependencies = [ + "arrayvec", +] + [[package]] name = "backtrace" version = "0.3.76" @@ -577,6 +641,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +[[package]] +name = "bit_field" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" + [[package]] name = "bitflags" version = "1.3.2" @@ -592,6 +662,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bitstream-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" + [[package]] name = "block" version = "0.1.6" @@ -657,6 +733,33 @@ dependencies = [ "piper", ] +[[package]] +name = "brotli" +version = "8.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "built" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" + [[package]] name = "bumpalo" version = "3.19.0" @@ -772,6 +875,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.3" @@ -807,6 +920,16 @@ dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "chrono-tz" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6139a8597ed92cf816dfb33f5dd6cf0bb93a6adc938f11039f371bc5bcd26c3" +dependencies = [ + "chrono", + "phf 0.12.1", +] + [[package]] name = "clap" version = "4.5.48" @@ -857,6 +980,15 @@ dependencies = [ "error-code", ] +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -980,6 +1112,19 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "core-graphics-types", + "foreign-types 0.3.2", + "libc", +] + [[package]] name = "core-graphics" version = "0.23.2" @@ -1004,6 +1149,18 @@ dependencies = [ "libc", ] +[[package]] +name = "core-text" +version = "19.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" +dependencies = [ + "core-foundation 0.9.4", + "core-graphics 0.22.3", + "foreign-types 0.3.2", + "libc", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -1242,6 +1399,17 @@ dependencies = [ "libloading", ] +[[package]] +name = "dlopen2" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b4f5f101177ff01b8ec4ecc81eead416a8aa42819a2869311b3420fa114ffa" +dependencies = [ + "libc", + "once_cell", + "winapi", +] + [[package]] name = "document-features" version = "0.2.11" @@ -1263,6 +1431,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "dyn-clone" version = "1.0.20" @@ -1331,6 +1505,15 @@ dependencies = [ "profiling", ] +[[package]] +name = "egui-phosphor" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171d57331491e92f0a7c73fad1088716e3200984309f4f8684731b750cee1378" +dependencies = [ + "egui", +] + [[package]] name = "egui-wgpu" version = "0.31.1" @@ -1440,6 +1623,12 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "env_home" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" + [[package]] name = "epaint" version = "0.31.1" @@ -1464,6 +1653,26 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7e7a64c02cf7a5b51e745a9e45f60660a286f151c238b9d397b3e923f5082f" +[[package]] +name = "equator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" +dependencies = [ + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -1507,6 +1716,31 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "expat-sys" +version = "2.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" +dependencies = [ + "cmake", + "pkg-config", +] + +[[package]] +name = "exr" +version = "1.73.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide 0.8.9", + "rayon-core", + "smallvec", + "zune-inflate", +] + [[package]] name = "eyre" version = "0.6.12" @@ -1614,7 +1848,7 @@ dependencies = [ "serde_yaml", "shell-words", "shellexpand", - "toml", + "toml 0.5.11", ] [[package]] @@ -1629,6 +1863,19 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "font-loader" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c49d6b4c11dca1a1dd931a34a9f397e2da91abe3de4110505f3530a80e560b52" +dependencies = [ + "core-foundation 0.9.4", + "core-text", + "libc", + "servo-fontconfig", + "winapi", +] + [[package]] name = "foreign-types" version = "0.3.2" @@ -1680,6 +1927,17 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "freetype-sys" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" +dependencies = [ + "cmake", + "libc", + "pkg-config", +] + [[package]] name = "fs-tail" version = "0.1.4" @@ -1837,6 +2095,16 @@ dependencies = [ "weezl", ] +[[package]] +name = "gif" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae047235e33e2829703574b54fdec96bfbad892062d97fed2f76022287de61b" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "gimli" version = "0.32.3" @@ -2355,10 +2623,10 @@ dependencies = [ "bytemuck", "byteorder", "color_quant", - "gif", + "gif 0.11.4", "jpeg-decoder", "num-iter", - "num-rational", + "num-rational 0.3.2", "num-traits", "png 0.16.8", "scoped_threadpool", @@ -2373,12 +2641,38 @@ checksum = "529feb3e6769d234375c4cf1ee2ce713682b8e76538cb13f9fc23e1400a591e7" dependencies = [ "bytemuck", "byteorder-lite", + "color_quant", + "exr", + "gif 0.13.3", + "image-webp", "moxcms", "num-traits", "png 0.18.0", + "qoi", + "ravif", + "rayon", + "rgb", "tiff 0.10.3", + "zune-core", + "zune-jpeg", ] +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imgref" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c5cedc30da3a610cac6b4ba17597bdf7152cf974e8aab3afb3d54455e371c8" + [[package]] name = "immutable-chunkmap" version = "2.1.2" @@ -2437,6 +2731,17 @@ dependencies = [ "libc", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "io-uring" version = "0.7.10" @@ -2476,6 +2781,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.15" @@ -2593,11 +2907,48 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "komorebi-bar" +version = "0.1.39" +dependencies = [ + "chrono", + "chrono-tz", + "clap", + "color-eyre", + "crossbeam-channel", + "dirs 6.0.0", + "dunce", + "eframe", + "egui-phosphor", + "font-loader", + "hotwatch", + "image 0.25.8", + "komorebi-client", + "komorebi-themes", + "lazy_static", + "netdev", + "num", + "num-derive", + "num-traits", + "parking_lot", + "random_word", + "reqwest", + "schemars 0.8.22", + "serde", + "serde_json_lenient", + "starship-battery", + "sysinfo", + "tracing", + "tracing-subscriber", + "which", +] + [[package]] name = "komorebi-client" version = "0.1.0" dependencies = [ "komorebi", + "komorebi-themes", "serde_json_lenient", ] @@ -2662,12 +3013,34 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "lebe" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" + [[package]] name = "libc" version = "0.2.176" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" +[[package]] +name = "libfuzzer-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5037190e1f70cbeef565bd267599242926f724d3b8a9f510fd7e0b540cfa4404" +dependencies = [ + "arbitrary", + "cc", +] + [[package]] name = "libgit2-sys" version = "0.18.2+1.9.1" @@ -2792,6 +3165,24 @@ dependencies = [ "logos-codegen", ] +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + [[package]] name = "malloc_buf" version = "0.0.6" @@ -2810,6 +3201,16 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "memchr" version = "2.7.6" @@ -3019,6 +3420,78 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "netdev" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862209dce034f82a44c95ce2b5183730d616f2a68746b9c1959aa2572e77c0a1" +dependencies = [ + "dlopen2", + "ipnet", + "libc", + "netlink-packet-core", + "netlink-packet-route", + "netlink-sys", + "once_cell", + "system-configuration", + "windows-sys 0.59.0", +] + +[[package]] +name = "netlink-packet-core" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4" +dependencies = [ + "anyhow", + "byteorder", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-route" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0e7987b28514adf555dc1f9a5c30dfc3e50750bbaffb1aec41ca7b23dcd8e4" +dependencies = [ + "anyhow", + "bitflags 2.9.4", + "byteorder", + "libc", + "log", + "netlink-packet-core", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-utils" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" +dependencies = [ + "anyhow", + "byteorder", + "paste", + "thiserror 1.0.69", +] + +[[package]] +name = "netlink-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16c903aa70590cb93691bf97a767c8d1d6122d2cc9070433deb3bbf36ce8bd23" +dependencies = [ + "bytes", + "libc", + "log", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + [[package]] name = "nix" version = "0.29.0" @@ -3060,6 +3533,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + [[package]] name = "notify" version = "6.1.1" @@ -3110,12 +3589,56 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational 0.4.2", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -3147,6 +3670,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -3745,7 +4279,7 @@ dependencies = [ "approx", "num-traits", "palette_derive", - "phf", + "phf 0.8.0", "phf_codegen", ] @@ -3826,7 +4360,16 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", +] + +[[package]] +name = "phf" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" +dependencies = [ + "phf_shared 0.12.1", ] [[package]] @@ -3836,7 +4379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" dependencies = [ "phf_generator", - "phf_shared", + "phf_shared 0.8.0", ] [[package]] @@ -3845,7 +4388,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", "rand 0.7.3", ] @@ -3855,7 +4398,16 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" dependencies = [ - "siphasher", + "siphasher 0.3.11", +] + +[[package]] +name = "phf_shared" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" +dependencies = [ + "siphasher 1.0.1", ] [[package]] @@ -3907,6 +4459,19 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "plist" +version = "1.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3af6b589e163c5a788fab00ce0c0366f6efbb9959c2f9874b224936af7fce7e1" +dependencies = [ + "base64", + "indexmap 2.11.4", + "quick-xml 0.38.3", + "serde", + "time", +] + [[package]] name = "png" version = "0.16.8" @@ -3976,7 +4541,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit", + "toml_edit 0.23.6", ] [[package]] @@ -3993,6 +4558,19 @@ name = "profiling" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" +dependencies = [ + "quote", + "syn 2.0.106", +] [[package]] name = "pxfm" @@ -4003,6 +4581,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + [[package]] name = "quick-error" version = "2.0.1" @@ -4111,6 +4698,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -4131,6 +4728,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -4149,6 +4756,15 @@ dependencies = [ "getrandom 0.2.16", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -4167,6 +4783,69 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "random_word" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e47a395bdb55442b883c89062d6bcff25dc90fa5f8369af81e0ac6d49d78cf81" +dependencies = [ + "ahash", + "brotli", + "paste", + "rand 0.9.2", + "unicase", +] + +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand 0.8.5", + "rand_chacha 0.3.1", + "simd_helpers", + "system-deps", + "thiserror 1.0.69", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5825c26fddd16ab9f515930d49028a630efec172e903483c94796cfe31893e6b" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + [[package]] name = "raw-window-handle" version = "0.6.2" @@ -4639,6 +5318,15 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -4705,6 +5393,27 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "servo-fontconfig" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" +dependencies = [ + "libc", + "servo-fontconfig-sys", +] + +[[package]] +name = "servo-fontconfig-sys" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" +dependencies = [ + "expat-sys", + "freetype-sys", + "pkg-config", +] + [[package]] name = "sha1" version = "0.10.6" @@ -4718,9 +5427,9 @@ dependencies = [ [[package]] name = "shadow-rs" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8aa5c0570cd9654158bd39f0f8caba24edbc058313946e89f4648b1de1ecf49" +checksum = "72d18183cef626bce22836103349c7050d73db799be0171386b80947d157ae32" dependencies = [ "const_format", "git2", @@ -4774,12 +5483,27 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "siphasher" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "slab" version = "0.4.11" @@ -4871,6 +5595,24 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "starship-battery" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b781e3db6801873ce18c19041da668920c46223cdc7059ea20e2f8fe1ba85a2" +dependencies = [ + "cfg-if", + "core-foundation 0.10.1", + "lazycell", + "libc", + "mach2", + "nix 0.30.1", + "num-traits", + "plist", + "uom", + "windows-sys 0.60.2", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -5015,6 +5757,25 @@ dependencies = [ "libc", ] +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml 0.8.23", + "version-compare", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + [[package]] name = "tempfile" version = "3.23.0" @@ -5258,6 +6019,27 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime 0.6.11", + "toml_edit 0.22.27", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + [[package]] name = "toml_datetime" version = "0.7.2" @@ -5267,6 +6049,19 @@ dependencies = [ "serde_core", ] +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap 2.11.4", + "serde", + "serde_spanned", + "toml_datetime 0.6.11", + "winnow", +] + [[package]] name = "toml_edit" version = "0.23.6" @@ -5274,7 +6069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b" dependencies = [ "indexmap 2.11.4", - "toml_datetime", + "toml_datetime 0.7.2", "toml_parser", "winnow", ] @@ -5480,6 +6275,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + [[package]] name = "unicode-ident" version = "1.0.19" @@ -5510,6 +6311,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "uom" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd5cfe7d84f6774726717f358a37f5bca8fca273bed4de40604ad129d1107b49" +dependencies = [ + "num-traits", + "typenum", +] + [[package]] name = "url" version = "2.5.7" @@ -5534,6 +6345,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "v_frame" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + [[package]] name = "valuable" version = "0.1.1" @@ -5546,6 +6368,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version-compare" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" + [[package]] name = "version_check" version = "0.9.5" @@ -5927,6 +6755,18 @@ dependencies = [ "web-sys", ] +[[package]] +name = "which" +version = "7.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762" +dependencies = [ + "either", + "env_home", + "rustix 1.1.2", + "winsafe", +] + [[package]] name = "winapi" version = "0.3.9" @@ -6494,7 +7334,7 @@ dependencies = [ "cfg_aliases", "concurrent-queue", "core-foundation 0.9.4", - "core-graphics", + "core-graphics 0.23.2", "cursor-icon", "dpi", "js-sys", @@ -6539,6 +7379,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "wit-bindgen" version = "0.46.0" @@ -6842,6 +7688,15 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + [[package]] name = "zune-jpeg" version = "0.4.21" diff --git a/Cargo.toml b/Cargo.toml index a9a94344..15a74e7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = [ "komorebi", "komorebi-client", - "komorebic", + "komorebic", "komorebi-bar" ] @@ -12,8 +12,15 @@ chrono = "0.4" chrono-tz = "0.10" clap = { version = "4", features = ["derive", "wrap_help"] } color-eyre = "0.6" +crossbeam-channel = "0.5" +crossbeam-utils = "0.8" dirs = "6" +dunce = "1" +eframe = "0.31" +egui_extras = "0.31" +hotwatch = "0.5" lazy_static = "1" +parking_lot = "0.12" pastey = "0.1" schemars = "0.8" serde = { version = "1", features = ["derive"] } @@ -21,3 +28,7 @@ serde_json = { package = "serde_json_lenient", version = "0.2" } shadow-rs = "1" sysinfo = "0.37" thiserror = "2" +tracing = "0.1" +tracing-appender = "0.2" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +which = "7" diff --git a/docs/komorebi.bar.example.json b/docs/komorebi.bar.example.json new file mode 100644 index 00000000..d1254319 --- /dev/null +++ b/docs/komorebi.bar.example.json @@ -0,0 +1,64 @@ +{ + "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.38/schema.bar.json", + "monitor": 0, + "font_family": "JetBrainsMono Nerd Font", + "height": 30, + "theme": { + "palette": "Base16", + "name": "Ashes", + "accent": "Base0D" + }, + "left_widgets": [ + { + "Komorebi": { + "workspaces": { + "enable": true, + "hide_empty_workspaces": false + }, + "layout": { + "enable": true + }, + "focused_window": { + "enable": true, + "show_icon": true + } + } + } + ], + "right_widgets": [ + { + "Update": { + "enable": true + } + }, + { + "Storage": { + "enable": true + } + }, + { + "Memory": { + "enable": true + } + }, + { + "Network": { + "enable": true, + "show_activity": true, + "show_total_activity": true, + } + }, + { + "Date": { + "enable": true, + "format": "DayDateMonthYear" + } + }, + { + "Time": { + "enable": true, + "format": "TwentyFourHour" + } + }, + ] +} diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml new file mode 100644 index 00000000..2d9e42cc --- /dev/null +++ b/komorebi-bar/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "komorebi-bar" +version = "0.1.39" +edition = "2024" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +komorebi-client = { path = "../komorebi-client", default-features = false } +komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", version = "0.1.38" } + +chrono-tz = { workspace = true } +chrono = { workspace = true } +clap = { workspace = true } +color-eyre = { workspace = true } +crossbeam-channel = { workspace = true } +dirs = { workspace = true } +dunce = { workspace = true } +eframe = { workspace = true } +egui-phosphor = "0.9" +font-loader = "0.11" +hotwatch = { workspace = true } +image = "0.25" +lazy_static = { workspace = true } +netdev = "0.36" +num = "0.4" +num-derive = "0.4" +num-traits = "0.2" +parking_lot = { workspace = true } +random_word = { version = "0.5", features = ["en"] } +reqwest = { version = "0.12", features = ["blocking"] } +schemars = { workspace = true, optional = true } +serde = { workspace = true } +serde_json = { workspace = true } +starship-battery = "0.10" +sysinfo = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +which = { workspace = true } +#windows = { workspace = true } +#windows-core = { workspace = true } +#windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "0c9d7ee1b807347c507d3a9862dd007b4d3f4354" } +#windows-icons-fallback = { package = "windows-icons", git = "https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" } + +[features] +default = ["schemars"] +schemars = ["dep:schemars", "komorebi-client/default", "komorebi-themes/default"] diff --git a/komorebi-bar/src/bar.rs b/komorebi-bar/src/bar.rs new file mode 100644 index 00000000..e80277bd --- /dev/null +++ b/komorebi-bar/src/bar.rs @@ -0,0 +1,1347 @@ +use crate::AUTO_SELECT_FILL_COLOUR; +use crate::AUTO_SELECT_TEXT_COLOUR; +use crate::BAR_HEIGHT; +use crate::DEFAULT_PADDING; +use crate::KomorebiEvent; +use crate::MAX_LABEL_WIDTH; +use crate::MONITOR_LEFT; +use crate::MONITOR_RIGHT; +use crate::MONITOR_TOP; +use crate::config::KomobarConfig; +use crate::config::KomobarTheme; +use crate::config::MonitorConfigOrIndex; +use crate::config::Position; +use crate::config::PositionConfig; +use crate::config::get_individual_spacing; +use crate::render::Color32Ext; +use crate::render::Grouping; +use crate::render::RenderConfig; +use crate::render::RenderExt; +use crate::widgets::komorebi::Komorebi; +use crate::widgets::komorebi::MonitorInfo; +use crate::widgets::widget::BarWidget; +use crate::widgets::widget::WidgetConfig; +use crossbeam_channel::Receiver; +use crossbeam_channel::TryRecvError; +use eframe::egui::Align; +use eframe::egui::Align2; +use eframe::egui::Area; +use eframe::egui::CentralPanel; +use eframe::egui::Color32; +use eframe::egui::Context; +use eframe::egui::FontData; +use eframe::egui::FontDefinitions; +use eframe::egui::FontFamily; +use eframe::egui::FontId; +use eframe::egui::Frame; +use eframe::egui::Id; +use eframe::egui::Layout; +use eframe::egui::Margin; +use eframe::egui::Pos2; +use eframe::egui::Rgba; +use eframe::egui::Style; +use eframe::egui::TextStyle; +use eframe::egui::Vec2; +use eframe::egui::ViewportCommand; +use eframe::egui::Visuals; +use font_loader::system_fonts; +use font_loader::system_fonts::FontPropertyBuilder; +use komorebi_client::Colour; +use komorebi_client::NotificationEvent; +use komorebi_client::PathExt; +use komorebi_client::SocketMessage; +use komorebi_themes::Base16Wrapper; +use komorebi_themes::Catppuccin; +use komorebi_themes::catppuccin_egui; +use lazy_static::lazy_static; +use parking_lot::Mutex; +use std::cell::RefCell; +use std::path::PathBuf; +use std::process::ChildStdin; +use std::rc::Rc; +use std::sync::Arc; +use std::sync::atomic::Ordering; + +lazy_static! { + static ref SESSION_STDIN: Mutex> = Mutex::new(None); +} + +// fn start_powershell() -> Result<()> { +// // found running session, do nothing +// if SESSION_STDIN.lock().as_mut().is_some() { +// tracing::debug!("PowerShell session already started"); +// return Ok(()); +// } +// +// tracing::debug!("Starting PowerShell session"); +// +// let mut child = Command::new("powershell.exe") +// .args(["-NoLogo", "-NoProfile", "-Command", "-"]) +// .stdin(Stdio::piped()) +// .creation_flags(CREATE_NO_WINDOW) +// .spawn()?; +// +// let stdin = child.stdin.take().expect("stdin piped"); +// +// // Store stdin for later commands +// let mut session_stdin = SESSION_STDIN.lock(); +// *session_stdin = Option::from(stdin); +// +// Ok(()) +// } + +// fn stop_powershell() -> Result<()> { +// tracing::debug!("Stopping PowerShell session"); +// +// if let Some(mut session_stdin) = SESSION_STDIN.lock().take() { +// if let Err(e) = session_stdin.write_all(b"exit\n") { +// tracing::error!(error = %e, "failed to write exit command to PowerShell stdin"); +// return Err(e); +// } +// if let Err(e) = session_stdin.flush() { +// tracing::error!(error = %e, "failed to flush PowerShell stdin"); +// return Err(e); +// } +// +// tracing::debug!("PowerShell session stopped"); +// } else { +// tracing::debug!("PowerShell session already stopped"); +// } +// +// Ok(()) +// } + +// pub fn exec_powershell(cmd: &str) -> Result<()> { +// if let Some(session_stdin) = SESSION_STDIN.lock().as_mut() { +// if let Err(e) = writeln!(session_stdin, "{cmd}") { +// tracing::error!(error = %e, cmd = cmd, "failed to write command to PowerShell stdin"); +// return Err(e); +// } +// +// if let Err(e) = session_stdin.flush() { +// tracing::error!(error = %e, "failed to flush PowerShell stdin"); +// return Err(e); +// } +// +// return Ok(()); +// } +// +// Err(Error::new( +// ErrorKind::NotFound, +// "PowerShell session not started", +// )) +// } + +pub struct Komobar { + // pub hwnd: Option, + pub monitor_index: Option, + pub disabled: bool, + pub config: KomobarConfig, + pub render_config: Rc>, + pub monitor_info: Option>>, + pub left_widgets: Vec>, + pub center_widgets: Vec>, + pub right_widgets: Vec>, + pub rx_gui: Receiver, + pub rx_config: Receiver, + pub bg_color: Rc>, + pub bg_color_with_alpha: Rc>, + pub scale_factor: f32, + pub size_rect: komorebi_client::Rect, + pub work_area_offset: komorebi_client::Rect, + applied_theme_on_first_frame: bool, + mouse_follows_focus: bool, + // input_config: InputConfig, +} + +// struct InputConfig { +// accumulated_scroll_delta: Vec2, +// act_on_vertical_scroll: bool, +// act_on_horizontal_scroll: bool, +// vertical_scroll_threshold: f32, +// horizontal_scroll_threshold: f32, +// vertical_scroll_max_threshold: f32, +// horizontal_scroll_max_threshold: f32, +// } + +pub fn apply_theme( + ctx: &Context, + theme: KomobarTheme, + bg_color: Rc>, + bg_color_with_alpha: Rc>, + transparency_alpha: Option, + grouping: Option, + render_config: Rc>, +) { + let (auto_select_fill, auto_select_text) = match theme { + KomobarTheme::Catppuccin { + name: catppuccin, + accent: catppuccin_value, + auto_select_fill: catppuccin_auto_select_fill, + auto_select_text: catppuccin_auto_select_text, + } => { + match catppuccin { + Catppuccin::Frappe => { + catppuccin_egui::set_theme(ctx, catppuccin_egui::FRAPPE); + let catppuccin_value = catppuccin_value.unwrap_or_default(); + let accent = catppuccin_value.color32(catppuccin.as_theme()); + + ctx.style_mut(|style| { + style.visuals.selection.stroke.color = accent; + style.visuals.widgets.hovered.fg_stroke.color = accent; + style.visuals.widgets.active.fg_stroke.color = accent; + style.visuals.override_text_color = None; + }); + + bg_color.replace(catppuccin_egui::FRAPPE.base); + } + Catppuccin::Latte => { + catppuccin_egui::set_theme(ctx, catppuccin_egui::LATTE); + let catppuccin_value = catppuccin_value.unwrap_or_default(); + let accent = catppuccin_value.color32(catppuccin.as_theme()); + + ctx.style_mut(|style| { + style.visuals.selection.stroke.color = accent; + style.visuals.widgets.hovered.fg_stroke.color = accent; + style.visuals.widgets.active.fg_stroke.color = accent; + style.visuals.override_text_color = None; + }); + + bg_color.replace(catppuccin_egui::LATTE.base); + } + Catppuccin::Macchiato => { + catppuccin_egui::set_theme(ctx, catppuccin_egui::MACCHIATO); + let catppuccin_value = catppuccin_value.unwrap_or_default(); + let accent = catppuccin_value.color32(catppuccin.as_theme()); + + ctx.style_mut(|style| { + style.visuals.selection.stroke.color = accent; + style.visuals.widgets.hovered.fg_stroke.color = accent; + style.visuals.widgets.active.fg_stroke.color = accent; + style.visuals.override_text_color = None; + }); + + bg_color.replace(catppuccin_egui::MACCHIATO.base); + } + Catppuccin::Mocha => { + catppuccin_egui::set_theme(ctx, catppuccin_egui::MOCHA); + let catppuccin_value = catppuccin_value.unwrap_or_default(); + let accent = catppuccin_value.color32(catppuccin.as_theme()); + + ctx.style_mut(|style| { + style.visuals.selection.stroke.color = accent; + style.visuals.widgets.hovered.fg_stroke.color = accent; + style.visuals.widgets.active.fg_stroke.color = accent; + style.visuals.override_text_color = None; + }); + + bg_color.replace(catppuccin_egui::MOCHA.base); + } + } + + ( + catppuccin_auto_select_fill.map(|c| c.color32(catppuccin.as_theme())), + catppuccin_auto_select_text.map(|c| c.color32(catppuccin.as_theme())), + ) + } + KomobarTheme::Base16 { + name: base16, + accent: base16_value, + auto_select_fill: base16_auto_select_fill, + auto_select_text: base16_auto_select_text, + } => { + ctx.set_style(base16.style()); + let base16_value = base16_value.unwrap_or_default(); + let accent = base16_value.color32(Base16Wrapper::Base16(base16)); + + ctx.style_mut(|style| { + style.visuals.selection.stroke.color = accent; + style.visuals.widgets.hovered.fg_stroke.color = accent; + style.visuals.widgets.active.fg_stroke.color = accent; + }); + + bg_color.replace(base16.background()); + + ( + base16_auto_select_fill.map(|c| c.color32(Base16Wrapper::Base16(base16))), + base16_auto_select_text.map(|c| c.color32(Base16Wrapper::Base16(base16))), + ) + } + KomobarTheme::Custom { + colours, + accent: base16_value, + auto_select_fill: base16_auto_select_fill, + auto_select_text: base16_auto_select_text, + } => { + let background = colours.background(); + ctx.set_style(colours.style()); + let base16_value = base16_value.unwrap_or_default(); + let accent = base16_value.color32(Base16Wrapper::Custom(colours.clone())); + + ctx.style_mut(|style| { + style.visuals.selection.stroke.color = accent; + style.visuals.widgets.hovered.fg_stroke.color = accent; + style.visuals.widgets.active.fg_stroke.color = accent; + }); + + bg_color.replace(background); + + ( + base16_auto_select_fill.map(|c| c.color32(Base16Wrapper::Custom(colours.clone()))), + base16_auto_select_text.map(|c| c.color32(Base16Wrapper::Custom(colours.clone()))), + ) + } + }; + + AUTO_SELECT_FILL_COLOUR.store( + auto_select_fill.map_or(0, |c| Colour::from(c).into()), + Ordering::SeqCst, + ); + AUTO_SELECT_TEXT_COLOUR.store( + auto_select_text.map_or(0, |c| Colour::from(c).into()), + Ordering::SeqCst, + ); + + // Apply transparency_alpha + let theme_color = *bg_color.borrow(); + + bg_color_with_alpha.replace(theme_color.try_apply_alpha(transparency_alpha)); + + // apply rounding to the widgets + if let Some(Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config)) = + &grouping + && let Some(rounding) = config.rounding + { + ctx.style_mut(|style| { + style.visuals.widgets.noninteractive.corner_radius = rounding.into(); + style.visuals.widgets.inactive.corner_radius = rounding.into(); + style.visuals.widgets.hovered.corner_radius = rounding.into(); + style.visuals.widgets.active.corner_radius = rounding.into(); + style.visuals.widgets.open.corner_radius = rounding.into(); + }); + } + + // Update RenderConfig's background_color so that widgets will have the new color + render_config.borrow_mut().background_color = *bg_color.borrow(); +} + +impl Komobar { + pub fn apply_config( + &mut self, + ctx: &Context, + previous_monitor_info: Option>>, + ) { + MAX_LABEL_WIDTH.store( + self.config.max_label_width.unwrap_or(400.0) as i32, + Ordering::SeqCst, + ); + + if let Some(font_family) = &self.config.font_family { + tracing::info!("attempting to add custom font family: {font_family}"); + Self::add_custom_font(ctx, font_family); + } + + // Update the `size_rect` so that the bar position can be changed on the EGUI update + // function + self.update_size_rect(); + + self.try_apply_theme(ctx); + + if let Some(font_size) = &self.config.font_size { + tracing::info!("attempting to set custom font size: {font_size}"); + Self::set_font_size(ctx, *font_size); + } + + self.render_config.replace((&self.config).new_renderconfig( + ctx, + *self.bg_color.borrow(), + self.config.icon_scale, + )); + + let mut monitor_info = previous_monitor_info; + let mut komorebi_widgets = Vec::new(); + + for (idx, widget_config) in self.config.left_widgets.iter().enumerate() { + if let WidgetConfig::Komorebi(config) = widget_config { + komorebi_widgets.push((Komorebi::from(config), idx, Alignment::Left)); + } + } + + if let Some(center_widgets) = &self.config.center_widgets { + for (idx, widget_config) in center_widgets.iter().enumerate() { + if let WidgetConfig::Komorebi(config) = widget_config { + komorebi_widgets.push((Komorebi::from(config), idx, Alignment::Center)); + } + } + } + + for (idx, widget_config) in self.config.right_widgets.iter().enumerate() { + if let WidgetConfig::Komorebi(config) = widget_config { + komorebi_widgets.push((Komorebi::from(config), idx, Alignment::Right)); + } + } + + let mut left_widgets = self + .config + .left_widgets + .iter() + .filter(|config| config.enabled()) + .map(|config| config.as_boxed_bar_widget()) + .collect::>>(); + + let mut center_widgets = match &self.config.center_widgets { + Some(center_widgets) => center_widgets + .iter() + .filter(|config| config.enabled()) + .map(|config| config.as_boxed_bar_widget()) + .collect::>>(), + None => vec![], + }; + + let mut right_widgets = self + .config + .right_widgets + .iter() + .filter(|config| config.enabled()) + .map(|config| config.as_boxed_bar_widget()) + .collect::>>(); + + if !komorebi_widgets.is_empty() { + komorebi_widgets + .into_iter() + .for_each(|(mut widget, idx, side)| { + match monitor_info { + None => { + monitor_info = Some(widget.monitor_info.clone()); + } + Some(ref previous) => { + if widget.workspaces.is_some() { + previous + .borrow_mut() + .update_from_self(&widget.monitor_info.borrow()); + } + + widget.monitor_info = previous.clone(); + } + } + + let boxed: Box = Box::new(widget); + match side { + Alignment::Left => left_widgets[idx] = boxed, + Alignment::Center => center_widgets[idx] = boxed, + Alignment::Right => right_widgets[idx] = boxed, + } + }); + } + + right_widgets.reverse(); + + self.left_widgets = left_widgets; + self.center_widgets = center_widgets; + self.right_widgets = right_widgets; + + let (usr_monitor_index, config_work_area_offset) = match &self.config.monitor { + MonitorConfigOrIndex::MonitorConfig(monitor_config) => { + (monitor_config.index, monitor_config.work_area_offset) + } + MonitorConfigOrIndex::Index(idx) => (*idx, None), + }; + + let mapped_info = self.monitor_info.as_ref().map(|info| { + let monitor = info.borrow(); + ( + monitor.monitor_usr_idx_map.get(&usr_monitor_index).copied(), + monitor.mouse_follows_focus, + ) + }); + + if let Some(info) = mapped_info { + self.monitor_index = info.0; + self.mouse_follows_focus = info.1; + } + + if let Some(monitor_index) = self.monitor_index { + if let (prev_rect, Some(new_rect)) = (&self.work_area_offset, &config_work_area_offset) + { + if new_rect != prev_rect { + self.work_area_offset = *new_rect; + if let Err(error) = komorebi_client::send_message( + &SocketMessage::MonitorWorkAreaOffset(monitor_index, *new_rect), + ) { + tracing::error!( + "error applying work area offset to monitor '{}': {}", + monitor_index, + error, + ); + } else { + tracing::info!("work area offset applied to monitor: {}", monitor_index); + } + } + } else if let Some(height) = self.config.height.or(Some(BAR_HEIGHT)) { + // We only add the `bottom_margin` to the work_area_offset since the top margin is + // already considered on the `size_rect.top` + let bottom_margin = self + .config + .margin + .as_ref() + .map_or(0, |v| v.to_individual(0.0).bottom as i32); + let new_rect = komorebi_client::Rect { + left: 0, + top: (height as i32) + + (self.size_rect.top - MONITOR_TOP.load(Ordering::SeqCst)) + + bottom_margin, + right: 0, + bottom: (height as i32) + + (self.size_rect.top - MONITOR_TOP.load(Ordering::SeqCst)) + + bottom_margin, + }; + + if new_rect != self.work_area_offset { + self.work_area_offset = new_rect; + if let Err(error) = komorebi_client::send_message( + &SocketMessage::MonitorWorkAreaOffset(monitor_index, new_rect), + ) { + tracing::error!( + "error applying work area offset to monitor '{monitor_index}': {error}" + ); + } else { + tracing::info!("work area offset applied to monitor: {monitor_index}",); + } + } + } + } else if self.monitor_info.is_some() && !self.disabled { + tracing::warn!( + "couldn't find the monitor index of this bar! Disabling the bar until the monitor connects..." + ); + self.disabled = true; + } else { + tracing::warn!( + "couldn't find the monitor index of this bar, if the bar is starting up this is normal until it receives the first state from komorebi." + ); + self.disabled = true; + } + + // if let Some(mouse) = &self.config.mouse { + // self.input_config.act_on_vertical_scroll = + // mouse.on_scroll_up.is_some() || mouse.on_scroll_down.is_some(); + // self.input_config.act_on_horizontal_scroll = + // mouse.on_scroll_left.is_some() || mouse.on_scroll_right.is_some(); + // self.input_config.vertical_scroll_threshold = mouse + // .vertical_scroll_threshold + // .unwrap_or(30.0) + // .clamp(10.0, 300.0); + // self.input_config.horizontal_scroll_threshold = mouse + // .horizontal_scroll_threshold + // .unwrap_or(30.0) + // .clamp(10.0, 300.0); + // // limit how many "ticks" can be accumulated + // self.input_config.vertical_scroll_max_threshold = + // self.input_config.vertical_scroll_threshold * 3.0; + // self.input_config.horizontal_scroll_max_threshold = + // self.input_config.horizontal_scroll_threshold * 3.0; + // + // if mouse.has_command() { + // start_powershell().unwrap_or_else(|_| { + // tracing::error!("failed to start powershell session"); + // }); + // } else { + // stop_powershell().unwrap_or_else(|_| { + // tracing::error!("failed to stop powershell session"); + // }); + // } + // } + + tracing::info!("widget configuration options applied"); + + self.monitor_info = monitor_info; + } + + /// Updates the `size_rect` field. Returns a bool indicating if the field was changed or not + fn update_size_rect(&mut self) { + let position = self.config.position.clone().unwrap_or(PositionConfig { + start: Some(Position { + x: MONITOR_LEFT.load(Ordering::SeqCst) as f32, + y: MONITOR_TOP.load(Ordering::SeqCst) as f32, + }), + end: Some(Position { + x: MONITOR_RIGHT.load(Ordering::SeqCst) as f32, + y: BAR_HEIGHT, + }), + }); + + let mut start = position.start.unwrap_or(Position { + x: MONITOR_LEFT.load(Ordering::SeqCst) as f32, + y: MONITOR_TOP.load(Ordering::SeqCst) as f32, + }); + + let mut end = position.end.unwrap_or(Position { + x: MONITOR_RIGHT.load(Ordering::SeqCst) as f32, + y: BAR_HEIGHT, + }); + + if let Some(height) = self.config.height { + end.y = height; + } + + let margin = get_individual_spacing(0.0, &self.config.margin); + + start.y += margin.top; + start.x += margin.left; + end.x -= margin.left + margin.right; + + if end.y == 0.0 { + tracing::warn!( + "position.end.y is set to 0.0 which will make your bar invisible on a config reload - this is usually set to 50.0 by default" + ) + } + + self.size_rect = komorebi_client::Rect { + left: start.x as i32, + top: start.y as i32, + right: end.x as i32, + bottom: end.y as i32, + }; + } + + fn try_apply_theme(&mut self, ctx: &Context) { + match &self.config.theme { + Some(theme) => { + apply_theme( + ctx, + theme.clone(), + self.bg_color.clone(), + self.bg_color_with_alpha.clone(), + self.config.transparency_alpha, + self.config.grouping, + self.render_config.clone(), + ); + } + None => { + let home_dir: PathBuf = std::env::var("KOMOREBI_CONFIG_HOME").map_or_else( + |_| dirs::home_dir().expect("there is no home directory"), + |home_path| { + let home = home_path.replace_env(); + + assert!( + home.is_dir(), + "$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory" + ); + + home + + }, + ); + + let bar_transparency_alpha = self.config.transparency_alpha; + let bar_grouping = self.config.grouping; + let config = home_dir.join("komorebi.json"); + match komorebi_client::StaticConfig::read(&config) { + Ok(config) => { + if let Some(theme) = config.theme { + apply_theme( + ctx, + KomobarTheme::from(theme), + self.bg_color.clone(), + self.bg_color_with_alpha.clone(), + bar_transparency_alpha, + bar_grouping, + self.render_config.clone(), + ); + } + } + Err(_) => { + ctx.set_style(Style::default()); + self.bg_color.replace(Style::default().visuals.panel_fill); + + // apply rounding to the widgets since we didn't call `apply_theme` + if let Some( + Grouping::Bar(config) + | Grouping::Alignment(config) + | Grouping::Widget(config), + ) = &bar_grouping + && let Some(rounding) = config.rounding + { + ctx.style_mut(|style| { + style.visuals.widgets.noninteractive.corner_radius = + rounding.into(); + style.visuals.widgets.inactive.corner_radius = rounding.into(); + style.visuals.widgets.hovered.corner_radius = rounding.into(); + style.visuals.widgets.active.corner_radius = rounding.into(); + style.visuals.widgets.open.corner_radius = rounding.into(); + }); + } + } + } + } + } + } + + pub fn new( + cc: &eframe::CreationContext<'_>, + rx_gui: Receiver, + rx_config: Receiver, + config: KomobarConfig, + ) -> Self { + let mut komobar = Self { + // hwnd: process_hwnd(), + monitor_index: None, + disabled: false, + config, + render_config: Rc::new(RefCell::new(RenderConfig::new())), + monitor_info: None, + left_widgets: vec![], + center_widgets: vec![], + right_widgets: vec![], + rx_gui, + rx_config, + bg_color: Rc::new(RefCell::new(Style::default().visuals.panel_fill)), + bg_color_with_alpha: Rc::new(RefCell::new(Style::default().visuals.panel_fill)), + scale_factor: cc.egui_ctx.native_pixels_per_point().unwrap_or(1.0), + size_rect: komorebi_client::Rect::default(), + work_area_offset: komorebi_client::Rect::default(), + applied_theme_on_first_frame: false, + mouse_follows_focus: false, + // input_config: InputConfig { + // accumulated_scroll_delta: Vec2::new(0.0, 0.0), + // act_on_vertical_scroll: false, + // act_on_horizontal_scroll: false, + // vertical_scroll_threshold: 0.0, + // horizontal_scroll_threshold: 0.0, + // vertical_scroll_max_threshold: 0.0, + // horizontal_scroll_max_threshold: 0.0, + // }, + }; + + komobar.apply_config(&cc.egui_ctx, None); + // needs a double apply the first time for some reason + komobar.apply_config(&cc.egui_ctx, None); + + komobar + } + + fn set_font_size(ctx: &Context, font_size: f32) { + ctx.style_mut(|style| { + style.text_styles = [ + (TextStyle::Small, FontId::new(9.0, FontFamily::Proportional)), + ( + TextStyle::Body, + FontId::new(font_size, FontFamily::Proportional), + ), + ( + TextStyle::Button, + FontId::new(font_size, FontFamily::Proportional), + ), + ( + TextStyle::Heading, + FontId::new(18.0, FontFamily::Proportional), + ), + ( + TextStyle::Monospace, + FontId::new(font_size, FontFamily::Monospace), + ), + ] + .into(); + }); + } + + fn add_custom_font(ctx: &Context, name: &str) { + let mut fonts = FontDefinitions::default(); + egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular); + + // let mut fallbacks = HashMap::new(); + + // fallbacks.insert("Microsoft YaHei", "C:\\Windows\\Fonts\\msyh.ttc"); // chinese + // fallbacks.insert("Malgun Gothic", "C:\\Windows\\Fonts\\malgun.ttf"); // korean + // fallbacks.insert("Leelawadee UI", "C:\\Windows\\Fonts\\LeelawUI.ttf"); // thai + + // for (name, path) in fallbacks { + // if let Ok(bytes) = std::fs::read(path) { + // fonts + // .font_data + // .insert(name.to_owned(), Arc::from(FontData::from_owned(bytes))); + // + // for family in [FontFamily::Proportional, FontFamily::Monospace] { + // fonts + // .families + // .entry(family) + // .or_default() + // .insert(0, name.to_owned()); + // } + // } + // } + + let property = FontPropertyBuilder::new().family(name).build(); + + if let Some((font, _)) = system_fonts::get(&property) { + fonts + .font_data + .insert(name.to_owned(), Arc::new(FontData::from_owned(font))); + + for family in [FontFamily::Proportional, FontFamily::Monospace] { + fonts + .families + .entry(family) + .or_default() + .insert(0, name.to_owned()); + } + } + + // Tell egui to use these fonts: + ctx.set_fonts(fonts); + } + + pub fn position_bar(&self, ctx: &Context) { + ctx.send_viewport_cmd(ViewportCommand::OuterPosition(Pos2::new( + self.size_rect.top as f32, + self.size_rect.left as f32, + ))); + + ctx.send_viewport_cmd(ViewportCommand::InnerSize(Vec2::new( + self.size_rect.right as f32, + self.size_rect.bottom as f32, + ))); + } + + fn update_monitor_coordinates(&mut self, monitor_size: &komorebi_client::Rect) { + // Store the new monitor coordinates + MONITOR_TOP.store(monitor_size.top, Ordering::SeqCst); + MONITOR_LEFT.store(monitor_size.left, Ordering::SeqCst); + MONITOR_RIGHT.store(monitor_size.right, Ordering::SeqCst); + + // Since the `config.position` is changed on `main.rs` we need to update it here. + // If the user had set up some `start` position, that will be overriden here + // since we have no way to know what was that value since it might have been + // changed on `main.rs`. However if the users use the new configs this won't be + // a problem for them. + if let Some(start) = self.config.position.as_mut().and_then(|p| p.start.as_mut()) { + start.x = monitor_size.left as f32; + start.y = monitor_size.top as f32; + } + } +} +impl eframe::App for Komobar { + // Needed for transparency + fn clear_color(&self, _visuals: &Visuals) -> [f32; 4] { + Rgba::TRANSPARENT.to_array() + } + + fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) { + // if self.hwnd.is_none() { + // self.hwnd = process_hwnd(); + // } + + if self.scale_factor != ctx.native_pixels_per_point().unwrap_or(1.0) { + self.scale_factor = ctx.native_pixels_per_point().unwrap_or(1.0); + self.apply_config(ctx, self.monitor_info.clone()); + } + + if let Ok(updated_config) = self.rx_config.try_recv() { + self.config = updated_config; + self.apply_config(ctx, self.monitor_info.clone()); + } + + match self.rx_gui.try_recv() { + Err(error) => match error { + TryRecvError::Empty => {} + TryRecvError::Disconnected => { + tracing::error!( + "failed to receive komorebi notification on gui thread: {error}" + ); + } + }, + Ok(KomorebiEvent::Notification(notification)) => { + let state = ¬ification.state; + let usr_monitor_index = match &self.config.monitor { + MonitorConfigOrIndex::MonitorConfig(monitor_config) => monitor_config.index, + MonitorConfigOrIndex::Index(idx) => *idx, + }; + let monitor_index = state.monitor_usr_idx_map.get(&usr_monitor_index).copied(); + self.monitor_index = monitor_index; + let mut should_apply_config = false; + + {} + + if self.monitor_index.is_none() + || self + .monitor_index + .is_some_and(|idx| idx >= state.monitors.elements().len()) + { + if !self.disabled { + // Monitor for this bar got disconnected lets disable the bar until it + // reconnects + self.disabled = true; + tracing::warn!( + "This bar's monitor got disconnected. The bar will be disabled until it reconnects..." + ); + } + return; + } else { + if self.disabled { + tracing::info!("Found this bar's monitor. The bar will be enabled!"); + + // Restore the bar in case it has been minimized when the monitor + // disconnected + // if let Some(hwnd) = self.hwnd { + // let window = komorebi_client::Window::from(hwnd); + // if window.is_miminized() { + // komorebi_client::WindowsApi::restore_window(hwnd); + // } + // } + + // Reset the current `work_area_offset` so that it gets recalculated and + // properly applied again, since if the monitor has connected for the first + // time it won't have the work_area_offset applied but the bar thinks it + // does. + self.work_area_offset = komorebi_client::Rect::default(); + + should_apply_config = true; + } + self.disabled = false; + } + + if matches!(notification.event, NotificationEvent::Monitor(_)) { + let monitor_index = self.monitor_index.expect("should have a monitor index"); + + let monitor_size = state.monitors.elements()[monitor_index].size; + + self.update_monitor_coordinates(&monitor_size); + + should_apply_config = true; + } + + if self.disabled { + return; + } + + // Check if monitor coordinates/size has changed + if let Some(monitor_index) = self.monitor_index { + let monitor_size = state.monitors.elements()[monitor_index].size; + let top = MONITOR_TOP.load(Ordering::SeqCst); + let left = MONITOR_LEFT.load(Ordering::SeqCst); + let right = MONITOR_RIGHT.load(Ordering::SeqCst); + let rect = komorebi_client::Rect { + top, + left, + bottom: monitor_size.bottom, + right, + }; + if monitor_size != rect { + tracing::info!( + "Monitor coordinates/size has changed, storing new coordinates: {:#?}", + monitor_size + ); + + self.update_monitor_coordinates(&monitor_size); + + should_apply_config = true; + } + } + + if let Some(monitor_info) = &self.monitor_info { + monitor_info.borrow_mut().update( + self.monitor_index, + notification.state, + self.render_config.borrow().show_all_icons, + ); + handle_notification( + ctx, + notification.event, + self.bg_color.clone(), + self.bg_color_with_alpha.clone(), + self.config.transparency_alpha, + self.config.grouping, + self.config.theme.clone(), + self.render_config.clone(), + ); + } + + if should_apply_config { + self.apply_config(ctx, self.monitor_info.clone()); + + // Reposition the Bar + self.position_bar(ctx); + } + } + Ok(KomorebiEvent::Reconnect) => { + if let Some(monitor_index) = self.monitor_index { + if let Err(error) = komorebi_client::send_message( + &SocketMessage::MonitorWorkAreaOffset(monitor_index, self.work_area_offset), + ) { + tracing::error!( + "error applying work area offset to monitor '{}': {}", + monitor_index, + error, + ); + } else { + tracing::info!("work area offset applied to monitor: {}", monitor_index); + } + } + } + } + + if self.disabled { + // The check for disabled is performed above, if we get here and the bar is still + // disabled then we should return without drawing anything. + return; + } + + if !self.applied_theme_on_first_frame { + self.try_apply_theme(ctx); + self.applied_theme_on_first_frame = true; + } + + // Check if egui's Window size is the expected one, if not, update it + if let Some(current_rect) = ctx.input(|i| i.viewport().outer_rect) { + // Get the correct size according to scale factor + let current_rect = komorebi_client::Rect { + left: (current_rect.min.x * self.scale_factor) as i32, + top: (current_rect.min.y * self.scale_factor) as i32, + right: ((current_rect.max.x - current_rect.min.x) * self.scale_factor) as i32, + bottom: ((current_rect.max.y - current_rect.min.y) * self.scale_factor) as i32, + }; + + if self.size_rect != current_rect { + self.position_bar(ctx); + } + } + + let frame = match &self.config.padding { + None => { + if let Some(frame) = &self.config.frame { + Frame::NONE + .inner_margin(Margin::symmetric( + frame.inner_margin.x as i8, + frame.inner_margin.y as i8, + )) + .fill(*self.bg_color_with_alpha.borrow()) + } else { + Frame::NONE + .inner_margin(Margin::same(0)) + .fill(*self.bg_color_with_alpha.borrow()) + } + } + Some(padding) => { + let padding = padding.to_individual(DEFAULT_PADDING); + Frame::NONE + .inner_margin(Margin { + top: padding.top as i8, + bottom: padding.bottom as i8, + left: padding.left as i8, + right: padding.right as i8, + }) + .fill(*self.bg_color_with_alpha.borrow()) + } + }; + + let mut render_config = self.render_config.borrow_mut(); + + let frame = render_config.change_frame_on_bar(frame, &ctx.style()); + + CentralPanel::default().frame(frame).show(ctx, |ui| { + // if let Some(mouse_config) = &self.config.mouse { + // let command = if ui + // .input(|i| i.pointer.button_double_clicked(PointerButton::Primary)) + // { + // tracing::debug!("Input: primary button double clicked"); + // &mouse_config.on_primary_double_click + // } else if ui.input(|i| i.pointer.button_clicked(PointerButton::Secondary)) { + // tracing::debug!("Input: secondary button clicked"); + // &mouse_config.on_secondary_click + // } else if ui.input(|i| i.pointer.button_clicked(PointerButton::Middle)) { + // tracing::debug!("Input: middle button clicked"); + // &mouse_config.on_middle_click + // } else if ui.input(|i| i.pointer.button_clicked(PointerButton::Extra1)) { + // tracing::debug!("Input: extra1 button clicked"); + // &mouse_config.on_extra1_click + // } else if ui.input(|i| i.pointer.button_clicked(PointerButton::Extra2)) { + // tracing::debug!("Input: extra2 button clicked"); + // &mouse_config.on_extra2_click + // } else if self.input_config.act_on_vertical_scroll + // || self.input_config.act_on_horizontal_scroll + // { + // let scroll_delta = ui.input(|input| input.smooth_scroll_delta); + // + // self.input_config.accumulated_scroll_delta += scroll_delta; + // + // if scroll_delta.y != 0.0 && self.input_config.act_on_vertical_scroll { + // // Do not store more than the max threshold + // self.input_config.accumulated_scroll_delta.y = + // self.input_config.accumulated_scroll_delta.y.clamp( + // -self.input_config.vertical_scroll_max_threshold, + // self.input_config.vertical_scroll_max_threshold, + // ); + // + // // When the accumulated scroll passes the threshold, trigger a tick. + // if self.input_config.accumulated_scroll_delta.y.abs() + // >= self.input_config.vertical_scroll_threshold + // { + // let direction_command = + // if self.input_config.accumulated_scroll_delta.y > 0.0 { + // &mouse_config.on_scroll_up + // } else { + // &mouse_config.on_scroll_down + // }; + // + // // Remove one tick's worth of scroll from the accumulator, preserving any excess. + // self.input_config.accumulated_scroll_delta.y -= + // self.input_config.vertical_scroll_threshold + // * self.input_config.accumulated_scroll_delta.y.signum(); + // + // tracing::debug!( + // "Input: vertical scroll ticked. excess: {} | threshold: {}", + // self.input_config.accumulated_scroll_delta.y, + // self.input_config.vertical_scroll_threshold + // ); + // + // direction_command + // } else { + // &None + // } + // } else if scroll_delta.x != 0.0 && self.input_config.act_on_horizontal_scroll { + // // Do not store more than the max threshold + // self.input_config.accumulated_scroll_delta.x = + // self.input_config.accumulated_scroll_delta.x.clamp( + // -self.input_config.horizontal_scroll_max_threshold, + // self.input_config.horizontal_scroll_max_threshold, + // ); + // + // // When the accumulated scroll passes the threshold, trigger a tick. + // if self.input_config.accumulated_scroll_delta.x.abs() + // >= self.input_config.horizontal_scroll_threshold + // { + // let direction_command = + // if self.input_config.accumulated_scroll_delta.x > 0.0 { + // &mouse_config.on_scroll_left + // } else { + // &mouse_config.on_scroll_right + // }; + // + // // Remove one tick's worth of scroll from the accumulator, preserving any excess. + // self.input_config.accumulated_scroll_delta.x -= + // self.input_config.horizontal_scroll_threshold + // * self.input_config.accumulated_scroll_delta.x.signum(); + // + // tracing::debug!( + // "Input: horizontal scroll ticked. excess: {} | threshold: {}", + // self.input_config.accumulated_scroll_delta.x, + // self.input_config.horizontal_scroll_threshold + // ); + // + // direction_command + // } else { + // &None + // } + // } else { + // &None + // } + // } else { + // &None + // }; + // + // if let Some(command) = command { + // command.execute(self.mouse_follows_focus); + // } + // } + + // Apply grouping logic for the bar as a whole + let area_frame = if let Some(frame) = &self.config.frame { + Frame::NONE + .inner_margin(Margin::symmetric(0, frame.inner_margin.y as i8)) + .outer_margin(Margin::same(0)) + } else { + Frame::NONE + .inner_margin(Margin::same(0)) + .outer_margin(Margin::same(0)) + }; + + let available_height = ui.max_rect().max.y; + ctx.style_mut(|style| { + style.spacing.interact_size.y = available_height; + }); + + if !self.left_widgets.is_empty() { + // Left-aligned widgets layout + Area::new(Id::new("left_panel")) + .anchor(Align2::LEFT_CENTER, [0.0, 0.0]) // Align in the left center of the window + .show(ctx, |ui| { + let mut left_area_frame = area_frame; + if let Some(padding) = self + .config + .padding + .as_ref() + .map(|s| s.to_individual(DEFAULT_PADDING)) + { + left_area_frame.inner_margin.left = padding.left as i8; + left_area_frame.inner_margin.top = padding.top as i8; + left_area_frame.inner_margin.bottom = padding.bottom as i8; + } else if let Some(frame) = &self.config.frame { + left_area_frame.inner_margin.left = frame.inner_margin.x as i8; + left_area_frame.inner_margin.top = frame.inner_margin.y as i8; + left_area_frame.inner_margin.bottom = frame.inner_margin.y as i8; + } + + left_area_frame.show(ui, |ui| { + ui.horizontal(|ui| { + let mut render_conf = render_config.clone(); + render_conf.alignment = Some(Alignment::Left); + + render_config.apply_on_alignment(ui, |ui| { + for w in &mut self.left_widgets { + w.render(ctx, ui, &mut render_conf); + } + }); + }); + }); + }); + } + + if !self.right_widgets.is_empty() { + // Right-aligned widgets layout + Area::new(Id::new("right_panel")) + .anchor(Align2::RIGHT_CENTER, [0.0, 0.0]) // Align in the right center of the window + .show(ctx, |ui| { + let mut right_area_frame = area_frame; + if let Some(padding) = self + .config + .padding + .as_ref() + .map(|s| s.to_individual(DEFAULT_PADDING)) + { + right_area_frame.inner_margin.right = padding.right as i8; + right_area_frame.inner_margin.top = padding.top as i8; + right_area_frame.inner_margin.bottom = padding.bottom as i8; + } else if let Some(frame) = &self.config.frame { + right_area_frame.inner_margin.right = frame.inner_margin.x as i8; + right_area_frame.inner_margin.top = frame.inner_margin.y as i8; + right_area_frame.inner_margin.bottom = frame.inner_margin.y as i8; + } + + right_area_frame.show(ui, |ui| { + let initial_size = Vec2 { + x: ui.available_size_before_wrap().x, + y: ui.spacing().interact_size.y, + }; + ui.allocate_ui_with_layout( + initial_size, + Layout::right_to_left(Align::Center), + |ui| { + let mut render_conf = render_config.clone(); + render_conf.alignment = Some(Alignment::Right); + + render_config.apply_on_alignment(ui, |ui| { + for w in &mut self.right_widgets { + w.render(ctx, ui, &mut render_conf); + } + }); + }, + ); + }); + }); + } + + if !self.center_widgets.is_empty() { + // Floating center widgets + Area::new(Id::new("center_panel")) + .anchor(Align2::CENTER_CENTER, [0.0, 0.0]) // Align in the center of the window + .show(ctx, |ui| { + let mut center_area_frame = area_frame; + if let Some(padding) = self + .config + .padding + .as_ref() + .map(|s| s.to_individual(DEFAULT_PADDING)) + { + center_area_frame.inner_margin.top = padding.top as i8; + center_area_frame.inner_margin.bottom = padding.bottom as i8; + } else if let Some(frame) = &self.config.frame { + center_area_frame.inner_margin.top = frame.inner_margin.y as i8; + center_area_frame.inner_margin.bottom = frame.inner_margin.y as i8; + } + + center_area_frame.show(ui, |ui| { + ui.horizontal(|ui| { + let mut render_conf = render_config.clone(); + render_conf.alignment = Some(Alignment::Center); + + render_config.apply_on_alignment(ui, |ui| { + for w in &mut self.center_widgets { + w.render(ctx, ui, &mut render_conf); + } + }); + }); + }); + }); + } + }); + } +} + +#[derive(Copy, Clone)] +pub enum Alignment { + Left, + Center, + Right, +} + +#[allow(clippy::too_many_arguments)] +fn handle_notification( + ctx: &Context, + event: komorebi_client::NotificationEvent, + bg_color: Rc>, + bg_color_with_alpha: Rc>, + transparency_alpha: Option, + grouping: Option, + default_theme: Option, + render_config: Rc>, +) { + if let NotificationEvent::Socket(message) = event { + match message { + SocketMessage::ReloadStaticConfiguration(path) => { + if let Ok(config) = komorebi_client::StaticConfig::read(&path) { + if let Some(theme) = config.theme { + apply_theme( + ctx, + KomobarTheme::from(theme), + bg_color.clone(), + bg_color_with_alpha.clone(), + transparency_alpha, + grouping, + render_config, + ); + tracing::info!("applied theme from updated komorebi.json"); + } else if let Some(default_theme) = default_theme { + apply_theme( + ctx, + default_theme, + bg_color.clone(), + bg_color_with_alpha.clone(), + transparency_alpha, + grouping, + render_config, + ); + tracing::info!( + "removed theme from updated komorebi.json and applied default theme" + ); + } else { + tracing::warn!( + "theme was removed from updated komorebi.json but there was no default theme to apply" + ); + } + } + } + SocketMessage::Theme(theme) => { + apply_theme( + ctx, + KomobarTheme::from(*theme), + bg_color, + bg_color_with_alpha.clone(), + transparency_alpha, + grouping, + render_config, + ); + tracing::info!("applied theme from komorebi socket message"); + } + _ => {} + } + } +} diff --git a/komorebi-bar/src/config.rs b/komorebi-bar/src/config.rs new file mode 100644 index 00000000..33ae0103 --- /dev/null +++ b/komorebi-bar/src/config.rs @@ -0,0 +1,699 @@ +use crate::DEFAULT_PADDING; +// use crate::bar::exec_powershell; +use crate::render::Grouping; +use crate::widgets::widget::WidgetConfig; +use color_eyre::eyre; +use eframe::egui::Pos2; +use eframe::egui::TextBuffer; +use eframe::egui::Vec2; +use komorebi_client::KomorebiTheme; +use komorebi_client::Rect; +use serde::Deserialize; +use serde::Serialize; +use std::collections::HashMap; +use std::path::PathBuf; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +/// The `komorebi.bar.json` configuration file reference for `v0.1.39` +pub struct KomobarConfig { + /// Bar height (default: 50) + pub height: Option, + /// Bar padding. Use one value for all sides or use a grouped padding for horizontal and/or + /// vertical definition which can each take a single value for a symmetric padding or two + /// values for each side, i.e.: + /// ```json + /// "padding": { + /// "horizontal": 10 + /// } + /// ``` + /// or: + /// ```json + /// "padding": { + /// "horizontal": [left, right] + /// } + /// ``` + /// You can also set individual padding on each side like this: + /// ```json + /// "padding": { + /// "top": 10, + /// "bottom": 10, + /// "left": 10, + /// "right": 10, + /// } + /// ``` + /// By default, padding is set to 10 on all sides. + pub padding: Option, + /// Bar margin. Use one value for all sides or use a grouped margin for horizontal and/or + /// vertical definition which can each take a single value for a symmetric margin or two + /// values for each side, i.e.: + /// ```json + /// "margin": { + /// "horizontal": 10 + /// } + /// ``` + /// or: + /// ```json + /// "margin": { + /// "vertical": [top, bottom] + /// } + /// ``` + /// You can also set individual margin on each side like this: + /// ```json + /// "margin": { + /// "top": 10, + /// "bottom": 10, + /// "left": 10, + /// "right": 10, + /// } + /// ``` + /// By default, margin is set to 0 on all sides. + pub margin: Option, + /// Bar positioning options + #[serde(alias = "viewport")] + pub position: Option, + /// Frame options (see: https://docs.rs/egui/latest/egui/containers/frame/struct.Frame.html) + pub frame: Option, + /// The monitor index or the full monitor options + pub monitor: MonitorConfigOrIndex, + /// Font family + pub font_family: Option, + /// Font size (default: 12.5) + pub font_size: Option, + /// Scale of the icons relative to the font_size [[1.0-2.0]]. (default: 1.4) + pub icon_scale: Option, + /// Max label width before text truncation (default: 400.0) + pub max_label_width: Option, + /// Theme + pub theme: Option, + /// Alpha value for the color transparency [[0-255]] (default: 200) + pub transparency_alpha: Option, + /// Spacing between widgets (default: 10.0) + pub widget_spacing: Option, + /// Visual grouping for widgets + pub grouping: Option, + /// Options for mouse interaction on the bar + // pub mouse: Option, + /// Left side widgets (ordered left-to-right) + pub left_widgets: Vec, + /// Center widgets (ordered left-to-right) + pub center_widgets: Option>, + /// Right side widgets (ordered left-to-right) + pub right_widgets: Vec, +} + +impl KomobarConfig { + pub fn aliases(raw: &str) { + let mut map = HashMap::new(); + map.insert("position", ["viewport"]); + map.insert("end", ["inner_frame"]); + + let mut display = false; + + for aliases in map.values() { + for a in aliases { + if raw.contains(a) { + display = true; + } + } + } + + if display { + println!( + "\nYour bar configuration file contains some options that have been renamed or deprecated:\n" + ); + for (canonical, aliases) in map { + for alias in aliases { + if raw.contains(alias) { + println!(r#""{alias}" is now "{canonical}""#); + } + } + } + } + } + + pub fn show_all_icons_on_komorebi_workspace(widgets: &[WidgetConfig]) -> bool { + widgets + .iter() + .any(|w| matches!(w, WidgetConfig::Komorebi(config) if config.workspaces.is_some_and(|w| w.enable && w.display.is_some_and(|s| matches!(s, + WorkspacesDisplayFormat::AllIcons + | WorkspacesDisplayFormat::AllIconsAndText + | WorkspacesDisplayFormat::AllIconsAndTextOnSelected))))) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct PositionConfig { + /// The desired starting position of the bar (0,0 = top left of the screen) + #[serde(alias = "position")] + pub start: Option, + /// The desired size of the bar from the starting position (usually monitor width x desired height) + #[serde(alias = "inner_size")] + pub end: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct FrameConfig { + /// Margin inside the painted frame + pub inner_margin: Position, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(untagged)] +pub enum MonitorConfigOrIndex { + /// The monitor index where you want the bar to show + Index(usize), + /// The full monitor options with the index and an optional work_area_offset + MonitorConfig(MonitorConfig), +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct MonitorConfig { + /// Komorebi monitor index of the monitor on which to render the bar + pub index: usize, + /// Automatically apply a work area offset for this monitor to accommodate the bar + pub work_area_offset: Option, +} + +pub type Padding = SpacingKind; +pub type Margin = SpacingKind; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(untagged)] +// WARNING: To any developer messing with this code in the future: The order here matters! +// `Grouped` needs to come last, otherwise serde might mistaken an `IndividualSpacingConfig` for a +// `GroupedSpacingConfig` with both `vertical` and `horizontal` set to `None` ignoring the +// individual values. +pub enum SpacingKind { + All(f32), + Individual(IndividualSpacingConfig), + Grouped(GroupedSpacingConfig), +} + +impl SpacingKind { + pub fn to_individual(&self, default: f32) -> IndividualSpacingConfig { + match self { + SpacingKind::All(m) => IndividualSpacingConfig::all(*m), + SpacingKind::Grouped(grouped_spacing_config) => { + let vm = grouped_spacing_config.vertical.as_ref().map_or( + IndividualSpacingConfig::vertical(default), + |vm| match vm { + GroupedSpacingOptions::Symmetrical(m) => { + IndividualSpacingConfig::vertical(*m) + } + GroupedSpacingOptions::Split(tm, bm) => { + IndividualSpacingConfig::vertical(*tm).bottom(*bm) + } + }, + ); + let hm = grouped_spacing_config.horizontal.as_ref().map_or( + IndividualSpacingConfig::horizontal(default), + |hm| match hm { + GroupedSpacingOptions::Symmetrical(m) => { + IndividualSpacingConfig::horizontal(*m) + } + GroupedSpacingOptions::Split(lm, rm) => { + IndividualSpacingConfig::horizontal(*lm).right(*rm) + } + }, + ); + IndividualSpacingConfig { + top: vm.top, + bottom: vm.bottom, + left: hm.left, + right: hm.right, + } + } + SpacingKind::Individual(m) => *m, + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct GroupedSpacingConfig { + pub vertical: Option, + pub horizontal: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(untagged)] +pub enum GroupedSpacingOptions { + Symmetrical(f32), + Split(f32, f32), +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct IndividualSpacingConfig { + pub top: f32, + pub bottom: f32, + pub left: f32, + pub right: f32, +} + +#[allow(dead_code)] +impl IndividualSpacingConfig { + pub const ZERO: Self = IndividualSpacingConfig { + top: 0.0, + bottom: 0.0, + left: 0.0, + right: 0.0, + }; + + pub fn all(value: f32) -> Self { + IndividualSpacingConfig { + top: value, + bottom: value, + left: value, + right: value, + } + } + + pub fn horizontal(value: f32) -> Self { + IndividualSpacingConfig { + top: 0.0, + bottom: 0.0, + left: value, + right: value, + } + } + + pub fn vertical(value: f32) -> Self { + IndividualSpacingConfig { + top: value, + bottom: value, + left: 0.0, + right: 0.0, + } + } + + pub fn top(self, value: f32) -> Self { + IndividualSpacingConfig { top: value, ..self } + } + + pub fn bottom(self, value: f32) -> Self { + IndividualSpacingConfig { + bottom: value, + ..self + } + } + + pub fn left(self, value: f32) -> Self { + IndividualSpacingConfig { + left: value, + ..self + } + } + + pub fn right(self, value: f32) -> Self { + IndividualSpacingConfig { + right: value, + ..self + } + } +} + +pub fn get_individual_spacing( + default: f32, + spacing: &Option, +) -> IndividualSpacingConfig { + spacing + .as_ref() + .map_or(IndividualSpacingConfig::all(default), |s| { + s.to_individual(default) + }) +} + +// #[derive(Clone, Debug, Serialize, Deserialize)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// #[serde(untagged)] +// pub enum MouseMessage { +// /// Send a message to the komorebi client. +// /// By default, a batch of messages are sent in the following order: +// /// FocusMonitorAtCursor => +// /// MouseFollowsFocus(false) => +// /// {message} => +// /// MouseFollowsFocus({original.value}) +// /// +// /// Example: +// /// ```json +// /// "on_extra2_click": { +// /// "message": { +// /// "type": "NewWorkspace" +// /// } +// /// }, +// /// ``` +// /// or: +// /// ```json +// /// "on_middle_click": { +// /// "focus_monitor_at_cursor": false, +// /// "ignore_mouse_follows_focus": false, +// /// "message": { +// /// "type": "TogglePause" +// /// } +// /// } +// /// ``` +// /// or: +// /// ```json +// /// "on_scroll_up": { +// /// "message": { +// /// "type": "CycleFocusWorkspace", +// /// "content": "Previous" +// /// } +// /// } +// /// ``` +// Komorebi(KomorebiMouseMessage), +// /// Execute a custom command. +// /// CMD (%variable%), Bash ($variable) and PowerShell ($Env:variable) variables will be resolved. +// /// Example: `komorebic toggle-pause` +// Command(String), +// } +// +// #[derive(Clone, Debug, Serialize, Deserialize)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct KomorebiMouseMessage { +// /// Send the FocusMonitorAtCursor message (default:true) +// pub focus_monitor_at_cursor: Option, +// /// Wrap the {message} with a MouseFollowsFocus(false) and MouseFollowsFocus({original.value}) message (default:true) +// pub ignore_mouse_follows_focus: Option, +// /// The message to send to the komorebi client +// pub message: komorebi_client::SocketMessage, +// } +// +// #[derive(Clone, Debug, Serialize, Deserialize)] +// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +// pub struct MouseConfig { +// /// Command to send on primary/left double button click +// pub on_primary_double_click: Option, +// /// Command to send on secondary/right button click +// pub on_secondary_click: Option, +// /// Command to send on middle button click +// pub on_middle_click: Option, +// /// Command to send on extra1/back button click +// pub on_extra1_click: Option, +// /// Command to send on extra2/forward button click +// pub on_extra2_click: Option, +// +// /// Defines how many points a user needs to scroll vertically to make a "tick" on a mouse/touchpad/touchscreen (default: 30) +// pub vertical_scroll_threshold: Option, +// /// Command to send on scrolling up (every tick) +// pub on_scroll_up: Option, +// /// Command to send on scrolling down (every tick) +// pub on_scroll_down: Option, +// +// /// Defines how many points a user needs to scroll horizontally to make a "tick" on a mouse/touchpad/touchscreen (default: 30) +// pub horizontal_scroll_threshold: Option, +// /// Command to send on scrolling left (every tick) +// pub on_scroll_left: Option, +// /// Command to send on scrolling right (every tick) +// pub on_scroll_right: Option, +// } +// +// impl MouseConfig { +// pub fn has_command(&self) -> bool { +// [ +// &self.on_primary_double_click, +// &self.on_secondary_click, +// &self.on_middle_click, +// &self.on_extra1_click, +// &self.on_extra2_click, +// &self.on_scroll_up, +// &self.on_scroll_down, +// &self.on_scroll_left, +// &self.on_scroll_right, +// ] +// .iter() +// .any(|opt| matches!(opt, Some(MouseMessage::Command(_)))) +// } +// } +// +// impl MouseMessage { +// pub fn execute(&self, mouse_follows_focus: bool) { +// match self { +// MouseMessage::Komorebi(config) => { +// let mut messages = Vec::new(); +// +// if config.focus_monitor_at_cursor.unwrap_or(true) { +// messages.push(SocketMessage::FocusMonitorAtCursor); +// } +// +// if config.ignore_mouse_follows_focus.unwrap_or(true) { +// messages.push(SocketMessage::MouseFollowsFocus(false)); +// messages.push(config.message.clone()); +// messages.push(SocketMessage::MouseFollowsFocus(mouse_follows_focus)); +// } else { +// messages.push(config.message.clone()); +// } +// +// tracing::debug!("Sending messages: {messages:?}"); +// +// if komorebi_client::send_batch(messages).is_err() { +// tracing::error!("could not send commands"); +// } +// } +// MouseMessage::Command(cmd) => { +// tracing::debug!("Executing command: {}", cmd); +// +// let cmd_no_env = cmd.replace_env(); +// +// if exec_powershell(cmd_no_env.to_str().expect("Invalid command")).is_err() { +// tracing::error!("Failed to execute '{}'", cmd); +// } +// } +// }; +// } +// } + +impl KomobarConfig { + pub fn read(path: &PathBuf) -> eyre::Result { + let content = std::fs::read_to_string(path)?; + let mut value: Self = match path.extension().unwrap().to_string_lossy().as_str() { + "json" => serde_json::from_str(&content)?, + _ => panic!("unsupported format"), + }; + + if value.frame.is_none() { + value.frame = Some(FrameConfig { + inner_margin: Position { + x: DEFAULT_PADDING, + y: DEFAULT_PADDING, + }, + }); + } + + Ok(value) + } +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct Position { + /// X coordinate + pub x: f32, + /// Y coordinate + pub y: f32, +} + +impl From for Vec2 { + fn from(value: Position) -> Self { + Self { + x: value.x, + y: value.y, + } + } +} + +impl From for Pos2 { + fn from(value: Position) -> Self { + Self { + x: value.x, + y: value.y, + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(tag = "palette")] +pub enum KomobarTheme { + /// A theme from catppuccin-egui + Catppuccin { + /// Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin) + name: komorebi_themes::Catppuccin, + accent: Option, + auto_select_fill: Option, + auto_select_text: Option, + }, + /// A theme from base16-egui-themes + Base16 { + /// Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/) + name: komorebi_themes::Base16, + accent: Option, + auto_select_fill: Option, + auto_select_text: Option, + }, + /// A custom Base16 theme + Custom { + /// Colours of the custom Base16 theme palette + colours: Box, + accent: Option, + auto_select_fill: Option, + auto_select_text: Option, + }, +} + +impl From for KomobarTheme { + fn from(value: KomorebiTheme) -> Self { + match value { + KomorebiTheme::Catppuccin { + name, bar_accent, .. + } => Self::Catppuccin { + name, + accent: bar_accent, + auto_select_fill: None, + auto_select_text: None, + }, + KomorebiTheme::Base16 { + name, bar_accent, .. + } => Self::Base16 { + name, + accent: bar_accent, + auto_select_fill: None, + auto_select_text: None, + }, + KomorebiTheme::Custom { + colours, + bar_accent, + .. + } => Self::Custom { + colours, + accent: bar_accent, + auto_select_fill: None, + auto_select_text: None, + }, + } + } +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum LabelPrefix { + /// Show no prefix + None, + /// Show an icon + Icon, + /// Show text + Text, + /// Show an icon and text + IconAndText, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum DisplayFormat { + /// Show only icon + Icon, + /// Show only text + Text, + /// Show an icon and text for the selected element, and text on the rest + TextAndIconOnSelected, + /// Show both icon and text + IconAndText, + /// Show an icon and text for the selected element, and icons on the rest + IconAndTextOnSelected, +} + +macro_rules! extend_enum { + ($existing_enum:ident, $new_enum:ident, { $($(#[$meta:meta])* $variant:ident),* $(,)? }) => { + #[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)] + #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] + pub enum $new_enum { + // Add new variants + $( + $(#[$meta])* + $variant, + )* + // Include a variant that wraps the existing enum and flatten it when deserializing + #[serde(untagged)] + Existing($existing_enum), + } + + // Implement From for the existing enum + impl From<$existing_enum> for $new_enum { + fn from(value: $existing_enum) -> Self { + $new_enum::Existing(value) + } + } + }; +} + +extend_enum!(DisplayFormat, WorkspacesDisplayFormat, { + /// Show all icons only + AllIcons, + /// Show both all icons and text + AllIconsAndText, + /// Show all icons and text for the selected element, and all icons on the rest + AllIconsAndTextOnSelected, +}); + +#[cfg(test)] +mod tests { + use serde::Deserialize; + use serde::Serialize; + use serde_json::json; + + #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] + #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] + pub enum OriginalDisplayFormat { + /// Show None Of The Things + NoneOfTheThings, + } + + extend_enum!(OriginalDisplayFormat, ExtendedDisplayFormat, { + /// Show Some Of The Things + SomeOfTheThings, + }); + + #[derive(serde::Deserialize)] + struct ExampleConfig { + #[allow(unused)] + format: ExtendedDisplayFormat, + } + + #[test] + pub fn extend_new_variant() { + let raw = json!({ + "format": "SomeOfTheThings", + }) + .to_string(); + + assert!(serde_json::from_str::(&raw).is_ok()) + } + + #[test] + pub fn extend_existing_variant() { + let raw = json!({ + "format": "NoneOfTheThings", + }) + .to_string(); + + assert!(serde_json::from_str::(&raw).is_ok()) + } + + #[test] + pub fn extend_invalid_variant() { + let raw = json!({ + "format": "ALLOFTHETHINGS", + }) + .to_string(); + + assert!(serde_json::from_str::(&raw).is_err()) + } +} diff --git a/komorebi-bar/src/main.rs b/komorebi-bar/src/main.rs new file mode 100644 index 00000000..29a07c31 --- /dev/null +++ b/komorebi-bar/src/main.rs @@ -0,0 +1,373 @@ +mod bar; +mod config; +mod render; +mod selected_frame; +mod ui; +mod widgets; + +use crate::bar::Komobar; +use crate::config::KomobarConfig; +use crate::config::Position; +use crate::config::PositionConfig; +use clap::Parser; +use color_eyre::eyre; +use config::MonitorConfigOrIndex; +use eframe::egui::ViewportBuilder; +use font_loader::system_fonts; +use hotwatch::EventKind; +use hotwatch::Hotwatch; +use komorebi_client::PathExt; +use komorebi_client::SocketMessage; +use komorebi_client::SubscribeOptions; +use komorebi_client::replace_env_in_path; +use std::io::BufReader; +use std::io::Read; +use std::path::PathBuf; +use std::sync::atomic::AtomicI32; +use std::sync::atomic::AtomicU32; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; +use std::time::Duration; +use tracing_subscriber::EnvFilter; + +pub static MAX_LABEL_WIDTH: AtomicI32 = AtomicI32::new(400); +pub static MONITOR_LEFT: AtomicI32 = AtomicI32::new(0); +pub static MONITOR_TOP: AtomicI32 = AtomicI32::new(0); +pub static MONITOR_RIGHT: AtomicI32 = AtomicI32::new(0); +pub static MONITOR_INDEX: AtomicUsize = AtomicUsize::new(0); +pub static BAR_HEIGHT: f32 = 50.0; +pub static DEFAULT_PADDING: f32 = 10.0; + +pub static AUTO_SELECT_FILL_COLOUR: AtomicU32 = AtomicU32::new(0); +pub static AUTO_SELECT_TEXT_COLOUR: AtomicU32 = AtomicU32::new(0); + +#[derive(Parser)] +#[clap(author, about, version)] +struct Opts { + /// Print the JSON schema of the configuration file and exit + #[clap(long)] + schema: bool, + /// Print a list of fonts available on this system and exit + #[clap(long)] + fonts: bool, + /// Path to a JSON or YAML configuration file + #[clap(short, long)] + #[clap(value_parser = replace_env_in_path)] + config: Option, + /// Write an example komorebi.bar.json to disk + #[clap(long)] + quickstart: bool, + /// Print a list of aliases that can be renamed to canonical variants + #[clap(long)] + #[clap(hide = true)] + aliases: bool, +} + +pub enum KomorebiEvent { + Notification(komorebi_client::Notification), + Reconnect, +} + +fn main() -> eyre::Result<()> { + let opts: Opts = Opts::parse(); + + #[cfg(feature = "schemars")] + if opts.schema { + let settings = schemars::r#gen::SchemaSettings::default().with(|s| { + s.option_nullable = false; + s.option_add_null_type = false; + s.inline_subschemas = true; + }); + + let generator = settings.into_generator(); + let socket_message = generator.into_root_schema_for::(); + let schema = serde_json::to_string_pretty(&socket_message)?; + + println!("{schema}"); + std::process::exit(0); + } + + if opts.fonts { + for font in system_fonts::query_all() { + println!("{font}"); + } + + std::process::exit(0); + } + + if std::env::var("RUST_LIB_BACKTRACE").is_err() { + unsafe { + std::env::set_var("RUST_LIB_BACKTRACE", "1"); + } + } + + color_eyre::install()?; + + if std::env::var("RUST_LOG").is_err() { + unsafe { + std::env::set_var("RUST_LOG", "info"); + } + } + + tracing::subscriber::set_global_default( + tracing_subscriber::fmt::Subscriber::builder() + .with_env_filter(EnvFilter::from_default_env()) + .finish(), + )?; + + let home_dir: PathBuf = std::env::var("KOMOREBI_CONFIG_HOME").map_or_else( + |_| { + dirs::home_dir() + .expect("there is no home directory") + .join(".config") + .join("komorebi") + }, + |home_path| { + let home = home_path.replace_env(); + + assert!( + home.is_dir(), + "$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory" + ); + + home + }, + ); + + if opts.quickstart { + let komorebi_bar_json = include_str!("../../docs/komorebi.bar.example.json").to_string(); + std::fs::write(home_dir.join("komorebi.bar.json"), komorebi_bar_json)?; + println!( + "Example komorebi.bar.json file written to {}", + home_dir.display() + ); + + std::process::exit(0); + } + + let default_config_path = home_dir.join("komorebi.bar.json"); + + let config_path = opts.config.or_else(|| { + default_config_path + .is_file() + .then_some(default_config_path.clone()) + }); + + let mut config = match config_path { + None => { + let komorebi_bar_json = + include_str!("../../docs/komorebi.bar.example.json").to_string(); + + std::fs::write(&default_config_path, komorebi_bar_json)?; + tracing::info!( + "created example configuration file: {}", + default_config_path.display() + ); + + KomobarConfig::read(&default_config_path)? + } + Some(ref config) => { + if !opts.aliases { + tracing::info!("found configuration file: {}", config.display()); + } + + KomobarConfig::read(config)? + } + }; + + let config_path = config_path.unwrap_or(default_config_path); + + if opts.aliases { + KomobarConfig::aliases(&std::fs::read_to_string(&config_path)?); + std::process::exit(0); + } + + let state = serde_json::from_str::(&komorebi_client::send_query( + &SocketMessage::State, + )?)?; + + let (usr_monitor_index, work_area_offset) = match &config.monitor { + MonitorConfigOrIndex::MonitorConfig(monitor_config) => { + (monitor_config.index, monitor_config.work_area_offset) + } + MonitorConfigOrIndex::Index(idx) => (*idx, None), + }; + let monitor_index = state + .monitor_usr_idx_map + .get(&usr_monitor_index) + .map_or(usr_monitor_index, |i| *i); + + MONITOR_RIGHT.store( + state.monitors.elements()[monitor_index].size.right, + Ordering::SeqCst, + ); + + MONITOR_TOP.store( + state.monitors.elements()[monitor_index].size.top, + Ordering::SeqCst, + ); + + MONITOR_LEFT.store( + state.monitors.elements()[monitor_index].size.left, + Ordering::SeqCst, + ); + + MONITOR_INDEX.store(monitor_index, Ordering::SeqCst); + + match config.position { + None => { + config.position = Some(PositionConfig { + start: Some(Position { + x: state.monitors.elements()[monitor_index].size.left as f32, + y: state.monitors.elements()[monitor_index].size.top as f32, + }), + end: Some(Position { + x: state.monitors.elements()[monitor_index].size.right as f32, + y: 50.0, + }), + }) + } + Some(ref mut position) => { + if position.start.is_none() { + position.start = Some(Position { + x: state.monitors.elements()[monitor_index].size.left as f32, + y: state.monitors.elements()[monitor_index].size.top as f32, + }); + } + + if position.end.is_none() { + position.end = Some(Position { + x: state.monitors.elements()[monitor_index].size.right as f32, + y: 50.0, + }) + } + } + } + + let viewport_builder = ViewportBuilder::default() + .with_decorations(false) + .with_transparent(true) + .with_taskbar(false); + + let native_options = eframe::NativeOptions { + viewport: viewport_builder, + ..Default::default() + }; + + if let Some(rect) = &work_area_offset { + komorebi_client::send_message(&SocketMessage::MonitorWorkAreaOffset(monitor_index, *rect))?; + tracing::info!("work area offset applied to monitor: {}", monitor_index); + } + + let (tx_gui, rx_gui) = crossbeam_channel::unbounded(); + let (tx_config, rx_config) = crossbeam_channel::unbounded(); + + let mut hotwatch = Hotwatch::new()?; + let config_path_cl = config_path.clone(); + + hotwatch.watch(config_path, move |event| match event.kind { + EventKind::Modify(_) | EventKind::Remove(_) => match KomobarConfig::read(&config_path_cl) { + Ok(updated) => { + tracing::info!("configuration file updated: {}", config_path_cl.display()); + + if let Err(error) = tx_config.send(updated) { + tracing::error!("could not send configuration update to gui: {error}") + } + } + Err(error) => { + tracing::error!("{error}"); + } + }, + _ => {} + })?; + + tracing::info!("watching configuration file for changes"); + + eframe::run_native( + "komorebi-bar", + native_options, + Box::new(|cc| { + let ctx_repainter = cc.egui_ctx.clone(); + std::thread::spawn(move || loop { + std::thread::sleep(Duration::from_secs(1)); + ctx_repainter.request_repaint(); + }); + + let ctx_komorebi = cc.egui_ctx.clone(); + std::thread::spawn(move || { + let subscriber_name = format!("komorebi-bar-{}", random_word::get(random_word::Lang::En)); + + let listener = komorebi_client::subscribe_with_options(&subscriber_name, SubscribeOptions { + filter_state_changes: true, + }) + .expect("could not subscribe to komorebi notifications"); + + tracing::info!("subscribed to komorebi notifications: \"{}\"", subscriber_name); + + for client in listener.incoming() { + match client { + Ok(subscription) => { + let mut buffer = Vec::new(); + let mut reader = BufReader::new(subscription); + + // this is when we know a shutdown has been sent + if matches!(reader.read_to_end(&mut buffer), Ok(0)) { + tracing::info!("disconnected from komorebi"); + + // keep trying to reconnect to komorebi + while komorebi_client::send_message( + &SocketMessage::AddSubscriberSocket(subscriber_name.clone()), + ) + .is_err() + { + std::thread::sleep(Duration::from_secs(1)); + } + + tracing::info!("reconnected to komorebi"); + + if let Err(error) = tx_gui.send(KomorebiEvent::Reconnect) { + tracing::error!("could not send komorebi reconnect event to gui thread: {error}") + } + + ctx_komorebi.request_repaint(); + continue; + } + + match String::from_utf8(buffer) { + Ok(notification_string) => { + match serde_json::from_str::( + ¬ification_string, + ) { + Ok(notification) => { + tracing::debug!("received notification from komorebi"); + + if let Err(error) = tx_gui.send(KomorebiEvent::Notification(notification)) { + tracing::error!("could not send komorebi notification update to gui thread: {error}") + } + + ctx_komorebi.request_repaint(); + } + Err(error) => { + tracing::error!("could not deserialize komorebi notification: {error}"); + } + } + } + Err(error) => { + tracing::error!( + "komorebi notification string was invalid utf8: {error}" + ) + } + } + } + Err(error) => { + tracing::error!("{error}"); + } + } + } + }); + + Ok(Box::new(Komobar::new(cc, rx_gui, rx_config, config))) + }), + ) + .map_err(|error| color_eyre::eyre::Error::msg(error.to_string())) +} diff --git a/komorebi-bar/src/render.rs b/komorebi-bar/src/render.rs new file mode 100644 index 00000000..88b43234 --- /dev/null +++ b/komorebi-bar/src/render.rs @@ -0,0 +1,429 @@ +use crate::AUTO_SELECT_FILL_COLOUR; +use crate::AUTO_SELECT_TEXT_COLOUR; +use crate::bar::Alignment; +use crate::config::KomobarConfig; +use crate::config::MonitorConfigOrIndex; +use eframe::egui::Color32; +use eframe::egui::Context; +use eframe::egui::CornerRadius; +use eframe::egui::FontId; +use eframe::egui::Frame; +use eframe::egui::InnerResponse; +use eframe::egui::Margin; +use eframe::egui::Shadow; +use eframe::egui::TextStyle; +use eframe::egui::Ui; +use komorebi_client::Colour; +use komorebi_client::Rgb; +use serde::Deserialize; +use serde::Serialize; +use std::num::NonZeroU32; +use std::sync::Arc; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +static SHOW_KOMOREBI_LAYOUT_OPTIONS: AtomicUsize = AtomicUsize::new(0); + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(tag = "kind")] +pub enum Grouping { + /// No grouping is applied + None, + /// Widgets are grouped as a whole + Bar(GroupingConfig), + /// Widgets are grouped by alignment + Alignment(GroupingConfig), + /// Widgets are grouped individually + Widget(GroupingConfig), +} + +#[derive(Clone)] +pub struct RenderConfig { + /// Komorebi monitor index of the monitor on which to render the bar + pub monitor_idx: usize, + /// Spacing between widgets + pub spacing: f32, + /// Sets how widgets are grouped + pub grouping: Grouping, + /// Background color + pub background_color: Color32, + /// Alignment of the widgets + pub alignment: Option, + /// Add more inner margin when adding a widget group + pub more_inner_margin: bool, + /// Set to true after the first time the apply_on_widget was called on an alignment + pub applied_on_widget: bool, + /// FontId for text + pub text_font_id: FontId, + /// FontId for icon (based on scaling the text font id) + pub icon_font_id: FontId, + /// Show all icons on the workspace section of the Komorebi widget + pub show_all_icons: bool, + /// Background color of the selected frame + pub auto_select_fill: Option, + /// Text color of the selected frame + pub auto_select_text: Option, +} + +pub trait RenderExt { + fn new_renderconfig( + &self, + ctx: &Context, + background_color: Color32, + icon_scale: Option, + ) -> RenderConfig; +} + +impl RenderExt for &KomobarConfig { + fn new_renderconfig( + &self, + ctx: &Context, + background_color: Color32, + icon_scale: Option, + ) -> RenderConfig { + let text_font_id = ctx + .style() + .text_styles + .get(&TextStyle::Body) + .cloned() + .unwrap_or_else(FontId::default); + + let mut icon_font_id = text_font_id.clone(); + icon_font_id.size *= icon_scale.unwrap_or(1.4).clamp(1.0, 2.0); + + let monitor_idx = match &self.monitor { + MonitorConfigOrIndex::MonitorConfig(monitor_config) => monitor_config.index, + MonitorConfigOrIndex::Index(idx) => *idx, + }; + + // check if any of the alignments have a komorebi widget with the workspace set to show all icons + let show_all_icons = + KomobarConfig::show_all_icons_on_komorebi_workspace(&self.left_widgets) + || self + .center_widgets + .as_ref() + .is_some_and(|list| KomobarConfig::show_all_icons_on_komorebi_workspace(list)) + || KomobarConfig::show_all_icons_on_komorebi_workspace(&self.right_widgets); + + RenderConfig { + monitor_idx, + spacing: self.widget_spacing.unwrap_or(10.0), + grouping: self.grouping.unwrap_or(Grouping::None), + background_color, + alignment: None, + more_inner_margin: false, + applied_on_widget: false, + text_font_id, + icon_font_id, + show_all_icons, + auto_select_fill: NonZeroU32::new(AUTO_SELECT_FILL_COLOUR.load(Ordering::SeqCst)) + .map(|c| Colour::Rgb(Rgb::from(c.get())).into()), + auto_select_text: NonZeroU32::new(AUTO_SELECT_TEXT_COLOUR.load(Ordering::SeqCst)) + .map(|c| Colour::Rgb(Rgb::from(c.get())).into()), + } + } +} + +impl RenderConfig { + pub fn load_show_komorebi_layout_options() -> bool { + SHOW_KOMOREBI_LAYOUT_OPTIONS.load(Ordering::SeqCst) != 0 + } + + pub fn store_show_komorebi_layout_options(show: bool) { + SHOW_KOMOREBI_LAYOUT_OPTIONS.store(show as usize, Ordering::SeqCst); + } + + pub fn new() -> Self { + Self { + monitor_idx: 0, + spacing: 0.0, + grouping: Grouping::None, + background_color: Color32::BLACK, + alignment: None, + more_inner_margin: false, + applied_on_widget: false, + text_font_id: FontId::default(), + icon_font_id: FontId::default(), + show_all_icons: false, + auto_select_fill: None, + auto_select_text: None, + } + } + + pub fn change_frame_on_bar( + &mut self, + frame: Frame, + ui_style: &Arc, + ) -> Frame { + self.alignment = None; + + if let Grouping::Bar(config) = self.grouping { + return self.define_group_frame( + //TODO: this outer margin can be a config + Some(Margin { + left: 10, + right: 10, + top: 6, + bottom: 6, + }), + config, + ui_style, + ); + } + + frame + } + + pub fn apply_on_alignment( + &mut self, + ui: &mut Ui, + add_contents: impl FnOnce(&mut Ui) -> R, + ) -> InnerResponse { + self.alignment = None; + + if let Grouping::Alignment(config) = self.grouping { + return self.define_group(None, config, ui, add_contents); + } + + Self::fallback_group(ui, add_contents) + } + + pub fn apply_on_widget( + &mut self, + more_inner_margin: bool, + ui: &mut Ui, + add_contents: impl FnOnce(&mut Ui) -> R, + ) -> InnerResponse { + self.more_inner_margin = more_inner_margin; + let outer_margin = self.widget_outer_margin(ui); + + if let Grouping::Widget(config) = self.grouping { + return self.define_group(Some(outer_margin), config, ui, add_contents); + } + + self.fallback_widget_group(Some(outer_margin), ui, add_contents) + } + + fn fallback_group(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse { + InnerResponse { + inner: add_contents(ui), + response: ui.response().clone(), + } + } + + fn fallback_widget_group( + &mut self, + outer_margin: Option, + ui: &mut Ui, + add_contents: impl FnOnce(&mut Ui) -> R, + ) -> InnerResponse { + Frame::NONE + .outer_margin(outer_margin.unwrap_or(Margin::ZERO)) + .inner_margin(match self.more_inner_margin { + true => Margin::symmetric(5, 0), + false => Margin::same(0), + }) + .show(ui, add_contents) + } + + fn define_group( + &mut self, + outer_margin: Option, + config: GroupingConfig, + ui: &mut Ui, + add_contents: impl FnOnce(&mut Ui) -> R, + ) -> InnerResponse { + self.define_group_frame(outer_margin, config, ui.style()) + .show(ui, add_contents) + } + + pub fn define_group_frame( + &mut self, + outer_margin: Option, + config: GroupingConfig, + ui_style: &Arc, + ) -> Frame { + Frame::group(ui_style) + .outer_margin(outer_margin.unwrap_or(Margin::ZERO)) + .inner_margin(match self.more_inner_margin { + true => Margin::symmetric(6, 1), + false => Margin::symmetric(1, 1), + }) + .stroke(ui_style.visuals.widgets.noninteractive.bg_stroke) + .corner_radius(match config.rounding { + Some(rounding) => rounding.into(), + None => ui_style.visuals.widgets.noninteractive.corner_radius, + }) + .fill( + self.background_color + .try_apply_alpha(config.transparency_alpha), + ) + .shadow(match config.style { + Some(style) => match style { + // new styles can be added if needed here + GroupingStyle::Default => Shadow::NONE, + GroupingStyle::DefaultWithShadowB4O1S3 => Shadow { + blur: 4, + offset: [1, 1], + spread: 3, + color: Color32::BLACK.try_apply_alpha(config.transparency_alpha), + }, + GroupingStyle::DefaultWithShadowB4O0S3 => Shadow { + blur: 4, + offset: [0, 0], + spread: 3, + color: Color32::BLACK.try_apply_alpha(config.transparency_alpha), + }, + GroupingStyle::DefaultWithShadowB0O1S3 => Shadow { + blur: 0, + offset: [1, 1], + spread: 3, + color: Color32::BLACK.try_apply_alpha(config.transparency_alpha), + }, + GroupingStyle::DefaultWithGlowB3O1S2 => Shadow { + blur: 3, + offset: [1, 1], + spread: 2, + color: ui_style + .visuals + .selection + .stroke + .color + .try_apply_alpha(config.transparency_alpha), + }, + GroupingStyle::DefaultWithGlowB3O0S2 => Shadow { + blur: 3, + offset: [0, 0], + spread: 2, + color: ui_style + .visuals + .selection + .stroke + .color + .try_apply_alpha(config.transparency_alpha), + }, + GroupingStyle::DefaultWithGlowB0O1S2 => Shadow { + blur: 0, + offset: [1, 1], + spread: 2, + color: ui_style + .visuals + .selection + .stroke + .color + .try_apply_alpha(config.transparency_alpha), + }, + }, + None => Shadow::NONE, + }) + } + + fn widget_outer_margin(&mut self, ui: &mut Ui) -> Margin { + let spacing = if self.applied_on_widget { + // Remove the default item spacing from the margin + (self.spacing - ui.spacing().item_spacing.x) as i8 + } else { + 0 + }; + + if !self.applied_on_widget { + self.applied_on_widget = true; + } + + Margin { + left: match self.alignment { + Some(align) => match align { + Alignment::Left => spacing, + Alignment::Center => spacing, + Alignment::Right => 0, + }, + None => 0, + }, + right: match self.alignment { + Some(align) => match align { + Alignment::Left => 0, + Alignment::Center => 0, + Alignment::Right => spacing, + }, + None => 0, + }, + top: 0, + bottom: 0, + } + } +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct GroupingConfig { + /// Styles for the grouping + pub style: Option, + /// Alpha value for the color transparency [[0-255]] (default: 200) + pub transparency_alpha: Option, + /// Rounding values for the 4 corners. Can be a single or 4 values. + pub rounding: Option, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum GroupingStyle { + #[serde(alias = "CtByte")] + Default, + /// A shadow is added under the default group. (blur: 4, offset: x-1 y-1, spread: 3) + #[serde(alias = "CtByteWithShadow")] + #[serde(alias = "DefaultWithShadow")] + DefaultWithShadowB4O1S3, + /// A shadow is added under the default group. (blur: 4, offset: x-0 y-0, spread: 3) + DefaultWithShadowB4O0S3, + /// A shadow is added under the default group. (blur: 0, offset: x-1 y-1, spread: 3) + DefaultWithShadowB0O1S3, + /// A glow is added under the default group. (blur: 3, offset: x-1 y-1, spread: 2) + DefaultWithGlowB3O1S2, + /// A glow is added under the default group. (blur: 3, offset: x-0 y-0, spread: 2) + DefaultWithGlowB3O0S2, + /// A glow is added under the default group. (blur: 0, offset: x-1 y-1, spread: 2) + DefaultWithGlowB0O1S2, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(untagged)] +pub enum RoundingConfig { + /// All 4 corners are the same + Same(f32), + /// All 4 corners are custom. Order: NW, NE, SW, SE + Individual([f32; 4]), +} + +impl From for CornerRadius { + fn from(value: RoundingConfig) -> Self { + match value { + RoundingConfig::Same(value) => Self::same(value as u8), + RoundingConfig::Individual(values) => { + let values = values.map(|f| f as u8); + Self { + nw: values[0], + ne: values[1], + sw: values[2], + se: values[3], + } + } + } + } +} + +pub trait Color32Ext { + fn try_apply_alpha(self, transparency_alpha: Option) -> Self; +} + +impl Color32Ext for Color32 { + /// Tries to apply the alpha value to the Color32 + fn try_apply_alpha(self, transparency_alpha: Option) -> Self { + if let Some(alpha) = transparency_alpha { + return Color32::from_rgba_unmultiplied(self.r(), self.g(), self.b(), alpha); + } + + self + } +} diff --git a/komorebi-bar/src/selected_frame.rs b/komorebi-bar/src/selected_frame.rs new file mode 100644 index 00000000..6a9347e1 --- /dev/null +++ b/komorebi-bar/src/selected_frame.rs @@ -0,0 +1,89 @@ +use eframe::egui::Color32; +use eframe::egui::CursorIcon; +use eframe::egui::Frame; +use eframe::egui::Margin; +use eframe::egui::Response; +use eframe::egui::Sense; +use eframe::egui::Stroke; +use eframe::egui::Ui; + +/// Same as SelectableLabel, but supports all content +pub struct SelectableFrame { + selected: bool, + selected_fill: Option, +} + +impl SelectableFrame { + pub fn new(selected: bool) -> Self { + Self { + selected, + selected_fill: None, + } + } + + pub fn new_auto(selected: bool, selected_fill: Option) -> Self { + Self { + selected, + selected_fill, + } + } + + pub fn show(self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> Response { + let Self { + selected, + selected_fill, + } = self; + + Frame::NONE + .show(ui, |ui| { + let response = ui.interact(ui.max_rect(), ui.unique_id(), Sense::click()); + + if ui.is_rect_visible(response.rect) { + // take into account the stroke width + let inner_margin = Margin::symmetric( + ui.style().spacing.button_padding.x as i8 - 1, + ui.style().spacing.button_padding.y as i8 - 1, + ); + + // since the stroke is drawn inside the frame, we always reserve space for it + if selected && response.hovered() { + let visuals = ui.style().interact_selectable(&response, selected); + + Frame::NONE + .stroke(Stroke::new(1.0, visuals.bg_stroke.color)) + .corner_radius(visuals.corner_radius) + .fill(selected_fill.unwrap_or(visuals.bg_fill)) + .inner_margin(inner_margin) + .show(ui, add_contents); + } else if response.hovered() || response.highlighted() || response.has_focus() { + let visuals = ui.style().interact_selectable(&response, selected); + + Frame::NONE + .stroke(Stroke::new(1.0, visuals.bg_stroke.color)) + .corner_radius(visuals.corner_radius) + .fill(visuals.bg_fill) + .inner_margin(inner_margin) + .show(ui, add_contents); + } else if selected { + let visuals = ui.style().interact_selectable(&response, selected); + + Frame::NONE + .stroke(Stroke::new(1.0, visuals.bg_fill)) + .corner_radius(visuals.corner_radius) + .fill(selected_fill.unwrap_or(visuals.bg_fill)) + .inner_margin(inner_margin) + .show(ui, add_contents); + } else { + Frame::NONE + .stroke(Stroke::new(1.0, Color32::TRANSPARENT)) + .inner_margin(inner_margin) + .show(ui, add_contents); + } + } + + response + }) + .inner + .on_hover_cursor(CursorIcon::PointingHand) + } +} diff --git a/komorebi-bar/src/ui.rs b/komorebi-bar/src/ui.rs new file mode 100644 index 00000000..24d58444 --- /dev/null +++ b/komorebi-bar/src/ui.rs @@ -0,0 +1,22 @@ +use eframe::egui::Align; +use eframe::egui::Layout; +use eframe::egui::Response; +use eframe::egui::Ui; +use eframe::egui::Vec2; +use eframe::egui::Widget; + +pub struct CustomUi<'ui>(pub &'ui mut Ui); + +impl CustomUi<'_> { + pub fn add_sized_left_to_right( + &mut self, + max_size: impl Into, + widget: impl Widget, + ) -> Response { + let layout = + Layout::from_main_dir_and_cross_align(self.0.layout().main_dir(), Align::Center); + self.0 + .allocate_ui_with_layout(max_size.into(), layout, |ui| ui.add(widget)) + .inner + } +} diff --git a/komorebi-bar/src/widgets/applications.rs b/komorebi-bar/src/widgets/applications.rs new file mode 100644 index 00000000..2bdbae1e --- /dev/null +++ b/komorebi-bar/src/widgets/applications.rs @@ -0,0 +1,404 @@ +use super::ImageIcon; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use eframe::egui::Color32; +use eframe::egui::Context; +use eframe::egui::CornerRadius; +use eframe::egui::FontId; +use eframe::egui::Frame; +use eframe::egui::Image; +use eframe::egui::Label; +use eframe::egui::Margin; +use eframe::egui::RichText; +use eframe::egui::Sense; +use eframe::egui::Stroke; +use eframe::egui::StrokeKind; +use eframe::egui::Ui; +use eframe::egui::Vec2; +use eframe::egui::vec2; +use komorebi_client::PathExt; +use serde::Deserialize; +use serde::Serialize; +use std::process::Command; +use std::sync::Arc; +use std::time::Duration; +use std::time::Instant; +use tracing; + +/// Minimum interval between consecutive application launches to prevent accidental spamming. +const MIN_LAUNCH_INTERVAL: Duration = Duration::from_millis(800); + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct ApplicationsConfig { + /// Enables or disables the applications widget. + pub enable: bool, + /// Whether to show the launch command on hover (optional). + /// Could be overridden per application. Defaults to `false` if not set. + pub show_command_on_hover: Option, + /// Horizontal spacing between application buttons. + pub spacing: Option, + /// Default display format for all applications (optional). + /// Could be overridden per application. Defaults to `Icon`. + pub display: Option, + /// List of configured applications to display. + pub items: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct AppConfig { + /// Whether to enable this application button (optional). + /// Inherits from the global `Applications` setting if omitted. + pub enable: Option, + /// Whether to show the launch command on hover (optional). + /// Inherits from the global `Applications` setting if omitted. + pub show_command_on_hover: Option, + /// Display name of the application. + pub name: String, + /// Optional icon: a path to an image or a text-based glyph (e.g., from Nerd Fonts). + /// If not set, and if the `command` is a path to an executable, an icon might be extracted from it. + /// Note: glyphs require a compatible `font_family`. + pub icon: Option, + /// Command to execute (e.g. path to the application or shell command). + pub command: String, + /// Display format for this application button (optional). Overrides global format if set. + pub display: Option, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Default)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum DisplayFormat { + /// Show only the application icon. + #[default] + Icon, + /// Show only the application name as text. + Text, + /// Show both the application icon and name. + IconAndText, +} + +#[derive(Clone, Debug)] +pub struct Applications { + /// Whether the applications widget is enabled. + pub enable: bool, + /// Horizontal spacing between application buttons. + pub spacing: Option, + /// Applications to be rendered in the UI. + pub items: Vec, +} + +impl BarWidget for Applications { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if !self.enable { + return; + } + + let icon_config = IconConfig { + font_id: config.icon_font_id.clone(), + size: config.icon_font_id.size, + color: ctx.style().visuals.selection.stroke.color, + }; + + if let Some(spacing) = self.spacing { + ui.spacing_mut().item_spacing.x = spacing; + } + + config.apply_on_widget(false, ui, |ui| { + for app in &mut self.items { + app.render(ctx, ui, &icon_config); + } + }); + } +} + +impl From<&ApplicationsConfig> for Applications { + fn from(applications_config: &ApplicationsConfig) -> Self { + let items = applications_config + .items + .iter() + .enumerate() + .map(|(index, config)| { + let command = UserCommand::new(&config.command); + + App { + enable: config.enable.unwrap_or(applications_config.enable), + #[allow(clippy::obfuscated_if_else)] + name: config + .name + .is_empty() + .then(|| format!("App {}", index + 1)) + .unwrap_or_else(|| config.name.clone()), + icon: Icon::try_from_path(config.icon.as_deref()) + .or_else(|| Icon::try_from_command(&command)), + command, + display: config + .display + .or(applications_config.display) + .unwrap_or_default(), + show_command_on_hover: config + .show_command_on_hover + .or(applications_config.show_command_on_hover) + .unwrap_or(false), + } + }) + .collect(); + + Self { + enable: applications_config.enable, + items, + spacing: applications_config.spacing, + } + } +} + +/// A single resolved application entry used at runtime. +#[derive(Clone, Debug)] +pub struct App { + /// Whether this application is enabled. + pub enable: bool, + /// Display name of the application. Defaults to "App N" if not set. + pub name: String, + /// Icon to display for this application, if available. + pub icon: Option, + /// Command to execute when the application is launched. + pub command: UserCommand, + /// Display format (icon, text, or both). + pub display: DisplayFormat, + /// Whether to show the launch command on hover. + pub show_command_on_hover: bool, +} + +impl App { + /// Renders the application button in the provided `Ui` context with a given icon size. + #[inline] + pub fn render(&mut self, ctx: &Context, ui: &mut Ui, icon_config: &IconConfig) { + if self.enable + && SelectableFrame::new(false) + .show(ui, |ui| { + ui.spacing_mut().item_spacing = Vec2::splat(4.0); + + match self.display { + DisplayFormat::Icon => self.draw_icon(ctx, ui, icon_config), + DisplayFormat::Text => self.draw_name(ui), + DisplayFormat::IconAndText => { + self.draw_icon(ctx, ui, icon_config); + self.draw_name(ui); + } + } + + // Add hover text with command information + let response = ui.response(); + if self.show_command_on_hover { + response.on_hover_text(format!("Launch: {}", self.command.as_ref())); + } + }) + .clicked() + { + // Launch the application when clicked + self.command.launch_if_ready(); + } + } + + /// Draws the application's icon within the UI if available, + /// or falls back to a default placeholder icon. + #[inline] + fn draw_icon(&self, ctx: &Context, ui: &mut Ui, icon_config: &IconConfig) { + if let Some(icon) = &self.icon { + icon.draw(ctx, ui, icon_config); + } else { + Icon::draw_fallback(ui, Vec2::splat(icon_config.size)); + } + } + + /// Displays the application's name as a non-selectable label within the UI. + #[inline] + fn draw_name(&self, ui: &mut Ui) { + ui.add(Label::new(&self.name).selectable(false)); + } +} + +/// Holds image/text data to be used as an icon in the UI. +/// This represents source icon data before rendering. +#[derive(Clone, Debug)] +pub enum Icon { + /// RGBA image used for rendering the icon. + Image(ImageIcon), + /// Text-based icon, e.g. from a font like Nerd Fonts. + Text(String), +} + +impl Icon { + /// Attempts to create an [`Icon`] from a string path or text glyph/glyphs. + /// + /// - Environment variables in the path are resolved using [`PathExt::replace_env`]. + /// - Uses [`ImageIcon::try_load`] to load and cache the icon image based on the resolved path. + /// - If the path is invalid but the string is non-empty, it is interpreted as a text-based icon and + /// returned as [`Icon::Text`]. + /// - Returns `None` if the input is empty, `None`, or image loading fails. + #[inline] + pub fn try_from_path(icon: Option<&str>) -> Option { + let icon = icon.map(str::trim)?; + if icon.is_empty() { + return None; + } + + let path = icon.replace_env(); + if !path.is_file() { + return Some(Icon::Text(icon.to_owned())); + } + + let image_icon = ImageIcon::try_load(path.as_ref(), || match image::open(&path) { + Ok(img) => Some(img), + Err(err) => { + tracing::error!("Failed to load icon from {:?}, error: {}", path, err); + None + } + })?; + + Some(Icon::Image(image_icon)) + } + + /// Attempts to create an [`Icon`] by extracting an image from the executable path of a [`UserCommand`]. + /// + /// - Uses [`ImageIcon::try_load`] to load and cache the icon image based on the resolved executable path. + /// - Returns [`Icon::Image`] if an icon is successfully extracted. + /// - Returns `None` if the executable path is unavailable or icon extraction fails. + #[inline] + pub fn try_from_command(_command: &UserCommand) -> Option { + // let path = command.get_executable()?; + // let image_icon = ImageIcon::try_load(path.as_ref(), || { + // let path_str = path.to_str()?; + // windows_icons::get_icon_by_path(path_str) + // .or_else(|| windows_icons_fallback::get_icon_by_path(path_str)) + // })?; + // Some(Icon::Image(image_icon)) + None + } + + /// Renders the icon in the given [`Ui`] using the provided [`IconConfig`]. + #[inline] + pub fn draw(&self, ctx: &Context, ui: &mut Ui, icon_config: &IconConfig) { + match self { + Icon::Image(image_icon) => { + Frame::NONE + .inner_margin(Margin::same(ui.style().spacing.button_padding.y as i8)) + .show(ui, |ui| { + ui.add( + Image::from_texture(&image_icon.texture(ctx)) + .maintain_aspect_ratio(true) + .fit_to_exact_size(Vec2::splat(icon_config.size)), + ); + }); + } + Icon::Text(icon) => { + let rich_text = RichText::new(icon) + .font(icon_config.font_id.clone()) + .size(icon_config.size) + .color(icon_config.color); + ui.add(Label::new(rich_text).selectable(false)); + } + } + } + + /// Draws a fallback icon when the specified icon cannot be loaded. + /// Displays a simple crossed-out rectangle as a placeholder. + #[inline] + pub fn draw_fallback(ui: &mut Ui, icon_size: Vec2) { + let (response, painter) = ui.allocate_painter(icon_size, Sense::hover()); + let stroke = Stroke::new(1.0, ui.style().visuals.text_color()); + let mut rect = response.rect; + let rounding = CornerRadius::same((rect.width() * 0.1) as u8); + rect = rect.shrink(stroke.width); + let c = rect.center(); + let r = rect.width() / 2.0; + painter.rect_stroke(rect, rounding, stroke, StrokeKind::Outside); + painter.line_segment([c - vec2(r, r), c + vec2(r, r)], stroke); + } +} + +/// Configuration structure for icon rendering +#[derive(Clone, Debug)] +pub struct IconConfig { + /// Font used for text-based icons + pub font_id: FontId, + /// Size of the icon + pub size: f32, + /// Color of the icon used for text-based icons + pub color: Color32, +} + +/// A structure to manage command execution with cooldown prevention. +#[derive(Clone, Debug)] +pub struct UserCommand { + /// The command string to execute + pub command: Arc, + /// Last time this command was executed (used for cooldown control) + pub last_launch: Instant, +} + +impl AsRef for UserCommand { + #[inline] + fn as_ref(&self) -> &str { + &self.command + } +} + +impl UserCommand { + /// Creates a new [`UserCommand`] with environment variables in the command path + /// resolved using [`PathExt::replace_env`]. + #[inline] + pub fn new(command: &str) -> Self { + // Allow immediate launch by initializing last_launch in the past + let last_launch = Instant::now() - 2 * MIN_LAUNCH_INTERVAL; + + Self { + command: Arc::from(command.replace_env().to_str().unwrap_or_default()), + last_launch, + } + } + + // /// Attempts to resolve the executable path from the command string. + // /// + // /// Resolution logic: + // /// - Splits the command by ".exe" and checks if the first part is an existing file. + // /// - If not, attempts to locate the binary using [`which`] on this name. + // /// - If still unresolved, takes the first word (separated by whitespace) and attempts + // /// to find it in the system `PATH` using [`which`]. + // /// + // /// Returns `None` if no executable path can be determined. + // #[inline] + // pub fn get_executable(&self) -> Option> { + // if let Some(binary) = self.command.split(".exe").next().map(Path::new) { + // if binary.is_file() { + // return Some(Cow::Borrowed(binary)); + // } else if let Ok(binary) = which(binary) { + // return Some(Cow::Owned(binary)); + // } + // } + // + // which(self.command.split(' ').next()?).ok().map(Cow::Owned) + // } + + /// Attempts to launch the specified command in a separate thread if enough time has passed + /// since the last launch. This prevents repeated launches from rapid consecutive clicks. + /// + /// Errors during launch are logged using the `tracing` crate. + pub fn launch_if_ready(&mut self) { + let now = Instant::now(); + // Check if enough time has passed since the last launch + if now.duration_since(self.last_launch) < MIN_LAUNCH_INTERVAL { + return; + } + + self.last_launch = now; + let command_string = self.command.clone(); + // Launch the application in a separate thread to avoid blocking the UI + std::thread::spawn(move || { + if let Err(e) = Command::new("cmd").args(["/C", &command_string]).spawn() { + tracing::error!("Failed to launch command '{}': {}", command_string, e); + } + }); + } +} diff --git a/komorebi-bar/src/widgets/battery.rs b/komorebi-bar/src/widgets/battery.rs new file mode 100644 index 00000000..f44ebe1d --- /dev/null +++ b/komorebi-bar/src/widgets/battery.rs @@ -0,0 +1,189 @@ +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use starship_battery::Manager; +use starship_battery::State; +use starship_battery::units::ratio::percent; +use std::process::Command; +use std::time::Duration; +use std::time::Instant; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct BatteryConfig { + /// Enable the Battery widget + pub enable: bool, + /// Hide the widget if the battery is at full charge + pub hide_on_full_charge: Option, + /// Data refresh interval (default: 10 seconds) + pub data_refresh_interval: Option, + /// Display label prefix + pub label_prefix: Option, + /// Select when the current percentage is under this value [[1-100]] + pub auto_select_under: Option, +} + +impl From for Battery { + fn from(value: BatteryConfig) -> Self { + let data_refresh_interval = value.data_refresh_interval.unwrap_or(10); + + Self { + enable: value.enable, + hide_on_full_charge: value.hide_on_full_charge.unwrap_or(false), + manager: Manager::new().unwrap(), + last_state: None, + data_refresh_interval, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::Icon), + auto_select_under: value.auto_select_under.map(|u| u.clamp(1, 100)), + state: BatteryState::Discharging, + last_updated: Instant::now() + .checked_sub(Duration::from_secs(data_refresh_interval)) + .unwrap(), + } + } +} + +pub enum BatteryState { + Charging, + Discharging, + High, + Medium, + Low, + Warning, +} + +#[derive(Clone, Debug)] +struct BatteryOutput { + label: String, + selected: bool, +} + +pub struct Battery { + pub enable: bool, + hide_on_full_charge: bool, + manager: Manager, + pub state: BatteryState, + data_refresh_interval: u64, + label_prefix: LabelPrefix, + auto_select_under: Option, + last_state: Option, + last_updated: Instant, +} + +impl Battery { + fn output(&mut self) -> Option { + let mut output = self.last_state.clone(); + + let now = Instant::now(); + if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) { + output = None; + + if let Ok(mut batteries) = self.manager.batteries() + && let Some(Ok(first)) = batteries.nth(0) + { + let percentage = first.state_of_charge().get::().round() as u8; + + if percentage == 100 && self.hide_on_full_charge { + output = None + } else { + match first.state() { + State::Charging => self.state = BatteryState::Charging, + State::Discharging => { + self.state = match percentage { + p if p > 75 => BatteryState::Discharging, + p if p > 50 => BatteryState::High, + p if p > 25 => BatteryState::Medium, + p if p > 10 => BatteryState::Low, + _ => BatteryState::Warning, + } + } + _ => {} + } + + let selected = self.auto_select_under.is_some_and(|u| percentage <= u); + + output = Some(BatteryOutput { + label: match self.label_prefix { + LabelPrefix::Text | LabelPrefix::IconAndText => { + format!("BAT: {percentage}%") + } + LabelPrefix::None | LabelPrefix::Icon => { + format!("{percentage}%") + } + }, + selected, + }) + } + } + + self.last_state.clone_from(&output); + self.last_updated = now; + } + + output + } +} + +impl BarWidget for Battery { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let output = self.output(); + if let Some(output) = output { + let emoji = match self.state { + BatteryState::Charging => egui_phosphor::regular::BATTERY_CHARGING, + BatteryState::Discharging => egui_phosphor::regular::BATTERY_FULL, + BatteryState::High => egui_phosphor::regular::BATTERY_HIGH, + BatteryState::Medium => egui_phosphor::regular::BATTERY_MEDIUM, + BatteryState::Low => egui_phosphor::regular::BATTERY_LOW, + BatteryState::Warning => egui_phosphor::regular::BATTERY_WARNING, + }; + + let auto_text_color = config.auto_select_text.filter(|_| output.selected); + + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => emoji.to_string(), + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + auto_text_color.unwrap_or(ctx.style().visuals.selection.stroke.color), + 100.0, + ); + + layout_job.append( + &output.label, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: auto_text_color.unwrap_or(ctx.style().visuals.text_color()), + valign: Align::Center, + ..Default::default() + }, + ); + + let auto_focus_fill = config.auto_select_fill; + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new_auto(output.selected, auto_focus_fill) + .show(ui, |ui| ui.add(Label::new(layout_job).selectable(false))) + .clicked() + && let Err(error) = Command::new("cmd.exe") + .args(["/C", "start", "ms-settings:batterysaver"]) + .spawn() + { + eprintln!("{error}") + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/cpu.rs b/komorebi-bar/src/widgets/cpu.rs new file mode 100644 index 00000000..9fff789a --- /dev/null +++ b/komorebi-bar/src/widgets/cpu.rs @@ -0,0 +1,132 @@ +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use std::process::Command; +use std::time::Duration; +use std::time::Instant; +use sysinfo::RefreshKind; +use sysinfo::System; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct CpuConfig { + /// Enable the Cpu widget + pub enable: bool, + /// Data refresh interval (default: 10 seconds) + pub data_refresh_interval: Option, + /// Display label prefix + pub label_prefix: Option, + /// Select when the current percentage is over this value [[1-100]] + pub auto_select_over: Option, +} + +impl From for Cpu { + fn from(value: CpuConfig) -> Self { + let data_refresh_interval = value.data_refresh_interval.unwrap_or(10); + + Self { + enable: value.enable, + system: System::new_with_specifics( + RefreshKind::default().without_memory().without_processes(), + ), + data_refresh_interval, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::IconAndText), + auto_select_over: value.auto_select_over.map(|o| o.clamp(1, 100)), + last_updated: Instant::now() + .checked_sub(Duration::from_secs(data_refresh_interval)) + .unwrap(), + } + } +} + +#[derive(Clone, Debug)] +struct CpuOutput { + label: String, + selected: bool, +} + +pub struct Cpu { + pub enable: bool, + system: System, + data_refresh_interval: u64, + label_prefix: LabelPrefix, + auto_select_over: Option, + last_updated: Instant, +} + +impl Cpu { + fn output(&mut self) -> CpuOutput { + let now = Instant::now(); + if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) { + self.system.refresh_cpu_usage(); + self.last_updated = now; + } + + let used = self.system.global_cpu_usage() as u8; + let selected = self.auto_select_over.is_some_and(|o| used >= o); + + CpuOutput { + label: match self.label_prefix { + LabelPrefix::Text | LabelPrefix::IconAndText => format!("CPU: {used}%"), + LabelPrefix::None | LabelPrefix::Icon => format!("{used}%"), + }, + selected, + } + } +} + +impl BarWidget for Cpu { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let output = self.output(); + if !output.label.is_empty() { + let auto_text_color = config.auto_select_text.filter(|_| output.selected); + + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + egui_phosphor::regular::CPU.to_string() + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + auto_text_color.unwrap_or(ctx.style().visuals.selection.stroke.color), + 100.0, + ); + + layout_job.append( + &output.label, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: auto_text_color.unwrap_or(ctx.style().visuals.text_color()), + valign: Align::Center, + ..Default::default() + }, + ); + + let auto_focus_fill = config.auto_select_fill; + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new_auto(output.selected, auto_focus_fill) + .show(ui, |ui| ui.add(Label::new(layout_job).selectable(false))) + .clicked() + && let Err(error) = + Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn() + { + eprintln!("{error}") + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/date.rs b/komorebi-bar/src/widgets/date.rs new file mode 100644 index 00000000..5fe662fa --- /dev/null +++ b/komorebi-bar/src/widgets/date.rs @@ -0,0 +1,240 @@ +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use chrono::Local; +use chrono_tz::Tz; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::WidgetText; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use std::time::Duration; +use std::time::Instant; + +/// Custom format with additive modifiers for integer format specifiers +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct CustomModifiers { + /// Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html) + format: String, + /// Additive modifiers for integer format specifiers (e.g. { "%U": 1 } to increment the zero-indexed week number by 1) + modifiers: std::collections::HashMap, +} + +impl CustomModifiers { + fn apply(&self, output: &str) -> String { + let int_formatters = vec![ + "%Y", "%C", "%y", "%m", "%d", "%e", "%w", "%u", "%U", "%W", "%G", "%g", "%V", "%j", + "%H", "%k", "%I", "%l", "%M", "%S", "%f", + ]; + + let mut modified_output = output.to_string(); + + for (modifier, value) in &self.modifiers { + // check if formatter is integer type + if !int_formatters.contains(&modifier.as_str()) { + continue; + } + + // get the strftime value of modifier + let formatted_modifier = Local::now().format(modifier).to_string(); + + // find the gotten value in the original output + if let Some(pos) = modified_output.find(&formatted_modifier) { + let start = pos; + let end = start + formatted_modifier.len(); + // replace that value with the modified value + if let Ok(num) = formatted_modifier.parse::() { + modified_output.replace_range(start..end, &(num + value).to_string()); + } + } + } + + modified_output + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct DateConfig { + /// Enable the Date widget + pub enable: bool, + /// Set the Date format + pub format: DateFormat, + /// Display label prefix + pub label_prefix: Option, + /// TimeZone (https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html) + /// + /// Use a custom format to display additional information, i.e.: + /// ```json + /// { + /// "Date": { + /// "enable": true, + /// "format": { "Custom": "%D %Z (Tokyo)" }, + /// "timezone": "Asia/Tokyo" + /// } + ///} + /// ``` + pub timezone: Option, +} + +impl From for Date { + fn from(value: DateConfig) -> Self { + let data_refresh_interval = 1; + + Self { + enable: value.enable, + format: value.format, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::Icon), + timezone: value.timezone, + data_refresh_interval, + last_state: String::new(), + last_updated: Instant::now() + .checked_sub(Duration::from_secs(data_refresh_interval)) + .unwrap(), + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum DateFormat { + /// Month/Date/Year format (09/08/24) + MonthDateYear, + /// Year-Month-Date format (2024-09-08) + YearMonthDate, + /// Date-Month-Year format (8-Sep-2024) + DateMonthYear, + /// Day Date Month Year format (8 September 2024) + DayDateMonthYear, + /// Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html) + Custom(String), + /// Custom format with modifiers + CustomModifiers(CustomModifiers), +} + +impl DateFormat { + pub fn next(&mut self) { + match self { + DateFormat::MonthDateYear => *self = Self::YearMonthDate, + DateFormat::YearMonthDate => *self = Self::DateMonthYear, + DateFormat::DateMonthYear => *self = Self::DayDateMonthYear, + DateFormat::DayDateMonthYear => *self = Self::MonthDateYear, + _ => {} + }; + } + + pub fn fmt_string(&self) -> String { + match self { + DateFormat::MonthDateYear => String::from("%D"), + DateFormat::YearMonthDate => String::from("%F"), + DateFormat::DateMonthYear => String::from("%v"), + DateFormat::DayDateMonthYear => String::from("%A %e %B %Y"), + DateFormat::Custom(custom) => custom.to_string(), + DateFormat::CustomModifiers(custom) => custom.format.clone(), + } + } +} + +#[derive(Clone, Debug)] +pub struct Date { + pub enable: bool, + pub format: DateFormat, + label_prefix: LabelPrefix, + timezone: Option, + data_refresh_interval: u64, + last_state: String, + last_updated: Instant, +} + +impl Date { + fn output(&mut self) -> String { + let mut output = self.last_state.clone(); + let now = Instant::now(); + + if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) { + let formatted = match &self.timezone { + Some(timezone) => match timezone.parse::() { + Ok(tz) => Local::now() + .with_timezone(&tz) + .format(&self.format.fmt_string()) + .to_string() + .trim() + .to_string(), + Err(_) => format!("Invalid timezone: {timezone}"), + }, + None => Local::now() + .format(&self.format.fmt_string()) + .to_string() + .trim() + .to_string(), + }; + + // if custom modifiers are used, apply them + output = match &self.format { + DateFormat::CustomModifiers(custom) => custom.apply(&formatted), + _ => formatted, + }; + + self.last_state.clone_from(&output); + self.last_updated = now; + } + + output + } +} + +impl BarWidget for Date { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let mut output = self.output(); + if !output.is_empty() { + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + egui_phosphor::regular::CALENDAR_DOTS.to_string() + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + ctx.style().visuals.selection.stroke.color, + 100.0, + ); + + if let LabelPrefix::Text | LabelPrefix::IconAndText = self.label_prefix { + output.insert_str(0, "DATE: "); + } + + layout_job.append( + &output, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: ctx.style().visuals.text_color(), + valign: Align::Center, + ..Default::default() + }, + ); + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new(false) + .show(ui, |ui| { + ui.add( + Label::new(WidgetText::LayoutJob(layout_job.clone())) + .selectable(false), + ) + }) + .clicked() + { + self.format.next() + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/keyboard.rs b/komorebi-bar/src/widgets/keyboard.rs new file mode 100644 index 00000000..8e7f4c33 --- /dev/null +++ b/komorebi-bar/src/widgets/keyboard.rs @@ -0,0 +1,177 @@ +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::WidgetText; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use std::time::Duration; +use std::time::Instant; +use windows::Win32::Globalization::LCIDToLocaleName; +use windows::Win32::Globalization::LOCALE_ALLOW_NEUTRAL_NAMES; +use windows::Win32::System::SystemServices::LOCALE_NAME_MAX_LENGTH; +use windows::Win32::UI::Input::KeyboardAndMouse::GetKeyboardLayout; +use windows::Win32::UI::WindowsAndMessaging::GetForegroundWindow; +use windows::Win32::UI::WindowsAndMessaging::GetWindowThreadProcessId; + +const DEFAULT_DATA_REFRESH_INTERVAL: u64 = 1; +const ERROR_TEXT: &str = "Error"; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KeyboardConfig { + /// Enable the Input widget + pub enable: bool, + /// Data refresh interval (default: 1 second) + pub data_refresh_interval: Option, + /// Display label prefix + pub label_prefix: Option, +} + +impl From for Keyboard { + fn from(value: KeyboardConfig) -> Self { + let data_refresh_interval = value + .data_refresh_interval + .unwrap_or(DEFAULT_DATA_REFRESH_INTERVAL); + + Self { + enable: value.enable, + data_refresh_interval, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::IconAndText), + last_updated: Instant::now(), + lang_name: get_lang(), + } + } +} + +pub struct Keyboard { + pub enable: bool, + data_refresh_interval: u64, + label_prefix: LabelPrefix, + last_updated: Instant, + lang_name: String, +} + +/// Retrieves the name of the active keyboard layout for the current foreground window. +/// +/// This function determines the active keyboard layout by querying the system for the +/// foreground window's thread ID and its associated keyboard layout. It then attempts +/// to retrieve the locale name corresponding to the keyboard layout. +/// +/// # Failure Cases +/// +/// This function can fail in two distinct scenarios: +/// +/// 1. **Failure to Retrieve the Locale Name**: +/// If the system fails to retrieve the locale name (e.g., due to an invalid or unsupported +/// language identifier), the function will return `Err(())`. +/// +/// 2. **Invalid UTF-16 Characters in the Locale Name**: +/// If the retrieved locale name contains invalid UTF-16 sequences, the conversion to a Rust +/// `String` will fail, and the function will return `Err(())`. +/// +/// # Returns +/// +/// - `Ok(String)`: The name of the active keyboard layout as a valid UTF-8 string. +/// - `Err(())`: Indicates that the function failed to retrieve the locale name or encountered +/// invalid UTF-16 characters during conversion. +fn get_active_keyboard_layout() -> Result { + let foreground_window_tid = unsafe { GetWindowThreadProcessId(GetForegroundWindow(), None) }; + let lcid = unsafe { GetKeyboardLayout(foreground_window_tid) }; + + // Extract the low word (language identifier) from the keyboard layout handle. + let lang_id = (lcid.0 as u32) & 0xFFFF; + let mut locale_name_buffer = [0; LOCALE_NAME_MAX_LENGTH as usize]; + let char_count = unsafe { + LCIDToLocaleName( + lang_id, + Some(&mut locale_name_buffer), + LOCALE_ALLOW_NEUTRAL_NAMES, + ) + }; + + match char_count { + 0 => Err(()), + _ => String::from_utf16(&locale_name_buffer[..char_count as usize]).map_err(|_| ()), + } +} + +/// Retrieves the name of the active keyboard layout or a fallback error message. +/// +/// # Behavior +/// +/// - **Success Case**: +/// If [`get_active_keyboard_layout`] succeeds, this function returns the retrieved keyboard +/// layout name as a `String`. +/// +/// - **Failure Case**: +/// If [`get_active_keyboard_layout`] fails, this function returns the value of `ERROR_TEXT` +/// as a fallback message. This ensures that the function always returns a valid `String`, +/// even in error scenarios. +/// +/// # Returns +/// +/// A `String` representing either: +/// - The name of the active keyboard layout, or +/// - The fallback error message (`ERROR_TEXT`) if the layout name cannot be retrieved. +fn get_lang() -> String { + get_active_keyboard_layout() + .map(|l| l.trim_end_matches('\0').to_string()) + .unwrap_or_else(|_| ERROR_TEXT.to_string()) +} + +impl Keyboard { + fn output(&mut self) -> String { + let now = Instant::now(); + if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) { + self.last_updated = now; + self.lang_name = get_lang(); + } + + match self.label_prefix { + LabelPrefix::Text | LabelPrefix::IconAndText => format!("KB: {}", self.lang_name), + LabelPrefix::None | LabelPrefix::Icon => self.lang_name.clone(), + } + } +} + +impl BarWidget for Keyboard { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let output = self.output(); + if !output.is_empty() { + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + egui_phosphor::regular::KEYBOARD.to_string() + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + ctx.style().visuals.selection.stroke.color, + 100.0, + ); + + layout_job.append( + &output, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: ctx.style().visuals.text_color(), + valign: Align::Center, + ..Default::default() + }, + ); + + config.apply_on_widget(true, ui, |ui| { + ui.add(Label::new(WidgetText::LayoutJob(layout_job.clone())).selectable(false)) + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/komorebi.rs b/komorebi-bar/src/widgets/komorebi.rs new file mode 100644 index 00000000..c3ad933c --- /dev/null +++ b/komorebi-bar/src/widgets/komorebi.rs @@ -0,0 +1,1015 @@ +use super::ImageIcon; +use crate::MAX_LABEL_WIDTH; +use crate::MONITOR_INDEX; +use crate::config::DisplayFormat; +use crate::config::DisplayFormat::*; +use crate::config::WorkspacesDisplayFormat; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::ui::CustomUi; +use crate::widgets::komorebi_layout::KomorebiLayout; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Color32; +use eframe::egui::Context; +use eframe::egui::CornerRadius; +use eframe::egui::FontId; +use eframe::egui::Frame; +use eframe::egui::Image; +use eframe::egui::Label; +use eframe::egui::Margin; +use eframe::egui::Response; +use eframe::egui::RichText; +use eframe::egui::Sense; +use eframe::egui::Stroke; +use eframe::egui::StrokeKind; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::Vec2; +use eframe::egui::text::LayoutJob; +use eframe::egui::vec2; +use komorebi_client::Container; +use komorebi_client::PathExt; +use komorebi_client::Rect; +use komorebi_client::SocketMessage; +use komorebi_client::SocketMessage::*; +use komorebi_client::State; +use komorebi_client::Window; +use komorebi_client::Workspace; +use komorebi_client::WorkspaceLayer; +use serde::Deserialize; +use serde::Serialize; +use std::cell::RefCell; +use std::collections::BTreeMap; +use std::collections::HashMap; +use std::io::Result as IoResult; +use std::path::Path; +use std::rc::Rc; +use std::sync::atomic::Ordering; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KomorebiConfig { + /// Configure the Workspaces widget + pub workspaces: Option, + /// Configure the Layout widget + pub layout: Option, + /// Configure the Workspace Layer widget + pub workspace_layer: Option, + /// Configure the Focused Container widget + #[serde(alias = "focused_window")] + pub focused_container: Option, + /// Configure the Locked Container widget + pub locked_container: Option, + /// Configure the Configuration Switcher widget + pub configuration_switcher: Option, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KomorebiWorkspacesConfig { + /// Enable the Komorebi Workspaces widget + pub enable: bool, + /// Hide workspaces without any windows + pub hide_empty_workspaces: bool, + /// Display format of the workspace + pub display: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KomorebiLayoutConfig { + /// Enable the Komorebi Layout widget + pub enable: bool, + /// List of layout options + pub options: Option>, + /// Display format of the current layout + pub display: Option, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KomorebiWorkspaceLayerConfig { + /// Enable the Komorebi Workspace Layer widget + pub enable: bool, + /// Display format of the current layer + pub display: Option, + /// Show the widget event if the layer is Tiling + pub show_when_tiling: Option, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KomorebiFocusedContainerConfig { + /// Enable the Komorebi Focused Container widget + pub enable: bool, + /// DEPRECATED: use 'display' instead (Show the icon of the currently focused container) + pub show_icon: Option, + /// Display format of the currently focused container + pub display: Option, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KomorebiLockedContainerConfig { + /// Enable the Komorebi Locked Container widget + pub enable: bool, + /// Display format of the current locked state + pub display: Option, + /// Show the widget event if the layer is unlocked + pub show_when_unlocked: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct KomorebiConfigurationSwitcherConfig { + /// Enable the Komorebi Configurations widget + pub enable: bool, + /// A map of display friendly name => path to configuration.json + pub configurations: BTreeMap, +} + +impl From<&KomorebiConfig> for Komorebi { + fn from(cfg: &KomorebiConfig) -> Self { + let configuration_switcher = cfg.configuration_switcher.clone().map(|mut cs| { + for location in cs.configurations.values_mut() { + let path = Path::new(location).replace_env(); + *location = dunce::simplified(&path).to_string_lossy().to_string(); + } + cs + }); + + Self { + monitor_info: Rc::new(RefCell::new(MonitorInfo { + hide_empty_workspaces: cfg + .workspaces + .map(|w| w.hide_empty_workspaces) + .unwrap_or_default(), + ..Default::default() + })), + workspaces: cfg.workspaces.and_then(WorkspacesBar::try_from), + layout: cfg.layout.clone(), + focused_container: cfg + .focused_container + .and_then(FocusedContainerBar::try_from), + workspace_layer: cfg.workspace_layer.and_then(WorkspaceLayerBar::try_from), + locked_container: cfg.locked_container.and_then(LockedContainerBar::try_from), + configuration_switcher, + } + } +} + +#[derive(Clone, Debug)] +pub struct Komorebi { + pub monitor_info: Rc>, + pub workspaces: Option, + pub layout: Option, + pub focused_container: Option, + pub workspace_layer: Option, + pub locked_container: Option, + pub configuration_switcher: Option, +} + +impl BarWidget for Komorebi { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + self.render_workspaces(ctx, ui, config); + self.render_workspace_layer(ctx, ui, config); + self.render_layout(ctx, ui, config); + self.render_config_switcher(ui, config); + self.render_locked_container(ctx, ui, config); + self.render_focused_container(ctx, ui, config); + } +} + +impl Komorebi { + /// Renders the workspace bar for the current monitor. + /// Updates the focused workspace when a workspace is clicked. + fn render_workspaces(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + let monitor_info = &mut *self.monitor_info.borrow_mut(); + + let bar = match &mut self.workspaces { + Some(wg) if !monitor_info.workspaces.is_empty() => wg, + _ => return, + }; + + bar.text_size = Vec2::splat(config.text_font_id.size); + bar.icon_size = Vec2::splat(config.icon_font_id.size); + + config.apply_on_widget(false, ui, |ui| { + for (index, workspace) in monitor_info.workspaces.iter().enumerate() { + if !workspace.should_show { + continue; + } + + let response = SelectableFrame::new(workspace.is_selected) + .show(ui, |ui| (bar.renderer)(bar, ctx, ui, workspace)); + + if response.clicked() { + let message = FocusMonitorWorkspaceNumber(monitor_info.monitor_index, index); + if Self::send_with_mouse_follow_off(monitor_info, message).is_ok() { + monitor_info.focused_workspace_idx = Some(index); + } + } + } + }); + } + + /// Renders the workspace layer bar for the current monitor. + /// Handles user clicks to toggle the workspace layer. + fn render_workspace_layer(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + let Some(bar) = &self.workspace_layer else { + return; + }; + + let monitor_info = &*self.monitor_info.borrow(); + let Some(layer) = monitor_info.focused_workspace_layer() else { + return; + }; + + if (matches!(layer, WorkspaceLayer::Floating) + || bar.show_when_tiling && matches!(layer, WorkspaceLayer::Tiling)) + { + let size = Vec2::splat(config.icon_font_id.size); + config.apply_on_widget(false, ui, |ui| { + let layer_frame = SelectableFrame::new(false) + .show(ui, |ui| (bar.renderer)(ctx, ui, &layer, size)) + .on_hover_text(layer.to_string()); + + if layer_frame.clicked() { + let _ = Self::send_messages(&[ + FocusMonitorAtCursor, + MouseFollowsFocus(false), + ToggleWorkspaceLayer, + MouseFollowsFocus(monitor_info.mouse_follows_focus), + ]); + } + }); + } + } + + /// Renders the configuration switcher bar. + /// For each available configuration, displays a selectable label. + /// On click, sends a message to replace the current Komorebi configuration. + fn render_config_switcher(&mut self, ui: &mut Ui, config: &mut RenderConfig) { + let configuration_switcher = match &self.configuration_switcher { + Some(config) if config.enable => config, + _ => return, + }; + for (name, location) in configuration_switcher.configurations.iter() { + let path = Path::new(location); + if path.is_file() { + config.apply_on_widget(false, ui, |ui| { + let response = SelectableFrame::new(false) + .show(ui, |ui| ui.add(Label::new(name).selectable(false))); + if response.clicked() { + let path = dunce::canonicalize(path).unwrap_or_else(|_| path.to_owned()); + let _ = Self::send_messages(&[ReplaceConfiguration(path)]); + } + }); + } + } + } + + fn render_layout(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if let Some(layout_config) = &self.layout + && layout_config.enable + { + let monitor_info = &mut *self.monitor_info.borrow_mut(); + let workspace_idx = monitor_info.focused_workspace_idx; + monitor_info + .layout + .show(ctx, ui, config, layout_config, workspace_idx); + } + } + + /// Renders the locked container bar for the current monitor. + /// + /// Shows lock status and allows toggling the lock state when clicked. + /// Only renders if a focused container exists and either the container is locked + /// or `show_when_unlocked` is enabled in the bar configuration. + fn render_locked_container(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + let Some(bar) = &self.locked_container else { + return; + }; + + let monitor_info = &*self.monitor_info.borrow(); + let is_locked = monitor_info + .focused_container() + .map(|container| container.is_locked) + .unwrap_or_default(); + + let (icon_font, txt_font) = (config.icon_font_id.clone(), config.text_font_id.clone()); + if (bar.show_when_unlocked || is_locked) && monitor_info.focused_container().is_some() { + config.apply_on_widget(false, ui, |ui| { + SelectableFrame::new(false) + .show(ui, |ui| { + (bar.renderer)(ctx, ui, is_locked, icon_font, txt_font) + }) + .clicked() + .then(|| Self::send_messages(&[FocusMonitorAtCursor, ToggleLock])); + }); + } + } + + fn render_focused_container(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + let Some(bar) = &self.focused_container else { + return; + }; + let monitor_info = &*self.monitor_info.borrow(); + let Some(container) = monitor_info.focused_container() else { + return; + }; + config.apply_on_widget(false, ui, |ui| { + let (len, focused_idx) = (container.windows.len(), container.focused_window_idx); + + for (idx, window) in container.windows.iter().enumerate() { + let selected = idx == focused_idx && len != 1; + let text_color = if selected { + ctx.style().visuals.selection.stroke.color + } else { + ui.style().visuals.text_color() + }; + + let response = SelectableFrame::new(selected).show(ui, |ui| { + (bar.renderer)(bar, ctx, ui, window, text_color, idx == focused_idx) + }); + + if response.clicked() && !selected { + let _ = Self::send_with_mouse_follow_off(monitor_info, FocusStackWindow(idx)); + } + } + }); + } + + /// Sends a message to Komorebi, temporarily disabling MouseFollowsFocus if it's enabled. + fn send_with_mouse_follow_off(monitor: &MonitorInfo, message: SocketMessage) -> IoResult<()> { + let messages: &[SocketMessage] = if monitor.mouse_follows_focus { + &[MouseFollowsFocus(false), message, MouseFollowsFocus(true)] + } else { + &[message] + }; + Self::send_messages(messages) + } + + /// Sends a batch of messages to Komorebi, logging errors on failure. + fn send_messages(messages: &[SocketMessage]) -> IoResult<()> { + komorebi_client::send_batch(messages).map_err(|err| { + tracing::error!("Failed to send message(s): {:?}\nError: {}", messages, err); + err + }) + } +} + +/// Workspace bar with a pre-selected render strategy for efficient +/// workspace display +#[derive(Clone, Debug)] +pub struct WorkspacesBar { + /// Chosen rendering function for this widget + renderer: fn(&Self, &Context, &mut Ui, &WorkspaceInfo), + /// Text size (default: 12.5) + text_size: Vec2, + /// Icon size (default: 12.5 * 1.4) + icon_size: Vec2, +} + +impl WorkspacesBar { + /// Creates a `WorkspacesBar` instance from a workspace configuration. + /// + /// Selects a render strategy based on the given display format + /// for optimal performance. Returns `None` if the widget is disabled. + fn try_from(value: KomorebiWorkspacesConfig) -> Option { + use WorkspacesDisplayFormat::*; + if !value.enable { + return None; + } + // Selects a render strategy according to the workspace config's display format + // for better performance + let renderer: fn(&Self, &Context, &mut Ui, &WorkspaceInfo) = + match value.display.unwrap_or(DisplayFormat::Text.into()) { + // 1: Show icons if any, fallback if none | Only hover workspace name + AllIcons | Existing(DisplayFormat::Icon) => |bar, ctx, ui, ws| { + bar.show_icons(ctx, ui, ws) + .unwrap_or_else(|| bar.show_fallback_icon(ctx, ui, ws)) + .on_hover_text(&ws.name); + }, + // 2: Show icons, with no fallback | Label workspace name (no hover) + AllIconsAndText | Existing(DisplayFormat::IconAndText) => |bar, ctx, ui, ws| { + bar.show_icons(ctx, ui, ws); + Self::show_label(ctx, ui, ws); + }, + // 3: Show icons, fallback if no icons and not selected | Label workspace name if selected else hover + AllIconsAndTextOnSelected | Existing(DisplayFormat::IconAndTextOnSelected) => { + |bar, ctx, ui, ws| { + if bar.show_icons(ctx, ui, ws).is_none() && !ws.is_selected { + bar.show_fallback_icon(ctx, ui, ws); + } + if ws.is_selected { + Self::show_label(ctx, ui, ws); + } else { + ui.response().on_hover_text(&ws.name); + } + } + } + // 4: Show icons if selected and has icons (no fallback) | Label workspace name + Existing(DisplayFormat::TextAndIconOnSelected) => |bar, ctx, ui, ws| { + if ws.is_selected { + bar.show_icons(ctx, ui, ws); + } + Self::show_label(ctx, ui, ws); + }, + // 5: Never show icon (no icons at all) | Label workspace name always + Existing(DisplayFormat::Text) => |_, ctx, ui, ws| { + Self::show_label(ctx, ui, ws); + }, + }; + + Some(Self { + renderer, + icon_size: Vec2::splat(12.5), + text_size: Vec2::splat(12.5 * 1.4), + }) + } + + /// Draws all window icons for the workspace, using larger size for the focused container. + /// Returns response if icons exist, or None. + fn show_icons(&self, ctx: &Context, ui: &mut Ui, ws: &WorkspaceInfo) -> Option { + ws.has_icons.then(|| { + Frame::NONE + .inner_margin(Margin::same(ui.style().spacing.button_padding.y as i8)) + .show(ui, |ui| { + for container in &ws.containers { + for icon in container.windows.iter().filter_map(|win| win.icon.as_ref()) { + ui.add( + Image::from(&icon.texture(ctx)) + .maintain_aspect_ratio(true) + .fit_to_exact_size(if container.is_focused { + self.icon_size + } else { + self.text_size + }), + ); + } + } + }) + .response + }) + } + + /// Draws a fallback icon (a rectangle with a diagonal) for the workspace. + fn show_fallback_icon(&self, ctx: &Context, ui: &mut Ui, ws: &WorkspaceInfo) -> Response { + let (response, painter) = ui.allocate_painter(self.icon_size, Sense::hover()); + let stroke: Stroke = Stroke::new( + 1.0, + if ws.is_selected { + ctx.style().visuals.selection.stroke.color + } else { + ui.style().visuals.text_color() + }, + ); + let mut rect = response.rect; + let rounding = CornerRadius::same((rect.width() * 0.1) as u8); + rect = rect.shrink(stroke.width); + let c = rect.center(); + let r = rect.width() / 2.0; + painter.rect_stroke(rect, rounding, stroke, StrokeKind::Outside); + painter.line_segment([c - vec2(r, r), c + vec2(r, r)], stroke); + response + } + + /// Shows the workspace label (colored if selected). + fn show_label(ctx: &Context, ui: &mut Ui, ws: &WorkspaceInfo) -> Response { + if ws.is_selected { + let text = RichText::new(&ws.name).color(ctx.style().visuals.selection.stroke.color); + ui.add(Label::new(text).selectable(false)) + } else { + ui.add(Label::new(&ws.name).selectable(false)) + } + } +} + +/// Structure for displaying the focused container's windows in the bar. +/// Uses a pre-selected rendering strategy (based on config) for efficient display +#[derive(Clone, Debug)] +pub struct FocusedContainerBar { + /// Chosen rendering function for this widget + renderer: fn(&Self, &Context, &mut Ui, &WindowInfo, Color32, focused: bool), + /// Icon size (default: 12.5 * 1.4) + icon_size: Vec2, +} + +impl FocusedContainerBar { + /// Creates a `FocusedContainerBar` from the given configuration. + /// + /// Selects a render strategy based on the display format or legacy icon setting. + /// Returns `None` if the widget is disabled. + fn try_from(value: KomorebiFocusedContainerConfig) -> Option { + if !value.enable { + return None; + } + // Handle legacy setting - convert show_icon to display format + let format = value + .display + .unwrap_or(if value.show_icon.unwrap_or(false) { + IconAndText + } else { + Text + }); + + // Select renderer strategy based on display format for better performance + let renderer: fn(&FocusedContainerBar, &Context, &mut Ui, &WindowInfo, Color32, bool) = + match format { + Icon => |_self, ctx, ui, info, _color, _focused| { + FocusedContainerBar::show_icon::(_self, ctx, ui, info); + }, + Text => |_self, _ctx, ui, info, color, _focused| { + FocusedContainerBar::show_title(_self, ui, info, color); + }, + IconAndText => |_self, ctx, ui, info, color, _focused| { + FocusedContainerBar::show_icon::(_self, ctx, ui, info); + FocusedContainerBar::show_title(_self, ui, info, color); + }, + IconAndTextOnSelected => |_self, ctx, ui, info, color, focused| { + FocusedContainerBar::show_icon::(_self, ctx, ui, info); + if focused { + FocusedContainerBar::show_title(_self, ui, info, color); + } + }, + TextAndIconOnSelected => |_self, ctx, ui, info, color, focused| { + if focused { + FocusedContainerBar::show_icon::(_self, ctx, ui, info); + } + FocusedContainerBar::show_title(_self, ui, info, color); + }, + }; + + Some(FocusedContainerBar { + renderer, + icon_size: Vec2::splat(12.5 * 1.4), + }) + } + + /// Draws window icon(s) at configured size; adds hover text if HOVEL is true. + fn show_icon(&self, ctx: &Context, ui: &mut Ui, info: &WindowInfo) { + let inner_response = Frame::NONE + .inner_margin(Margin::same(ui.style().spacing.button_padding.y as i8)) + .show(ui, |ui| { + for icon in info.icon.iter() { + let img = Image::from(&icon.texture(ctx)).maintain_aspect_ratio(true); + ui.add(img.fit_to_exact_size(self.icon_size)); + } + }); + if HOVEL && let Some(title) = &info.title { + inner_response.response.on_hover_text(title); + } + } + + /// Renders the window title label in color, truncating if needed. + fn show_title(&self, ui: &mut Ui, info: &WindowInfo, color: Color32) { + if let Some(title) = &info.title { + let text = Label::new(RichText::new(title).color(color)).selectable(false); + + let x = MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32; + let y = ui.available_height(); + CustomUi(ui).add_sized_left_to_right(Vec2::new(x, y), text.truncate()); + } + } +} + +/// Workspace layer bar with a pre-selected render strategy for efficient +/// layer display +#[derive(Clone, Debug)] +pub struct WorkspaceLayerBar { + /// Show the widget even if the layer is Tiling + show_when_tiling: bool, + /// Chosen rendering function for this widget + renderer: fn(&Context, &mut Ui, &WorkspaceLayer, Vec2), +} + +impl WorkspaceLayerBar { + /// Creates a `WorkspaceLayerBar` from the given configuration. + /// + /// Selects a render strategy based on the display format. + /// Returns `None` if the widget is disabled. + fn try_from(value: KomorebiWorkspaceLayerConfig) -> Option { + if !value.enable { + return None; + } + let display_format = value.display.unwrap_or(Text); + + // Select renderer strategy based on display format for better performance + let renderer: fn(&Context, &mut Ui, &WorkspaceLayer, Vec2) = match display_format { + Icon => Self::draw_layer_icon, + Text => |_ctx, ui, layer, _size| { + ui.add(Label::new(layer.to_string()).selectable(false)); + }, + _ => |ctx, ui, layer, size| { + Self::draw_layer_icon(ctx, ui, layer, size); + ui.add(Label::new(layer.to_string()).selectable(false)); + }, + }; + + Some(Self { + show_when_tiling: value.show_when_tiling.unwrap_or_default(), + renderer, + }) + } + + /// Draws an icon representing the current workspace layer. + fn draw_layer_icon(ctx: &Context, ui: &mut Ui, layer: &WorkspaceLayer, size: Vec2) { + if matches!(layer, WorkspaceLayer::Tiling) { + let (response, painter) = ui.allocate_painter(size, Sense::hover()); + let color = ctx.style().visuals.selection.stroke.color; + let stroke = Stroke::new(1.0, color); + let mut rect = response.rect; + let corner = CornerRadius::same((rect.width() * 0.1) as u8); + rect = rect.shrink(stroke.width); + + // tiling + let mut rect_left = response.rect; + rect_left.set_width(rect.width() * 0.48); + rect_left.set_height(rect.height() * 0.98); + let mut rect_right = rect_left; + rect_left = rect_left.translate(Vec2::new( + rect.width() * 0.01 + stroke.width, + rect.width() * 0.01 + stroke.width, + )); + rect_right = rect_right.translate(Vec2::new( + rect.width() * 0.51 + stroke.width, + rect.width() * 0.01 + stroke.width, + )); + painter.rect_filled(rect_left, corner, color); + painter.rect_stroke(rect_right, corner, stroke, StrokeKind::Outside); + } else { + let (response, painter) = ui.allocate_painter(size, Sense::hover()); + let color = ctx.style().visuals.selection.stroke.color; + let stroke = Stroke::new(1.0, color); + let mut rect = response.rect; + let corner = CornerRadius::same((rect.width() * 0.1) as u8); + rect = rect.shrink(stroke.width); + + // floating + let mut rect_left = response.rect; + rect_left.set_width(rect.width() * 0.65); + rect_left.set_height(rect.height() * 0.65); + let mut rect_right = rect_left; + rect_left = rect_left.translate(Vec2::new( + rect.width() * 0.01 + stroke.width, + rect.width() * 0.01 + stroke.width, + )); + rect_right = rect_right.translate(Vec2::new( + rect.width() * 0.34 + stroke.width, + rect.width() * 0.34 + stroke.width, + )); + painter.rect_filled(rect_left, corner, color); + painter.rect_stroke(rect_right, corner, stroke, StrokeKind::Outside); + } + } +} + +/// Locked container bar for displaying and interacting with container lock state +#[derive(Clone, Debug)] +pub struct LockedContainerBar { + /// Show the widget even when unlocked + show_when_unlocked: bool, + /// Chosen rendering function for this widget + renderer: fn(&Context, &mut Ui, bool, FontId, FontId), +} + +impl LockedContainerBar { + /// Creates a `LockedContainerBar` from the given configuration. + /// + /// Selects a render strategy based on the display format. + /// Returns `None` if the widget is disabled. + fn try_from(value: KomorebiLockedContainerConfig) -> Option { + if !value.enable { + return None; + } + let display_format = value.display.unwrap_or(DisplayFormat::Text); + + // Select renderer strategy based on display format for better performance + let renderer: fn(&Context, &mut Ui, bool, FontId, FontId) = match display_format { + DisplayFormat::Icon => |ctx, ui, is_locked, icon_font, _txt_font| { + let layout_job = Self::icon_layout(ctx, is_locked, icon_font); + ui.add(Label::new(layout_job).selectable(false)); + }, + DisplayFormat::Text => |ctx, ui, is_locked, _icon_font, txt_font| { + let mut layout_job = LayoutJob::default(); + Self::append_text(&mut layout_job, ctx, is_locked, txt_font); + ui.add(Label::new(layout_job).selectable(false)); + }, + _ => |ctx, ui: &mut Ui, is_locked, icon_font, txt_font| { + let mut layout_job = Self::icon_layout(ctx, is_locked, icon_font); + Self::append_text(&mut layout_job, ctx, is_locked, txt_font); + ui.add(Label::new(layout_job).selectable(false)); + }, + }; + + Some(Self { + show_when_unlocked: value.show_when_unlocked.unwrap_or_default(), + renderer, + }) + } + + /// Builds a layout job for the lock/unlock icon, + /// using the provided font and current lock state. + fn icon_layout(ctx: &Context, is_locked: bool, icon_font: FontId) -> LayoutJob { + LayoutJob::simple( + if is_locked { + egui_phosphor::regular::LOCK_KEY.to_string() + } else { + egui_phosphor::regular::LOCK_SIMPLE_OPEN.to_string() + }, + icon_font, + ctx.style().visuals.selection.stroke.color, + 100.0, + ) + } + + /// Appends lock/unlock status text to the given layout job, + /// using the specified font and current lock state. + fn append_text(job: &mut LayoutJob, ctx: &Context, is_locked: bool, txt_font: FontId) { + job.append( + if is_locked { "Locked" } else { "Unlocked" }, + 10.0, + TextFormat { + font_id: txt_font, + color: ctx.style().visuals.text_color(), + valign: Align::Center, + ..Default::default() + }, + ) + } +} + +/// Represents the full state of a single monitor for the Komorebi bar/UI. +/// +/// Includes all workspaces, containers, windows, layout, focus, +/// display options, and monitor indices. Used to render the current monitor +/// state in UI widgets. +/// +/// Updated whenever Komorebi state changes. +#[derive(Clone, Debug)] +pub struct MonitorInfo { + pub workspaces: Vec, + pub layout: KomorebiLayout, + pub mouse_follows_focus: bool, + pub work_area_offset: Option, + pub monitor_index: usize, + pub monitor_usr_idx_map: HashMap, + pub focused_workspace_idx: Option, + pub show_all_icons: bool, + pub hide_empty_workspaces: bool, +} + +impl Default for MonitorInfo { + fn default() -> Self { + Self { + workspaces: Vec::new(), + layout: KomorebiLayout::Default(komorebi_client::DefaultLayout::BSP), + mouse_follows_focus: true, + work_area_offset: None, + monitor_index: MONITOR_INDEX.load(Ordering::SeqCst), + monitor_usr_idx_map: HashMap::new(), + focused_workspace_idx: None, + show_all_icons: false, + hide_empty_workspaces: false, + } + } +} + +impl MonitorInfo { + /// Returns a reference to the currently focused workspace, if any. + pub fn focused_workspace(&self) -> Option<&WorkspaceInfo> { + self.workspaces.get(self.focused_workspace_idx?) + } + + /// Returns the layer of the focused workspace, if available. + pub fn focused_workspace_layer(&self) -> Option { + self.focused_workspace().map(|ws| ws.layer) + } + + /// Returns the focused container within the focused workspace, if any. + pub fn focused_container(&self) -> Option<&ContainerInfo> { + self.focused_workspace() + .and_then(WorkspaceInfo::focused_container) + } +} + +impl MonitorInfo { + pub fn update_from_self(&mut self, config: &Self) { + self.hide_empty_workspaces = config.hide_empty_workspaces; + } + + /// Updates monitor state from the given State, setting all fields based on the selected + /// monitor and its workspaces + pub fn update(&mut self, monitor_index: Option, state: State, show_all_icons: bool) { + self.show_all_icons = show_all_icons; + self.monitor_usr_idx_map = state.monitor_usr_idx_map; + + match monitor_index { + Some(idx) if idx < state.monitors.elements().len() => self.monitor_index = idx, + // The bar's monitor is diconnected, so the bar is disabled no need to check anything + // any further otherwise we'll get `OutOfBounds` panics. + _ => return, + }; + self.mouse_follows_focus = state.mouse_follows_focus; + + let monitor = &state.monitors.elements()[self.monitor_index]; + self.work_area_offset = monitor.work_area_offset; + self.focused_workspace_idx = Some(monitor.focused_workspace_idx()); + + // Layout + let focused_ws = &monitor.workspaces()[monitor.focused_workspace_idx()]; + self.layout = Self::resolve_layout(focused_ws, state.is_paused); + + self.workspaces.clear(); + self.workspaces.extend(Self::workspaces( + self.show_all_icons, + self.hide_empty_workspaces, + self.focused_workspace_idx, + monitor.workspaces().iter().enumerate(), + )); + } + + /// Builds an iterator of WorkspaceInfo for the monitor. + fn workspaces<'a, I>( + show_all_icons: bool, + hide_empty_ws: bool, + focused_ws_idx: Option, + iter: I, + ) -> impl Iterator + 'a + where + I: Iterator + 'a, + { + let fn_containers_from = if show_all_icons { + |ws| ContainerInfo::from_all_containers(ws) + } else { + |ws| { + ContainerInfo::from_focused_container(ws) + .into_iter() + .collect() + } + }; + iter.map(move |(index, ws)| { + let containers = fn_containers_from(ws); + WorkspaceInfo { + name: ws + .name + .to_owned() + .unwrap_or_else(|| format!("{}", index + 1)), + focused_container_idx: containers.iter().position(|c| c.is_focused), + has_icons: containers + .iter() + .any(|container| container.windows.iter().any(|window| window.icon.is_some())), + containers, + layer: ws.layer, + should_show: !hide_empty_ws || focused_ws_idx == Some(index) || !ws.is_empty(), + is_selected: focused_ws_idx == Some(index), + } + }) + } + + /// Determines the current layout of the focused workspace + fn resolve_layout(focused_ws: &Workspace, is_paused: bool) -> KomorebiLayout { + if focused_ws.monocle_container.is_some() { + KomorebiLayout::Monocle + } else if !focused_ws.tile { + KomorebiLayout::Floating + } else if is_paused { + KomorebiLayout::Paused + } else { + match focused_ws.layout { + komorebi_client::Layout::Default(layout) => KomorebiLayout::Default(layout), + } + } + } +} + +/// Describes the state of a single workspace on a monitor. +/// +/// Contains the workspace name, its containers (tiled, floating, +/// monocle), focus state, layer (tiling/floating), and display +/// flags for UI rendering. +#[derive(Clone, Debug)] +pub struct WorkspaceInfo { + pub name: String, + pub containers: Vec, + pub focused_container_idx: Option, + pub layer: WorkspaceLayer, + pub should_show: bool, + pub is_selected: bool, + pub has_icons: bool, +} + +impl WorkspaceInfo { + /// Returns a reference to the focused container in this workspace, if any. + pub fn focused_container(&self) -> Option<&ContainerInfo> { + self.containers.get(self.focused_container_idx?) + } +} + +/// Holds information about a window container (tiled, floating, or monocle) +/// within a workspace. +/// +/// Includes a list of windows, the focused window index, and flags for focus +/// and lock status. +#[derive(Clone, Debug)] +pub struct ContainerInfo { + pub windows: Vec, + pub focused_window_idx: usize, + pub is_focused: bool, + pub is_locked: bool, +} + +impl ContainerInfo { + /// Returns all containers for the given workspace in the following order: + /// + /// 1. The monocle container (if present) is included first. + /// 2. All tiled containers are included next. + /// 3. All floating windows are added last, each as a separate container. + /// + /// Function ensures only one container is marked as focused, prioritizing + /// floating → monocle → tiled. + pub fn from_all_containers(ws: &Workspace) -> Vec { + let has_focused_float = ws.floating_windows().iter().any(|w| w.is_focused()); + + // Monocle container first if present + let monocle = ws + .monocle_container + .as_ref() + .map(|c| Self::from_container(c, !has_focused_float)); + + // All tiled containers, focus only if there's no monocle/focused float + let has_focused_monocle_or_float = has_focused_float || monocle.is_some(); + let tiled = ws.containers().iter().enumerate().map(|(i, c)| { + let is_focused = !has_focused_monocle_or_float && i == ws.focused_container_idx(); + Self::from_container(c, is_focused) + }); + + // All floating windows + let floats = ws.floating_windows().iter().map(Self::from_window); + // All windows + monocle.into_iter().chain(tiled).chain(floats).collect() + } + + /// Creates a `ContainerInfo` for the currently focused item in the workspace. + /// + /// The function checks focus in the following order: + /// 1. Focused floating window + /// 2. Monocle container + /// 3. Focused tiled container + pub fn from_focused_container(ws: &Workspace) -> Option { + if let Some(window) = ws.floating_windows().iter().find(|w| w.is_focused()) { + return Some(Self::from_window(window)); + } + if let Some(container) = &ws.monocle_container { + Some(Self::from_container(container, true)) + } else { + ws.focused_container() + .map(|container| Self::from_container(container, true)) + } + } + + /// Creates a `ContainerInfo` from a given container. + pub fn from_container(container: &Container, is_focused: bool) -> Self { + Self { + windows: container.windows().iter().map(WindowInfo::from).collect(), + focused_window_idx: container.focused_window_idx(), + is_focused, + is_locked: container.locked, + } + } + + /// Creates a `ContainerInfo` from a single floating window. + /// The window becomes the only entry in `windows`, is marked as focused + /// if applicable, and `is_locked` is set to false. + pub fn from_window(window: &Window) -> Self { + Self { + windows: vec![window.into()], + focused_window_idx: 0, + is_focused: window.is_focused(), + is_locked: false, // locked is only container feature + } + } +} + +/// Stores basic information about a single window in a container. +/// Contains the window's title and its icon, if available. +#[derive(Clone, Debug)] +pub struct WindowInfo { + pub title: Option, + pub icon: Option, +} + +impl From<&Window> for WindowInfo { + fn from(value: &Window) -> Self { + Self { + title: value.title(), + icon: None, + // icon: ImageIcon::try_load(value.hwnd, || { + // windows_icons::get_icon_by_hwnd(value.hwnd) + // .or_else(|| windows_icons_fallback::get_icon_by_process_id(value.process_id())) + // }), + } + } +} diff --git a/komorebi-bar/src/widgets/komorebi_layout.rs b/komorebi-bar/src/widgets/komorebi_layout.rs new file mode 100644 index 00000000..85bc9388 --- /dev/null +++ b/komorebi-bar/src/widgets/komorebi_layout.rs @@ -0,0 +1,323 @@ +use crate::config::DisplayFormat; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::komorebi::KomorebiLayoutConfig; +use eframe::egui::Context; +use eframe::egui::CornerRadius; +use eframe::egui::FontId; +use eframe::egui::Frame; +use eframe::egui::Label; +use eframe::egui::Sense; +use eframe::egui::Stroke; +use eframe::egui::StrokeKind; +use eframe::egui::Ui; +use eframe::egui::Vec2; +use eframe::egui::vec2; +use komorebi_client::SocketMessage; +use serde::Deserialize; +use serde::Deserializer; +use serde::Serialize; +use serde::de::Error; +use serde_json::from_str; +use std::fmt::Display; +use std::fmt::Formatter; + +#[derive(Copy, Clone, Debug, Serialize, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(untagged)] +pub enum KomorebiLayout { + Default(komorebi_client::DefaultLayout), + Monocle, + Floating, + Paused, + Custom, +} + +impl<'de> Deserialize<'de> for KomorebiLayout { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + + // Attempt to deserialize the string as a DefaultLayout + if let Ok(default_layout) = from_str::(&format!("\"{s}\"")) + { + return Ok(KomorebiLayout::Default(default_layout)); + } + + // Handle other cases + match s.as_str() { + "Monocle" => Ok(KomorebiLayout::Monocle), + "Floating" => Ok(KomorebiLayout::Floating), + "Paused" => Ok(KomorebiLayout::Paused), + "Custom" => Ok(KomorebiLayout::Custom), + _ => Err(Error::custom(format!("Invalid layout: {s}"))), + } + } +} + +impl Display for KomorebiLayout { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + KomorebiLayout::Default(layout) => write!(f, "{layout}"), + KomorebiLayout::Monocle => write!(f, "Monocle"), + KomorebiLayout::Floating => write!(f, "Floating"), + KomorebiLayout::Paused => write!(f, "Paused"), + KomorebiLayout::Custom => write!(f, "Custom"), + } + } +} + +impl KomorebiLayout { + fn is_default(&mut self) -> bool { + matches!(self, KomorebiLayout::Default(_)) + } + + fn on_click( + &mut self, + show_options: &bool, + monitor_idx: usize, + workspace_idx: Option, + ) -> bool { + if self.is_default() { + !show_options + } else { + self.on_click_option(monitor_idx, workspace_idx); + false + } + } + + fn on_click_option(&mut self, monitor_idx: usize, workspace_idx: Option) { + match self { + KomorebiLayout::Default(option) => { + if let Some(ws_idx) = workspace_idx + && komorebi_client::send_message(&SocketMessage::WorkspaceLayout( + monitor_idx, + ws_idx, + *option, + )) + .is_err() + { + tracing::error!("could not send message to komorebi: WorkspaceLayout"); + } + } + KomorebiLayout::Monocle => { + if komorebi_client::send_batch([ + SocketMessage::FocusMonitorAtCursor, + SocketMessage::ToggleMonocle, + ]) + .is_err() + { + tracing::error!("could not send message to komorebi: ToggleMonocle"); + } + } + KomorebiLayout::Floating => { + if komorebi_client::send_batch([ + SocketMessage::FocusMonitorAtCursor, + SocketMessage::ToggleTiling, + ]) + .is_err() + { + tracing::error!("could not send message to komorebi: ToggleTiling"); + } + } + KomorebiLayout::Paused => { + if komorebi_client::send_message(&SocketMessage::TogglePause).is_err() { + tracing::error!("could not send message to komorebi: TogglePause"); + } + } + KomorebiLayout::Custom => {} + } + } + + fn show_icon(&mut self, is_selected: bool, font_id: FontId, ctx: &Context, ui: &mut Ui) { + // paint custom icons for the layout + let size = Vec2::splat(font_id.size); + let (response, painter) = ui.allocate_painter(size, Sense::hover()); + let color = if is_selected { + ctx.style().visuals.selection.stroke.color + } else { + ui.style().visuals.text_color() + }; + let stroke = Stroke::new(1.0, color); + let mut rect = response.rect; + let rounding = CornerRadius::same((rect.width() * 0.1) as u8); + rect = rect.shrink(stroke.width); + let c = rect.center(); + let r = rect.width() / 2.0; + painter.rect_stroke(rect, rounding, stroke, StrokeKind::Outside); + + match self { + KomorebiLayout::Default(layout) => match layout { + komorebi_client::DefaultLayout::BSP => { + painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke); + painter.line_segment([c, c + vec2(r, 0.0)], stroke); + painter.line_segment([c + vec2(r / 2.0, 0.0), c + vec2(r / 2.0, r)], stroke); + } + komorebi_client::DefaultLayout::Columns => { + painter.line_segment([c - vec2(r / 2.0, r), c + vec2(-r / 2.0, r)], stroke); + painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke); + painter.line_segment([c - vec2(-r / 2.0, r), c + vec2(r / 2.0, r)], stroke); + } + komorebi_client::DefaultLayout::Rows => { + painter.line_segment([c - vec2(r, r / 2.0), c + vec2(r, -r / 2.0)], stroke); + painter.line_segment([c - vec2(r, 0.0), c + vec2(r, 0.0)], stroke); + painter.line_segment([c - vec2(r, -r / 2.0), c + vec2(r, r / 2.0)], stroke); + } + komorebi_client::DefaultLayout::VerticalStack => { + painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke); + painter.line_segment([c, c + vec2(r, 0.0)], stroke); + } + komorebi_client::DefaultLayout::RightMainVerticalStack => { + painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke); + painter.line_segment([c - vec2(r, 0.0), c], stroke); + } + komorebi_client::DefaultLayout::HorizontalStack => { + painter.line_segment([c - vec2(r, 0.0), c + vec2(r, 0.0)], stroke); + painter.line_segment([c, c + vec2(0.0, r)], stroke); + } + komorebi_client::DefaultLayout::UltrawideVerticalStack => { + painter.line_segment([c - vec2(r / 2.0, r), c + vec2(-r / 2.0, r)], stroke); + painter.line_segment([c + vec2(r / 2.0, 0.0), c + vec2(r, 0.0)], stroke); + painter.line_segment([c - vec2(-r / 2.0, r), c + vec2(r / 2.0, r)], stroke); + } + komorebi_client::DefaultLayout::Grid => { + painter.line_segment([c - vec2(r, 0.0), c + vec2(r, 0.0)], stroke); + painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke); + } + // TODO: @CtByte can you think of a nice icon to draw here? + komorebi_client::DefaultLayout::Scrolling => { + painter.line_segment([c - vec2(r / 2.0, r), c + vec2(-r / 2.0, r)], stroke); + painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke); + painter.line_segment([c - vec2(-r / 2.0, r), c + vec2(r / 2.0, r)], stroke); + } + }, + KomorebiLayout::Monocle => {} + KomorebiLayout::Floating => { + let mut rect_left = response.rect; + rect_left.set_width(rect.width() * 0.5); + rect_left.set_height(rect.height() * 0.5); + let mut rect_right = rect_left; + rect_left = rect_left.translate(Vec2::new( + rect.width() * 0.1 + stroke.width, + rect.width() * 0.1 + stroke.width, + )); + rect_right = rect_right.translate(Vec2::new( + rect.width() * 0.35 + stroke.width, + rect.width() * 0.35 + stroke.width, + )); + painter.rect_filled(rect_left, rounding, color); + painter.rect_stroke(rect_right, rounding, stroke, StrokeKind::Outside); + } + KomorebiLayout::Paused => { + let mut rect_left = response.rect; + rect_left.set_width(rect.width() * 0.25); + rect_left.set_height(rect.height() * 0.8); + let mut rect_right = rect_left; + rect_left = rect_left.translate(Vec2::new( + rect.width() * 0.2 + stroke.width, + rect.width() * 0.1 + stroke.width, + )); + rect_right = rect_right.translate(Vec2::new( + rect.width() * 0.55 + stroke.width, + rect.width() * 0.1 + stroke.width, + )); + painter.rect_filled(rect_left, rounding, color); + painter.rect_filled(rect_right, rounding, color); + } + KomorebiLayout::Custom => { + painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke); + painter.line_segment([c + vec2(0.0, r / 2.0), c + vec2(r, r / 2.0)], stroke); + painter.line_segment([c - vec2(0.0, r / 3.0), c - vec2(r, r / 3.0)], stroke); + } + } + } + + pub fn show( + &mut self, + ctx: &Context, + ui: &mut Ui, + render_config: &mut RenderConfig, + layout_config: &KomorebiLayoutConfig, + workspace_idx: Option, + ) { + let monitor_idx = render_config.monitor_idx; + let font_id = render_config.icon_font_id.clone(); + let mut show_options = RenderConfig::load_show_komorebi_layout_options(); + let format = layout_config.display.unwrap_or(DisplayFormat::IconAndText); + + if !self.is_default() { + show_options = false; + } + + render_config.apply_on_widget(false, ui, |ui| { + let layout_frame = SelectableFrame::new(false) + .show(ui, |ui| { + if let DisplayFormat::Icon | DisplayFormat::IconAndText = format { + self.show_icon(true, font_id.clone(), ctx, ui); + } + + if let DisplayFormat::Text | DisplayFormat::IconAndText = format { + ui.add(Label::new(self.to_string()).selectable(false)); + } + }) + .on_hover_text(self.to_string()); + + if layout_frame.clicked() { + show_options = self.on_click(&show_options, monitor_idx, workspace_idx); + } + + if show_options && let Some(workspace_idx) = workspace_idx { + Frame::NONE.show(ui, |ui| { + ui.add( + Label::new(egui_phosphor::regular::ARROW_FAT_LINES_RIGHT.to_string()) + .selectable(false), + ); + + let mut layout_options = layout_config.options.clone().unwrap_or(vec![ + KomorebiLayout::Default(komorebi_client::DefaultLayout::BSP), + KomorebiLayout::Default(komorebi_client::DefaultLayout::Columns), + KomorebiLayout::Default(komorebi_client::DefaultLayout::Rows), + KomorebiLayout::Default(komorebi_client::DefaultLayout::VerticalStack), + KomorebiLayout::Default( + komorebi_client::DefaultLayout::RightMainVerticalStack, + ), + KomorebiLayout::Default(komorebi_client::DefaultLayout::HorizontalStack), + KomorebiLayout::Default( + komorebi_client::DefaultLayout::UltrawideVerticalStack, + ), + KomorebiLayout::Default(komorebi_client::DefaultLayout::Grid), + //KomorebiLayout::Custom, + KomorebiLayout::Monocle, + KomorebiLayout::Floating, + KomorebiLayout::Paused, + ]); + + for layout_option in &mut layout_options { + let is_selected = self == layout_option; + + if SelectableFrame::new(is_selected) + .show(ui, |ui| { + layout_option.show_icon(is_selected, font_id.clone(), ctx, ui) + }) + .on_hover_text(match layout_option { + KomorebiLayout::Default(layout) => layout.to_string(), + KomorebiLayout::Monocle => "Toggle monocle".to_string(), + KomorebiLayout::Floating => "Toggle tiling".to_string(), + KomorebiLayout::Paused => "Toggle pause".to_string(), + KomorebiLayout::Custom => "Custom".to_string(), + }) + .clicked() + { + layout_option.on_click_option(monitor_idx, Some(workspace_idx)); + show_options = false; + }; + } + }); + } + }); + + RenderConfig::store_show_komorebi_layout_options(show_options); + } +} diff --git a/komorebi-bar/src/widgets/media.rs b/komorebi-bar/src/widgets/media.rs new file mode 100644 index 00000000..2428d063 --- /dev/null +++ b/komorebi-bar/src/widgets/media.rs @@ -0,0 +1,122 @@ +use crate::MAX_LABEL_WIDTH; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::ui::CustomUi; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::Vec2; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use std::sync::atomic::Ordering; +use windows::Media::Control::GlobalSystemMediaTransportControlsSessionManager; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct MediaConfig { + /// Enable the Media widget + pub enable: bool, +} + +impl From for Media { + fn from(value: MediaConfig) -> Self { + Self::new(value.enable) + } +} + +#[derive(Clone, Debug)] +pub struct Media { + pub enable: bool, + pub session_manager: GlobalSystemMediaTransportControlsSessionManager, +} + +impl Media { + pub fn new(enable: bool) -> Self { + Self { + enable, + session_manager: GlobalSystemMediaTransportControlsSessionManager::RequestAsync() + .unwrap() + .get() + .unwrap(), + } + } + + pub fn toggle(&self) { + if let Ok(session) = self.session_manager.GetCurrentSession() + && let Ok(op) = session.TryTogglePlayPauseAsync() + { + op.get().unwrap_or_default(); + } + } + + fn output(&mut self) -> String { + if let Ok(session) = self.session_manager.GetCurrentSession() + && let Ok(operation) = session.TryGetMediaPropertiesAsync() + && let Ok(properties) = operation.get() + && let (Ok(artist), Ok(title)) = (properties.Artist(), properties.Title()) + { + if artist.is_empty() { + return format!("{title}"); + } + + if title.is_empty() { + return format!("{artist}"); + } + + return format!("{artist} - {title}"); + } + + String::new() + } +} + +impl BarWidget for Media { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let output = self.output(); + if !output.is_empty() { + let mut layout_job = LayoutJob::simple( + egui_phosphor::regular::HEADPHONES.to_string(), + config.icon_font_id.clone(), + ctx.style().visuals.selection.stroke.color, + 100.0, + ); + + layout_job.append( + &output, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: ctx.style().visuals.text_color(), + valign: Align::Center, + ..Default::default() + }, + ); + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new(false) + .show(ui, |ui| { + let available_height = ui.available_height(); + let mut custom_ui = CustomUi(ui); + + custom_ui.add_sized_left_to_right( + Vec2::new( + MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32, + available_height, + ), + Label::new(layout_job).selectable(false).truncate(), + ) + }) + .clicked() + { + self.toggle(); + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/memory.rs b/komorebi-bar/src/widgets/memory.rs new file mode 100644 index 00000000..145d8547 --- /dev/null +++ b/komorebi-bar/src/widgets/memory.rs @@ -0,0 +1,137 @@ +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use std::process::Command; +use std::time::Duration; +use std::time::Instant; +use sysinfo::RefreshKind; +use sysinfo::System; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct MemoryConfig { + /// Enable the Memory widget + pub enable: bool, + /// Data refresh interval (default: 10 seconds) + pub data_refresh_interval: Option, + /// Display label prefix + pub label_prefix: Option, + /// Select when the current percentage is over this value [[1-100]] + pub auto_select_over: Option, +} + +impl From for Memory { + fn from(value: MemoryConfig) -> Self { + let data_refresh_interval = value.data_refresh_interval.unwrap_or(10); + + Self { + enable: value.enable, + system: System::new_with_specifics( + RefreshKind::default().without_cpu().without_processes(), + ), + data_refresh_interval, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::IconAndText), + auto_select_over: value.auto_select_over.map(|o| o.clamp(1, 100)), + last_updated: Instant::now() + .checked_sub(Duration::from_secs(data_refresh_interval)) + .unwrap(), + } + } +} + +#[derive(Clone, Debug)] +struct MemoryOutput { + label: String, + selected: bool, +} + +pub struct Memory { + pub enable: bool, + system: System, + data_refresh_interval: u64, + label_prefix: LabelPrefix, + auto_select_over: Option, + last_updated: Instant, +} + +impl Memory { + fn output(&mut self) -> MemoryOutput { + let now = Instant::now(); + if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) { + self.system.refresh_memory(); + self.last_updated = now; + } + + let used = self.system.used_memory(); + let total = self.system.total_memory(); + let usage = ((used * 100) / total) as u8; + let selected = self.auto_select_over.is_some_and(|o| usage >= o); + + MemoryOutput { + label: match self.label_prefix { + LabelPrefix::Text | LabelPrefix::IconAndText => { + format!("RAM: {usage}%") + } + LabelPrefix::None | LabelPrefix::Icon => format!("{usage}%"), + }, + selected, + } + } +} + +impl BarWidget for Memory { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let output = self.output(); + if !output.label.is_empty() { + let auto_text_color = config.auto_select_text.filter(|_| output.selected); + + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + egui_phosphor::regular::MEMORY.to_string() + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + auto_text_color.unwrap_or(ctx.style().visuals.selection.stroke.color), + 100.0, + ); + + layout_job.append( + &output.label, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: auto_text_color.unwrap_or(ctx.style().visuals.text_color()), + valign: Align::Center, + ..Default::default() + }, + ); + + let auto_focus_fill = config.auto_select_fill; + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new_auto(output.selected, auto_focus_fill) + .show(ui, |ui| ui.add(Label::new(layout_job).selectable(false))) + .clicked() + && let Err(error) = Command::new("open") + .args(["-a", "Activity Monitor"]) + .spawn() + { + eprintln!("{error}") + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/mod.rs b/komorebi-bar/src/widgets/mod.rs new file mode 100644 index 00000000..56b19d53 --- /dev/null +++ b/komorebi-bar/src/widgets/mod.rs @@ -0,0 +1,173 @@ +use eframe::egui::ColorImage; +use eframe::egui::Context; +use eframe::egui::TextureHandle; +use eframe::egui::TextureOptions; +use image::RgbaImage; +use std::collections::HashMap; +use std::path::Path; +use std::sync::Arc; +use std::sync::LazyLock; +use std::sync::RwLock; + +pub mod applications; +pub mod battery; +pub mod cpu; +pub mod date; +// pub mod keyboard; +pub mod komorebi; +mod komorebi_layout; +// pub mod media; +pub mod memory; +pub mod network; +pub mod storage; +pub mod time; +pub mod update; +pub mod widget; + +/// Global cache for icon images and their associated GPU textures. +pub static ICONS_CACHE: IconsCache = IconsCache::new(); + +/// In-memory cache for icon images and their associated GPU textures. +/// +/// Stores raw [`ColorImage`]s and [`TextureHandle`]s keyed by [`ImageIconId`]. +/// Texture entries are context-dependent and automatically invalidated when the [`Context`] changes. +#[allow(clippy::type_complexity)] +pub struct IconsCache { + textures: LazyLock, HashMap)>>, + images: LazyLock>>>, +} + +impl IconsCache { + /// Creates a new empty IconsCache instance. + #[inline] + pub const fn new() -> Self { + Self { + textures: LazyLock::new(|| RwLock::new((None, HashMap::new()))), + images: LazyLock::new(|| RwLock::new(HashMap::new())), + } + } + + /// Retrieves or creates a texture handle for the given icon ID and image. + /// + /// If a texture for the given ID already exists for the current [`Context`], it is reused. + /// Otherwise, a new texture is created, inserted into the cache, and returned. + /// The cache is reset if the [`Context`] has changed. + #[inline] + pub fn texture(&self, ctx: &Context, id: &ImageIconId, img: &Arc) -> TextureHandle { + if let Some(texture) = self.get_texture(ctx, id) { + return texture; + } + let texture_handle = ctx.load_texture("icon", img.clone(), TextureOptions::default()); + self.insert_texture(ctx, id.clone(), texture_handle.clone()); + texture_handle + } + + /// Returns the cached texture for the given icon ID if it exists and matches the current [`Context`]. + pub fn get_texture(&self, ctx: &Context, id: &ImageIconId) -> Option { + let textures_lock = self.textures.read().unwrap(); + if textures_lock.0.as_ref() == Some(ctx) { + return textures_lock.1.get(id).cloned(); + } + None + } + + /// Inserts a texture handle, resetting the cache if the [`Context`] has changed. + pub fn insert_texture(&self, ctx: &Context, id: ImageIconId, texture: TextureHandle) { + let mut textures_lock = self.textures.write().unwrap(); + + if textures_lock.0.as_ref() != Some(ctx) { + textures_lock.0 = Some(ctx.clone()); + textures_lock.1.clear(); + } + + textures_lock.1.insert(id, texture); + } + + /// Returns the cached image for the given icon ID, if available. + pub fn get_image(&self, id: &ImageIconId) -> Option> { + self.images.read().unwrap().get(id).cloned() + } + + /// Caches a raw [`ColorImage`] associated with the given icon ID. + pub fn insert_image(&self, id: ImageIconId, image: Arc) { + self.images.write().unwrap().insert(id, image); + } +} + +#[inline] +fn rgba_to_color_image(rgba_image: &RgbaImage) -> ColorImage { + let size = [rgba_image.width() as usize, rgba_image.height() as usize]; + let pixels = rgba_image.as_flat_samples(); + ColorImage::from_rgba_unmultiplied(size, pixels.as_slice()) +} + +/// Represents an image-based icon with a unique ID and pixel data. +#[derive(Clone, Debug)] +pub struct ImageIcon { + /// Unique identifier for the image icon, used for texture caching. + pub id: ImageIconId, + /// Shared pixel data of the icon in `ColorImage` format. + pub image: Arc, +} + +impl ImageIcon { + /// Creates a new [`ImageIcon`] from the given ID and image data. + #[inline] + pub fn new(id: ImageIconId, image: Arc) -> Self { + Self { id, image } + } + + /// Loads an [`ImageIcon`] from [`ICONS_CACHE`] or calls `loader` if not cached. + /// The loaded image is converted to a [`ColorImage`], cached, and returned. + #[inline] + pub fn try_load(id: impl Into, loader: F) -> Option + where + F: FnOnce() -> Option, + I: Into, + { + let id = id.into(); + let image = ICONS_CACHE.get_image(&id).or_else(|| { + let img = loader()?; + let img = Arc::new(rgba_to_color_image(&img.into())); + ICONS_CACHE.insert_image(id.clone(), img.clone()); + Some(img) + })?; + + Some(ImageIcon::new(id, image)) + } + + /// Returns a texture handle for the icon, using the given [`Context`]. + /// + /// If the texture is already cached in [`ICONS_CACHE`], it is reused. + /// Otherwise, a new texture is created from the [`ColorImage`] and cached. + #[inline] + pub fn texture(&self, ctx: &Context) -> TextureHandle { + ICONS_CACHE.texture(ctx, &self.id, &self.image) + } +} + +/// Unique identifier for an image-based icon. +/// +/// Used to distinguish cached images and textures by either a file path +/// or a Windows window handle. +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub enum ImageIconId { + /// Identifier based on a file system path. + Path(Arc), + /// Windows HWND handle. + Hwnd(isize), +} + +impl From<&Path> for ImageIconId { + #[inline] + fn from(value: &Path) -> Self { + Self::Path(value.into()) + } +} + +impl From for ImageIconId { + #[inline] + fn from(value: isize) -> Self { + Self::Hwnd(value) + } +} diff --git a/komorebi-bar/src/widgets/network.rs b/komorebi-bar/src/widgets/network.rs new file mode 100644 index 00000000..25c4b6ed --- /dev/null +++ b/komorebi-bar/src/widgets/network.rs @@ -0,0 +1,553 @@ +use crate::bar::Alignment; +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Color32; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::text::LayoutJob; +use num_derive::FromPrimitive; +use serde::Deserialize; +use serde::Serialize; +use std::fmt; +use std::process::Command; +use std::time::Duration; +use std::time::Instant; +use sysinfo::Networks; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct NetworkConfig { + /// Enable the Network widget + pub enable: bool, + /// Show total received and transmitted activity + #[serde(alias = "show_total_data_transmitted")] + pub show_total_activity: bool, + /// Show received and transmitted activity + #[serde(alias = "show_network_activity")] + pub show_activity: bool, + /// Show default interface + pub show_default_interface: Option, + /// Characters to reserve for received and transmitted activity + #[serde(alias = "network_activity_fill_characters")] + pub activity_left_padding: Option, + /// Data refresh interval (default: 10 seconds) + pub data_refresh_interval: Option, + /// Display label prefix + pub label_prefix: Option, + /// Select when the value is over a limit (1MiB is 1048576 bytes (1024*1024)) + pub auto_select: Option, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct NetworkSelectConfig { + /// Select the total received data when it's over this value + pub total_received_over: Option, + /// Select the total transmitted data when it's over this value + pub total_transmitted_over: Option, + /// Select the received data when it's over this value + pub received_over: Option, + /// Select the transmitted data when it's over this value + pub transmitted_over: Option, +} + +impl From for Network { + fn from(value: NetworkConfig) -> Self { + let default_refresh_interval = 10; + let data_refresh_interval = value.data_refresh_interval.unwrap_or(10); + + Self { + enable: value.enable, + show_total_activity: value.show_total_activity, + show_activity: value.show_activity, + show_default_interface: value.show_default_interface.unwrap_or(true), + networks_network_activity: Networks::new_with_refreshed_list(), + default_interface: String::new(), + default_refresh_interval, + data_refresh_interval, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::Icon), + auto_select: value.auto_select, + activity_left_padding: value.activity_left_padding.unwrap_or_default(), + last_updated_default_interface: Instant::now() + .checked_sub(Duration::from_secs(default_refresh_interval)) + .unwrap(), + last_state_total_activity: vec![], + last_state_activity: vec![], + last_updated_network_activity: Instant::now() + .checked_sub(Duration::from_secs(data_refresh_interval)) + .unwrap(), + } + } +} + +pub struct Network { + pub enable: bool, + pub show_total_activity: bool, + pub show_activity: bool, + pub show_default_interface: bool, + networks_network_activity: Networks, + default_refresh_interval: u64, + data_refresh_interval: u64, + label_prefix: LabelPrefix, + auto_select: Option, + default_interface: String, + last_updated_default_interface: Instant, + last_state_total_activity: Vec, + last_state_activity: Vec, + last_updated_network_activity: Instant, + activity_left_padding: usize, +} + +impl Network { + fn default_interface(&mut self) { + let now = Instant::now(); + + if now.duration_since(self.last_updated_default_interface) + > Duration::from_secs(self.default_refresh_interval) + { + if let Ok(interface) = netdev::get_default_interface() + && let Some(friendly_name) = &interface.friendly_name + { + self.default_interface.clone_from(friendly_name); + } + + self.last_updated_default_interface = now; + } + } + + fn network_activity(&mut self) -> (Vec, Vec) { + let mut activity = self.last_state_activity.clone(); + let mut total_activity = self.last_state_total_activity.clone(); + let now = Instant::now(); + + if now.duration_since(self.last_updated_network_activity) + > Duration::from_secs(self.data_refresh_interval) + { + activity.clear(); + total_activity.clear(); + + if let Ok(interface) = netdev::get_default_interface() + && let Some(friendly_name) = &interface.friendly_name + { + self.default_interface.clone_from(friendly_name); + + self.networks_network_activity.refresh(true); + + for (interface_name, data) in &self.networks_network_activity { + if friendly_name.eq(interface_name) { + if self.show_activity { + let received = + Self::to_pretty_bytes(data.received(), self.data_refresh_interval); + let transmitted = Self::to_pretty_bytes( + data.transmitted(), + self.data_refresh_interval, + ); + + activity.push(NetworkReading::new( + NetworkReadingFormat::Speed, + ReadingValue::from(received), + ReadingValue::from(transmitted), + )); + } + + if self.show_total_activity { + let total_received = Self::to_pretty_bytes(data.total_received(), 1); + let total_transmitted = + Self::to_pretty_bytes(data.total_transmitted(), 1); + + total_activity.push(NetworkReading::new( + NetworkReadingFormat::Total, + ReadingValue::from(total_received), + ReadingValue::from(total_transmitted), + )) + } + } + } + } + + self.last_state_activity.clone_from(&activity); + self.last_state_total_activity.clone_from(&total_activity); + self.last_updated_network_activity = now; + } + + (activity, total_activity) + } + + fn reading_to_labels( + &self, + select_received: bool, + select_transmitted: bool, + ctx: &Context, + reading: &NetworkReading, + config: RenderConfig, + ) -> (Label, Label) { + let (text_down, text_up) = match self.label_prefix { + LabelPrefix::None | LabelPrefix::Icon => match reading.format { + NetworkReadingFormat::Speed => ( + format!( + "{: >width$}/s ", + reading.received.pretty, + width = self.activity_left_padding + ), + format!( + "{: >width$}/s", + reading.transmitted.pretty, + width = self.activity_left_padding + ), + ), + NetworkReadingFormat::Total => ( + format!("{} ", reading.received.pretty), + reading.transmitted.pretty.clone(), + ), + }, + LabelPrefix::Text | LabelPrefix::IconAndText => match reading.format { + NetworkReadingFormat::Speed => ( + format!( + "DOWN: {: >width$}/s ", + reading.received.pretty, + width = self.activity_left_padding + ), + format!( + "UP: {: >width$}/s", + reading.transmitted.pretty, + width = self.activity_left_padding + ), + ), + NetworkReadingFormat::Total => ( + format!("\u{2211}DOWN: {}/s ", reading.received.pretty), + format!("\u{2211}UP: {}/s", reading.transmitted.pretty), + ), + }, + }; + + let auto_text_color_received = config.auto_select_text.filter(|_| select_received); + let auto_text_color_transmitted = config.auto_select_text.filter(|_| select_transmitted); + + // icon + let mut layout_job_down = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + if select_received { + egui_phosphor::regular::ARROW_FAT_LINES_DOWN.to_string() + } else { + egui_phosphor::regular::ARROW_FAT_DOWN.to_string() + } + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + auto_text_color_received.unwrap_or(ctx.style().visuals.selection.stroke.color), + 100.0, + ); + + // text + layout_job_down.append( + &text_down, + ctx.style().spacing.item_spacing.x, + TextFormat { + font_id: config.text_font_id.clone(), + color: auto_text_color_received.unwrap_or(ctx.style().visuals.text_color()), + valign: Align::Center, + ..Default::default() + }, + ); + + // icon + let mut layout_job_up = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + if select_transmitted { + egui_phosphor::regular::ARROW_FAT_LINES_UP.to_string() + } else { + egui_phosphor::regular::ARROW_FAT_UP.to_string() + } + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + auto_text_color_transmitted.unwrap_or(ctx.style().visuals.selection.stroke.color), + 100.0, + ); + + // text + layout_job_up.append( + &text_up, + ctx.style().spacing.item_spacing.x, + TextFormat { + font_id: config.text_font_id.clone(), + color: auto_text_color_transmitted.unwrap_or(ctx.style().visuals.text_color()), + valign: Align::Center, + ..Default::default() + }, + ); + + ( + Label::new(layout_job_down).selectable(false), + Label::new(layout_job_up).selectable(false), + ) + } + + fn to_pretty_bytes(input_in_bytes: u64, timespan_in_s: u64) -> (u64, String) { + let input = input_in_bytes as f32 / timespan_in_s as f32; + let mut magnitude = input.log(1024f32) as u32; + + // let the base unit be KiB + if magnitude < 1 { + magnitude = 1; + } + + let base: Option = num::FromPrimitive::from_u32(magnitude); + let result = input / ((1u64) << (magnitude * 10)) as f32; + + ( + input as u64, + match base { + Some(DataUnit::B) => format!("{result:.1} B"), + Some(unit) => format!("{result:.1} {unit}iB"), + None => String::from("Unknown data unit"), + }, + ) + } + + fn show_frame( + &self, + selected: bool, + auto_focus_fill: Option, + ui: &mut Ui, + add_contents: impl FnOnce(&mut Ui) -> R, + ) { + if SelectableFrame::new_auto(selected, auto_focus_fill) + .show(ui, add_contents) + .clicked() + && let Err(error) = Command::new("open") + .args(["x-apple.systempreferences:com.apple.Network-Settings.extension"]) + .spawn() + { + eprintln!("{error}"); + } + } +} + +impl BarWidget for Network { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let is_reversed = matches!(config.alignment, Some(Alignment::Right)); + + // widget spacing: make sure to use the same config to call the apply_on_widget function + let mut render_config = config.clone(); + + if self.show_total_activity || self.show_activity { + let (activity, total_activity) = self.network_activity(); + + if self.show_total_activity { + for reading in &total_activity { + render_config.apply_on_widget(false, ui, |ui| { + let select_received = self.auto_select.is_some_and(|f| { + f.total_received_over + .is_some_and(|o| reading.received.value > o) + }); + let select_transmitted = self.auto_select.is_some_and(|f| { + f.total_transmitted_over + .is_some_and(|o| reading.transmitted.value > o) + }); + + let labels = self.reading_to_labels( + select_received, + select_transmitted, + ctx, + reading, + config.clone(), + ); + + if is_reversed { + self.show_frame( + select_transmitted, + config.auto_select_fill, + ui, + |ui| ui.add(labels.1), + ); + self.show_frame( + select_received, + config.auto_select_fill, + ui, + |ui| ui.add(labels.0), + ); + } else { + self.show_frame( + select_received, + config.auto_select_fill, + ui, + |ui| ui.add(labels.0), + ); + self.show_frame( + select_transmitted, + config.auto_select_fill, + ui, + |ui| ui.add(labels.1), + ); + } + }); + } + } + + if self.show_activity { + for reading in &activity { + render_config.apply_on_widget(false, ui, |ui| { + let select_received = self.auto_select.is_some_and(|f| { + f.received_over.is_some_and(|o| reading.received.value > o) + }); + let select_transmitted = self.auto_select.is_some_and(|f| { + f.transmitted_over + .is_some_and(|o| reading.transmitted.value > o) + }); + + let labels = self.reading_to_labels( + select_received, + select_transmitted, + ctx, + reading, + config.clone(), + ); + + if is_reversed { + self.show_frame( + select_transmitted, + config.auto_select_fill, + ui, + |ui| ui.add(labels.1), + ); + self.show_frame( + select_received, + config.auto_select_fill, + ui, + |ui| ui.add(labels.0), + ); + } else { + self.show_frame( + select_received, + config.auto_select_fill, + ui, + |ui| ui.add(labels.0), + ); + self.show_frame( + select_transmitted, + config.auto_select_fill, + ui, + |ui| ui.add(labels.1), + ); + } + }); + } + } + } + + if self.show_default_interface { + self.default_interface(); + + if !self.default_interface.is_empty() { + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + egui_phosphor::regular::WIFI_HIGH.to_string() + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + ctx.style().visuals.selection.stroke.color, + 100.0, + ); + + if let LabelPrefix::Text | LabelPrefix::IconAndText = self.label_prefix { + self.default_interface.insert_str(0, "NET: "); + } + + layout_job.append( + &self.default_interface, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: ctx.style().visuals.text_color(), + valign: Align::Center, + ..Default::default() + }, + ); + + render_config.apply_on_widget(false, ui, |ui| { + self.show_frame(false, None, ui, |ui| { + ui.add(Label::new(layout_job).selectable(false)) + }); + }); + } + } + + // widget spacing: pass on the config that was use for calling the apply_on_widget function + *config = render_config.clone(); + } + } +} + +#[derive(Clone)] +enum NetworkReadingFormat { + Speed = 0, + Total = 1, +} + +#[derive(Clone)] +struct ReadingValue { + value: u64, + pretty: String, +} + +impl From<(u64, String)> for ReadingValue { + fn from(value: (u64, String)) -> Self { + Self { + value: value.0, + pretty: value.1, + } + } +} + +#[derive(Clone)] +struct NetworkReading { + format: NetworkReadingFormat, + received: ReadingValue, + transmitted: ReadingValue, +} + +impl NetworkReading { + fn new( + format: NetworkReadingFormat, + received: ReadingValue, + transmitted: ReadingValue, + ) -> Self { + Self { + format, + received, + transmitted, + } + } +} + +#[derive(Debug, FromPrimitive)] +enum DataUnit { + B = 0, + K = 1, + M = 2, + G = 3, + T = 4, + P = 5, + E = 6, + Z = 7, + Y = 8, +} + +impl fmt::Display for DataUnit { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{self:?}") + } +} diff --git a/komorebi-bar/src/widgets/storage.rs b/komorebi-bar/src/widgets/storage.rs new file mode 100644 index 00000000..070edb68 --- /dev/null +++ b/komorebi-bar/src/widgets/storage.rs @@ -0,0 +1,171 @@ +use crate::bar::Alignment; +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use std::process::Command; +use std::time::Duration; +use std::time::Instant; +use sysinfo::Disks; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct StorageConfig { + /// Enable the Storage widget + pub enable: bool, + /// Data refresh interval (default: 10 seconds) + pub data_refresh_interval: Option, + /// Display label prefix + pub label_prefix: Option, + /// Show disks that are read only. (default: false) + pub show_read_only_disks: Option, + /// Show removable disks. (default: true) + pub show_removable_disks: Option, + /// Select when the current percentage is over this value [[1-100]] + pub auto_select_over: Option, + /// Hide when the current percentage is under this value [[1-100]] + pub auto_hide_under: Option, +} + +impl From for Storage { + fn from(value: StorageConfig) -> Self { + Self { + enable: value.enable, + disks: Disks::new_with_refreshed_list(), + data_refresh_interval: value.data_refresh_interval.unwrap_or(10), + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::IconAndText), + show_read_only_disks: value.show_read_only_disks.unwrap_or(false), + show_removable_disks: value.show_removable_disks.unwrap_or(true), + auto_select_over: value.auto_select_over.map(|o| o.clamp(1, 100)), + auto_hide_under: value.auto_hide_under.map(|o| o.clamp(1, 100)), + last_updated: Instant::now(), + } + } +} + +struct StorageDisk { + label: String, + selected: bool, +} + +pub struct Storage { + pub enable: bool, + disks: Disks, + data_refresh_interval: u64, + label_prefix: LabelPrefix, + show_read_only_disks: bool, + show_removable_disks: bool, + auto_select_over: Option, + auto_hide_under: Option, + last_updated: Instant, +} + +impl Storage { + fn output(&mut self) -> Vec { + let now = Instant::now(); + if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) { + self.disks.refresh(true); + self.last_updated = now; + } + + let mut disks = vec![]; + + for disk in &self.disks { + if disk.is_read_only() && !self.show_read_only_disks { + continue; + } + if disk.is_removable() && !self.show_removable_disks { + continue; + } + let mount = disk.mount_point(); + let total = disk.total_space(); + let available = disk.available_space(); + let used = total - available; + let percentage = ((used * 100) / total) as u8; + + let hide = self.auto_hide_under.is_some_and(|u| percentage <= u); + + if !hide { + let selected = self.auto_select_over.is_some_and(|o| percentage >= o); + + disks.push(StorageDisk { + label: match self.label_prefix { + LabelPrefix::Text | LabelPrefix::IconAndText => { + format!("{} {}%", mount.to_string_lossy(), percentage) + } + LabelPrefix::None | LabelPrefix::Icon => format!("{percentage}%"), + }, + selected, + }) + } + } + + disks.sort_by(|a, b| a.label.cmp(&b.label)); + + disks + } +} + +impl BarWidget for Storage { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let mut output = self.output(); + let is_reversed = matches!(config.alignment, Some(Alignment::Right)); + + if is_reversed { + output.reverse(); + } + + for output in output { + let auto_text_color = config.auto_select_text.filter(|_| output.selected); + + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + egui_phosphor::regular::HARD_DRIVES.to_string() + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + auto_text_color.unwrap_or(ctx.style().visuals.selection.stroke.color), + 100.0, + ); + + layout_job.append( + &output.label, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: auto_text_color.unwrap_or(ctx.style().visuals.text_color()), + valign: Align::Center, + ..Default::default() + }, + ); + + let auto_focus_fill = config.auto_select_fill; + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new_auto(output.selected, auto_focus_fill) + .show(ui, |ui| ui.add(Label::new(layout_job).selectable(false))) + .clicked() + { + let parts: Vec<&str> = output.label.split(' ').collect(); + let path = parts[..parts.len() - 1].join(" "); + + if let Err(error) = Command::new("open").args([path]).spawn() { + eprintln!("{error}") + } + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/time.rs b/komorebi-bar/src/widgets/time.rs new file mode 100644 index 00000000..240ab0f2 --- /dev/null +++ b/komorebi-bar/src/widgets/time.rs @@ -0,0 +1,538 @@ +use crate::bar::Alignment; +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use chrono::Local; +use chrono::NaiveTime; +use chrono_tz::Tz; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::CornerRadius; +use eframe::egui::Label; +use eframe::egui::Sense; +use eframe::egui::Stroke; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::Vec2; +use eframe::egui::text::LayoutJob; +use eframe::epaint::StrokeKind; +use lazy_static::lazy_static; +use serde::Deserialize; +use serde::Serialize; +use std::time::Duration; +use std::time::Instant; + +lazy_static! { + static ref TIME_RANGES: Vec<(&'static str, NaiveTime)> = { + vec![ + ( + egui_phosphor::regular::MOON, + NaiveTime::from_hms_opt(0, 0, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::ALARM, + NaiveTime::from_hms_opt(6, 0, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::BREAD, + NaiveTime::from_hms_opt(6, 1, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::BARBELL, + NaiveTime::from_hms_opt(6, 30, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::COFFEE, + NaiveTime::from_hms_opt(8, 0, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::CLOCK, + NaiveTime::from_hms_opt(8, 30, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::HAMBURGER, + NaiveTime::from_hms_opt(12, 0, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::CLOCK_AFTERNOON, + NaiveTime::from_hms_opt(12, 30, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::FORK_KNIFE, + NaiveTime::from_hms_opt(18, 0, 0).expect("invalid"), + ), + ( + egui_phosphor::regular::MOON_STARS, + NaiveTime::from_hms_opt(18, 30, 0).expect("invalid"), + ), + ] + }; +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct TimeConfig { + /// Enable the Time widget + pub enable: bool, + /// Set the Time format + pub format: TimeFormat, + /// Display label prefix + pub label_prefix: Option, + /// TimeZone (https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html) + /// + /// Use a custom format to display additional information, i.e.: + /// ```json + /// { + /// "Time": { + /// "enable": true, + /// "format": { "Custom": "%T %Z (Tokyo)" }, + /// "timezone": "Asia/Tokyo" + /// } + ///} + /// ``` + pub timezone: Option, + /// Change the icon depending on the time. The default icon is used between 8:30 and 12:00. (default: false) + pub changing_icon: Option, +} + +impl From for Time { + fn from(value: TimeConfig) -> Self { + // using 1 second made the widget look "less accurate" and lagging (especially having multiple with seconds). + // This is still better than getting an update every frame + let data_refresh_interval = 500; + + Self { + enable: value.enable, + format: value.format, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::Icon), + timezone: value.timezone, + changing_icon: value.changing_icon.unwrap_or_default(), + data_refresh_interval_millis: data_refresh_interval, + last_state: TimeOutput::new(), + last_updated: Instant::now() + .checked_sub(Duration::from_millis(data_refresh_interval)) + .unwrap(), + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum TimeFormat { + /// Twelve-hour format (with seconds) + TwelveHour, + /// Twelve-hour format (without seconds) + TwelveHourWithoutSeconds, + /// Twenty-four-hour format (with seconds) + TwentyFourHour, + /// Twenty-four-hour format (without seconds) + TwentyFourHourWithoutSeconds, + /// Twenty-four-hour format displayed as a binary clock with circles (with seconds) (https://en.wikipedia.org/wiki/Binary_clock) + BinaryCircle, + /// Twenty-four-hour format displayed as a binary clock with rectangles (with seconds) (https://en.wikipedia.org/wiki/Binary_clock) + BinaryRectangle, + /// Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html) + Custom(String), +} + +impl TimeFormat { + pub fn toggle(&mut self) { + match self { + TimeFormat::TwelveHour => *self = TimeFormat::TwelveHourWithoutSeconds, + TimeFormat::TwelveHourWithoutSeconds => *self = TimeFormat::TwentyFourHour, + TimeFormat::TwentyFourHour => *self = TimeFormat::TwentyFourHourWithoutSeconds, + TimeFormat::TwentyFourHourWithoutSeconds => *self = TimeFormat::BinaryCircle, + TimeFormat::BinaryCircle => *self = TimeFormat::BinaryRectangle, + TimeFormat::BinaryRectangle => *self = TimeFormat::TwelveHour, + _ => {} + }; + } + + fn fmt_string(&self) -> String { + match self { + TimeFormat::TwelveHour => String::from("%l:%M:%S %p"), + TimeFormat::TwelveHourWithoutSeconds => String::from("%l:%M %p"), + TimeFormat::TwentyFourHour => String::from("%T"), + TimeFormat::TwentyFourHourWithoutSeconds => String::from("%H:%M"), + TimeFormat::BinaryCircle => String::from("c%T"), + TimeFormat::BinaryRectangle => String::from("r%T"), + TimeFormat::Custom(format) => format.to_string(), + } + } +} + +#[derive(Clone, Debug)] +struct TimeOutput { + label: String, + icon: String, +} + +impl TimeOutput { + fn new() -> Self { + Self { + label: String::new(), + icon: String::new(), + } + } +} + +#[derive(Clone, Debug)] +pub struct Time { + pub enable: bool, + pub format: TimeFormat, + label_prefix: LabelPrefix, + timezone: Option, + changing_icon: bool, + data_refresh_interval_millis: u64, + last_state: TimeOutput, + last_updated: Instant, +} + +impl Time { + fn output(&mut self) -> TimeOutput { + let mut output = self.last_state.clone(); + let now = Instant::now(); + + if now.duration_since(self.last_updated) + > Duration::from_millis(self.data_refresh_interval_millis) + { + let (formatted, current_time) = match &self.timezone { + Some(timezone) => match timezone.parse::() { + Ok(tz) => { + let dt = Local::now().with_timezone(&tz); + ( + dt.format(&self.format.fmt_string()) + .to_string() + .trim() + .to_string(), + Some(dt.time()), + ) + } + Err(_) => (format!("Invalid timezone: {timezone:?}"), None), + }, + None => { + let dt = Local::now(); + ( + dt.format(&self.format.fmt_string()) + .to_string() + .trim() + .to_string(), + Some(dt.time()), + ) + } + }; + + if current_time.is_none() { + return TimeOutput { + label: formatted, + icon: egui_phosphor::regular::WARNING_CIRCLE.to_string(), + }; + } + + let current_range = match &self.changing_icon { + true => TIME_RANGES + .iter() + .rev() + .find(|&(_, start)| current_time.unwrap() > *start) + .cloned(), + false => None, + } + .unwrap_or((egui_phosphor::regular::CLOCK, NaiveTime::default())); + + output = TimeOutput { + label: formatted, + icon: current_range.0.to_string(), + }; + + self.last_state.clone_from(&output); + self.last_updated = now; + } + + output + } + + fn paint_binary_circle( + &mut self, + size: f32, + number: u32, + max_power: usize, + ctx: &Context, + ui: &mut Ui, + ) { + let full_height = size; + let height = full_height / 4.0; + let width = height; + let offset = height / 2.0 - height / 8.0; + + let (response, painter) = + ui.allocate_painter(Vec2::new(width, full_height + offset * 2.0), Sense::hover()); + let color = ctx.style().visuals.text_color(); + + let c = response.rect.center(); + let r = height / 2.0 - 0.5; + + if number == 1 || number == 3 || number == 5 || number == 7 || number == 9 { + painter.circle_filled(c + Vec2::new(0.0, height * 1.50 + offset), r, color); + } else { + painter.circle_filled(c + Vec2::new(0.0, height * 1.50 + offset), r / 2.5, color); + } + + if number == 2 || number == 3 || number == 6 || number == 7 { + painter.circle_filled(c + Vec2::new(0.0, height * 0.50 + offset), r, color); + } else { + painter.circle_filled(c + Vec2::new(0.0, height * 0.50 + offset), r / 2.5, color); + } + + if number == 4 || number == 5 || number == 6 || number == 7 { + painter.circle_filled(c + Vec2::new(0.0, -height * 0.50 + offset), r, color); + } else if max_power > 2 { + painter.circle_filled(c + Vec2::new(0.0, -height * 0.50 + offset), r / 2.5, color); + } + + if number == 8 || number == 9 { + painter.circle_filled(c + Vec2::new(0.0, -height * 1.50 + offset), r, color); + } else if max_power > 3 { + painter.circle_filled(c + Vec2::new(0.0, -height * 1.50 + offset), r / 2.5, color); + } + } + + fn paint_binary_rect( + &mut self, + size: f32, + number: u32, + max_power: usize, + ctx: &Context, + ui: &mut Ui, + ) { + let full_height = size; + let height = full_height / 4.0; + let width = height * 1.5; + let offset = height / 2.0 - height / 8.0; + + let (response, painter) = + ui.allocate_painter(Vec2::new(width, full_height + offset * 2.0), Sense::hover()); + let color = ctx.style().visuals.text_color(); + let stroke = Stroke::new(1.0, color); + + let round_all = CornerRadius::same((response.rect.width() * 0.1) as u8); + let round_top = CornerRadius { + nw: round_all.nw, + ne: round_all.ne, + ..Default::default() + }; + let round_none = CornerRadius::ZERO; + let round_bottom = CornerRadius { + sw: round_all.nw, + se: round_all.ne, + ..Default::default() + }; + + if max_power == 2 { + let mut rect = response + .rect + .shrink2(Vec2::new(stroke.width, stroke.width + offset)); + rect.set_height(rect.height() - height * 2.0); + rect = rect.translate(Vec2::new(0.0, height * 2.0 + offset)); + painter.rect_stroke(rect, round_all, stroke, StrokeKind::Outside); + } else if max_power == 3 { + let mut rect = response + .rect + .shrink2(Vec2::new(stroke.width, stroke.width + offset)); + rect.set_height(rect.height() - height); + rect = rect.translate(Vec2::new(0.0, height + offset)); + painter.rect_stroke(rect, round_all, stroke, StrokeKind::Outside); + } else { + let mut rect = response + .rect + .shrink2(Vec2::new(stroke.width, stroke.width + offset)); + rect = rect.translate(Vec2::new(0.0, 0.0 + offset)); + painter.rect_stroke(rect, round_all, stroke, StrokeKind::Outside); + } + + let mut rect_bin = response.rect; + rect_bin.set_width(width); + + if number == 1 || number == 5 || number == 9 { + rect_bin.set_height(height); + painter.rect_filled( + rect_bin.translate(Vec2::new(stroke.width, height * 3.0 + offset * 2.0)), + round_bottom, + color, + ); + } + if number == 2 { + rect_bin.set_height(height); + painter.rect_filled( + rect_bin.translate(Vec2::new(stroke.width, height * 2.0 + offset * 2.0)), + if max_power == 2 { + round_top + } else { + round_none + }, + color, + ); + } + if number == 3 { + rect_bin.set_height(height * 2.0); + painter.rect_filled( + rect_bin.translate(Vec2::new(stroke.width, height * 2.0 + offset * 2.0)), + round_bottom, + color, + ); + } + if number == 4 || number == 5 { + rect_bin.set_height(height); + painter.rect_filled( + rect_bin.translate(Vec2::new(stroke.width, height * 1.0 + offset * 2.0)), + if max_power == 3 { + round_top + } else { + round_none + }, + color, + ); + } + if number == 6 { + rect_bin.set_height(height * 2.0); + painter.rect_filled( + rect_bin.translate(Vec2::new(stroke.width, height * 1.0 + offset * 2.0)), + if max_power == 3 { + round_top + } else { + round_none + }, + color, + ); + } + if number == 7 { + rect_bin.set_height(height * 3.0); + painter.rect_filled( + rect_bin.translate(Vec2::new(stroke.width, height + offset * 2.0)), + if max_power == 3 { + round_all + } else { + round_bottom + }, + color, + ); + } + if number == 8 || number == 9 { + rect_bin.set_height(height); + painter.rect_filled( + rect_bin.translate(Vec2::new(stroke.width, 0.0 + offset * 2.0)), + round_top, + color, + ); + } + } +} + +impl BarWidget for Time { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let mut output = self.output(); + if !output.label.is_empty() { + let use_binary_circle = output.label.starts_with('c'); + let use_binary_rectangle = output.label.starts_with('r'); + + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => output.icon, + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + ctx.style().visuals.selection.stroke.color, + 100.0, + ); + + if let LabelPrefix::Text | LabelPrefix::IconAndText = self.label_prefix { + output.label.insert_str(0, "TIME: "); + } + + if !use_binary_circle && !use_binary_rectangle { + layout_job.append( + &output.label, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: ctx.style().visuals.text_color(), + valign: Align::Center, + ..Default::default() + }, + ); + } + + let font_id = config.icon_font_id.clone(); + let is_reversed = matches!(config.alignment, Some(Alignment::Right)); + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new(false) + .show(ui, |ui| { + if !is_reversed { + ui.add(Label::new(layout_job.clone()).selectable(false)); + } + + if use_binary_circle || use_binary_rectangle { + let ordered_output = if is_reversed { + output.label.chars().rev().collect() + } else { + output.label + }; + + for (section_index, section) in + ordered_output.split(':').enumerate() + { + ui.scope(|ui| { + ui.spacing_mut().item_spacing = Vec2::splat(2.0); + for (number_index, number_char) in + section.chars().enumerate() + { + if let Some(number) = number_char.to_digit(10) { + // the hour is the second char in the first section (in reverse, it's in the last section) + let max_power = match ( + is_reversed, + section_index, + number_index, + ) { + (true, 2, 1) | (false, 0, 1) => 2, + (true, _, 1) | (false, _, 0) => 3, + _ => 4, + }; + + if use_binary_circle { + self.paint_binary_circle( + font_id.size, + number, + max_power, + ctx, + ui, + ); + } else if use_binary_rectangle { + self.paint_binary_rect( + font_id.size, + number, + max_power, + ctx, + ui, + ); + } + } + } + }); + } + } + + if is_reversed { + ui.add(Label::new(layout_job.clone()).selectable(false)); + } + }) + .clicked() + { + self.format.toggle() + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/update.rs b/komorebi-bar/src/widgets/update.rs new file mode 100644 index 00000000..f33391ea --- /dev/null +++ b/komorebi-bar/src/widgets/update.rs @@ -0,0 +1,156 @@ +use crate::config::LabelPrefix; +use crate::render::RenderConfig; +use crate::selected_frame::SelectableFrame; +use crate::widgets::widget::BarWidget; +use eframe::egui::Align; +use eframe::egui::Context; +use eframe::egui::Label; +use eframe::egui::TextFormat; +use eframe::egui::Ui; +use eframe::egui::text::LayoutJob; +use serde::Deserialize; +use serde::Serialize; +use std::process::Command; +use std::time::Duration; +use std::time::Instant; + +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct UpdateConfig { + /// Enable the Update widget + pub enable: bool, + /// Data refresh interval (default: 12 hours) + pub data_refresh_interval: Option, + /// Display label prefix + pub label_prefix: Option, +} + +impl From for Update { + fn from(value: UpdateConfig) -> Self { + let data_refresh_interval = value.data_refresh_interval.unwrap_or(12); + + let mut latest_version = String::new(); + + let client = reqwest::blocking::Client::new(); + if let Ok(response) = client + .get("https://api.github.com/repos/LGUG2Z/komorebi/releases/latest") + .header("User-Agent", "komorebi-bar-version-checker") + .send() + { + #[derive(Deserialize)] + struct Release { + tag_name: String, + } + + if let Ok(release) = + serde_json::from_str::(&response.text().unwrap_or_default()) + { + let trimmed = release.tag_name.trim_start_matches("v"); + latest_version = trimmed.to_string(); + } + } + + Self { + enable: value.enable, + data_refresh_interval, + installed_version: env!("CARGO_PKG_VERSION").to_string(), + latest_version, + label_prefix: value.label_prefix.unwrap_or(LabelPrefix::IconAndText), + last_updated: Instant::now() + .checked_sub(Duration::from_secs(data_refresh_interval)) + .unwrap(), + } + } +} + +pub struct Update { + pub enable: bool, + data_refresh_interval: u64, + installed_version: String, + latest_version: String, + label_prefix: LabelPrefix, + last_updated: Instant, +} + +impl Update { + fn output(&mut self) -> String { + let now = Instant::now(); + if now.duration_since(self.last_updated) + > Duration::from_secs((self.data_refresh_interval * 60) * 60) + { + let client = reqwest::blocking::Client::new(); + if let Ok(response) = client + .get("https://api.github.com/repos/LGUG2Z/komorebi/releases/latest") + .header("User-Agent", "komorebi-bar-version-checker") + .send() + { + #[derive(Deserialize)] + struct Release { + tag_name: String, + } + + if let Ok(release) = + serde_json::from_str::(&response.text().unwrap_or_default()) + { + let trimmed = release.tag_name.trim_start_matches("v"); + self.latest_version = trimmed.to_string(); + } + } + + self.last_updated = now; + } + + if self.latest_version > self.installed_version { + format!("Update available! v{}", self.latest_version) + } else { + String::new() + } + } +} + +impl BarWidget for Update { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) { + if self.enable { + let output = self.output(); + if !output.is_empty() { + let mut layout_job = LayoutJob::simple( + match self.label_prefix { + LabelPrefix::Icon | LabelPrefix::IconAndText => { + egui_phosphor::regular::ROCKET_LAUNCH.to_string() + } + LabelPrefix::None | LabelPrefix::Text => String::new(), + }, + config.icon_font_id.clone(), + ctx.style().visuals.selection.stroke.color, + 100.0, + ); + + layout_job.append( + &output, + 10.0, + TextFormat { + font_id: config.text_font_id.clone(), + color: ctx.style().visuals.text_color(), + valign: Align::Center, + ..Default::default() + }, + ); + + config.apply_on_widget(false, ui, |ui| { + if SelectableFrame::new(false) + .show(ui, |ui| ui.add(Label::new(layout_job).selectable(false))) + .clicked() + && let Err(error) = Command::new("explorer.exe") + .args([format!( + "https://github.com/LGUG2Z/komorebi/releases/v{}", + self.latest_version + )]) + .spawn() + { + eprintln!("{error}") + } + }); + } + } + } +} diff --git a/komorebi-bar/src/widgets/widget.rs b/komorebi-bar/src/widgets/widget.rs new file mode 100644 index 00000000..d91fe1f8 --- /dev/null +++ b/komorebi-bar/src/widgets/widget.rs @@ -0,0 +1,94 @@ +use crate::render::RenderConfig; +use crate::widgets::applications::Applications; +use crate::widgets::applications::ApplicationsConfig; +use crate::widgets::battery::Battery; +use crate::widgets::battery::BatteryConfig; +use crate::widgets::cpu::Cpu; +use crate::widgets::cpu::CpuConfig; +use crate::widgets::date::Date; +use crate::widgets::date::DateConfig; +// use crate::widgets::keyboard::Keyboard; +// use crate::widgets::keyboard::KeyboardConfig; +use crate::widgets::komorebi::Komorebi; +use crate::widgets::komorebi::KomorebiConfig; +// use crate::widgets::media::Media; +// use crate::widgets::media::MediaConfig; +use crate::widgets::memory::Memory; +use crate::widgets::memory::MemoryConfig; +use crate::widgets::network::Network; +use crate::widgets::network::NetworkConfig; +use crate::widgets::storage::Storage; +use crate::widgets::storage::StorageConfig; +use crate::widgets::time::Time; +use crate::widgets::time::TimeConfig; +use crate::widgets::update::Update; +use crate::widgets::update::UpdateConfig; +use eframe::egui::Context; +use eframe::egui::Ui; +use serde::Deserialize; +use serde::Serialize; + +pub trait BarWidget { + fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig); +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum WidgetConfig { + Applications(ApplicationsConfig), + Battery(BatteryConfig), + Cpu(CpuConfig), + Date(DateConfig), + // Keyboard(KeyboardConfig), + Komorebi(KomorebiConfig), + // Media(MediaConfig), + Memory(MemoryConfig), + Network(NetworkConfig), + Storage(StorageConfig), + Time(TimeConfig), + Update(UpdateConfig), +} + +impl WidgetConfig { + pub fn as_boxed_bar_widget(&self) -> Box { + match self { + WidgetConfig::Applications(config) => Box::new(Applications::from(config)), + WidgetConfig::Battery(config) => Box::new(Battery::from(*config)), + WidgetConfig::Cpu(config) => Box::new(Cpu::from(*config)), + WidgetConfig::Date(config) => Box::new(Date::from(config.clone())), + // WidgetConfig::Keyboard(config) => Box::new(Keyboard::from(*config)), + WidgetConfig::Komorebi(config) => Box::new(Komorebi::from(config)), + // WidgetConfig::Media(config) => Box::new(Media::from(*config)), + WidgetConfig::Memory(config) => Box::new(Memory::from(*config)), + WidgetConfig::Network(config) => Box::new(Network::from(*config)), + WidgetConfig::Storage(config) => Box::new(Storage::from(*config)), + WidgetConfig::Time(config) => Box::new(Time::from(config.clone())), + WidgetConfig::Update(config) => Box::new(Update::from(*config)), + } + } + + pub fn enabled(&self) -> bool { + match self { + WidgetConfig::Applications(config) => config.enable, + WidgetConfig::Battery(config) => config.enable, + WidgetConfig::Cpu(config) => config.enable, + WidgetConfig::Date(config) => config.enable, + // WidgetConfig::Keyboard(config) => config.enable, + WidgetConfig::Komorebi(config) => { + config.workspaces.as_ref().is_some_and(|w| w.enable) + || config.layout.as_ref().is_some_and(|w| w.enable) + || config.focused_container.as_ref().is_some_and(|w| w.enable) + || config + .configuration_switcher + .as_ref() + .is_some_and(|w| w.enable) + } + // WidgetConfig::Media(config) => config.enable, + WidgetConfig::Memory(config) => config.enable, + WidgetConfig::Network(config) => config.enable, + WidgetConfig::Storage(config) => config.enable, + WidgetConfig::Time(config) => config.enable, + WidgetConfig::Update(config) => config.enable, + } + } +} diff --git a/komorebi-client/Cargo.toml b/komorebi-client/Cargo.toml index 3799e2df..ba54d833 100644 --- a/komorebi-client/Cargo.toml +++ b/komorebi-client/Cargo.toml @@ -5,6 +5,7 @@ edition = "2024" [dependencies] komorebi = { path = "../komorebi", default-features = false } +komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", version = "0.1.38"} serde_json = { workspace = true } [features] diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 8e63854c..215fcae8 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,21 +1,33 @@ pub use komorebi::DATA_DIR; pub use komorebi::Notification; +pub use komorebi::NotificationEvent; +pub use komorebi::container::Container; pub use komorebi::core::ApplicationIdentifier; pub use komorebi::core::MoveBehaviour; pub use komorebi::core::OperationBehaviour; pub use komorebi::core::Sizing; pub use komorebi::core::SocketMessage; pub use komorebi::core::StateQuery; +pub use komorebi::core::SubscribeOptions; pub use komorebi::core::WindowKind; pub use komorebi::core::arrangement::Axis; pub use komorebi::core::asc::ApplicationSpecificConfiguration; pub use komorebi::core::cycle_direction::CycleDirection; pub use komorebi::core::default_layout::DefaultLayout; +pub use komorebi::core::layout::Layout; pub use komorebi::core::operation_direction::OperationDirection; pub use komorebi::core::pathext::PathExt; pub use komorebi::core::pathext::replace_env_in_path; pub use komorebi::core::rect::Rect; +pub use komorebi::monitor_reconciliator::MonitorNotification; +pub use komorebi::state::State; +pub use komorebi::static_config::KomorebiTheme; pub use komorebi::static_config::StaticConfig; +pub use komorebi::window::Window; +pub use komorebi::workspace::Workspace; +pub use komorebi::workspace::WorkspaceLayer; +pub use komorebi_themes::colour::Colour; +pub use komorebi_themes::colour::Rgb; use std::borrow::Borrow; use std::io::BufReader; use std::io::Read; @@ -86,3 +98,29 @@ pub fn subscribe(name: &str) -> std::io::Result { Ok(listener) } + +pub fn subscribe_with_options( + name: &str, + options: SubscribeOptions, +) -> std::io::Result { + let socket = DATA_DIR.join(name); + + match std::fs::remove_file(&socket) { + Ok(()) => {} + Err(error) => match error.kind() { + std::io::ErrorKind::NotFound => {} + _ => { + return Err(error); + } + }, + }; + + let listener = UnixListener::bind(&socket)?; + + send_message(&SocketMessage::AddSubscriberSocketWithOptions( + name.to_string(), + options, + ))?; + + Ok(listener) +} diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index a6d960fd..c76fdb54 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -6,32 +6,31 @@ edition = "2024" [dependencies] komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", version = "0.1.38"} +quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } +block2 = "0.3" clap = { workspace = true } color-eyre = { workspace = true } -crossbeam-channel = "0.5" -crossbeam-utils = "0.8" +crossbeam-channel = { workspace = true } +crossbeam-utils = { workspace = true } ctrlc = { version = "3", features = ["termination"] } -dispatch2 = "0.3" dirs = { workspace = true } -hotwatch = "0.5" +dispatch2 = "0.3" +hotwatch = { workspace = true } lazy_static = { workspace = true } nanoid = "0.4" -block2 = "0.3" objc2 = "0.6" -objc2-core-services = "0.3" objc2-app-kit = "0.3" objc2-application-services = "0.3" -objc2-quartz-core = "0.3" -objc2-core-video = "0.3" objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } +objc2-core-services = "0.3" +objc2-core-video = "0.3" objc2-foundation = "0.3" -parking_lot = "0.12" +objc2-quartz-core = "0.3" +parking_lot = { workspace = true } pastey = { workspace = true } quick-xml = { version = "0.38", features = ["serialize"] } -# forked to patch in serde_json_lenient and update some old dependencies -quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } regex = "1" schemars = { workspace = true, optional = true } serde = { workspace = true } @@ -41,9 +40,9 @@ shadow-rs = { workspace = true } strum = { version = "0.27", features = ["derive"] } sysinfo = { workspace = true } thiserror = { workspace = true } -tracing = "0.1" -tracing-appender = "0.2" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing = { workspace = true } +tracing-appender = { workspace = true } +tracing-subscriber = { workspace = true } [build-dependencies] shadow-rs = { workspace = true } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index e92a1b7e..5769aa50 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -113,12 +113,18 @@ lazy_static! { static ref REGEX_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(HashMap::new())); static ref MANAGE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![])); - static ref IGNORE_IDENTIFIERS: Arc>> = - Arc::new(Mutex::new(vec![MatchingRule::Simple(IdWithIdentifier { + static ref IGNORE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![ + MatchingRule::Simple(IdWithIdentifier { kind: ApplicationIdentifier::Exe, id: String::from("Spotlight"), matching_strategy: Option::from(MatchingStrategy::Equals), - })])); + }), + MatchingRule::Simple(IdWithIdentifier { + kind: ApplicationIdentifier::Exe, + id: String::from("komorebi-bar"), + matching_strategy: Option::from(MatchingStrategy::Equals), + }) + ])); static ref SESSION_FLOATING_APPLICATIONS: Arc>> = Arc::new(Mutex::new(Vec::new())); static ref FLOATING_APPLICATIONS: Arc>> = @@ -181,12 +187,13 @@ pub fn notify_subscribers( ) -> eyre::Result<()> { let is_override_event = matches!( notification.event, - NotificationEvent::Socket(SocketMessage::AddSubscriberSocket(_)) + NotificationEvent::Monitor(_) + | NotificationEvent::Socket(SocketMessage::AddSubscriberSocket(_)) | NotificationEvent::Socket(SocketMessage::AddSubscriberSocketWithOptions(_, _)) - // | NotificationEvent::Socket(SocketMessage::Theme(_)) - | NotificationEvent::Socket(SocketMessage::ReloadStaticConfiguration(_)) // | NotificationEvent::WindowManager(WindowManagerEvent::TitleUpdate(_, _)) - // | NotificationEvent::WindowManager(WindowManagerEvent::Show(_, _)) - // | NotificationEvent::WindowManager(WindowManagerEvent::Uncloak(_, _)) + | NotificationEvent::Socket(SocketMessage::Theme(_)) + | NotificationEvent::Socket(SocketMessage::ReloadStaticConfiguration(_)) + // | NotificationEvent::WindowManager(WindowManagerEvent::TitleUpdate(_, _)) + | NotificationEvent::WindowManager(WindowManagerEvent::Show(_, _)) // | NotificationEvent::WindowManager(WindowManagerEvent::Uncloak(_, _)) ); let notification = &serde_json::to_string(¬ification)?; @@ -259,7 +266,7 @@ impl Default for AccessibilityUiElement { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Default)] pub struct AccessibilityObserver(pub Option>); unsafe impl Sync for AccessibilityObserver {} unsafe impl Send for AccessibilityObserver {} @@ -271,12 +278,6 @@ impl Deref for AccessibilityObserver { } } -impl Default for AccessibilityObserver { - fn default() -> Self { - Self(None) - } -} - pub fn cf_array_as(array: &CFArray) -> impl Iterator> + use<'_, T> { let count = CFArray::count(array); (0..count).flat_map(move |idx| { diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index f4cd7829..b57e33bd 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -53,10 +53,13 @@ pub struct MacosApi; impl MacosApi { pub fn set_wallpaper(path: &Path, display_id: u32) -> eyre::Result<()> { - let path_str = path.to_str().ok_or_eyre("Invalid path encoding")?; + let path_str = path + .to_str() + .ok_or_eyre("Invalid path encoding")? + .to_string(); - DispatchQueue::main().exec_sync(|| { - let ns_path = NSString::from_str(path_str); + DispatchQueue::main().exec_async(move || { + let ns_path = NSString::from_str(&path_str); let url = unsafe { NSURL::fileURLWithPath(&ns_path) }; let mtm = unsafe { MainThreadMarker::new_unchecked() }; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 6c3550bc..3b57add4 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -257,15 +257,16 @@ fn main() -> eyre::Result<()> { StaticConfig::postload(config, &wm)?; } - wm.lock().update_focused_workspace(true, true)?; + wm.lock().retile_all(false)?; border_manager::listen_for_notifications(wm.clone(), CoreFoundationRunLoop(run_loop)); theme_manager::listen_for_notifications(); - listen_for_commands(wm.clone()); - listen_for_events(wm.clone()); monitor_reconciliator::listen_for_notifications(wm.clone())?; reaper::listen_for_notifications(wm.clone()); + listen_for_commands(wm.clone()); + listen_for_events(wm.clone()); + let quit_ctrlc = Arc::new(AtomicBool::new(false)); let quit_thread = quit_ctrlc.clone(); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 240607e8..7638ef64 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1756,8 +1756,7 @@ pub fn read_commands_uds( SocketMessage::TogglePause | SocketMessage::State | SocketMessage::GlobalState - // | SocketMessage::Stop - => Ok(wm.process_command(message, &mut stream)?), + | SocketMessage::Stop => Ok(wm.process_command(message, &mut stream)?), _ => { tracing::trace!("ignoring while paused"); Ok(()) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index aca11f61..8bacc78e 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -338,6 +338,10 @@ impl Window { AccessibilityApi::copy_attribute_names(&self.element).is_some() } + pub fn is_focused(&self) -> bool { + MacosApi::foreground_window_id().unwrap_or_default() == self.id + } + #[tracing::instrument(skip_all)] pub fn observe( &self, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index c411e5c1..39364751 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -558,6 +558,9 @@ struct Start { #[clap(short, long)] #[clap(value_parser = replace_env_in_path)] config: Option, + /// Start komorebi-bar in a background process + #[clap(long)] + bar: bool, // /// Do not attempt to auto-apply a dumped state temp file from a previously running instance of komorebi // #[clap(long)] // clean_state: bool, @@ -568,6 +571,9 @@ struct Stop { /// Do not restore windows after stopping komorebi #[clap(long, hide = true)] ignore_restore: bool, + /// Stop komorebi-bar if it is running as a background process + #[clap(long)] + bar: bool, } #[derive(Parser)] @@ -1472,6 +1478,17 @@ fn main() -> eyre::Result<()> { return Ok(()); } + if arg.bar { + let mut command = &mut Command::new("komorebi-bar"); + + command = command + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .stdin(Stdio::null()); + + command.spawn()?; + } + println!("\nThank you for using komorebi!\n"); println!("# Commercial Use License"); println!( @@ -1504,6 +1521,10 @@ fn main() -> eyre::Result<()> { send_message(&SocketMessage::Stop)?; } + if arg.bar { + Command::new("pkill").arg("komorebi-bar").spawn()?; + } + // TODO: see if we need a force quit sometimes like we do on Windows // let mut system = sysinfo::System::new_all(); // system.refresh_processes(ProcessesToUpdate::All, true); From c3a756cbde2ca6441b43fa492e28c91630ef639c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 15:54:13 -0700 Subject: [PATCH 095/305] fix(bar): don't look up window titles at runtime Doing runtime lookups via methods on Window in komorebi-bar won't work because the AccessibilityObserver is not serialized and sent as part of the notifications. Instead, the notifications now take a snapshot of WindowDetails and embed them so they can be read directly in komorebi-bar. --- komorebi-bar/src/widgets/komorebi.rs | 2 +- komorebi/src/window.rs | 48 +++++++--------------------- komorebi/src/workspace.rs | 17 ++++------ 3 files changed, 20 insertions(+), 47 deletions(-) diff --git a/komorebi-bar/src/widgets/komorebi.rs b/komorebi-bar/src/widgets/komorebi.rs index c3ad933c..fcbb3445 100644 --- a/komorebi-bar/src/widgets/komorebi.rs +++ b/komorebi-bar/src/widgets/komorebi.rs @@ -1004,7 +1004,7 @@ pub struct WindowInfo { impl From<&Window> for WindowInfo { fn from(value: &Window) -> Self { Self { - title: value.title(), + title: value.details.as_ref().map(|details| details.title.clone()), icon: None, // icon: ImageIcon::try_load(value.hwnd, || { // windows_icons::get_icon_by_hwnd(value.hwnd) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 8bacc78e..53091099 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -43,7 +43,6 @@ use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use crate::window_manager_event_listener; use color_eyre::eyre; -use color_eyre::eyre::OptionExt; use objc2::__framework_prelude::Retained; use objc2_app_kit::NSApplicationActivationOptions; use objc2_app_kit::NSRunningApplication; @@ -184,10 +183,11 @@ pub struct Window { pub application: Application, #[serde(skip_deserializing)] observer: AccessibilityObserver, + pub details: Option, } #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct WindowDetails { pub title: String, pub exe: String, @@ -195,16 +195,14 @@ pub struct WindowDetails { pub subrole: String, } -impl TryFrom<&Window> for WindowDetails { - type Error = eyre::ErrReport; - - fn try_from(value: &Window) -> std::result::Result { - Ok(Self { - title: value.title().ok_or_eyre("can't read title")?, - exe: value.exe().ok_or_eyre("can't read exee")?, - role: value.role().ok_or_eyre("can't read role")?, - subrole: value.subrole().ok_or_eyre("can't read subrole")?, - }) +impl From<&Window> for WindowDetails { + fn from(value: &Window) -> Self { + Self { + title: value.title().unwrap_or_default(), + exe: value.exe().unwrap_or_default(), + role: value.role().unwrap_or_default(), + subrole: value.subrole().unwrap_or_default(), + } } } @@ -261,34 +259,11 @@ impl Serialize for Window { { let mut state = serializer.serialize_struct("Window", 6)?; state.serialize_field("id", &self.id)?; - state.serialize_field( - "title", - &self - .title() - .unwrap_or_else(|| String::from("could not get window title")), - )?; - state.serialize_field( - "exe", - &self - .exe() - .unwrap_or_else(|| String::from("could not get window exe")), - )?; - state.serialize_field( - "role", - &self - .role() - .unwrap_or_else(|| String::from("could not get window accessibility role")), - )?; - state.serialize_field( - "subrole", - &self - .subrole() - .unwrap_or_else(|| String::from("could not get window accessibility subrole")), - )?; state.serialize_field( "rect", &Rect::from(MacosApi::window_rect(&self.element).unwrap_or_default()), )?; + state.serialize_field("details", &WindowDetails::from(self))?; state.end() } } @@ -331,6 +306,7 @@ impl Window { element: AccessibilityUiElement(element), application, observer: AccessibilityObserver(Some(observer)), + details: None, }) } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index fdf974ab..6ae9c0a8 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -975,31 +975,28 @@ impl Workspace { pub fn visible_window_details(&self) -> Vec { let mut vec: Vec = vec![]; - if let Some(maximized) = &self.maximized_window - && let Ok(details) = (maximized).try_into() - { + if let Some(maximized) = &self.maximized_window { + let details = maximized.into(); vec.push(details); } if let Some(monocle) = &self.monocle_container && let Some(focused) = monocle.focused_window() - && let Ok(details) = focused.try_into() { + let details = focused.into(); vec.push(details); } for container in self.containers() { - if let Some(focused) = container.focused_window() - && let Ok(details) = focused.try_into() - { + if let Some(focused) = container.focused_window() { + let details = focused.into(); vec.push(details); } } for window in self.floating_windows() { - if let Ok(details) = window.try_into() { - vec.push(details); - } + let details = window.into(); + vec.push(details); } vec From c9eeaf3999db6a08ab94b5b479516bd4996c9865 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 30 Sep 2025 18:50:22 -0700 Subject: [PATCH 096/305] chore(deps): bump egui and eframe to 0.32 --- Cargo.lock | 396 +++++++++++++++---------------- Cargo.toml | 6 +- deny.toml | 11 +- dependencies.json | 159 ++++++++++--- komorebi-bar/Cargo.toml | 8 +- komorebi-bar/src/bar.rs | 1 + komorebi-bar/src/widgets/date.rs | 3 +- komorebi-client/Cargo.toml | 3 +- komorebi/Cargo.toml | 2 +- 9 files changed, 338 insertions(+), 251 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b262c34..5e99eab3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,15 +20,15 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "accesskit" -version = "0.17.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3d3b8f9bae46a948369bc4a03e815d4ed6d616bd00de4051133a5019dc31c5a" +checksum = "e25ae84c0260bdf5df07796d7cc4882460de26a2b406ec0e6c42461a723b271b" [[package]] name = "accesskit_atspi_common" -version = "0.10.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c5dd55e6e94949498698daf4d48fb5659e824d7abec0d394089656ceaf99d4f" +checksum = "29bd41de2e54451a8ca0dd95ebf45b54d349d29ebceb7f20be264eee14e3d477" dependencies = [ "accesskit", "accesskit_consumer", @@ -40,20 +40,19 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47983a1084940ba9a39c077a8c63e55c619388be5476ac04c804cfbd1e63459" +checksum = "8bfae7c152994a31dc7d99b8eeac7784a919f71d1b306f4b83217e110fd3824c" dependencies = [ "accesskit", "hashbrown 0.15.5", - "immutable-chunkmap", ] [[package]] name = "accesskit_macos" -version = "0.18.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7329821f3bd1101e03a7d2e03bd339e3ac0dc64c70b4c9f9ae1949e3ba8dece1" +checksum = "692dd318ff8a7a0ffda67271c4bd10cf32249656f4e49390db0b26ca92b095f2" dependencies = [ "accesskit", "accesskit_consumer", @@ -65,9 +64,9 @@ dependencies = [ [[package]] name = "accesskit_unix" -version = "0.13.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcee751cc20d88678c33edaf9c07e8b693cd02819fe89053776f5313492273f5" +checksum = "c5f7474c36606d0fe4f438291d667bae7042ea2760f506650ad2366926358fc8" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -83,24 +82,23 @@ dependencies = [ [[package]] name = "accesskit_windows" -version = "0.24.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24fcd5d23d70670992b823e735e859374d694a3d12bfd8dd32bd3bd8bedb5d81" +checksum = "70a042b62c9c05bf7b616f015515c17d2813f3ba89978d6f4fc369735d60700a" dependencies = [ "accesskit", "accesskit_consumer", "hashbrown 0.15.5", - "paste", "static_assertions", - "windows 0.58.0", - "windows-core 0.58.0", + "windows 0.61.3", + "windows-core 0.61.2", ] [[package]] name = "accesskit_winit" -version = "0.23.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6a48dad5530b6deb9fc7a52cc6c3bf72cdd9eb8157ac9d32d69f2427a5e879" +checksum = "5c1f0d3d13113d8857542a4f8d1a1c24d1dc1527b77aee8426127f4901588708" dependencies = [ "accesskit", "accesskit_macos", @@ -386,17 +384,6 @@ dependencies = [ "slab", ] -[[package]] -name = "async-fs" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5" -dependencies = [ - "async-lock", - "blocking", - "futures-lite", -] - [[package]] name = "async-io" version = "2.6.0" @@ -498,9 +485,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atspi" -version = "0.22.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be534b16650e35237bb1ed189ba2aab86ce65e88cc84c66f4935ba38575cecbf" +checksum = "c83247582e7508838caf5f316c00791eee0e15c0bf743e6880585b867e16815c" dependencies = [ "atspi-common", "atspi-connection", @@ -509,9 +496,9 @@ dependencies = [ [[package]] name = "atspi-common" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1909ed2dc01d0a17505d89311d192518507e8a056a48148e3598fef5e7bb6ba7" +checksum = "33dfc05e7cdf90988a197803bf24f5788f94f7c94a69efa95683e8ffe76cfdfb" dependencies = [ "enumflags2", "serde", @@ -525,9 +512,9 @@ dependencies = [ [[package]] name = "atspi-connection" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "430c5960624a4baaa511c9c0fcc2218e3b58f5dbcc47e6190cafee344b873333" +checksum = "4193d51303d8332304056ae0004714256b46b6635a5c556109b319c0d3784938" dependencies = [ "atspi-common", "atspi-proxies", @@ -537,14 +524,13 @@ dependencies = [ [[package]] name = "atspi-proxies" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e6c5de3e524cf967569722446bcd458d5032348554d9a17d7d72b041ab7496" +checksum = "d2eebcb9e7e76f26d0bcfd6f0295e1cd1e6f33bedbc5698a971db8dc43d7751c" dependencies = [ "atspi-common", "serde", "zbus", - "zvariant", ] [[package]] @@ -594,7 +580,7 @@ dependencies = [ [[package]] name = "base16-egui-themes" version = "0.1.0" -source = "git+https://github.com/LGUG2Z/base16-egui-themes?rev=96f26c88d83781f234d42222293ec73d23a39ad8#96f26c88d83781f234d42222293ec73d23a39ad8" +source = "git+https://github.com/LGUG2Z/base16-egui-themes?rev=c9008bd5cfa288c926e9ea3aa18c92073f9281bd#c9008bd5cfa288c926e9ea3aa18c92073f9281bd" dependencies = [ "egui", "schemars 0.8.22", @@ -674,15 +660,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "block-sys" version = "0.2.1" @@ -851,8 +828,9 @@ dependencies = [ [[package]] name = "catppuccin-egui" -version = "5.3.1" -source = "git+https://github.com/LGUG2Z/catppuccin-egui?rev=bdaff30959512c4f7ee7304117076a48633d777f#bdaff30959512c4f7ee7304117076a48633d777f" +version = "5.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62cca484c0a36096745da413bacbd290322fd194eb1ed2d9910deec392649f2a" dependencies = [ "egui", ] @@ -991,10 +969,11 @@ dependencies = [ [[package]] name = "codespan-reporting" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" dependencies = [ + "serde", "termcolor", "unicode-width", ] @@ -1161,15 +1140,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - [[package]] name = "crc32fast" version = "1.5.0" @@ -1219,16 +1189,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "ctrlc" version = "3.5.0" @@ -1236,7 +1196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881c5d0a13b2f1498e2306e82cbada78390e152d4b1378fb28a84f4dcd0dc4f3" dependencies = [ "dispatch", - "nix 0.30.1", + "nix", "windows-sys 0.61.1", ] @@ -1301,16 +1261,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - [[package]] name = "dirs" version = "3.0.2" @@ -1445,9 +1395,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc4feb366740ded31a004a0e4452fbf84e80ef432ecf8314c485210229672fd1" +checksum = "94bdf37f8d5bd9aa7f753573fdda9cf7343afa73dd28d7bfe9593bd9798fc07e" dependencies = [ "bytemuck", "emath", @@ -1455,9 +1405,9 @@ dependencies = [ [[package]] name = "eframe" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0dfe0859f3fb1bc6424c57d41e10e9093fe938f426b691e42272c2f336d915c" +checksum = "14d1c15e7bd136b309bd3487e6ffe5f668b354cd9768636a836dd738ac90eb0b" dependencies = [ "ahash", "bytemuck", @@ -1491,9 +1441,9 @@ dependencies = [ [[package]] name = "egui" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd34cec49ab55d85ebf70139cb1ccd29c977ef6b6ba4fe85489d6877ee9ef3" +checksum = "5d5d0306cd61ca75e29682926d71f2390160247f135965242e904a636f51c0dc" dependencies = [ "accesskit", "ahash", @@ -1503,22 +1453,24 @@ dependencies = [ "log", "nohash-hasher", "profiling", + "smallvec", + "unicode-segmentation", ] [[package]] name = "egui-phosphor" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171d57331491e92f0a7c73fad1088716e3200984309f4f8684731b750cee1378" +checksum = "80049258178b29a9807b15b5bcf3d60722a22a91d03bc9316935dec5ed5ed2e0" dependencies = [ "egui", ] [[package]] name = "egui-wgpu" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d319dfef570f699b6e9114e235e862a2ddcf75f0d1a061de9e1328d92146d820" +checksum = "c12eca13293f8eba27a32aaaa1c765bfbf31acd43e8d30d5881dcbe5e99ca0c7" dependencies = [ "ahash", "bytemuck", @@ -1536,9 +1488,9 @@ dependencies = [ [[package]] name = "egui-winit" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d9dfbb78fe4eb9c3a39ad528b90ee5915c252e77bbab9d4ebc576541ab67e13" +checksum = "f95d0a91f9cb0dc2e732d49c2d521ac8948e1f0b758f306fb7b14d6f5db3927f" dependencies = [ "accesskit_winit", "ahash", @@ -1556,9 +1508,9 @@ dependencies = [ [[package]] name = "egui_glow" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "910906e3f042ea6d2378ec12a6fd07698e14ddae68aed2d819ffe944a73aab9e" +checksum = "cc7037813341727937f9e22f78d912f3e29bc3c46e2f40a9e82bb51cbf5e4cfb" dependencies = [ "ahash", "bytemuck", @@ -1580,9 +1532,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "emath" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e4cadcff7a5353ba72b7fea76bf2122b5ebdbc68e8155aa56dfdea90083fe1b" +checksum = "45fd7bc25f769a3c198fe1cf183124bf4de3bd62ef7b4f1eaf6b08711a3af8db" dependencies = [ "bytemuck", ] @@ -1631,9 +1583,9 @@ checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" [[package]] name = "epaint" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fcc0f5a7c613afd2dee5e4b30c3e6acafb8ad6f0edb06068811f708a67c562" +checksum = "63adcea970b7a13094fe97a36ab9307c35a750f9e24bf00bb7ef3de573e0fddb" dependencies = [ "ab_glyph", "ahash", @@ -1649,9 +1601,9 @@ dependencies = [ [[package]] name = "epaint_default_fonts" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7e7a64c02cf7a5b51e745a9e45f60660a286f151c238b9d397b3e923f5082f" +checksum = "1537accc50c9cab5a272c39300bdd0dd5dca210f6e5e8d70be048df9596e7ca2" [[package]] name = "equator" @@ -2031,16 +1983,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "gethostname" version = "1.0.2" @@ -2238,6 +2180,18 @@ dependencies = [ "bitflags 2.9.4", ] +[[package]] +name = "gpu-allocator" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd" +dependencies = [ + "log", + "presser", + "thiserror 1.0.69", + "windows 0.58.0", +] + [[package]] name = "gpu-descriptor" version = "0.3.2" @@ -2285,6 +2239,7 @@ checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" dependencies = [ "cfg-if", "crunchy", + "num-traits", ] [[package]] @@ -2673,15 +2628,6 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c5cedc30da3a610cac6b4ba17597bdf7152cf974e8aab3afb3d54455e371c8" -[[package]] -name = "immutable-chunkmap" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3e98b1520e49e252237edc238a39869da9f3241f2ec19dc788c1d24694d1e4" -dependencies = [ - "arrayvec", -] - [[package]] name = "indenter" version = "0.3.4" @@ -2955,7 +2901,7 @@ dependencies = [ [[package]] name = "komorebi-themes" version = "0.1.39" -source = "git+https://github.com/LGUG2Z/komorebi#52a745d0a355f4eeeba468bea5174610a2ebf30f" +source = "git+https://github.com/LGUG2Z/komorebi?rev=1c23439f959bcfddf0f71918fc03a97dd4f30727#1c23439f959bcfddf0f71918fc03a97dd4f30727" dependencies = [ "base16-egui-themes", "catppuccin-egui", @@ -3063,6 +3009,12 @@ dependencies = [ "windows-link 0.2.0", ] +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + [[package]] name = "libredox" version = "0.1.10" @@ -3335,24 +3287,27 @@ dependencies = [ [[package]] name = "naga" -version = "24.0.0" +version = "25.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e380993072e52eef724eddfcde0ed013b0c023c3f0417336ed041aa9f076994e" +checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632" dependencies = [ "arrayvec", "bit-set", "bitflags 2.9.4", "cfg_aliases", "codespan-reporting", + "half", + "hashbrown 0.15.5", "hexf-parse", "indexmap 2.11.4", "log", + "num-traits", + "once_cell", "rustc-hash 1.1.0", "spirv", "strum 0.26.3", - "termcolor", "thiserror 2.0.17", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -3492,19 +3447,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" -[[package]] -name = "nix" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" -dependencies = [ - "bitflags 2.9.4", - "cfg-if", - "cfg_aliases", - "libc", - "memoffset", -] - [[package]] name = "nix" version = "0.30.1" @@ -3515,6 +3457,7 @@ dependencies = [ "cfg-if", "cfg_aliases", "libc", + "memoffset", ] [[package]] @@ -3688,6 +3631,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -4511,6 +4455,12 @@ dependencies = [ "windows-sys 0.61.1", ] +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + [[package]] name = "potential_utf" version = "0.1.3" @@ -4535,6 +4485,12 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + [[package]] name = "proc-macro-crate" version = "3.4.0" @@ -4607,9 +4563,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.30.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" dependencies = [ "memchr", "serde", @@ -4796,6 +4752,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "range-alloc" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d6831663a5098ea164f89cff59c6284e95f4e3c76ce9848d4529f5ccca9bde" + [[package]] name = "rav1e" version = "0.7.1" @@ -5414,17 +5376,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "shadow-rs" version = "1.4.0" @@ -5606,7 +5557,7 @@ dependencies = [ "lazycell", "libc", "mach2", - "nix 0.30.1", + "nix", "num-traits", "plist", "uom", @@ -6295,9 +6246,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.14" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" [[package]] name = "unicode-xid" @@ -6654,17 +6605,20 @@ checksum = "a751b3277700db47d3e574514de2eced5e54dc8a5436a3bf7a0b248b2cee16f3" [[package]] name = "wgpu" -version = "24.0.5" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0b3436f0729f6cdf2e6e9201f3d39dc95813fad61d826c1ed07918b4539353" +checksum = "ec8fb398f119472be4d80bc3647339f56eb63b2a331f6a3d16e25d8144197dd9" dependencies = [ "arrayvec", "bitflags 2.9.4", "cfg_aliases", "document-features", + "hashbrown 0.15.5", "js-sys", "log", + "naga", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle", "smallvec", @@ -6679,46 +6633,84 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "24.0.5" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f0aa306497a238d169b9dc70659105b4a096859a34894544ca81719242e1499" +checksum = "f7b882196f8368511d613c6aeec80655160db6646aebddf8328879a88d54e500" dependencies = [ "arrayvec", + "bit-set", "bit-vec", "bitflags 2.9.4", "cfg_aliases", "document-features", + "hashbrown 0.15.5", "indexmap 2.11.4", "log", "naga", "once_cell", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle", "rustc-hash 1.1.0", "smallvec", "thiserror 2.0.17", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-windows-linux-android", "wgpu-hal", "wgpu-types", ] [[package]] -name = "wgpu-hal" -version = "24.0.4" +name = "wgpu-core-deps-apple" +version = "25.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f112f464674ca69f3533248508ee30cb84c67cf06c25ff6800685f5e0294e259" +checksum = "cfd488b3239b6b7b185c3b045c39ca6bf8af34467a4c5de4e0b1a564135d093d" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-emscripten" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09ad7aceb3818e52539acc679f049d3475775586f3f4e311c30165cf2c00445" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cba5fb5f7f9c98baa7c889d444f63ace25574833df56f5b817985f641af58e46" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-hal" +version = "25.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f968767fe4d3d33747bbd1473ccd55bf0f6451f55d733b5597e67b5deab4ad17" dependencies = [ "android_system_properties", "arrayvec", "ash", + "bit-set", "bitflags 2.9.4", + "block", "bytemuck", + "cfg-if", "cfg_aliases", "core-graphics-types", "glow", "glutin_wgl_sys", "gpu-alloc", + "gpu-allocator", "gpu-descriptor", + "hashbrown 0.15.5", "js-sys", "khronos-egl", "libc", @@ -6728,30 +6720,33 @@ dependencies = [ "naga", "ndk-sys 0.5.0+25.2.9519653", "objc", - "once_cell", "ordered-float", "parking_lot", + "portable-atomic", "profiling", + "range-alloc", "raw-window-handle", "renderdoc-sys", - "rustc-hash 1.1.0", "smallvec", "thiserror 2.0.17", "wasm-bindgen", "web-sys", "wgpu-types", "windows 0.58.0", + "windows-core 0.58.0", ] [[package]] name = "wgpu-types" -version = "24.0.0" +version = "25.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50ac044c0e76c03a0378e7786ac505d010a873665e2d51383dcff8dd227dc69c" +checksum = "2aa49460c2a8ee8edba3fca54325540d904dd85b2e086ada762767e17d06e8bc" dependencies = [ "bitflags 2.9.4", + "bytemuck", "js-sys", "log", + "thiserror 2.0.17", "web-sys", ] @@ -7435,16 +7430,6 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b" -[[package]] -name = "xdg-home" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" -dependencies = [ - "libc", - "windows-sys 0.59.0", -] - [[package]] name = "xkbcommon-dl" version = "0.4.2" @@ -7505,13 +7490,12 @@ dependencies = [ [[package]] name = "zbus" -version = "4.4.0" +version = "5.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" +checksum = "2d07e46d035fb8e375b2ce63ba4e4ff90a7f73cf2ffb0138b29e1158d2eaadf7" dependencies = [ "async-broadcast", "async-executor", - "async-fs", "async-io", "async-lock", "async-process", @@ -7522,20 +7506,16 @@ dependencies = [ "enumflags2", "event-listener", "futures-core", - "futures-sink", - "futures-util", + "futures-lite", "hex", - "nix 0.29.0", + "nix", "ordered-stream", - "rand 0.8.5", "serde", "serde_repr", - "sha1", - "static_assertions", "tracing", "uds_windows", - "windows-sys 0.52.0", - "xdg-home", + "windows-sys 0.60.2", + "winnow", "zbus_macros", "zbus_names", "zvariant", @@ -7543,9 +7523,9 @@ dependencies = [ [[package]] name = "zbus-lockstep" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca2c5dceb099bddaade154055c926bb8ae507a18756ba1d8963fd7b51d8ed1d" +checksum = "29e96e38ded30eeab90b6ba88cb888d70aef4e7489b6cd212c5e5b5ec38045b6" dependencies = [ "zbus_xml", "zvariant", @@ -7553,9 +7533,9 @@ dependencies = [ [[package]] name = "zbus-lockstep-macros" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "709ab20fc57cb22af85be7b360239563209258430bccf38d8b979c5a2ae3ecce" +checksum = "dc6821851fa840b708b4cbbaf6241868cabc85a2dc22f426361b0292bfc0b836" dependencies = [ "proc-macro2", "quote", @@ -7567,35 +7547,38 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "4.4.0" +version = "5.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" +checksum = "57e797a9c847ed3ccc5b6254e8bcce056494b375b511b3d6edcec0aeb4defaca" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.106", + "zbus_names", + "zvariant", "zvariant_utils", ] [[package]] name = "zbus_names" -version = "3.0.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" +checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" dependencies = [ "serde", "static_assertions", + "winnow", "zvariant", ] [[package]] name = "zbus_xml" -version = "4.0.0" +version = "5.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3f374552b954f6abb4bd6ce979e6c9b38fb9d0cd7cc68a7d796e70c9f3a233" +checksum = "589e9a02bfafb9754bb2340a9e3b38f389772684c63d9637e76b1870377bec29" dependencies = [ - "quick-xml 0.30.0", + "quick-xml 0.36.2", "serde", "static_assertions", "zbus_names", @@ -7708,22 +7691,23 @@ dependencies = [ [[package]] name = "zvariant" -version = "4.2.0" +version = "5.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" +checksum = "999dd3be73c52b1fccd109a4a81e4fcd20fab1d3599c8121b38d04e1419498db" dependencies = [ "endi", "enumflags2", "serde", - "static_assertions", + "winnow", "zvariant_derive", + "zvariant_utils", ] [[package]] name = "zvariant_derive" -version = "4.2.0" +version = "5.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" +checksum = "6643fd0b26a46d226bd90d3f07c1b5321fe9bb7f04673cb37ac6d6883885b68e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7734,11 +7718,13 @@ dependencies = [ [[package]] name = "zvariant_utils" -version = "2.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" +checksum = "c6949d142f89f6916deca2232cf26a8afacf2b9fdc35ce766105e104478be599" dependencies = [ "proc-macro2", "quote", + "serde", "syn 2.0.106", + "winnow", ] diff --git a/Cargo.toml b/Cargo.toml index 15a74e7e..a2b24a80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,8 @@ members = [ [workspace.dependencies] +komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "1c23439f959bcfddf0f71918fc03a97dd4f30727" } + chrono = "0.4" chrono-tz = "0.10" clap = { version = "4", features = ["derive", "wrap_help"] } @@ -16,8 +18,8 @@ crossbeam-channel = "0.5" crossbeam-utils = "0.8" dirs = "6" dunce = "1" -eframe = "0.31" -egui_extras = "0.31" +eframe = "0.32" +egui_extras = "0.32" hotwatch = "0.5" lazy_static = "1" parking_lot = "0.12" diff --git a/deny.toml b/deny.toml index fc814d68..d97cd110 100644 --- a/deny.toml +++ b/deny.toml @@ -10,8 +10,9 @@ feature-depth = 1 [advisories] ignore = [ + { id = "RUSTSEC-2024-0436", reason = "paste is fine" }, { id = "RUSTSEC-2024-0320", reason = "not using any yaml features from this library" }, - { id = "RUSTSEC-2025-0056", reason = "only used for colour palette generation" } + { id = "RUSTSEC-2025-0056", reason = "only used for colour palette generation" }, ] [licenses] @@ -19,6 +20,7 @@ allow = [ "0BSD", "Apache-2.0", "Artistic-2.0", + "BSD-2-Clause", "BSD-3-Clause", "CC0-1.0", "ISC", @@ -32,7 +34,6 @@ allow = [ "LicenseRef-Komorebi-2.0", # these are also ok, but not yet used - # "BSD-2-Clause", # "BSL-1.0", # "MIT-0", ] @@ -53,6 +54,11 @@ crate = "komorebic" expression = "LicenseRef-Komorebi-2.0" license-files = [] +[[licenses.clarify]] +crate = "komorebi-bar" +expression = "LicenseRef-Komorebi-2.0" +license-files = [] + [[licenses.clarify]] crate = "komorebi-themes" expression = "LicenseRef-Komorebi-2.0" @@ -77,7 +83,6 @@ allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-git = [ "https://github.com/LGUG2Z/quickxml_to_serde", "https://github.com/LGUG2Z/base16-egui-themes", - "https://github.com/LGUG2Z/catppuccin-egui", "https://github.com/LGUG2Z/flavours", "https://github.com/LGUG2Z/komorebi", "https://github.com/LGUG2Z/base16_color_scheme", diff --git a/dependencies.json b/dependencies.json index 63745539..46ce0fbb 100644 --- a/dependencies.json +++ b/dependencies.json @@ -12,10 +12,10 @@ [ "ab_glyph 0.2.32 registry+https://github.com/rust-lang/crates.io-index", "ab_glyph_rasterizer 0.1.10 registry+https://github.com/rust-lang/crates.io-index", - "accesskit 0.17.1 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_consumer 0.26.0 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_macos 0.18.1 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_winit 0.23.1 registry+https://github.com/rust-lang/crates.io-index", + "accesskit 0.19.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_consumer 0.28.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_macos 0.20.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_winit 0.27.0 registry+https://github.com/rust-lang/crates.io-index", "addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", @@ -34,14 +34,17 @@ "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", + "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "cc 1.2.39 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", + "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", @@ -52,8 +55,10 @@ "core-foundation 0.10.1 registry+https://github.com/rust-lang/crates.io-index", "core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index", "core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index", + "core-graphics 0.22.3 registry+https://github.com/rust-lang/crates.io-index", "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "core-text 19.2.0 registry+https://github.com/rust-lang/crates.io-index", "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", @@ -72,17 +77,20 @@ "displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index", "document-features 0.2.11 registry+https://github.com/rust-lang/crates.io-index", "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", + "dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", - "ecolor 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "eframe 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "egui 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "egui-winit 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "egui_glow 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "egui-phosphor 0.10.0 registry+https://github.com/rust-lang/crates.io-index", + "egui-winit 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", - "emath 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "epaint 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "env_home 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", @@ -92,8 +100,10 @@ "find-msvc-tools 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "flate2 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "foreign-types-macros 0.2.3 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types-shared 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "foreign-types-shared 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", "futures-channel 0.3.31 registry+https://github.com/rust-lang/crates.io-index", @@ -105,6 +115,7 @@ "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", + "gif 0.13.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", @@ -126,7 +137,8 @@ "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "image 0.25.8 registry+https://github.com/rust-lang/crates.io-index", - "immutable-chunkmap 2.1.2 registry+https://github.com/rust-lang/crates.io-index", + "image-webp 0.2.4 registry+https://github.com/rust-lang/crates.io-index", + "imgref 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", @@ -134,6 +146,7 @@ "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", + "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", @@ -148,6 +161,7 @@ "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", + "mach2 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", "minimal-lexical 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", @@ -155,10 +169,15 @@ "moxcms 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "num-bigint 0.4.6 registry+https://github.com/rust-lang/crates.io-index", + "num-complex 0.4.6 registry+https://github.com/rust-lang/crates.io-index", "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "num-derive 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "num-integer 0.1.46 registry+https://github.com/rust-lang/crates.io-index", "num-iter 0.1.45 registry+https://github.com/rust-lang/crates.io-index", "num-rational 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "num-rational 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", @@ -181,6 +200,7 @@ "palette_derive 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", + "paste 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", @@ -192,15 +212,20 @@ "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", + "profiling-procmacros 1.0.17 registry+https://github.com/rust-lang/crates.io-index", "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index", + "qoi 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", + "rand 0.9.2 registry+https://github.com/rust-lang/crates.io-index", "rand_chacha 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "rand_chacha 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "rand_chacha 0.9.0 registry+https://github.com/rust-lang/crates.io-index", "rand_core 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "rand_core 0.6.4 registry+https://github.com/rust-lang/crates.io-index", + "rand_core 0.9.3 registry+https://github.com/rust-lang/crates.io-index", "rand_pcg 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", @@ -227,11 +252,12 @@ "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", - "shadow-rs 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "siphasher 0.3.11 registry+https://github.com/rust-lang/crates.io-index", + "siphasher 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", @@ -253,11 +279,15 @@ "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", + "typenum 1.18.0 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", + "uom 0.37.0 registry+https://github.com/rust-lang/crates.io-index", "url 2.5.7 registry+https://github.com/rust-lang/crates.io-index", "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", @@ -271,6 +301,7 @@ "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" ] ], @@ -290,15 +321,27 @@ [ "BSD-2-Clause", [ + "av1-grain 0.2.4 registry+https://github.com/rust-lang/crates.io-index", + "mach2 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "rav1e 0.7.1 registry+https://github.com/rust-lang/crates.io-index", + "v_frame 0.3.9 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "BSD-3-Clause", [ + "alloc-no-stdlib 2.0.4 registry+https://github.com/rust-lang/crates.io-index", + "alloc-stdlib 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "avif-serialize 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "brotli 8.0.2 registry+https://github.com/rust-lang/crates.io-index", + "brotli-decompressor 5.0.0 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", + "exr 1.73.0 registry+https://github.com/rust-lang/crates.io-index", + "lebe 0.5.3 registry+https://github.com/rust-lang/crates.io-index", "moxcms 0.7.5 registry+https://github.com/rust-lang/crates.io-index", - "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index" + "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index", + "ravif 0.11.20 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -310,7 +353,9 @@ [ "CC0-1.0", [ + "dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index", "file-id 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "imgref 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "notify 6.1.1 registry+https://github.com/rust-lang/crates.io-index", "notify-debouncer-full 0.1.0 registry+https://github.com/rust-lang/crates.io-index" ] @@ -318,26 +363,29 @@ [ "ISC", [ - "libloading 0.8.9 registry+https://github.com/rust-lang/crates.io-index" + "libloading 0.8.9 registry+https://github.com/rust-lang/crates.io-index", + "starship-battery 0.10.2 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "MIT", [ - "accesskit 0.17.1 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_consumer 0.26.0 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_macos 0.18.1 registry+https://github.com/rust-lang/crates.io-index", + "accesskit 0.19.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_consumer 0.28.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_macos 0.20.0 registry+https://github.com/rust-lang/crates.io-index", "addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", + "aligned-vec 0.6.4 registry+https://github.com/rust-lang/crates.io-index", "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", "anyhow 1.0.100 registry+https://github.com/rust-lang/crates.io-index", "arboard 3.6.1 registry+https://github.com/rust-lang/crates.io-index", + "arg_enum_proc_macro 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "arrayvec 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "atomic-waker 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -345,12 +393,17 @@ "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", + "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", "block-sys 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "block2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "block2 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "brotli 8.0.2 registry+https://github.com/rust-lang/crates.io-index", + "brotli-decompressor 5.0.0 registry+https://github.com/rust-lang/crates.io-index", + "built 0.7.7 registry+https://github.com/rust-lang/crates.io-index", "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "byteorder 1.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -358,12 +411,13 @@ "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "calm_io 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "calmio_filters 0.1.0 registry+https://github.com/rust-lang/crates.io-index", - "catppuccin-egui 5.3.1 git+https://github.com/LGUG2Z/catppuccin-egui?rev=bdaff30959512c4f7ee7304117076a48633d777f", + "catppuccin-egui 5.6.0 registry+https://github.com/rust-lang/crates.io-index", "cc 1.2.39 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", + "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", @@ -376,8 +430,10 @@ "core-foundation 0.10.1 registry+https://github.com/rust-lang/crates.io-index", "core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index", "core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index", + "core-graphics 0.22.3 registry+https://github.com/rust-lang/crates.io-index", "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "core-text 19.2.0 registry+https://github.com/rust-lang/crates.io-index", "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", @@ -401,16 +457,20 @@ "document-features 0.2.11 registry+https://github.com/rust-lang/crates.io-index", "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", - "ecolor 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "eframe 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "egui 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "egui-winit 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "egui_glow 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "egui-phosphor 0.10.0 registry+https://github.com/rust-lang/crates.io-index", + "egui-winit 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", - "emath 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "epaint 0.31.1 registry+https://github.com/rust-lang/crates.io-index", - "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index", + "env_home 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "equator 0.4.2 registry+https://github.com/rust-lang/crates.io-index", + "equator-macro 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", @@ -423,8 +483,11 @@ "flate2 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "flavours 0.7.2 git+https://github.com/LGUG2Z/flavours", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", + "font-loader 0.11.0 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "foreign-types-macros 0.2.3 registry+https://github.com/rust-lang/crates.io-index", + "foreign-types-shared 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "foreign-types-shared 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index", "fs-tail 0.1.4 registry+https://github.com/rust-lang/crates.io-index", @@ -438,6 +501,7 @@ "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", + "gif 0.13.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", @@ -465,7 +529,7 @@ "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "image 0.23.14 registry+https://github.com/rust-lang/crates.io-index", "image 0.25.8 registry+https://github.com/rust-lang/crates.io-index", - "immutable-chunkmap 2.1.2 registry+https://github.com/rust-lang/crates.io-index", + "image-webp 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", @@ -473,6 +537,7 @@ "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", + "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", @@ -487,7 +552,10 @@ "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", + "loop9 0.1.5 registry+https://github.com/rust-lang/crates.io-index", + "mach2 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", + "maybe-rayon 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "memchr 2.7.6 registry+https://github.com/rust-lang/crates.io-index", "memoffset 0.9.1 registry+https://github.com/rust-lang/crates.io-index", "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", @@ -498,14 +566,22 @@ "mio 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "nanoid 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", + "netdev 0.36.0 registry+https://github.com/rust-lang/crates.io-index", + "new_debug_unreachable 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "nom 7.1.3 registry+https://github.com/rust-lang/crates.io-index", + "noop_proc_macro 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", + "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "num-bigint 0.4.6 registry+https://github.com/rust-lang/crates.io-index", + "num-complex 0.4.6 registry+https://github.com/rust-lang/crates.io-index", "num-conv 0.1.0 registry+https://github.com/rust-lang/crates.io-index", + "num-derive 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "num-integer 0.1.46 registry+https://github.com/rust-lang/crates.io-index", "num-iter 0.1.45 registry+https://github.com/rust-lang/crates.io-index", "num-rational 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "num-rational 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "objc-sys 0.3.5 registry+https://github.com/rust-lang/crates.io-index", @@ -537,11 +613,14 @@ "palette_derive 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", + "paste 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", + "phf 0.12.1 registry+https://github.com/rust-lang/crates.io-index", "phf 0.8.0 registry+https://github.com/rust-lang/crates.io-index", "phf_codegen 0.8.0 registry+https://github.com/rust-lang/crates.io-index", "phf_generator 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "phf_shared 0.12.1 registry+https://github.com/rust-lang/crates.io-index", "phf_shared 0.8.0 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", @@ -552,6 +631,8 @@ "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", + "profiling-procmacros 1.0.17 registry+https://github.com/rust-lang/crates.io-index", + "qoi 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.38.3 registry+https://github.com/rust-lang/crates.io-index", @@ -559,11 +640,15 @@ "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", + "rand 0.9.2 registry+https://github.com/rust-lang/crates.io-index", "rand_chacha 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "rand_chacha 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "rand_chacha 0.9.0 registry+https://github.com/rust-lang/crates.io-index", "rand_core 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "rand_core 0.6.4 registry+https://github.com/rust-lang/crates.io-index", + "rand_core 0.9.3 registry+https://github.com/rust-lang/crates.io-index", "rand_pcg 0.2.1 registry+https://github.com/rust-lang/crates.io-index", + "random_word 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", @@ -593,13 +678,15 @@ "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", - "shadow-rs 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "simd-adler32 0.3.7 registry+https://github.com/rust-lang/crates.io-index", + "simd_helpers 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "siphasher 0.3.11 registry+https://github.com/rust-lang/crates.io-index", + "siphasher 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "slab 0.4.11 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", @@ -643,10 +730,14 @@ "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", "try-lock 0.2.5 registry+https://github.com/rust-lang/crates.io-index", "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", + "typenum 1.18.0 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", + "uom 0.37.0 registry+https://github.com/rust-lang/crates.io-index", "url 2.5.7 registry+https://github.com/rust-lang/crates.io-index", "utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index", @@ -657,16 +748,19 @@ "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "webbrowser 1.0.5 registry+https://github.com/rust-lang/crates.io-index", "weezl 0.1.10 registry+https://github.com/rust-lang/crates.io-index", + "which 7.0.3 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "MIT-0", [ + "dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index" ] ], @@ -681,13 +775,13 @@ [ "OFL-1.1", [ - "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index" + "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "Ubuntu-font-1.0", [ - "epaint_default_fonts 0.31.1 registry+https://github.com/rust-lang/crates.io-index" + "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -754,6 +848,7 @@ "objc2-security 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" ] ] diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 2d9e42cc..8afcd340 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -7,7 +7,7 @@ edition = "2024" [dependencies] komorebi-client = { path = "../komorebi-client", default-features = false } -komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", version = "0.1.38" } +komorebi-themes = { workspace = true } chrono-tz = { workspace = true } chrono = { workspace = true } @@ -17,7 +17,7 @@ crossbeam-channel = { workspace = true } dirs = { workspace = true } dunce = { workspace = true } eframe = { workspace = true } -egui-phosphor = "0.9" +egui-phosphor = "0.10" font-loader = "0.11" hotwatch = { workspace = true } image = "0.25" @@ -37,10 +37,6 @@ sysinfo = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } which = { workspace = true } -#windows = { workspace = true } -#windows-core = { workspace = true } -#windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "0c9d7ee1b807347c507d3a9862dd007b4d3f4354" } -#windows-icons-fallback = { package = "windows-icons", git = "https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" } [features] default = ["schemars"] diff --git a/komorebi-bar/src/bar.rs b/komorebi-bar/src/bar.rs index e80277bd..30777e3d 100644 --- a/komorebi-bar/src/bar.rs +++ b/komorebi-bar/src/bar.rs @@ -485,6 +485,7 @@ impl Komobar { .margin .as_ref() .map_or(0, |v| v.to_individual(0.0).bottom as i32); + let new_rect = komorebi_client::Rect { left: 0, top: (height as i32) diff --git a/komorebi-bar/src/widgets/date.rs b/komorebi-bar/src/widgets/date.rs index 5fe662fa..1922fd60 100644 --- a/komorebi-bar/src/widgets/date.rs +++ b/komorebi-bar/src/widgets/date.rs @@ -13,6 +13,7 @@ use eframe::egui::WidgetText; use eframe::egui::text::LayoutJob; use serde::Deserialize; use serde::Serialize; +use std::sync::Arc; use std::time::Duration; use std::time::Instant; @@ -225,7 +226,7 @@ impl BarWidget for Date { if SelectableFrame::new(false) .show(ui, |ui| { ui.add( - Label::new(WidgetText::LayoutJob(layout_job.clone())) + Label::new(WidgetText::LayoutJob(Arc::from(layout_job.clone()))) .selectable(false), ) }) diff --git a/komorebi-client/Cargo.toml b/komorebi-client/Cargo.toml index ba54d833..15ed8e36 100644 --- a/komorebi-client/Cargo.toml +++ b/komorebi-client/Cargo.toml @@ -5,7 +5,8 @@ edition = "2024" [dependencies] komorebi = { path = "../komorebi", default-features = false } -komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", version = "0.1.38"} +komorebi-themes = { workspace = true } + serde_json = { workspace = true } [features] diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index c76fdb54..71e0228b 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -5,7 +5,7 @@ description = "A tiling window manager for macOS" edition = "2024" [dependencies] -komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", version = "0.1.38"} +komorebi-themes = { workspace = true } quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } block2 = "0.3" From 75373c217426fac8079c03b3c7ba98f98ff7c626 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 1 Oct 2025 11:19:36 -0700 Subject: [PATCH 097/305] fix(bar): load app icons for focused window widget This commit adds the icon path to WindowDetails and then uses that path to look up and load the icon in komorebi-bar. --- Cargo.lock | 11 +++++++ komorebi-bar/Cargo.toml | 3 +- komorebi-bar/src/widgets/komorebi.rs | 41 +++++++++++++++++++++---- komorebi-bar/src/widgets/mod.rs | 10 +++---- komorebi/src/window.rs | 45 ++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e99eab3..b3db51c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2456,6 +2456,16 @@ dependencies = [ "cc", ] +[[package]] +name = "icns" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ccfbad7e08da70a5b48a924994a5afd93125ce5d45a3b0ba0b8da7bda59a40" +dependencies = [ + "byteorder", + "png 0.16.8", +] + [[package]] name = "icu_collections" version = "2.0.0" @@ -2868,6 +2878,7 @@ dependencies = [ "egui-phosphor", "font-loader", "hotwatch", + "icns", "image 0.25.8", "komorebi-client", "komorebi-themes", diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 8afcd340..3236ab41 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -9,8 +9,8 @@ edition = "2024" komorebi-client = { path = "../komorebi-client", default-features = false } komorebi-themes = { workspace = true } -chrono-tz = { workspace = true } chrono = { workspace = true } +chrono-tz = { workspace = true } clap = { workspace = true } color-eyre = { workspace = true } crossbeam-channel = { workspace = true } @@ -20,6 +20,7 @@ eframe = { workspace = true } egui-phosphor = "0.10" font-loader = "0.11" hotwatch = { workspace = true } +icns = "0.3" image = "0.25" lazy_static = { workspace = true } netdev = "0.36" diff --git a/komorebi-bar/src/widgets/komorebi.rs b/komorebi-bar/src/widgets/komorebi.rs index fcbb3445..3e207aab 100644 --- a/komorebi-bar/src/widgets/komorebi.rs +++ b/komorebi-bar/src/widgets/komorebi.rs @@ -28,6 +28,9 @@ use eframe::egui::Ui; use eframe::egui::Vec2; use eframe::egui::text::LayoutJob; use eframe::egui::vec2; +use icns::IconFamily; +use icns::IconType; +use image::RgbaImage; use komorebi_client::Container; use komorebi_client::PathExt; use komorebi_client::Rect; @@ -42,6 +45,8 @@ use serde::Serialize; use std::cell::RefCell; use std::collections::BTreeMap; use std::collections::HashMap; +use std::fs::File; +use std::io::BufReader; use std::io::Result as IoResult; use std::path::Path; use std::rc::Rc; @@ -1005,11 +1010,37 @@ impl From<&Window> for WindowInfo { fn from(value: &Window) -> Self { Self { title: value.details.as_ref().map(|details| details.title.clone()), - icon: None, - // icon: ImageIcon::try_load(value.hwnd, || { - // windows_icons::get_icon_by_hwnd(value.hwnd) - // .or_else(|| windows_icons_fallback::get_icon_by_process_id(value.process_id())) - // }), + icon: value + .details + .as_ref() + .map(|details| { + ImageIcon::try_load(details.icon_path.as_path(), || { + icns_to_rgba(&details.icon_path.to_string_lossy()) + }) + }) + .unwrap_or_default(), } } } + +pub fn icns_to_rgba(path: &str) -> Option { + let file = File::open(path).ok()?; + let icon_family = IconFamily::read(BufReader::new(file)).ok()?; + + let icon = icon_family + .get_icon_with_type(IconType::RGBA32_512x512_2x) + .or_else(|_| icon_family.get_icon_with_type(IconType::RGBA32_512x512)) + .or_else(|_| icon_family.get_icon_with_type(IconType::RGBA32_256x256)) + .or_else(|_| icon_family.get_icon_with_type(IconType::RGBA32_128x128)) + .or_else(|_| icon_family.get_icon_with_type(IconType::RGBA32_64x64)) + .or_else(|_| icon_family.get_icon_with_type(IconType::RGBA32_32x32)) + .or_else(|_| icon_family.get_icon_with_type(IconType::RGB24_128x128)) + .or_else(|_| icon_family.get_icon_with_type(IconType::RGB24_32x32)) + .ok()?; + + let width = icon.width(); + let height = icon.height(); + let data = icon.data().to_vec(); + + RgbaImage::from_raw(width, height, data) +} diff --git a/komorebi-bar/src/widgets/mod.rs b/komorebi-bar/src/widgets/mod.rs index 56b19d53..ba03e881 100644 --- a/komorebi-bar/src/widgets/mod.rs +++ b/komorebi-bar/src/widgets/mod.rs @@ -154,8 +154,8 @@ impl ImageIcon { pub enum ImageIconId { /// Identifier based on a file system path. Path(Arc), - /// Windows HWND handle. - Hwnd(isize), + /// Window ID + WindowId(u32), } impl From<&Path> for ImageIconId { @@ -165,9 +165,9 @@ impl From<&Path> for ImageIconId { } } -impl From for ImageIconId { +impl From for ImageIconId { #[inline] - fn from(value: isize) -> Self { - Self::Hwnd(value) + fn from(value: u32) -> Self { + Self::WindowId(value) } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 53091099..7873a3a4 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -63,6 +63,8 @@ use objc2_core_graphics::kCGWindowBounds; use objc2_core_graphics::kCGWindowName; use objc2_core_graphics::kCGWindowOwnerName; use objc2_core_graphics::kCGWindowOwnerPID; +use objc2_foundation::NSBundle; +use objc2_foundation::NSString; use regex::Regex; use serde::Deserialize; use serde::Serialize; @@ -74,6 +76,7 @@ use std::ffi::c_void; use std::fmt::Display; use std::fmt::Formatter; use std::fmt::Write; +use std::path::Path; use std::path::PathBuf; use std::ptr::NonNull; use std::str::FromStr; @@ -193,6 +196,7 @@ pub struct WindowDetails { pub exe: String, pub role: String, pub subrole: String, + pub icon_path: PathBuf, } impl From<&Window> for WindowDetails { @@ -202,6 +206,7 @@ impl From<&Window> for WindowDetails { exe: value.exe().unwrap_or_default(), role: value.role().unwrap_or_default(), subrole: value.subrole().unwrap_or_default(), + icon_path: value.icon_path().unwrap_or_default(), } } } @@ -419,6 +424,18 @@ impl Window { } } + pub fn bundle_path(&self) -> Option { + if let Ok(Some(path)) = self + .running_application() + .map(|app| unsafe { app.bundleURL() }) + .map(|url| url.map(|url| url.to_file_path())) + { + path + } else { + None + } + } + pub fn path(&self) -> Option { if let Ok(Some(path)) = self .running_application() @@ -431,6 +448,34 @@ impl Window { } } + pub fn icon_path(&self) -> Option { + if let Some(path) = self.bundle_path() { + unsafe { + if let Some(bundle) = + NSBundle::bundleWithPath(&NSString::from_str(&path.to_string_lossy())) + && let Some(icon_file) = + bundle.objectForInfoDictionaryKey(&NSString::from_str("CFBundleIconFile")) + && let Ok(icon_name) = icon_file.downcast::() + { + let mut icon_path = + format!("{}/Contents/Resources/{}", path.display(), icon_name); + + if !icon_path.ends_with(".icns") { + icon_path.push_str(".icns"); + } + + let path = Path::new(&icon_path); + + if path.exists() { + return Some(PathBuf::from(path)); + } + } + } + } + + None + } + pub fn role(&self) -> Option { AccessibilityApi::copy_attribute_value::(&self.element, kAXRoleAttribute) .map(|s| s.to_string()) From f5a979d4b401076ab79c0c3be41369117a04ff35 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 1 Oct 2025 13:55:42 -0700 Subject: [PATCH 098/305] fix(bar): calculate margin correctly --- komorebi-bar/src/bar.rs | 2 +- komorebi-bar/src/main.rs | 1 + komorebi-bar/src/widgets/date.rs | 2 +- komorebic/src/main.rs | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/komorebi-bar/src/bar.rs b/komorebi-bar/src/bar.rs index 30777e3d..a5649755 100644 --- a/komorebi-bar/src/bar.rs +++ b/komorebi-bar/src/bar.rs @@ -793,8 +793,8 @@ impl Komobar { pub fn position_bar(&self, ctx: &Context) { ctx.send_viewport_cmd(ViewportCommand::OuterPosition(Pos2::new( - self.size_rect.top as f32, self.size_rect.left as f32, + self.size_rect.top as f32, ))); ctx.send_viewport_cmd(ViewportCommand::InnerSize(Vec2::new( diff --git a/komorebi-bar/src/main.rs b/komorebi-bar/src/main.rs index 29a07c31..6ea376e8 100644 --- a/komorebi-bar/src/main.rs +++ b/komorebi-bar/src/main.rs @@ -247,6 +247,7 @@ fn main() -> eyre::Result<()> { let viewport_builder = ViewportBuilder::default() .with_decorations(false) .with_transparent(true) + .with_has_shadow(false) .with_taskbar(false); let native_options = eframe::NativeOptions { diff --git a/komorebi-bar/src/widgets/date.rs b/komorebi-bar/src/widgets/date.rs index 1922fd60..ddd80e9d 100644 --- a/komorebi-bar/src/widgets/date.rs +++ b/komorebi-bar/src/widgets/date.rs @@ -198,7 +198,7 @@ impl BarWidget for Date { let mut layout_job = LayoutJob::simple( match self.label_prefix { LabelPrefix::Icon | LabelPrefix::IconAndText => { - egui_phosphor::regular::CALENDAR_DOTS.to_string() + egui_phosphor::regular::CALENDAR.to_string() } LabelPrefix::None | LabelPrefix::Text => String::new(), }, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 39364751..20a23933 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1254,6 +1254,8 @@ fn main() -> eyre::Result<()> { std::fs::create_dir_all(data_dir)?; let mut komorebi_json = include_str!("../../docs/komorebi.example.json").to_string(); + let komorebi_bar_json = + include_str!("../../docs/komorebi.bar.example.json").to_string(); if std::env::var("KOMOREBI_CONFIG_HOME").is_ok() { komorebi_json = @@ -1261,12 +1263,14 @@ fn main() -> eyre::Result<()> { } let komorebi_path = HOME_DIR.join("komorebi.json"); + let bar_path = HOME_DIR.join("komorebi.bar.json"); let applications_path = HOME_DIR.join("applications.json"); let skhdrc_path = HOME_DIR.join("skhdrc"); let mut written_files = Vec::new(); write_file_with_prompt(&komorebi_path, &komorebi_json, &mut written_files)?; + write_file_with_prompt(&bar_path, &komorebi_bar_json, &mut written_files)?; let applications_json = include_str!("../applications.json"); write_file_with_prompt(&applications_path, applications_json, &mut written_files)?; From 82b6247371e85cd6d5cdbc2603530e8474966860 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 1 Oct 2025 14:16:36 -0700 Subject: [PATCH 099/305] fix(bar): don't show komorebi-bar icon in the dock --- Cargo.lock | 6 ++++-- dependencies.json | 1 + komorebi-bar/Cargo.toml | 2 ++ komorebi-bar/src/main.rs | 8 ++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3db51c5..6981d0f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2887,6 +2887,8 @@ dependencies = [ "num", "num-derive", "num-traits", + "objc2 0.6.2", + "objc2-app-kit 0.3.1", "parking_lot", "random_word", "reqwest", @@ -5073,9 +5075,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.6" +version = "0.103.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb" +checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" dependencies = [ "ring", "rustls-pki-types", diff --git a/dependencies.json b/dependencies.json index 46ce0fbb..2a273982 100644 --- a/dependencies.json +++ b/dependencies.json @@ -524,6 +524,7 @@ "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "hyper-util 0.1.17 registry+https://github.com/rust-lang/crates.io-index", "iana-time-zone 0.1.64 registry+https://github.com/rust-lang/crates.io-index", + "icns 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 3236ab41..1d9361d7 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -27,6 +27,8 @@ netdev = "0.36" num = "0.4" num-derive = "0.4" num-traits = "0.2" +objc2 = "0.6" +objc2-app-kit = "0.3" parking_lot = { workspace = true } random_word = { version = "0.5", features = ["en"] } reqwest = { version = "0.12", features = ["blocking"] } diff --git a/komorebi-bar/src/main.rs b/komorebi-bar/src/main.rs index 6ea376e8..c0b83ce7 100644 --- a/komorebi-bar/src/main.rs +++ b/komorebi-bar/src/main.rs @@ -20,6 +20,9 @@ use komorebi_client::PathExt; use komorebi_client::SocketMessage; use komorebi_client::SubscribeOptions; use komorebi_client::replace_env_in_path; +use objc2::MainThreadMarker; +use objc2_app_kit::NSApplication; +use objc2_app_kit::NSApplicationActivationPolicy; use std::io::BufReader; use std::io::Read; use std::path::PathBuf; @@ -288,6 +291,11 @@ fn main() -> eyre::Result<()> { "komorebi-bar", native_options, Box::new(|cc| { + unsafe { + let app = NSApplication::sharedApplication(MainThreadMarker::new_unchecked()); + app.setActivationPolicy(NSApplicationActivationPolicy::Accessory); + } + let ctx_repainter = cc.egui_ctx.clone(); std::thread::spawn(move || loop { std::thread::sleep(Duration::from_secs(1)); From b02711e86d43993afda158529661cbe1bb10d0f4 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 6 Oct 2025 15:00:38 -0700 Subject: [PATCH 100/305] fix(wm): improve video fullscreen handling This commit improves browser video fullscreen handling with borders. We are now emitting an event for AppKitWorkspaceNotification::NSWorkspaceActiveSpaceDidChangeNotification, even though it doesn't have a pid, by passing a dummy 0 pid. This is really stupid and I shouldn't do this. This lets us act with more granularity in process_event to destroy or redraw borders when entering or exiting browser video fullscreen. In addition, the reaper has been updated to not reap fullscreen windows so that they can be reintegrated into the layout without issue when fullscreen is exited. --- komorebi/src/notification_center_listener.rs | 16 +- komorebi/src/process_event.rs | 298 ++++++++++--------- komorebi/src/reaper.rs | 13 + komorebi/src/window_manager_event.rs | 7 +- 4 files changed, 187 insertions(+), 147 deletions(-) diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs index 7f71b1c6..6ffbb4b0 100644 --- a/komorebi/src/notification_center_listener.rs +++ b/komorebi/src/notification_center_listener.rs @@ -60,10 +60,18 @@ define_class! { match process_id { None => { - tracing::debug!( - "notification: {}, skipping as there is no associated process id", - notif.name() - ); + if let Ok(notification) = + AppKitWorkspaceNotification::from_str(¬if.name().to_string()) { + if matches!(notification, AppKitWorkspaceNotification::NSWorkspaceActiveSpaceDidChangeNotification) { + // TODO: this is really, really stupid + window_manager_event_listener::send_notification(WindowManagerEvent::SpaceChange(SystemNotification::AppKitWorkspace(notification), 0)); + } + } else { + tracing::debug!( + "notification: {}, skipping as there is no associated process id", + notif.name() + ); + } } Some(process_id) => { tracing::debug!("notification: {}, process: {process_id}", notif.name()); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 0f2efb46..60c7b6d0 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -71,6 +71,19 @@ impl WindowManager { return Ok(()); } + if matches!(event, WindowManagerEvent::SpaceChange(_, _)) + && let Some(space_id) = &self.space_id + && let Some(current_space_id) = current_space_id() + { + if *space_id == current_space_id { + border_manager::send_notification(None, None); + } else { + border_manager::destroy_all_borders()?; + } + + return Ok(()); + } + if let Some(space_id) = &self.space_id && let Some(current_space_id) = current_space_id() && *space_id != current_space_id @@ -164,7 +177,7 @@ impl WindowManager { let mut tabbed_window = false; if let Some(window_id) = application.main_window_id() - && matches!( + && matches!( notification, SystemNotification::Accessibility( AccessibilityNotification::AXMainWindowChanged @@ -172,186 +185,186 @@ impl WindowManager { AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification ) ) && let Some(element) = application.main_window() - { - let workspace = self.focused_workspace_mut()?; + { + let workspace = self.focused_workspace_mut()?; - let tabbed_applications = TABBED_APPLICATIONS.lock(); - if tabbed_applications.contains(&application_name) { - let mut first_tab_destroyed = false; + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&application_name) { + let mut first_tab_destroyed = false; - for window in workspace.visible_windows() { - if let Some(window) = window - && window.application.name().unwrap_or_default() - == application_name - { - let tab_rect = MacosApi::window_rect(&element)?; - let main_rect = match MacosApi::window_rect(&window.element) { - Ok(rect) => rect, - Err(AccessibilityError::Api( - AccessibilityApiError::InvalidUIElement, - )) => { - // this means we have closed the 1st tab, so we need this window object to be reaped - // and for the new 1st tab to be the key element of the window struct - if let Some(event) = - WindowManagerEvent::from_system_notification( - SystemNotification::Manual( - ManualNotification::ShowOnFocusChangeFirstTabDestroyed, - ), - event.process_id(), - Some(window_id), - ) - { - window_manager_event_listener::send_notification( - event, - ); - } + for window in workspace.visible_windows() { + if let Some(window) = window + && window.application.name().unwrap_or_default() + == application_name + { + let tab_rect = MacosApi::window_rect(&element)?; + let main_rect = match MacosApi::window_rect(&window.element) { + Ok(rect) => rect, + Err(AccessibilityError::Api( + AccessibilityApiError::InvalidUIElement, + )) => { + // this means we have closed the 1st tab, so we need this window object to be reaped + // and for the new 1st tab to be the key element of the window struct + if let Some(event) = + WindowManagerEvent::from_system_notification( + SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeFirstTabDestroyed, + ), + event.process_id(), + Some(window_id), + ) + { + window_manager_event_listener::send_notification( + event, + ); + } - first_tab_destroyed = true; + first_tab_destroyed = true; - tracing::debug!( + tracing::debug!( "first tab of a native tabbed app was destroyed; reaping window and sending a new show event" ); - tab_rect - } - Err(error) => return Err(error.into()), - }; + tab_rect + } + Err(error) => return Err(error.into()), + }; - if tab_rect == main_rect { - tracing::debug!("ignoring focus change for tabbed window"); - tabbed_window = true; + if tab_rect == main_rect { + tracing::debug!("ignoring focus change for tabbed window"); + tabbed_window = true; + } } } + + if first_tab_destroyed { + self.reap_invalid_windows_for_application(process_id)?; + } } - if first_tab_destroyed { - self.reap_invalid_windows_for_application(process_id)?; - } - } + drop(tabbed_applications); - drop(tabbed_applications); + if !tabbed_window { + let is_known = self.known_window_ids.get(&window_id).cloned(); + let mut is_on_current_workspace = false; - if !tabbed_window { - let is_known = self.known_window_ids.get(&window_id).cloned(); - let mut is_on_current_workspace = false; - - // TODO: figure out if this applies on macOS too - // don't want to trigger the full workspace updates when there are no managed - // containers - this makes floating windows on empty workspaces go into very - // annoying focus change loops which prevents users from interacting with them - if !matches!( + // TODO: figure out if this applies on macOS too + // don't want to trigger the full workspace updates when there are no managed + // containers - this makes floating windows on empty workspaces go into very + // annoying focus change loops which prevents users from interacting with them + if !matches!( self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling) ) && !self.focused_workspace()?.containers().is_empty() { - self.update_focused_workspace(self.mouse_follows_focus, false)?; - } + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } - let workspace = self.focused_workspace_mut()?; - if workspace.contains_window(window_id) { - is_on_current_workspace = true; - } + let workspace = self.focused_workspace_mut()?; + if workspace.contains_window(window_id) { + is_on_current_workspace = true; + } - let floating_window_idx = workspace - .floating_windows() - .iter() - .position(|w| w.id == window_id); + let floating_window_idx = workspace + .floating_windows() + .iter() + .position(|w| w.id == window_id); - match floating_window_idx { - None => { - // if let Some(w) = workspace.maximized_window() { - // if w.hwnd == window_id { - // return Ok(()); - // } - // } + match floating_window_idx { + None => { + // if let Some(w) = workspace.maximized_window() { + // if w.hwnd == window_id { + // return Ok(()); + // } + // } - if let Some(monocle) = &workspace.monocle_container { - if let Some(window) = monocle.focused_window() { - window.focus(false)?; - } - } else if !is_on_current_workspace && is_known.is_none() { - // thanks, I hate it - need to do this so that we don't mess up - // the workspace rules, but also don't miss events from dumb - // apps like notes, mail etc. - let mut has_matching_workspace_rule = false; - let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); - for rule in &*workspace_rules { - match &rule.matching_rule { - MatchingRule::Simple(r) => { - if r.id.trim_end_matches(".exe") == application_name - { - has_matching_workspace_rule = true; - } - } - // TODO: this is pretty coarse - MatchingRule::Composite(rules) => { - for r in rules { - if r.id.trim_end_matches(".exe") - == application_name + if let Some(monocle) = &workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(false)?; + } + } else if !is_on_current_workspace && is_known.is_none() { + // thanks, I hate it - need to do this so that we don't mess up + // the workspace rules, but also don't miss events from dumb + // apps like notes, mail etc. + let mut has_matching_workspace_rule = false; + let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + for rule in &*workspace_rules { + match &rule.matching_rule { + MatchingRule::Simple(r) => { + if r.id.trim_end_matches(".exe") == application_name { has_matching_workspace_rule = true; } } + // TODO: this is pretty coarse + MatchingRule::Composite(rules) => { + for r in rules { + if r.id.trim_end_matches(".exe") + == application_name + { + has_matching_workspace_rule = true; + } + } + } } } - } - if !has_matching_workspace_rule - && workspace.focus_container_by_window(window_id).is_err() - { - // if this fails, the app was probably open but windowless when komorebi - // launched, so the window hasn't been registered - we should treat it - // as a "Show" event - if let Some(event) = - WindowManagerEvent::from_system_notification( - SystemNotification::Manual( - ManualNotification::ShowOnFocusChangeWindowlessAppRestored, - ), - event.process_id(), - Some(window_id), - ) + if !has_matching_workspace_rule + && workspace.focus_container_by_window(window_id).is_err() { - window_manager_event_listener::send_notification( - event, - ); - should_switch_workspace_layer_to_tiling = false; + // if this fails, the app was probably open but windowless when komorebi + // launched, so the window hasn't been registered - we should treat it + // as a "Show" event + if let Some(event) = + WindowManagerEvent::from_system_notification( + SystemNotification::Manual( + ManualNotification::ShowOnFocusChangeWindowlessAppRestored, + ), + event.process_id(), + Some(window_id), + ) + { + window_manager_event_listener::send_notification( + event, + ); + should_switch_workspace_layer_to_tiling = false; + } } + } else if is_on_current_workspace { + workspace.focus_container_by_window(window_id)?; } - } else if is_on_current_workspace { - workspace.focus_container_by_window(window_id)?; - } - if should_switch_workspace_layer_to_tiling { - workspace.layer = WorkspaceLayer::Tiling; - } + if should_switch_workspace_layer_to_tiling { + workspace.layer = WorkspaceLayer::Tiling; + } - if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) - && !self.focused_workspace()?.containers().is_empty() { - self.update_focused_workspace(self.mouse_follows_focus, false)?; + if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) + && !self.focused_workspace()?.containers().is_empty() { + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } + } + Some(idx) => { + if let Some(_window) = workspace.floating_windows().get(idx) { + workspace.layer = WorkspaceLayer::Floating; + } } } - Some(idx) => { - if let Some(_window) = workspace.floating_windows().get(idx) { - workspace.layer = WorkspaceLayer::Floating; + + // maybe we don't need a separate reconciliator module?? this works pretty well! + if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { + self.focus_monitor(m_idx)?; + self.focus_workspace(w_idx)?; + let event = WindowManagerEvent::from_system_notification( + SystemNotification::Manual(ManualNotification::FocusOnCmdTab), + process_id, + Some(window_id), + ); + + if let Some(manual_event) = event { + window_manager_event_listener::send_notification(manual_event); } } } - - // maybe we don't need a separate reconciliator module?? this works pretty well! - if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { - self.focus_monitor(m_idx)?; - self.focus_workspace(w_idx)?; - let event = WindowManagerEvent::from_system_notification( - SystemNotification::Manual(ManualNotification::FocusOnCmdTab), - process_id, - Some(window_id) - ); - - if let Some(manual_event) = event { - window_manager_event_listener::send_notification(manual_event); - } - } } - } if matches!( notification, @@ -929,6 +942,7 @@ impl WindowManager { } } } + WindowManagerEvent::SpaceChange(_, _) => {} } self.update_known_window_ids(); diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs index c8301331..8f0f9d96 100644 --- a/komorebi/src/reaper.rs +++ b/komorebi/src/reaper.rs @@ -1,10 +1,12 @@ use crate::TABBED_APPLICATIONS; +use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityError; use crate::border_manager; use crate::window::Window; use crate::window_manager::WindowManager; use crossbeam_channel::Receiver; use crossbeam_channel::Sender; +use objc2_core_foundation::CFBoolean; use parking_lot::Mutex; use std::sync::Arc; use std::sync::OnceLock; @@ -115,6 +117,17 @@ pub fn notify_on_error( should_reap = false; } + if let Some(is_fullscreen) = + AccessibilityApi::copy_attribute_value::(&window.element, "AXFullScreen") + && is_fullscreen.as_bool() + { + tracing::debug!( + "skipping reap for fullscreen window {} during position update failure", + window.id + ); + should_reap = false; + } + if should_reap { send_notification(ReaperNotification::InvalidWindow(window.id)); } diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index eb00cbfa..75fb60f1 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -42,6 +42,7 @@ pub enum WindowManagerEvent { MoveEnd(SystemNotification, i32, u32), ResizeStart(SystemNotification, i32, u32), ResizeEnd(SystemNotification, i32, u32), + SpaceChange(SystemNotification, i32), } impl WindowManagerEvent { @@ -141,6 +142,7 @@ impl WindowManagerEvent { | WindowManagerEvent::MoveEnd(_, process_id, _) | WindowManagerEvent::ResizeStart(_, process_id, _) | WindowManagerEvent::ResizeEnd(_, process_id, _) + | WindowManagerEvent::SpaceChange(_, process_id) | WindowManagerEvent::Restore(_, process_id, _) => *process_id, } } @@ -157,6 +159,7 @@ impl WindowManagerEvent { | WindowManagerEvent::ResizeStart(n, _, _) | WindowManagerEvent::ResizeEnd(n, _, _) | WindowManagerEvent::Unmanage(n, _, _) + | WindowManagerEvent::SpaceChange(n, _) | WindowManagerEvent::Restore(n, _, _) => match n { SystemNotification::Accessibility(a) => a.to_string(), SystemNotification::AppKitWorkspace(a) => a.to_string(), @@ -168,7 +171,9 @@ impl WindowManagerEvent { pub fn window_id(&self) -> Option { match self { WindowManagerEvent::FocusChange(_, _, window_id) => *window_id, - WindowManagerEvent::Show(_, _) | WindowManagerEvent::Destroy(_, _) => None, + WindowManagerEvent::Show(_, _) + | WindowManagerEvent::Destroy(_, _) + | WindowManagerEvent::SpaceChange(_, _) => None, WindowManagerEvent::Minimize(_, _, window_id) | WindowManagerEvent::Manage(_, _, window_id) | WindowManagerEvent::Unmanage(_, _, window_id) From a8a2f923cf7d4e86e6e3463086b2f02f74aa4385 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 6 Oct 2025 15:41:12 -0700 Subject: [PATCH 101/305] style(mkdocs): add information about komorebi-bar --- docs/example-configurations.md | 31 +++++++++++++++++++++++++++++-- docs/installation.md | 2 ++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/example-configurations.md b/docs/example-configurations.md index 9c861faf..507d87ad 100644 --- a/docs/example-configurations.md +++ b/docs/example-configurations.md @@ -26,12 +26,18 @@ it requires to run, and will open the following System Settings tabs for you: * Settings -> Privacy & Security -> Screen & System Audio Recording With the example configurations downloaded and permissions granted, you can now -start `komorebi` +start `komorebi`: ```powershell komorebic start ``` +Alternatively, if you also want to start with the status bar, you can run: + +```powershell +komorebic start --bar +``` + ## komorebi.json The example window manager configuration sets some sane defaults and provides @@ -173,4 +179,25 @@ colon. ``` You can try the example komorebi configuration by running -`skhd --config ~/.config/komorebi/skhdrc`. \ No newline at end of file +`skhd --config ~/.config/komorebi/skhdrc`. + +## komorebi.bar.json + +The example status bar configuration sets some sane defaults and provides +a number of pre-configured widgets on the primary monitor. + +```json +{% include "./komorebi.bar.example.json" %} +``` + +### Themes + +Themes can be set in either `komorebi.json` or `komorebi.bar.json`. If set +in `komorebi.json`, the theme will be applied to both komorebi's borders and +stackbars as well as the status bar. + +If set in `komorebi.bar.json`, the theme will only be applied to the status bar. + +All [Catppuccin palette variants](https://catppuccin.com/) +and [most Base16 palette variants](https://tinted-theming.github.io/tinted-gallery/) +are available as themes. \ No newline at end of file diff --git a/docs/installation.md b/docs/installation.md index d0db4ded..5e296b6a 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -28,6 +28,7 @@ Clone the git repository, enter the directory, and build the following binaries: ```powershell cargo +stable install --path komorebi --locked --target-dir ~/.cargo/bin cargo +stable install --path komorebic --locked --target-dir ~/.cargo/bin +cargo +stable install --path komorebi-bar --locked --target-dir ~/.cargo/bin ``` If the binaries have been built and added to your `$PATH` correctly, you should @@ -47,6 +48,7 @@ Finally, you can run the following commands to clean up files created by the ```powershell rm -rf ~/.cargo/bin/komorebi rm -rf ~/.cargo/bin/komorebic +rm -rf ~/.cargo/bin/komorebi-bar rm -rf ~/.config/komorebi rm -rf "~/Library/Application Support/komorebi" ``` From 163ba7051d68443ffab6b63ad86d08083298d985 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 6 Oct 2025 15:50:39 -0700 Subject: [PATCH 102/305] docs(readme): update with relevant information --- README.md | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 217 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 46adabbc..fc6a50ce 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ Tiling Window Management for macOS.

+Screenshot 2025-10-06 at 3 55 50 PM + ## Overview _komorebi for Mac_ is a tiling window manager that works as an extension to the @@ -101,11 +103,219 @@ make an anonymous Bitcoin donation to ## Licensing for Commercial Use -A dedicated Individual Commercial Use License will eventually be made available -for those who want to use `komorebi` at work. +A dedicated Individual Commercial Use License is available for those who want to +use `komorebi` at work. -The Individual Commerical Use License will add “Commercial Use” as a “Permitted -Use” for the licensed individual only, for the duration of a valid paid license -subscription only. All provisions and restrictions enumerated in -the [Komorebi License](https://github.com/LGUG2Z/komorebi-license) will continue -to apply. +The Individual Commerical Use License adds “Commercial Use” as a “Permitted Use” +for the licensed individual only, for the duration of a valid paid license +subscription only. All provisions and restrictions enumerated in the [Komorebi +License](https://github.com/LGUG2Z/komorebi-license) continue to apply. + +More information, pricing and purchase links for Individual Commercial Use +Licenses [can be found here](https://lgug2z.com/software/komorebi). + +# Contribution Guidelines + +_komorebi for Mac_ is currently not accepting contributions. + +[//]: # (If you would like to contribute to `komorebi` please take the time to carefully) + +[//]: # (read the guidelines below.) + +[//]: # () +[//]: # (Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about how) + +[//]: # (code contributions to `komorebi` are licensed.) + +## Commit hygiene + +- Flatten all `use` statements +- Run `cargo +stable clippy` and ensure that all lints and suggestions have been + addressed before committing +- Run `cargo +nightly fmt --all` to ensure consistent formatting before + committing +- Use `git cz` with + the [Commitizen CLI](https://github.com/commitizen/cz-cli#conventional-commit-messages-as-a-global-utility) + to prepare commit messages +- Provide **at least** one short sentence or paragraph in your commit message + body to describe your thought process for + the changes being committed + +## PRs should contain only a single feature or bug fix + +It is very difficult to review pull requests which touch multiple unrelated +features and parts of the codebase. + +Please do not submit pull requests like this; you will be asked to separate them +into smaller PRs that deal only with one feature or bug fix at a time. + +If you are working on multiple features and bug fixes, I suggest that you cut a +branch called `local-trunk` from `master` which you keep up to date, and rebase +the various independent branches you are working on onto that branch if you want +to test them together or create a build with everything integrated. + +## Refactors to the codebase must have prior approval + +`komorebi` is a mature codebase with an internal consistency and structure that +has developed organically over close to half a decade. + +There are [countless hours of live coding videos](https://youtube.com/@LGUG2Z) +demonstrating work on this project and showing new contributors how to do +everything from basic tasks like implementing new `komorebic` commands to +distinguishing monitors by manufacturer hardware identifiers and video card +ports. + +Refactors to the structure of the codebase are not taken lightly and require +prior discussion and approval. + +Please do not start refactoring the codebase with the expectation of having your +changes integrated until you receive an explicit approval or a request to do so. + +Similarly, when implementing features and bug fixes, please stick to the +structure of the codebase as much as possible and do not take this as an +opportunity to do some "refactoring along the way". + +It is extremely difficult to review PRs for features and bug fixes if they are +lost in sweeping changes to the structure of the codebase. + +## Breaking changes to user-facing interfaces are unacceptable + +This includes but is not limited to: + +- All `komorebic` commands +- The `komorebi.json` schema +- The [ + `komorebi-application-specific-configuration`](https://github.com/LGUG2Z/komorebi-application-specific-configuration) + schema + +No user should ever find that their configuration file has stopped working after +upgrading to a new version of `komorebi`. + +More often than not there are ways to reformulate changes that may initially +seem like they require breaking user-facing interfaces into additive changes. + +For some inspiration please take a look +at [this commit](https://github.com/LGUG2Z/komorebi/commit/e7d928a065eb63bb4ea1fb864c69c1cae8cc763b) +which added the ability for users to specify colours in `komorebi.json` in Hex +format alongside RGB. + +There is also a process in place for graceful, non-breaking, deprecation of +configuration options that are no longer required. + +# Logs and Debugging + +Logs from `komorebi` will be appended to +`$HOME/Library/Application Support/komorebi/komorebi.log.$timestamp`. + +Whenever running the `komorebic stop` command or sending a Ctrl-C signal to +`komorebi` directly, the `komorebi` process ensures that all hidden windows are +restored before termination. + +## Panics and Deadlocks + +If `komorebi` ever stops responding, it is most likely either due to either a +panic or a deadlock. In the case of a panic, this will be reported in the log. +In the case of a deadlock, there will not be any errors in the log, but the +process and the log will appear frozen. + +If you believe you have encountered a deadlock, you can compile `komorebi` with +`--features deadlock_detection` and try reproducing the deadlock again. This +will check for deadlocks every 5 seconds in the background, and if a deadlock is +found, information about it will appear in the log which can be shared when +opening an issue. + +# Window Manager State and Integrations + +The current state of the window manager can be queried using the +`komorebic state` command, which returns a JSON representation of the `State` +struct. + +This may also be polled to build further integrations and widgets on top of. + +# Window Manager Event Subscriptions + +## Unix Domain Sockets + +It is possible to subscribe to notifications of every `WindowManagerEvent` and `SocketMessage` handled +by `komorebi` using [Unix Domain Sockets](https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/). + +UDS are also the only mode of communication between `komorebi` and `komorebic`. + +First, your application must create a socket in `$ENV:LocalAppData\komorebi`. Once the socket has been created, run the +following command: + +```powershell +komorebic.exe subscribe-socket +``` + +If the socket exists, komorebi will start pushing JSON data of successfully +handled events and messages as in the example above in the Named Pipes section. + +## Rust Client + +As of `v0.1.22` it is possible to use the `komorebi-client` crate to subscribe +to notifications of every `WindowManagerEvent` and `SocketMessage` handled by +`komorebi` in a Rust codebase. + +Below is a simple example of how to use `komorebi-client` in a basic Rust application. + +```rust +// komorebi-client = { git = "https://github.com/LGUG2Z/komorebi", tag = "v0.1.38"} + +use anyhow::Result; +use komorebi_client::Notification; +use komorebi_client::NotificationEvent; +use komorebi_client::UnixListener; +use komorebi_client::WindowManagerEvent; +use std::io::BufRead; +use std::io::BufReader; +use std::io::Read; + +pub fn main() -> anyhow::Result<()> { + let socket = komorebi_client::subscribe(NAME)?; + + for incoming in socket.incoming() { + match incoming { + Ok(data) => { + let reader = BufReader::new(data.try_clone()?); + + for line in reader.lines().flatten() { + let notification: Notification = match serde_json::from_str(&line) { + Ok(notification) => notification, + Err(error) => { + log::debug!("discarding malformed komorebi notification: {error}"); + continue; + } + }; + + // match and filter on desired notifications + } + } + Err(error) => { + log::debug!("{error}"); + } + } + } + +} +``` + +A read-world example can be found +in [komokana](https://github.com/LGUG2Z/komokana/blob/feature/komorebi-uds/src/main.rs). + +## Subscription Event Notification Schema + +A [JSON Schema](https://json-schema.org/) of the event notifications emitted to +subscribers can be generated with the `komorebic notification-schema` command. +The output of this command can be redirected to the clipboard or a file, which +can be used with services such as [Quicktype](https://app.quicktype.io/) to +generate type definitions in different programming languages. + +## Socket Message Schema + +A [JSON Schema](https://json-schema.org/) of socket messages used to send +instructions to `komorebi` can be generated with the `komorebic socket-schema` +command. The output of this command can be redirected to the clipboard or a +file, which can be used with services such +as [Quicktype](https://app.quicktype.io/) to generate type definitions in +different programming languages. From 245770d45a7e31f31798b8475aec76279d564d18 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 6 Oct 2025 16:37:14 -0700 Subject: [PATCH 103/305] chore(deps): cargo update --- Cargo.lock | 409 +++++++++++++++++++++++----------------------- dependencies.json | 147 +++++++++-------- 2 files changed, 280 insertions(+), 276 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6981d0f2..2bebf1ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -297,11 +297,11 @@ dependencies = [ "clipboard-win", "image 0.25.8", "log", - "objc2 0.6.2", - "objc2-app-kit 0.3.1", + "objc2 0.6.3", + "objc2-app-kit 0.3.2", "objc2-core-foundation", "objc2-core-graphics", - "objc2-foundation 0.3.1", + "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", "windows-sys 0.60.2", @@ -399,7 +399,7 @@ dependencies = [ "polling", "rustix 1.1.2", "slab", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -457,7 +457,7 @@ dependencies = [ "rustix 1.1.2", "signal-hook-registry", "slab", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -574,7 +574,7 @@ dependencies = [ "miniz_oxide 0.8.9", "object", "rustc-demangle", - "windows-link 0.2.0", + "windows-link 0.2.1", ] [[package]] @@ -690,11 +690,11 @@ dependencies = [ [[package]] name = "block2" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" dependencies = [ - "objc2 0.6.2", + "objc2 0.6.3", ] [[package]] @@ -745,18 +745,18 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytemuck" -version = "1.23.2" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" +checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f154e572231cb6ba2bd1176980827e3d5dc04cc183a75dea38109fbdd672d29" +checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", @@ -837,9 +837,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.39" +version = "1.2.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f" +checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb" dependencies = [ "find-msvc-tools", "jobserver", @@ -895,7 +895,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link 0.2.0", + "windows-link 0.2.1", ] [[package]] @@ -1047,9 +1047,9 @@ dependencies = [ [[package]] name = "const_format" -version = "0.2.34" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" dependencies = [ "const_format_proc_macros", ] @@ -1197,7 +1197,7 @@ checksum = "881c5d0a13b2f1498e2306e82cbada78390e152d4b1378fb28a84f4dcd0dc4f3" dependencies = [ "dispatch", "nix", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -1308,7 +1308,7 @@ dependencies = [ "libc", "option-ext", "redox_users 0.5.2", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -1324,9 +1324,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", + "block2 0.6.2", "libc", - "objc2 0.6.2", + "objc2 0.6.3", ] [[package]] @@ -1638,7 +1638,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -1761,9 +1761,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" +checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" [[package]] name = "fixedbitset" @@ -1773,9 +1773,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" dependencies = [ "crc32fast", "miniz_oxide 0.8.9", @@ -2109,10 +2109,10 @@ dependencies = [ "glutin_glx_sys", "glutin_wgl_sys", "libloading", - "objc2 0.6.2", - "objc2-app-kit 0.3.1", + "objc2 0.6.3", + "objc2-app-kit 0.3.2", "objc2-core-foundation", - "objc2-foundation 0.3.1", + "objc2-foundation 0.3.2", "once_cell", "raw-window-handle", "wayland-sys", @@ -2444,7 +2444,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.62.1", + "windows-core 0.62.2", ] [[package]] @@ -2836,15 +2836,15 @@ dependencies = [ "komorebi-themes", "lazy_static", "nanoid", - "objc2 0.6.2", - "objc2-app-kit 0.3.1", + "objc2 0.6.3", + "objc2-app-kit 0.3.2", "objc2-application-services", "objc2-core-foundation", "objc2-core-graphics", "objc2-core-services", "objc2-core-video", - "objc2-foundation 0.3.1", - "objc2-quartz-core 0.3.1", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", "parking_lot", "pastey", "quick-xml 0.38.3", @@ -2887,8 +2887,8 @@ dependencies = [ "num", "num-derive", "num-traits", - "objc2 0.6.2", - "objc2-app-kit 0.3.1", + "objc2 0.6.3", + "objc2-app-kit 0.3.2", "parking_lot", "random_word", "reqwest", @@ -3019,7 +3019,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" dependencies = [ "cfg-if", - "windows-link 0.2.0", + "windows-link 0.2.1", ] [[package]] @@ -3036,7 +3036,7 @@ checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ "bitflags 2.9.4", "libc", - "redox_syscall 0.5.17", + "redox_syscall 0.5.18", ] [[package]] @@ -3083,11 +3083,10 @@ checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] @@ -3290,9 +3289,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd32fa8935aeadb8a8a6b6b351e40225570a37c43de67690383d87ef170cd08" +checksum = "1cc7d85f3d741164e8972ad355e26ac6e51b20fcae5f911c7da8f2d8bbbb3f33" dependencies = [ "num-traits", "pxfm", @@ -3715,9 +3714,9 @@ dependencies = [ [[package]] name = "objc2" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561f357ba7f3a2a61563a186a163d0a3a5247e1089524a3981d49adb775078bc" +checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05" dependencies = [ "objc2-encode 4.1.0", ] @@ -3740,36 +3739,38 @@ dependencies = [ [[package]] name = "objc2-app-kit" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", + "block2 0.6.2", "libc", - "objc2 0.6.2", - "objc2-cloud-kit 0.3.1", - "objc2-core-data 0.3.1", + "objc2 0.6.3", + "objc2-cloud-kit 0.3.2", + "objc2-core-data 0.3.2", "objc2-core-foundation", "objc2-core-graphics", - "objc2-core-image 0.3.1", - "objc2-foundation 0.3.1", - "objc2-quartz-core 0.3.1", + "objc2-core-image 0.3.2", + "objc2-core-text", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", ] [[package]] name = "objc2-application-services" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9abc05b1f757ebfbd72f4f3f9a515662c67dfe66b26e71b37d818f56a1c2f17" +checksum = "69282c2b5bc58fba07cb9de2113619532eb551e98efe3d8d695509ef45fbd53b" dependencies = [ "bitflags 2.9.4", "libc", - "objc2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", "objc2-core-graphics", "objc2-core-services", - "objc2-foundation 0.3.1", + "objc2-foundation 0.3.2", ] [[package]] @@ -3787,13 +3788,13 @@ dependencies = [ [[package]] name = "objc2-cloud-kit" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17614fdcd9b411e6ff1117dfb1d0150f908ba83a7df81b1f118005fe0a8ea15d" +checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" dependencies = [ "bitflags 2.9.4", - "objc2 0.6.2", - "objc2-foundation 0.3.1", + "objc2 0.6.3", + "objc2-foundation 0.3.2", ] [[package]] @@ -3821,42 +3822,42 @@ dependencies = [ [[package]] name = "objc2-core-data" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291fbbf7d29287518e8686417cf7239c74700fd4b607623140a7d4a3c834329d" +checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" dependencies = [ "bitflags 2.9.4", - "objc2 0.6.2", - "objc2-foundation 0.3.1", + "objc2 0.6.3", + "objc2-foundation 0.3.2", ] [[package]] name = "objc2-core-foundation" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", + "block2 0.6.2", "dispatch2", "libc", - "objc2 0.6.2", + "objc2 0.6.3", ] [[package]] name = "objc2-core-graphics" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", + "block2 0.6.2", "dispatch2", "libc", - "objc2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", "objc2-io-surface", - "objc2-metal 0.3.1", + "objc2-metal 0.3.2", ] [[package]] @@ -3873,12 +3874,12 @@ dependencies = [ [[package]] name = "objc2-core-image" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b3dc0cc4386b6ccf21c157591b34a7f44c8e75b064f85502901ab2188c007e" +checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" dependencies = [ - "objc2 0.6.2", - "objc2-foundation 0.3.1", + "objc2 0.6.3", + "objc2-foundation 0.3.2", ] [[package]] @@ -3895,32 +3896,44 @@ dependencies = [ [[package]] name = "objc2-core-services" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "159be6e4cd366c7d236d798daa2aa71855230e5691cde045a0670ce01a06d664" +checksum = "583300ad934cba24ff5292aee751ecc070f7ca6b39a574cc21b7b5e588e06a0b" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", + "block2 0.6.2", "dispatch2", "libc", - "objc2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", "objc2-security", ] [[package]] -name = "objc2-core-video" -version = "0.3.1" +name = "objc2-core-text" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1989c3e76c7e978cab0ba9e6f4961cd00ed14ca21121444cc26877403bfb6303" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", - "objc2 0.6.2", + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-core-graphics", +] + +[[package]] +name = "objc2-core-video" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" +dependencies = [ + "bitflags 2.9.4", + "block2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", "objc2-core-graphics", "objc2-io-surface", - "objc2-metal 0.3.1", + "objc2-metal 0.3.2", ] [[package]] @@ -3950,22 +3963,22 @@ dependencies = [ [[package]] name = "objc2-foundation" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", + "block2 0.6.2", "libc", - "objc2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", ] [[package]] name = "objc2-io-kit" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a" +checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" dependencies = [ "libc", "objc2-core-foundation", @@ -3973,12 +3986,12 @@ dependencies = [ [[package]] name = "objc2-io-surface" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ "bitflags 2.9.4", - "objc2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", ] @@ -4008,13 +4021,13 @@ dependencies = [ [[package]] name = "objc2-metal" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f246c183239540aab1782457b35ab2040d4259175bd1d0c58e46ada7b47a874" +checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" dependencies = [ "bitflags 2.9.4", - "objc2 0.6.2", - "objc2-foundation 0.3.1", + "objc2 0.6.3", + "objc2-foundation 0.3.2", ] [[package]] @@ -4032,29 +4045,29 @@ dependencies = [ [[package]] name = "objc2-quartz-core" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ffb6a0cd5f182dc964334388560b12a57f7b74b3e2dec5e2722aa2dfb2ccd5" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" dependencies = [ "bitflags 2.9.4", - "block2 0.6.1", + "block2 0.6.2", "libc", - "objc2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", "objc2-core-graphics", "objc2-core-video", - "objc2-foundation 0.3.1", - "objc2-metal 0.3.1", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", ] [[package]] name = "objc2-security" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f8e0ef3ab66b08c42644dcb34dba6ec0a574bbd8adbb8bdbdc7a2779731a44" +checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" dependencies = [ "bitflags 2.9.4", - "objc2 0.6.2", + "objc2 0.6.3", "objc2-core-foundation", ] @@ -4259,9 +4272,9 @@ checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -4269,18 +4282,17 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "backtrace", "cfg-if", "libc", "petgraph", - "redox_syscall 0.5.17", + "redox_syscall 0.5.18", "smallvec", - "thread-id", - "windows-targets 0.52.6", + "windows-link 0.2.1", ] [[package]] @@ -4465,7 +4477,7 @@ dependencies = [ "hermit-abi", "pin-project-lite", "rustix 1.1.2", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -4858,9 +4870,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags 2.9.4", ] @@ -5048,7 +5060,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.11.0", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -5111,7 +5123,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -5325,9 +5337,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" +checksum = "6093cd8c01b25262b84927e0f7151692158fab02d961e04c979d3903eba7ecc5" dependencies = [ "base64", "chrono", @@ -5337,8 +5349,7 @@ dependencies = [ "schemars 0.8.22", "schemars 0.9.0", "schemars 1.0.4", - "serde", - "serde_derive", + "serde_core", "serde_json", "serde_with_macros", "time", @@ -5346,9 +5357,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327ada00f7d64abaac1e55a6911e90cf665aa051b9a561c7006c157f4633135e" +checksum = "a7e6c180db0816026a61afa1cff5344fb7ebded7e4d3062772179f2501481c27" dependencies = [ "darling", "proc-macro2", @@ -5688,9 +5699,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.37.1" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bddd368fda2f82ead69c03d46d351987cfa0c2a57abfa37a017f3aa3e9bf69a" +checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" dependencies = [ "libc", "memchr", @@ -5750,7 +5761,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix 1.1.2", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -5812,16 +5823,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "thread-id" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe8f25bbdd100db7e1d34acf7fd2dc59c4bf8f7483f505eaa7d4f12f76cc0ea" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "thread_local" version = "1.1.9" @@ -6198,9 +6199,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "tz-rs" @@ -6259,9 +6260,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "unicode-xid" @@ -6604,8 +6605,8 @@ dependencies = [ "jni", "log", "ndk-context", - "objc2 0.6.2", - "objc2-foundation 0.3.1", + "objc2 0.6.3", + "objc2-foundation 0.3.2", "url", "web-sys", ] @@ -6797,7 +6798,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -6857,8 +6858,8 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement 0.60.1", - "windows-interface 0.59.2", + "windows-implement 0.60.2", + "windows-interface 0.59.3", "windows-link 0.1.3", "windows-result 0.3.4", "windows-strings 0.4.2", @@ -6866,15 +6867,15 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.62.1" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6844ee5416b285084d3d3fffd743b925a6c9385455f64f6d4fa3031c4c2749a9" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "windows-implement 0.60.1", - "windows-interface 0.59.2", - "windows-link 0.2.0", - "windows-result 0.4.0", - "windows-strings 0.5.0", + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", ] [[package]] @@ -6901,9 +6902,9 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.60.1" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb307e42a74fb6de9bf3a02d9712678b22399c87e6fa869d6dfcd8c1b7754e0" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", @@ -6923,9 +6924,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.59.2" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", @@ -6940,9 +6941,9 @@ checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] name = "windows-link" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-numerics" @@ -6985,11 +6986,11 @@ dependencies = [ [[package]] name = "windows-result" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link 0.2.0", + "windows-link 0.2.1", ] [[package]] @@ -7013,11 +7014,11 @@ dependencies = [ [[package]] name = "windows-strings" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link 0.2.0", + "windows-link 0.2.1", ] [[package]] @@ -7062,16 +7063,16 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.4", + "windows-targets 0.53.5", ] [[package]] name = "windows-sys" -version = "0.61.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link 0.2.0", + "windows-link 0.2.1", ] [[package]] @@ -7122,19 +7123,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.4" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link 0.2.0", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows-link 0.2.1", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -7166,9 +7167,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" @@ -7190,9 +7191,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" @@ -7214,9 +7215,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" @@ -7226,9 +7227,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" @@ -7250,9 +7251,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" @@ -7274,9 +7275,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" @@ -7298,9 +7299,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" @@ -7322,9 +7323,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winit" diff --git a/dependencies.json b/dependencies.json index 2a273982..02a2c4d5 100644 --- a/dependencies.json +++ b/dependencies.json @@ -20,7 +20,7 @@ "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", - "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", + "anstream 0.6.21 registry+https://github.com/rust-lang/crates.io-index", "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", @@ -38,9 +38,9 @@ "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", - "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", - "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.39 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.40 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", @@ -97,8 +97,8 @@ "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", - "find-msvc-tools 0.1.2 registry+https://github.com/rust-lang/crates.io-index", - "flate2 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "flate2 1.1.4 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -156,7 +156,7 @@ "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", "litrs 0.4.2 registry+https://github.com/rust-lang/crates.io-index", - "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", + "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", @@ -166,7 +166,7 @@ "minimal-lexical 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.5 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", @@ -180,26 +180,27 @@ "num-rational 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", - "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-data 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-video 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-security 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-app-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-application-services 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-cloud-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-data 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-graphics 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-image 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-services 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-text 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-video 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-io-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-metal 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-quartz-core 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-security 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "object 0.37.3 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", "owned_ttf_parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "palette 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "palette_derive 0.5.0 registry+https://github.com/rust-lang/crates.io-index", - "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", - "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot 0.12.5 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot_core 0.9.12 registry+https://github.com/rust-lang/crates.io-index", "paste 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", @@ -249,8 +250,8 @@ "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.15.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.15.0 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", @@ -279,7 +280,7 @@ "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", - "typenum 1.18.0 registry+https://github.com/rust-lang/crates.io-index", + "typenum 1.19.0 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", @@ -339,7 +340,7 @@ "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", "exr 1.73.0 registry+https://github.com/rust-lang/crates.io-index", "lebe 0.5.3 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.5 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index", "ravif 0.11.20 registry+https://github.com/rust-lang/crates.io-index" ] @@ -379,7 +380,7 @@ "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", "aligned-vec 0.6.4 registry+https://github.com/rust-lang/crates.io-index", - "anstream 0.6.20 registry+https://github.com/rust-lang/crates.io-index", + "anstream 0.6.21 registry+https://github.com/rust-lang/crates.io-index", "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", @@ -400,19 +401,19 @@ "block-sys 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "block2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "block2 0.5.1 registry+https://github.com/rust-lang/crates.io-index", - "block2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", + "block2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "brotli 8.0.2 registry+https://github.com/rust-lang/crates.io-index", "brotli-decompressor 5.0.0 registry+https://github.com/rust-lang/crates.io-index", "built 0.7.7 registry+https://github.com/rust-lang/crates.io-index", - "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", - "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", "byteorder 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "byteorder-lite 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "calm_io 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "calmio_filters 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "catppuccin-egui 5.6.0 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.39 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.40 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", @@ -479,8 +480,8 @@ "fax_derive 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", - "find-msvc-tools 0.1.2 registry+https://github.com/rust-lang/crates.io-index", - "flate2 1.1.2 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "flate2 1.1.4 registry+https://github.com/rust-lang/crates.io-index", "flavours 0.7.2 git+https://github.com/LGUG2Z/flavours", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "font-loader 0.11.0 registry+https://github.com/rust-lang/crates.io-index", @@ -548,7 +549,7 @@ "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", "litrs 0.4.2 registry+https://github.com/rust-lang/crates.io-index", - "lock_api 0.4.13 registry+https://github.com/rust-lang/crates.io-index", + "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", @@ -588,32 +589,33 @@ "objc-sys 0.3.5 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.5.2 registry+https://github.com/rust-lang/crates.io-index", - "objc2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2 0.6.3 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.2.2 registry+https://github.com/rust-lang/crates.io-index", - "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-data 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-video 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-app-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-application-services 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-cloud-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-data 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-graphics 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-image 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-services 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-text 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-video 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-encode 3.0.0 registry+https://github.com/rust-lang/crates.io-index", "objc2-encode 4.1.0 registry+https://github.com/rust-lang/crates.io-index", "objc2-foundation 0.2.2 registry+https://github.com/rust-lang/crates.io-index", - "objc2-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-security 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-io-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-metal 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-quartz-core 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-security 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "object 0.37.3 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", "owo-colors 4.2.3 registry+https://github.com/rust-lang/crates.io-index", "palette 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "palette_derive 0.5.0 registry+https://github.com/rust-lang/crates.io-index", - "parking_lot 0.12.4 registry+https://github.com/rust-lang/crates.io-index", - "parking_lot_core 0.9.11 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot 0.12.5 registry+https://github.com/rust-lang/crates.io-index", + "parking_lot_core 0.9.12 registry+https://github.com/rust-lang/crates.io-index", "paste 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", @@ -676,8 +678,8 @@ "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.14.1 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.14.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.15.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.15.0 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", @@ -700,7 +702,7 @@ "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", - "sysinfo 0.37.1 registry+https://github.com/rust-lang/crates.io-index", + "sysinfo 0.37.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "tempfile 3.23.0 registry+https://github.com/rust-lang/crates.io-index", @@ -731,7 +733,7 @@ "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", "try-lock 0.2.5 registry+https://github.com/rust-lang/crates.io-index", "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", - "typenum 1.18.0 registry+https://github.com/rust-lang/crates.io-index", + "typenum 1.19.0 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", @@ -824,9 +826,9 @@ "Zlib", [ "adler32 1.2.0 registry+https://github.com/rust-lang/crates.io-index", - "bytemuck 1.23.2 registry+https://github.com/rust-lang/crates.io-index", - "bytemuck_derive 1.10.1 registry+https://github.com/rust-lang/crates.io-index", - "const_format 0.2.34 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", + "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", + "const_format 0.2.35 registry+https://github.com/rust-lang/crates.io-index", "const_format_proc_macros 0.2.34 registry+https://github.com/rust-lang/crates.io-index", "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", @@ -834,19 +836,20 @@ "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "objc2-app-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-application-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-cloud-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-data 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-foundation 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-graphics 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-image 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-services 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-core-video 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-io-kit 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-metal 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-quartz-core 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "objc2-security 0.3.1 registry+https://github.com/rust-lang/crates.io-index", + "objc2-app-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-application-services 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-cloud-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-data 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-graphics 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-image 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-services 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-text 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-core-video 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-io-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-metal 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-quartz-core 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-security 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", From 0789ed01364fc183e0c9d0ec323ae14582ee5615 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 6 Oct 2025 16:38:25 -0700 Subject: [PATCH 104/305] chore(deps): flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/a669fe77a8b0cd6f11419d89ea45a16691ca5121' (2025-09-18) → 'github:ipetkov/crane/1e7905b1eb1b551aade75169940557b6c51ed920' (2025-10-05) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/8eaee110344796db060382e15d3af0a9fc396e0e' (2025-09-19) → 'github:nixos/nixpkgs/7df7ff7d8e00218376575f0acdcc5d66741351ee' (2025-10-02) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/d2bac276ac7e669a1f09c48614538a37e3eb6d0f' (2025-09-22) → 'github:oxalica/rust-overlay/edea9f33f9a03f615ad3609a40fbcefe0ec835ca' (2025-10-06) --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index fbadd33e..292e9f2c 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1758215636, - "narHash": "sha256-8nkzkPbdxze8CxWhKWlcLbJEU1vfLM/nVqRlTy17V54=", + "lastModified": 1759691647, + "narHash": "sha256-OnyPw3KaXL909I+FNyD6jfkAP/gdL/K0iitMHxo7ieM=", "owner": "ipetkov", "repo": "crane", - "rev": "a669fe77a8b0cd6f11419d89ea45a16691ca5121", + "rev": "1e7905b1eb1b551aade75169940557b6c51ed920", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1758277210, - "narHash": "sha256-iCGWf/LTy+aY0zFu8q12lK8KuZp7yvdhStehhyX1v8w=", + "lastModified": 1759381078, + "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8eaee110344796db060382e15d3af0a9fc396e0e", + "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", "type": "github" }, "original": { @@ -78,11 +78,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1758508617, - "narHash": "sha256-kx2uELmVnAbiekj/YFfWR26OXqXedImkhe2ocnbumTA=", + "lastModified": 1759718104, + "narHash": "sha256-TbkLsgdnXHUXR4gOQBmhxkEE9ne+eHmX1chZHWRogy0=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d2bac276ac7e669a1f09c48614538a37e3eb6d0f", + "rev": "edea9f33f9a03f615ad3609a40fbcefe0ec835ca", "type": "github" }, "original": { From 05e4222a23ff6fa478cdd33c47e325a1cae16017 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 6 Oct 2025 16:50:10 -0700 Subject: [PATCH 105/305] refactor(rust): remove lots of unsafe blocks --- README.md | 13 +-- .../src/app_kit_notification_constants.rs | 2 +- komorebi/src/border_manager/border.rs | 4 +- komorebi/src/border_manager/ns_window.rs | 36 +++----- komorebi/src/core_graphics/mod.rs | 30 +++--- komorebi/src/input_event_listener.rs | 4 +- komorebi/src/macos_api.rs | 18 ++-- komorebi/src/notification_center_listener.rs | 92 +++++++++---------- komorebi/src/window.rs | 78 +++++++--------- 9 files changed, 120 insertions(+), 157 deletions(-) diff --git a/README.md b/README.md index fc6a50ce..85e5dd50 100644 --- a/README.md +++ b/README.md @@ -118,14 +118,11 @@ Licenses [can be found here](https://lgug2z.com/software/komorebi). _komorebi for Mac_ is currently not accepting contributions. -[//]: # (If you would like to contribute to `komorebi` please take the time to carefully) - -[//]: # (read the guidelines below.) - -[//]: # () -[//]: # (Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about how) - -[//]: # (code contributions to `komorebi` are licensed.) +[//]: # "If you would like to contribute to `komorebi` please take the time to carefully" +[//]: # "read the guidelines below." +[//]: # +[//]: # "Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about how" +[//]: # "code contributions to `komorebi` are licensed." ## Commit hygiene diff --git a/komorebi/src/app_kit_notification_constants.rs b/komorebi/src/app_kit_notification_constants.rs index 67283bc3..cd5d304b 100644 --- a/komorebi/src/app_kit_notification_constants.rs +++ b/komorebi/src/app_kit_notification_constants.rs @@ -69,7 +69,7 @@ impl TryFrom for AppKitWorkspaceNotification { type Error = strum::ParseError; fn try_from(value: NSNotification) -> Result { - let name = unsafe { value.name().to_string() }; + let name = value.name().to_string(); AppKitWorkspaceNotification::from_str(&name) } diff --git a/komorebi/src/border_manager/border.rs b/komorebi/src/border_manager/border.rs index 260715bf..a1dc2c84 100644 --- a/komorebi/src/border_manager/border.rs +++ b/komorebi/src/border_manager/border.rs @@ -101,9 +101,7 @@ impl Border { let rect = MacosApi::window_rect(&element).unwrap_or_default(); - let frame = Rect::from(CoreGraphicsApi::display_bounds(unsafe { - CGMainDisplayID() - })); + let frame = Rect::from(CoreGraphicsApi::display_bounds(CGMainDisplayID())); let ns_rect = NSRect::new( NSPoint::new( rect.origin.x, diff --git a/komorebi/src/border_manager/ns_window.rs b/komorebi/src/border_manager/ns_window.rs index 6a506052..4dc47c39 100644 --- a/komorebi/src/border_manager/ns_window.rs +++ b/komorebi/src/border_manager/ns_window.rs @@ -64,37 +64,31 @@ impl NsWindow { }; // Make transparent - unsafe { - window.setBackgroundColor(Some(&NSColor::clearColor())); - window.setAnimationBehavior(NSWindowAnimationBehavior::None); - window.disableSnapshotRestoration(); - window.setPreservesContentDuringLiveResize(false); - window.setRestorable(false); - } + window.setBackgroundColor(Some(&NSColor::clearColor())); + window.setAnimationBehavior(NSWindowAnimationBehavior::None); + window.disableSnapshotRestoration(); + window.setPreservesContentDuringLiveResize(false); + window.setRestorable(false); window.setHasShadow(false); window.setOpaque(false); window.setLevel(NSNormalWindowLevel); window.setIgnoresMouseEvents(true); - unsafe { - window.setCollectionBehavior( - NSWindowCollectionBehavior::CanJoinAllSpaces | - NSWindowCollectionBehavior::Stationary | - NSWindowCollectionBehavior::IgnoresCycle | - NSWindowCollectionBehavior::Transient - ); - } + window.setCollectionBehavior( + NSWindowCollectionBehavior::CanJoinAllSpaces | + NSWindowCollectionBehavior::Stationary | + NSWindowCollectionBehavior::IgnoresCycle | + NSWindowCollectionBehavior::Transient + ); let content_view = { let view = NSView::alloc(mtm); - unsafe { NSView::initWithFrame(view, window_frame) } + NSView::initWithFrame(view, window_frame) }; content_view.setWantsLayer(true); - unsafe { - content_view.setAutoresizesSubviews(false); - } + content_view.setAutoresizesSubviews(false); // Create and configure the layer for the border let layer = { @@ -120,9 +114,7 @@ impl NsWindow { } }; - unsafe { - content_view.setLayer(Some(&layer)); - } + content_view.setLayer(Some(&layer)); window.setContentView(Some(&content_view)); window.setMovableByWindowBackground(false); diff --git a/komorebi/src/core_graphics/mod.rs b/komorebi/src/core_graphics/mod.rs index bf7b71ea..5625607f 100644 --- a/komorebi/src/core_graphics/mod.rs +++ b/komorebi/src/core_graphics/mod.rs @@ -20,19 +20,17 @@ pub struct CoreGraphicsApi; impl CoreGraphicsApi { pub fn warp_mouse_cursor_position(x: i32, y: i32) -> Result<(), CoreGraphicsError> { - match unsafe { - CoreGraphicsError::from(CGWarpMouseCursorPosition(CGPoint::new( - x as CGFloat, - y as CGFloat, - ))) - } { + match CoreGraphicsError::from(CGWarpMouseCursorPosition(CGPoint::new( + x as CGFloat, + y as CGFloat, + ))) { CoreGraphicsError::Success => Ok(()), error => Err(error), } } pub fn contains_rect(smaller: CGRect, bigger: CGRect) -> bool { - unsafe { CGRectIntersectsRect(smaller, bigger) } + CGRectIntersectsRect(smaller, bigger) } pub fn connected_display_ids() -> Result, CoreGraphicsError> { @@ -55,11 +53,11 @@ impl CoreGraphicsApi { } pub fn display_bounds(display_id: u32) -> CGRect { - unsafe { CGDisplayBounds(display_id) } + CGDisplayBounds(display_id) } pub fn display_serial_number(display_id: u32) -> u32 { - unsafe { CGDisplaySerialNumber(display_id) } + CGDisplaySerialNumber(display_id) } pub fn display_bounds_for_window_rect(window_rect: CGRect) -> Option { @@ -113,13 +111,11 @@ impl CoreGraphicsApi { } pub fn window_list_info() -> Option> { - unsafe { - CGWindowListCopyWindowInfo( - // this is still way too many bogus windows - CGWindowListOption::OptionOnScreenOnly | CGWindowListOption::ExcludeDesktopElements, - // required when using OnScreenOnly - kCGNullWindowID, - ) - } + CGWindowListCopyWindowInfo( + // this is still way too many bogus windows + CGWindowListOption::OptionOnScreenOnly | CGWindowListOption::ExcludeDesktopElements, + // required when using OnScreenOnly + kCGNullWindowID, + ) } } diff --git a/komorebi/src/input_event_listener.rs b/komorebi/src/input_event_listener.rs index 3be16071..ac4a06de 100644 --- a/komorebi/src/input_event_listener.rs +++ b/komorebi/src/input_event_listener.rs @@ -92,8 +92,6 @@ impl InputEventListener { impl Drop for InputEventListener { fn drop(&mut self) { CFMachPort::invalidate(&self.port); - unsafe { - CGEvent::tap_enable(&self.port, false); - } + CGEvent::tap_enable(&self.port, false); } } diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index b57e33bd..c58221c3 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -60,7 +60,7 @@ impl MacosApi { DispatchQueue::main().exec_async(move || { let ns_path = NSString::from_str(&path_str); - let url = unsafe { NSURL::fileURLWithPath(&ns_path) }; + let url = NSURL::fileURLWithPath(&ns_path); let mtm = unsafe { MainThreadMarker::new_unchecked() }; let screens = NSScreen::screens(mtm); @@ -72,7 +72,7 @@ impl MacosApi { && let Ok(did) = did.downcast::() && did.as_u32() == display_id { - let workspace = unsafe { NSWorkspace::sharedWorkspace() }; + let workspace = NSWorkspace::sharedWorkspace(); unsafe { if let Err(error) = workspace.setDesktopImageURL_forScreen_options_error( &url, @@ -235,7 +235,7 @@ impl MacosApi { MonitorInfo { alphanumeric_serial_number: serial_number.to_string(), manufacturer_id: "".to_string(), - product_name: unsafe { screen.localizedName() }.to_string(), + product_name: screen.localizedName().to_string(), legacy_manufacturer_id: "".to_string(), product_id: "".to_string(), serial_number, @@ -265,7 +265,7 @@ impl MacosApi { let visible_frame = screen.visibleFrame(); let primary_display_height = - CoreGraphicsApi::display_bounds(unsafe { CGMainDisplayID() }) + CoreGraphicsApi::display_bounds(CGMainDisplayID()) .size .height; @@ -446,11 +446,9 @@ impl MacosApi { } pub fn cursor_pos() -> CGPoint { - unsafe { - let source = CGEventSource::new(CGEventSourceStateID::HIDSystemState); - let event = CGEvent::new(source.as_deref()); - CGEvent::location(event.as_deref()) - } + let source = CGEventSource::new(CGEventSourceStateID::HIDSystemState); + let event = CGEvent::new(source.as_deref()); + CGEvent::location(event.as_deref()) } pub fn monitor_from_point(point: CGPoint) -> Option { @@ -458,6 +456,6 @@ impl MacosApi { } pub fn left_mouse_button_is_pressed() -> bool { - (unsafe { NSEvent::pressedMouseButtons() } & 0x1 != 0) + NSEvent::pressedMouseButtons() & 0x1 != 0 } } diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs index 6ffbb4b0..9f947c7a 100644 --- a/komorebi/src/notification_center_listener.rs +++ b/komorebi/src/notification_center_listener.rs @@ -32,60 +32,58 @@ define_class! { impl NotificationCenterListenerNsObject { #[unsafe(method(handleNotification:))] fn handle_notification(&self, notif: &NSNotification) { - unsafe { - let mut process_id = None; - let mut window_id = None; - let mut valid_keys = vec![]; + let mut process_id = None; + let mut window_id = None; + let mut valid_keys = vec![]; - if let Some(user_info) = notif.userInfo() { - let all_keys = user_info.allKeys(); - for k in all_keys { - if let Some(key) = k.downcast_ref::() { - valid_keys.push(key.to_string()); - } - } - - if let Some(application_key) = - user_info.valueForKey(&NSString::from_str("NSWorkspaceApplicationKey")) - && let Some(application) = application_key.downcast_ref::() - { - process_id = Some(application.processIdentifier()); - if let Ok(application) = Application::new(application.processIdentifier()) { - window_id = application.main_window_id(); - } + if let Some(user_info) = notif.userInfo() { + let all_keys = user_info.allKeys(); + for k in all_keys { + if let Some(key) = k.downcast_ref::() { + valid_keys.push(key.to_string()); } } - tracing::trace!("received {} with keys {}", notif.name(), valid_keys.join(", ")); + if let Some(application_key) = + user_info.valueForKey(&NSString::from_str("NSWorkspaceApplicationKey")) + && let Some(application) = application_key.downcast_ref::() + { + process_id = Some(application.processIdentifier()); + if let Ok(application) = Application::new(application.processIdentifier()) { + window_id = application.main_window_id(); + } + } + } - match process_id { - None => { - if let Ok(notification) = - AppKitWorkspaceNotification::from_str(¬if.name().to_string()) { - if matches!(notification, AppKitWorkspaceNotification::NSWorkspaceActiveSpaceDidChangeNotification) { - // TODO: this is really, really stupid - window_manager_event_listener::send_notification(WindowManagerEvent::SpaceChange(SystemNotification::AppKitWorkspace(notification), 0)); - } - } else { - tracing::debug!( - "notification: {}, skipping as there is no associated process id", - notif.name() - ); + tracing::trace!("received {} with keys {}", notif.name(), valid_keys.join(", ")); + + match process_id { + None => { + if let Ok(notification) = + AppKitWorkspaceNotification::from_str(¬if.name().to_string()) { + if matches!(notification, AppKitWorkspaceNotification::NSWorkspaceActiveSpaceDidChangeNotification) { + // TODO: this is really, really stupid + window_manager_event_listener::send_notification(WindowManagerEvent::SpaceChange(SystemNotification::AppKitWorkspace(notification), 0)); } + } else { + tracing::debug!( + "notification: {}, skipping as there is no associated process id", + notif.name() + ); } - Some(process_id) => { - tracing::debug!("notification: {}, process: {process_id}", notif.name()); - if let Ok(notification) = - AppKitWorkspaceNotification::from_str(¬if.name().to_string()) - && let Some(event) = WindowManagerEvent::from_system_notification( - SystemNotification::AppKitWorkspace(notification), - process_id, - window_id, - ) - { - window_manager_event_listener::send_notification(event); - }; - } + } + Some(process_id) => { + tracing::debug!("notification: {}, process: {process_id}", notif.name()); + if let Ok(notification) = + AppKitWorkspaceNotification::from_str(¬if.name().to_string()) + && let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::AppKitWorkspace(notification), + process_id, + window_id, + ) + { + window_manager_event_listener::send_notification(event); + }; } } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 7873a3a4..75d17a20 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -414,10 +414,7 @@ impl Window { } pub fn bundle_identifier(&self) -> Option { - if let Ok(Some(identifier)) = self - .running_application() - .map(|app| unsafe { app.bundleIdentifier() }) - { + if let Ok(Some(identifier)) = self.running_application().map(|app| app.bundleIdentifier()) { Some(identifier.to_string()) } else { None @@ -427,7 +424,7 @@ impl Window { pub fn bundle_path(&self) -> Option { if let Ok(Some(path)) = self .running_application() - .map(|app| unsafe { app.bundleURL() }) + .map(|app| app.bundleURL()) .map(|url| url.map(|url| url.to_file_path())) { path @@ -439,7 +436,7 @@ impl Window { pub fn path(&self) -> Option { if let Ok(Some(path)) = self .running_application() - .map(|app| unsafe { app.executableURL() }) + .map(|app| app.executableURL()) .map(|ns_url| ns_url.map(|url| url.to_file_path())) { path @@ -449,27 +446,23 @@ impl Window { } pub fn icon_path(&self) -> Option { - if let Some(path) = self.bundle_path() { - unsafe { - if let Some(bundle) = - NSBundle::bundleWithPath(&NSString::from_str(&path.to_string_lossy())) - && let Some(icon_file) = - bundle.objectForInfoDictionaryKey(&NSString::from_str("CFBundleIconFile")) - && let Ok(icon_name) = icon_file.downcast::() - { - let mut icon_path = - format!("{}/Contents/Resources/{}", path.display(), icon_name); + if let Some(path) = self.bundle_path() + && let Some(bundle) = + NSBundle::bundleWithPath(&NSString::from_str(&path.to_string_lossy())) + && let Some(icon_file) = + bundle.objectForInfoDictionaryKey(&NSString::from_str("CFBundleIconFile")) + && let Ok(icon_name) = icon_file.downcast::() + { + let mut icon_path = format!("{}/Contents/Resources/{}", path.display(), icon_name); - if !icon_path.ends_with(".icns") { - icon_path.push_str(".icns"); - } + if !icon_path.ends_with(".icns") { + icon_path.push_str(".icns"); + } - let path = Path::new(&icon_path); + let path = Path::new(&icon_path); - if path.exists() { - return Some(PathBuf::from(path)); - } - } + if path.exists() { + return Some(PathBuf::from(path)); } } @@ -487,14 +480,10 @@ impl Window { } fn running_application(&self) -> Result, AccessibilityError> { - unsafe { - NSRunningApplication::runningApplicationWithProcessIdentifier( - self.application.process_id, - ) + NSRunningApplication::runningApplicationWithProcessIdentifier(self.application.process_id) .ok_or(AccessibilityError::Custom( AccessibilityCustomError::NSRunningApplication(self.application.process_id), )) - } } pub fn set_position(&self, rect: &Rect) -> Result<(), AccessibilityError> { @@ -509,26 +498,23 @@ impl Window { } pub fn focus(&self, mouse_follows_focus: bool) -> Result<(), LibraryError> { - unsafe { - match self.running_application() { - Ok(running_application) => { - running_application - .activateWithOptions(NSApplicationActivationOptions::empty()); - } - Err(error) => { - tracing::warn!( - "failed to get running application for {} ({:?}): {error}", - self.application.process_id, - self.application.name() - ); - } + match self.running_application() { + Ok(running_application) => { + running_application.activateWithOptions(NSApplicationActivationOptions::empty()); + } + Err(error) => { + tracing::warn!( + "failed to get running application for {} ({:?}): {error}", + self.application.process_id, + self.application.name() + ); } - - let cf_boolean = CFBoolean::new(true); - let value = &**cf_boolean; - AccessibilityApi::set_attribute_cf_value(&self.element, kAXMainAttribute, value)?; } + let cf_boolean = CFBoolean::new(true); + let value = &**cf_boolean; + AccessibilityApi::set_attribute_cf_value(&self.element, kAXMainAttribute, value)?; + if mouse_follows_focus { MacosApi::center_cursor_in_rect(&MacosApi::window_rect(&self.element)?.into())? } From ed2185a667852151ef57bf270bd0f5165a74b493 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 7 Oct 2025 16:46:38 -0700 Subject: [PATCH 106/305] feat(config): add window hiding position behaviour This commit adds a new monitor configuration option "window_hiding_position", which takes an enum with the variants BottomLeft and BottomRight. Until now the behaviour had been hard-coded to hide windows at the bottom left of every monitor. If no value is given on a monitor configuration object, this option will default to BottomLeft. --- komorebi/src/container.rs | 24 ++++++++++---- komorebi/src/core/mod.rs | 12 +++++++ komorebi/src/lib.rs | 8 +++++ komorebi/src/monitor.rs | 9 ++++++ komorebi/src/monitor_reconciliator.rs | 1 + komorebi/src/process_command.rs | 8 +++-- komorebi/src/process_event.rs | 11 ++++--- komorebi/src/state.rs | 1 + komorebi/src/static_config.rs | 13 ++++++++ komorebi/src/window.rs | 31 +++++++++++++++--- komorebi/src/window_manager.rs | 22 +++++++++---- komorebi/src/workspace.rs | 46 +++++++++++++++++---------- schema.json | 19 +++++++++++ 13 files changed, 167 insertions(+), 38 deletions(-) diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index 1bbcf093..cadd6992 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -1,4 +1,5 @@ use crate::accessibility::error::AccessibilityError; +use crate::core::WindowHidingPosition; use crate::lockable_sequence::Lockable; use crate::ring::Ring; use crate::window::Window; @@ -76,14 +77,18 @@ impl Container { self.remove_window_by_idx(focused_idx) } - pub fn add_window(&mut self, window: &Window) -> eyre::Result<()> { + pub fn add_window( + &mut self, + window: &Window, + hiding_position: WindowHidingPosition, + ) -> eyre::Result<()> { self.windows_mut().push_back(window.clone()); self.focus_window(self.windows().len().saturating_sub(1)); let focused_window_idx = self.focused_window_idx(); for (i, window) in self.windows_mut().iter_mut().enumerate() { if i != focused_window_idx { - window.hide()?; + window.hide(hiding_position)?; } } @@ -99,14 +104,17 @@ impl Container { /// Hides the unfocused windows of the container and restores the focused one. This function /// is used to make sure we update the window that should be shown on a stack. If the container /// isn't a stack this function won't change anything. - pub fn load_focused_window(&mut self) -> Result<(), AccessibilityError> { + pub fn load_focused_window( + &mut self, + hiding_position: WindowHidingPosition, + ) -> Result<(), AccessibilityError> { let focused_idx = self.focused_window_idx(); for (i, window) in self.windows_mut().iter_mut().enumerate() { if i == focused_idx { window.restore()?; } else { - window.hide()?; + window.hide(hiding_position)?; } } @@ -119,7 +127,11 @@ impl Container { window } - pub fn hide(&mut self, omit: Option) -> eyre::Result<()> { + pub fn hide( + &mut self, + hiding_position: WindowHidingPosition, + omit: Option, + ) -> eyre::Result<()> { for window in self.windows_mut().iter_mut().rev() { let mut should_hide = omit.is_none(); @@ -131,7 +143,7 @@ impl Container { } if should_hide { - window.hide()?; + window.hide(hiding_position)?; } } diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 87430cb4..432d4976 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -110,6 +110,18 @@ pub enum FloatingLayerBehaviour { Float, } +#[derive( + Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, +)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum WindowHidingPosition { + /// Hide windows in the bottom left corner of the screen + #[default] + BottomLeft, + /// Hide windows in the bottom right corner of the screen + BottomRight, +} + #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )] diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 5769aa50..cb51198a 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -308,3 +308,11 @@ pub fn hidden_frame_bottom_left(screen_frame: CGRect, window_size: CGSize) -> CG CGRect::new(CGPoint::new(origin_x, origin_y), window_size) } + +pub fn hidden_frame_bottom_right(screen_frame: CGRect, window_size: CGSize) -> CGRect { + let visible_sliver: f64 = 1.0; + let origin_x = screen_frame.origin.x + screen_frame.size.width - visible_sliver; + let origin_y = screen_frame.origin.y + screen_frame.size.height - visible_sliver; + + CGRect::new(CGPoint::new(origin_x, origin_y), window_size) +} diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index b5401174..43dd9b35 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -2,6 +2,7 @@ use crate::DEFAULT_CONTAINER_PADDING; use crate::DEFAULT_WORKSPACE_PADDING; use crate::container::Container; use crate::core::FloatingLayerBehaviour; +use crate::core::WindowHidingPosition; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; use crate::core::operation_direction::OperationDirection; @@ -70,6 +71,7 @@ pub struct Monitor { pub last_focused_workspace: Option, pub wallpaper: Option, pub floating_layer_behaviour: Option, + pub window_hiding_position: WindowHidingPosition, } pub fn new( @@ -97,6 +99,7 @@ pub fn new( workspace_padding: None, wallpaper: None, floating_layer_behaviour: None, + window_hiding_position: WindowHidingPosition::default(), } } @@ -127,6 +130,7 @@ impl Monitor { last_focused_workspace: None, wallpaper: None, floating_layer_behaviour: None, + window_hiding_position: WindowHidingPosition::default(), } } @@ -147,6 +151,7 @@ impl Monitor { workspace_padding: None, wallpaper: None, floating_layer_behaviour: None, + window_hiding_position: WindowHidingPosition::default(), } } @@ -181,6 +186,7 @@ impl Monitor { let window_based_work_area_offset = self.window_based_work_area_offset; let window_based_work_area_offset_limit = self.window_based_work_area_offset_limit; let floating_layer_behaviour = self.floating_layer_behaviour; + let window_hiding_position = self.window_hiding_position; if let Some(workspace) = self.workspaces_mut().get_mut(workspace_idx) { workspace.globals = WorkspaceGlobals { @@ -193,6 +199,7 @@ impl Monitor { window_based_work_area_offset, window_based_work_area_offset_limit, floating_layer_behaviour, + window_hiding_position, } } } @@ -452,6 +459,7 @@ impl Monitor { let window_based_work_area_offset = self.window_based_work_area_offset; let window_based_work_area_offset_limit = self.window_based_work_area_offset_limit; let floating_layer_behaviour = self.floating_layer_behaviour; + let window_hiding_position = self.window_hiding_position; for workspace in self.workspaces_mut() { workspace.globals = WorkspaceGlobals { @@ -464,6 +472,7 @@ impl Monitor { window_based_work_area_offset, window_based_work_area_offset_limit, floating_layer_behaviour, + window_hiding_position, } } } diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index f44ceb0e..847c5c4c 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -383,6 +383,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result workspace_padding: cached.workspace_padding, wallpaper: cached.wallpaper.clone(), floating_layer_behaviour: cached.floating_layer_behaviour, + window_hiding_position: cached.window_hiding_position, }; let focused_workspace_idx = m.focused_workspace_idx(); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7638ef64..29421dd1 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -566,6 +566,10 @@ impl WindowManager { SocketMessage::ToggleFloat => self.toggle_float(false)?, SocketMessage::ToggleWorkspaceLayer => { let mouse_follows_focus = self.mouse_follows_focus; + let hiding_position = self + .focused_monitor() + .ok_or_eyre("there is no monitor")? + .window_hiding_position; let workspace = self.focused_workspace_mut()?; let mut to_focus = None; @@ -631,7 +635,7 @@ impl WindowManager { } for window in workspace.floating_windows_mut() { - window.hide()?; + window.hide(hiding_position)?; } } else { let focused_container_idx = workspace.focused_container_idx(); @@ -662,7 +666,7 @@ impl WindowManager { for window in window_idx_pairs { // TODO: figure out z order - window.hide()?; + window.hide(hiding_position)?; // window.lower()?; } } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 60c7b6d0..25dde249 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -14,6 +14,7 @@ use crate::app_kit_notification_constants::AppKitWorkspaceNotification; use crate::border_manager; use crate::core::Sizing; use crate::core::WindowContainerBehaviour; +use crate::core::WindowHidingPosition; use crate::core::config_generation::MatchingRule; use crate::core::default_layout::DefaultLayout; use crate::core::layout::Layout; @@ -441,7 +442,8 @@ impl WindowManager { "ignoring show event for window already associated with another workspace" ); - AdhocWindow::hide(window_id, element)?; + // TODO: probably shouldn't default here + AdhocWindow::hide(window_id, element, WindowHidingPosition::default())?; create = false; } } @@ -462,7 +464,6 @@ impl WindowManager { && let Ok(mut window) = Window::new(element, application.clone()) { window.observe(&self.run_loop, None)?; - let behaviour = self .window_management_behaviour(focused_monitor_idx, focused_workspace_idx); let workspace = self.focused_workspace_mut()?; @@ -534,10 +535,12 @@ impl WindowManager { self.update_focused_workspace(false, false)?; } WindowContainerBehaviour::Append => { + let window_hiding_position = + workspace.globals.window_hiding_position; workspace .focused_container_mut() .ok_or_eyre("there is no focused container")? - .add_window(&window)?; + .add_window(&window, window_hiding_position)?; workspace.layer = WorkspaceLayer::Tiling; self.update_focused_workspace(true, false)?; } @@ -575,7 +578,7 @@ impl WindowManager { if !(monocle_window_event || workspace.layer != WorkspaceLayer::Tiling) && monocle_container.is_some() { - window.hide()?; + window.hide(workspace.globals.window_hiding_position)?; } } diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs index 11c37b17..f36850cc 100644 --- a/komorebi/src/state.rs +++ b/komorebi/src/state.rs @@ -151,6 +151,7 @@ impl From<&WindowManager> for State { workspace_padding: monitor.workspace_padding, wallpaper: monitor.wallpaper.clone(), floating_layer_behaviour: monitor.floating_layer_behaviour, + window_hiding_position: monitor.window_hiding_position, }) .collect::>(); stripped_monitors.focus(wm.monitors.focused_idx()); diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index e7a879be..f2dc18cc 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -17,6 +17,7 @@ use crate::core::OperationBehaviour; use crate::core::Placement; use crate::core::SocketMessage; use crate::core::WindowContainerBehaviour; +use crate::core::WindowHidingPosition; use crate::core::WindowManagementBehaviour; use crate::core::arrangement::Axis; use crate::core::asc::ApplicationSpecificConfiguration; @@ -305,6 +306,9 @@ pub struct MonitorConfig { /// Determine what happens to a new window when the Floating workspace layer is active (default: Tile) #[serde(skip_serializing_if = "Option::is_none")] pub floating_layer_behaviour: Option, + /// Determine which position windows should be hidden at on this monitor + #[serde(skip_serializing_if = "Option::is_none")] + pub window_hiding_position: Option, } impl From<&Monitor> for MonitorConfig { @@ -342,6 +346,7 @@ impl From<&Monitor> for MonitorConfig { workspace_padding, wallpaper: value.wallpaper.clone(), floating_layer_behaviour: value.floating_layer_behaviour, + window_hiding_position: Some(value.window_hiding_position), } } } @@ -1252,6 +1257,8 @@ impl StaticConfig { monitor.workspace_padding = monitor_config.workspace_padding; monitor.wallpaper = monitor_config.wallpaper.clone(); monitor.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + monitor.window_hiding_position = + monitor_config.window_hiding_position.unwrap_or_default(); monitor.update_workspaces_globals(offset); for (j, ws) in monitor.workspaces_mut().iter_mut().enumerate() { @@ -1333,6 +1340,8 @@ impl StaticConfig { m.container_padding = monitor_config.container_padding; m.workspace_padding = monitor_config.workspace_padding; m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + m.window_hiding_position = + monitor_config.window_hiding_position.unwrap_or_default(); m.update_workspaces_globals(offset); @@ -1418,6 +1427,8 @@ impl StaticConfig { monitor.workspace_padding = monitor_config.workspace_padding; monitor.wallpaper = monitor_config.wallpaper.clone(); monitor.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + monitor.window_hiding_position = + monitor_config.window_hiding_position.unwrap_or_default(); monitor.update_workspaces_globals(offset); @@ -1491,6 +1502,8 @@ impl StaticConfig { m.container_padding = monitor_config.container_padding; m.workspace_padding = monitor_config.workspace_padding; m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + m.window_hiding_position = + monitor_config.window_hiding_position.unwrap_or_default(); m.update_workspaces_globals(offset); diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 75d17a20..ac0c54d8 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -31,12 +31,14 @@ use crate::accessibility::notification_constants::kAXWindowResizedNotification; use crate::application::Application; use crate::cf_dictionary_value; use crate::core::ApplicationIdentifier; +use crate::core::WindowHidingPosition; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; use crate::core::rect::Rect; use crate::core_graphics::CoreGraphicsApi; use crate::hidden_frame_bottom_left; +use crate::hidden_frame_bottom_right; use crate::macos_api::MacosApi; use crate::reaper; use crate::window_manager_event::SystemNotification; @@ -341,7 +343,10 @@ impl Window { } #[tracing::instrument(skip_all)] - pub fn hide(&mut self) -> Result<(), AccessibilityError> { + pub fn hide( + &mut self, + hiding_position: WindowHidingPosition, + ) -> Result<(), AccessibilityError> { let rect = MacosApi::window_rect(&self.element)?; let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); @@ -352,7 +357,14 @@ impl Window { if let Some(monitor_size) = CoreGraphicsApi::display_bounds_for_window_rect(rect) { // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API - let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); + let hidden_rect = match hiding_position { + WindowHidingPosition::BottomLeft => { + hidden_frame_bottom_left(monitor_size, rect.size) + } + WindowHidingPosition::BottomRight => { + hidden_frame_bottom_right(monitor_size, rect.size) + } + }; tracing::debug!( "hiding {} and setting restore point to {},{}", @@ -804,7 +816,11 @@ impl AdhocWindow { } #[tracing::instrument(skip_all)] - pub fn hide(id: u32, element: &CFRetained) -> Result<(), AccessibilityError> { + pub fn hide( + id: u32, + element: &CFRetained, + hiding_position: WindowHidingPosition, + ) -> Result<(), AccessibilityError> { let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock(); if let Entry::Vacant(entry) = window_restore_positions.entry(id) { let rect = MacosApi::window_rect(element)?; @@ -813,7 +829,14 @@ impl AdhocWindow { drop(window_restore_positions); // I don't love this, but it's basically what Aerospace does in lieu of an actual "Hide" API - let hidden_rect = hidden_frame_bottom_left(monitor_size, rect.size); + let hidden_rect = match hiding_position { + WindowHidingPosition::BottomLeft => { + hidden_frame_bottom_left(monitor_size, rect.size) + } + WindowHidingPosition::BottomRight => { + hidden_frame_bottom_right(monitor_size, rect.size) + } + }; tracing::debug!( "hiding window with id {id} and setting restore point to {},{}", diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 0c11473a..5b14a9b9 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -15,6 +15,7 @@ use crate::core::OperationBehaviour; use crate::core::Placement; use crate::core::Sizing; use crate::core::WindowContainerBehaviour; +use crate::core::WindowHidingPosition; use crate::core::WindowManagementBehaviour; use crate::core::arrangement::Arrangement; use crate::core::arrangement::Axis; @@ -1122,8 +1123,9 @@ impl WindowManager { } } + let window_hiding_position = workspace.globals.window_hiding_position; if changed_focus && let Some(container) = workspace.focused_container_mut() { - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; if let Some(window) = container.focused_window() { window.focus(mouse_follows_focus)?; } @@ -1204,6 +1206,7 @@ impl WindowManager { tracing::info!("cycling container windows"); let mouse_follows_focus = self.mouse_follows_focus; + let window_hiding_position = self.focused_workspace()?.globals.window_hiding_position; let container = self.focused_container_mut()?; @@ -1218,7 +1221,7 @@ impl WindowManager { let next_idx = direction.next_idx(current_idx, len); container.focus_window(next_idx); - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; if let Some(window) = container.focused_window() { window.focus(mouse_follows_focus)?; @@ -1280,11 +1283,16 @@ impl WindowManager { pub fn monocle_on(&mut self) -> eyre::Result<()> { tracing::info!("enabling monocle"); + let hiding_position = self + .focused_monitor() + .ok_or_eyre("there is no monitor")? + .window_hiding_position; + let workspace = self.focused_workspace_mut()?; workspace.new_monocle_container()?; for container in workspace.containers_mut() { - container.hide(None)?; + container.hide(hiding_position, None)?; } Ok(()) @@ -2161,6 +2169,7 @@ impl WindowManager { tracing::info!("cycling container window index"); let mouse_follows_focus = self.mouse_follows_focus; + let window_hiding_position = self.focused_workspace()?.globals.window_hiding_position; let container = if let Some(container) = &mut self.focused_workspace_mut()?.monocle_container { @@ -2181,7 +2190,7 @@ impl WindowManager { container.windows_mut().swap(current_idx, next_idx); container.focus_window(next_idx); - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; if let Some(window) = container.focused_window() { window.focus(mouse_follows_focus)?; @@ -2195,6 +2204,7 @@ impl WindowManager { tracing::info!("focusing container window at index {idx}"); let mouse_follows_focus = self.mouse_follows_focus; + let window_hiding_position = self.focused_workspace()?.globals.window_hiding_position; let container = if let Some(container) = &mut self.focused_workspace_mut()?.monocle_container { @@ -2215,7 +2225,7 @@ impl WindowManager { } container.focus_window(idx); - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; if let Some(window) = container.focused_window() { window.focus(mouse_follows_focus)?; @@ -2432,7 +2442,7 @@ impl WindowManager { // Hide the window we are about to remove if it is on the currently focused workspace if op.is_origin(focused_monitor_idx, focused_workspace_idx) { - window.hide()?; + window.hide(WindowHidingPosition::default())?; should_update_focused_workspace = true; } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 6ae9c0a8..db579e9b 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -3,6 +3,7 @@ use crate::container::Container; use crate::core::FloatingLayerBehaviour; use crate::core::SocketMessage; use crate::core::WindowContainerBehaviour; +use crate::core::WindowHidingPosition; use crate::core::arrangement::Axis; use crate::core::cycle_direction::CycleDirection; use crate::core::default_layout::DefaultLayout; @@ -139,6 +140,7 @@ pub struct WorkspaceGlobals { pub window_based_work_area_offset: Option, pub window_based_work_area_offset_limit: isize, pub floating_layer_behaviour: Option, + pub window_hiding_position: WindowHidingPosition, } impl Workspace { @@ -249,6 +251,8 @@ impl Workspace { .container_idx_for_window(window_id) .ok_or_eyre("there is no container/window")?; + let window_hiding_position = self.globals.window_hiding_position; + let container = self .containers_mut() .get_mut(container_idx) @@ -267,7 +271,7 @@ impl Workspace { container.focus_window(window_idx); if should_load { - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; } self.focus_container(container_idx); @@ -283,7 +287,7 @@ impl Workspace { }; let mut container = Container::default(); - container.add_window(window)?; + container.add_window(window, self.globals.window_hiding_position)?; self.insert_container_at_idx(next_idx, container); @@ -437,6 +441,8 @@ impl Workspace { .container_idx_for_window(window_id) .ok_or_eyre("there is no window")?; + let window_hiding_position = self.globals.window_hiding_position; + let container = self .containers_mut() .get_mut(container_idx) @@ -456,7 +462,7 @@ impl Workspace { self.remove_container_by_idx(container_idx); self.focus_previous_container(); } else { - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; if let Some(window) = container.focused_window() { window.focus(false)?; } @@ -593,6 +599,7 @@ impl Workspace { // this is what we use for stacking pub fn move_window_to_container(&mut self, target_container_idx: usize) -> eyre::Result<()> { let focused_idx = self.focused_container_idx(); + let window_hiding_position = self.globals.window_hiding_position; let container = self .focused_container_mut() @@ -612,7 +619,7 @@ impl Workspace { target_container_idx } } else { - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; target_container_idx }; @@ -621,18 +628,19 @@ impl Workspace { .get_mut(adjusted_target_container_index) .ok_or_eyre("there is no container")?; - target_container.add_window(&window)?; + target_container.add_window(&window, window_hiding_position)?; self.focus_container(adjusted_target_container_index); self.focused_container_mut() .ok_or_eyre("there is no container")? - .load_focused_window()?; + .load_focused_window(window_hiding_position)?; Ok(()) } pub fn new_container_for_focused_window(&mut self) -> eyre::Result<()> { let focused_container_idx = self.focused_container_idx(); + let window_hiding_position = self.globals.window_hiding_position; let container = self .focused_container_mut() @@ -645,17 +653,19 @@ impl Workspace { if container.windows().is_empty() { self.remove_container_by_idx(focused_container_idx); } else { - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; } self.new_container_for_window(&window)?; let mut container = Container::default(); - container.add_window(&window)?; + container.add_window(&window, window_hiding_position)?; Ok(()) } pub fn hide(&mut self, omit: Option) -> eyre::Result<()> { + let window_hiding_position = self.globals.window_hiding_position; + for window in self.floating_windows_mut().iter_mut().rev() { let mut should_hide = omit.is_none(); @@ -666,7 +676,7 @@ impl Workspace { should_hide = true } - if should_hide && let Err(error) = window.hide() { + if should_hide && let Err(error) = window.hide(window_hiding_position) { tracing::warn!( "failed to hide floating window, but this might be because it is already hidden: {error}" ); @@ -674,7 +684,7 @@ impl Workspace { } for container in self.containers_mut() { - container.hide(omit)?; + container.hide(window_hiding_position, omit)?; } // if let Some(window) = self.maximized_window() { @@ -682,7 +692,7 @@ impl Workspace { // } if let Some(container) = &mut self.monocle_container { - container.hide(omit)?; + container.hide(window_hiding_position, omit)?; } Ok(()) @@ -822,12 +832,14 @@ impl Workspace { self.monocle_container .as_mut() .ok_or_eyre("there is no monocle container")? - .load_focused_window()?; + .load_focused_window(self.globals.window_hiding_position)?; Ok(()) } pub fn reintegrate_monocle_container(&mut self) -> eyre::Result<()> { + let window_hiding_position = self.globals.window_hiding_position; + let restore_idx = self .monocle_container_restore_idx .ok_or_eyre("there is no monocle restore index")?; @@ -850,7 +862,7 @@ impl Workspace { self.focus_container(restore_idx); self.focused_container_mut() .ok_or_eyre("there is no container")? - .load_focused_window()?; + .load_focused_window(window_hiding_position)?; self.monocle_container = None; self.monocle_container_restore_idx = None; @@ -859,6 +871,8 @@ impl Workspace { } pub fn new_floating_window(&mut self) -> eyre::Result<()> { + let window_hiding_position = self.globals.window_hiding_position; + let window = if let Some(monocle_container) = &mut self.monocle_container { let window = monocle_container .remove_focused_window() @@ -868,7 +882,7 @@ impl Workspace { self.monocle_container = None; self.monocle_container_restore_idx = None; } else { - monocle_container.load_focused_window()?; + monocle_container.load_focused_window(self.globals.window_hiding_position)?; } window @@ -890,7 +904,7 @@ impl Workspace { self.focus_container(focused_idx.saturating_sub(1)); } } else { - container.load_focused_window()?; + container.load_focused_window(window_hiding_position)?; } window @@ -908,7 +922,7 @@ impl Workspace { .ok_or_eyre("there is no floating window")?; let mut container = Container::default(); - container.add_window(&window)?; + container.add_window(&window, self.globals.window_hiding_position)?; self.insert_container_at_idx(focused_idx, container); diff --git a/schema.json b/schema.json index 4b0d8399..94e9029b 100644 --- a/schema.json +++ b/schema.json @@ -1244,6 +1244,25 @@ "type": "integer", "format": "int" }, + "window_hiding_position": { + "description": "Determine which position windows should be hidden at on this monitor", + "oneOf": [ + { + "description": "Hide windows in the bottom left corner of the screen", + "type": "string", + "enum": [ + "BottomLeft" + ] + }, + { + "description": "Hide windows in the bottom right corner of the screen", + "type": "string", + "enum": [ + "BottomRight" + ] + } + ] + }, "work_area_offset": { "description": "Monitor-specific work area offset (default: None)", "type": "object", From 7bbad6539d0d1de427449ef22dc1610542a32e8a Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 7 Oct 2025 18:41:44 -0700 Subject: [PATCH 107/305] fix(wm): ensure messages window close by click is handled Stupid Apple stuff. Something was up with Messages leaving a ghost tile when being closed by the red dot vs. cmd+w - this change fixes that, but will probably break something else. --- komorebi/src/window.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index ac0c54d8..e8feba9f 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -85,6 +85,7 @@ use std::str::FromStr; use strum::Display; use strum::EnumString; use tracing::instrument; +use crate::reaper::ReaperNotification; const NOTIFICATIONS: &[&str] = &[ kAXWindowMiniaturizedNotification, @@ -224,6 +225,10 @@ impl Drop for Window { .unwrap_or_else(|| String::from("")) ); + // Messages wouldn't close on click which is annoying, this handles that edge case + // for now - hopefully it doesn't break anything else + reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + // make sure the observer gets removed from any run loops AccessibilityApi::invalidate_observer(&self.observer); } From acee420bd3c883b1e6be608bb60d81cd14fdf662 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 9 Oct 2025 12:37:27 -0700 Subject: [PATCH 108/305] feat(wm): implement ws reconciliator with source debouncing Hello infinite workspace switching loop, my old friend. Reimplemented the old workspace reconciliator from komorebi for Windows with additional source debouncing and tested by furiously mashing alt-1 and alt+2 for 20s. No loop! --- komorebi/src/lib.rs | 1 + komorebi/src/main.rs | 2 + komorebi/src/process_event.rs | 23 +++-- komorebi/src/window.rs | 2 +- komorebi/src/workspace_reconciliator.rs | 108 ++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 14 deletions(-) create mode 100644 komorebi/src/workspace_reconciliator.rs diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index cb51198a..408315f3 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -72,6 +72,7 @@ pub mod window_manager; pub mod window_manager_event; pub mod window_manager_event_listener; pub mod workspace; +pub mod workspace_reconciliator; lazy_static! { pub static ref HOME_DIR: PathBuf = { diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 3b57add4..4f26514a 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -20,6 +20,7 @@ use komorebi::static_config::StaticConfig; use komorebi::theme_manager; use komorebi::window_manager::WindowManager; use komorebi::window_manager_event_listener; +use komorebi::workspace_reconciliator; use objc2::rc::autoreleasepool; use objc2_application_services::AXIsProcessTrusted; use objc2_core_foundation::CFRunLoop; @@ -263,6 +264,7 @@ fn main() -> eyre::Result<()> { theme_manager::listen_for_notifications(); monitor_reconciliator::listen_for_notifications(wm.clone())?; reaper::listen_for_notifications(wm.clone()); + workspace_reconciliator::listen_for_notifications(wm.clone()); listen_for_commands(wm.clone()); listen_for_events(wm.clone()); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 25dde249..a2f9f5fa 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -34,6 +34,7 @@ use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use crate::window_manager_event_listener; use crate::workspace::WorkspaceLayer; +use crate::workspace_reconciliator; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use parking_lot::Mutex; @@ -176,6 +177,7 @@ impl WindowManager { let application_name = application.name().unwrap_or_default().clone(); let mut should_switch_workspace_layer_to_tiling = true; let mut tabbed_window = false; + let mut needs_reconciliation = false; if let Some(window_id) = application.main_window_id() && matches!( @@ -350,20 +352,14 @@ impl WindowManager { } } - // maybe we don't need a separate reconciliator module?? this works pretty well! - if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { - self.focus_monitor(m_idx)?; - self.focus_workspace(w_idx)?; - let event = WindowManagerEvent::from_system_notification( - SystemNotification::Manual(ManualNotification::FocusOnCmdTab), - process_id, - Some(window_id), - ); - - if let Some(manual_event) = event { - window_manager_event_listener::send_notification(manual_event); + if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known + && matches!( + notification, + SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification) + ) { + workspace_reconciliator::send_notification(m_idx, w_idx, event); + needs_reconciliation = true; } - } } } @@ -373,6 +369,7 @@ impl WindowManager { AccessibilityNotification::AXMainWindowChanged ) ) && !tabbed_window + && !needs_reconciliation { self.reap_invalid_windows_for_application(process_id)?; self.update_focused_workspace(false, false)?; diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index e8feba9f..82a75040 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -41,6 +41,7 @@ use crate::hidden_frame_bottom_left; use crate::hidden_frame_bottom_right; use crate::macos_api::MacosApi; use crate::reaper; +use crate::reaper::ReaperNotification; use crate::window_manager_event::SystemNotification; use crate::window_manager_event::WindowManagerEvent; use crate::window_manager_event_listener; @@ -85,7 +86,6 @@ use std::str::FromStr; use strum::Display; use strum::EnumString; use tracing::instrument; -use crate::reaper::ReaperNotification; const NOTIFICATIONS: &[&str] = &[ kAXWindowMiniaturizedNotification, diff --git a/komorebi/src/workspace_reconciliator.rs b/komorebi/src/workspace_reconciliator.rs new file mode 100644 index 00000000..36842236 --- /dev/null +++ b/komorebi/src/workspace_reconciliator.rs @@ -0,0 +1,108 @@ +#![deny(clippy::unwrap_used, clippy::expect_used)] + +use crate::window_manager::WindowManager; +use crate::window_manager_event::WindowManagerEvent; +use crossbeam_channel::Receiver; +use crossbeam_channel::Sender; +use parking_lot::Mutex; +use std::sync::Arc; +use std::sync::OnceLock; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; + +#[derive(Copy, Clone, Debug)] +pub struct Notification { + pub monitor_idx: usize, + pub workspace_idx: usize, + pub triggered_by: WindowManagerEvent, +} + +static RECONCILIATION_IN_PROGRESS: AtomicBool = AtomicBool::new(false); + +static CHANNEL: OnceLock<(Sender, Receiver)> = OnceLock::new(); + +pub fn channel() -> &'static (Sender, Receiver) { + CHANNEL.get_or_init(|| crossbeam_channel::bounded(1)) +} + +fn event_tx() -> Sender { + channel().0.clone() +} + +fn event_rx() -> Receiver { + channel().1.clone() +} + +pub fn send_notification( + monitor_idx: usize, + workspace_idx: usize, + triggered_by: WindowManagerEvent, +) { + if !RECONCILIATION_IN_PROGRESS.load(Ordering::Relaxed) { + tracing::debug!("sending reconciliation request"); + if event_tx() + .try_send(Notification { + monitor_idx, + workspace_idx, + triggered_by, + }) + .is_err() + { + tracing::warn!("channel is full; dropping notification") + } + } +} + +pub fn listen_for_notifications(wm: Arc>) { + std::thread::spawn(move || { + loop { + match handle_notifications(wm.clone()) { + Ok(()) => { + tracing::warn!("restarting finished thread"); + } + Err(error) => { + if cfg!(debug_assertions) { + tracing::error!("restarting failed thread: {:?}", error) + } else { + tracing::error!("restarting failed thread: {}", error) + } + } + } + } + }); +} +pub fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> { + tracing::info!("listening"); + + let receiver = event_rx(); + + for notification in &receiver { + RECONCILIATION_IN_PROGRESS.store(true, Ordering::Relaxed); + tracing::info!("running reconciliation for notification {notification:?}"); + + let mut wm = wm.lock(); + let focused_monitor_idx = wm.focused_monitor_idx(); + let focused_workspace_idx = + wm.focused_workspace_idx_for_monitor_idx(focused_monitor_idx)?; + + let focused_pair = (focused_monitor_idx, focused_workspace_idx); + let updated_pair = (notification.monitor_idx, notification.workspace_idx); + + if focused_pair != updated_pair { + tracing::info!("reconciliating workspace"); + wm.focus_monitor(notification.monitor_idx)?; + let mouse_follows_focus = wm.mouse_follows_focus; + + if let Some(monitor) = wm.focused_monitor_mut() { + let previous_idx = monitor.focused_workspace_idx(); + monitor.last_focused_workspace = Option::from(previous_idx); + monitor.focus_workspace(notification.workspace_idx)?; + monitor.load_focused_workspace(mouse_follows_focus)?; + } + } + + RECONCILIATION_IN_PROGRESS.store(false, Ordering::Relaxed); + } + + Ok(()) +} From 141eedfd609fe4073b039b427667f2b9870d23d6 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 9 Oct 2025 19:18:21 -0700 Subject: [PATCH 109/305] fix(wm): preserve state on screen lock and unlock Screen locking and unlocking is a bit weird in macOS because it's implemented as a separate app which is activated and deactivated, so unique events for screen lock and unlock are never emitted by the system. This commit encapsulates the logic to detect the relevant events on the loginwindow into the creation of ScreenLock and ScreenUnlock WindowManagerEvent variants. --- komorebi/src/notification_center_listener.rs | 56 ++++++++++++++------ komorebi/src/process_event.rs | 21 +++++++- komorebi/src/reaper.rs | 6 ++- komorebi/src/window_manager_event.rs | 8 +++ 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs index 9f947c7a..317ee939 100644 --- a/komorebi/src/notification_center_listener.rs +++ b/komorebi/src/notification_center_listener.rs @@ -35,6 +35,7 @@ define_class! { let mut process_id = None; let mut window_id = None; let mut valid_keys = vec![]; + let mut application = None; if let Some(user_info) = notif.userInfo() { let all_keys = user_info.allKeys(); @@ -46,19 +47,20 @@ define_class! { if let Some(application_key) = user_info.valueForKey(&NSString::from_str("NSWorkspaceApplicationKey")) - && let Some(application) = application_key.downcast_ref::() + && let Some(running_application) = application_key.downcast_ref::() { - process_id = Some(application.processIdentifier()); - if let Ok(application) = Application::new(application.processIdentifier()) { - window_id = application.main_window_id(); + process_id = Some(running_application.processIdentifier()); + if let Ok(app) = Application::new(running_application.processIdentifier()) { + window_id = app.main_window_id(); + application = Some(app); } } } tracing::trace!("received {} with keys {}", notif.name(), valid_keys.join(", ")); - match process_id { - None => { + match process_id { + None => { if let Ok(notification) = AppKitWorkspaceNotification::from_str(¬if.name().to_string()) { if matches!(notification, AppKitWorkspaceNotification::NSWorkspaceActiveSpaceDidChangeNotification) { @@ -74,16 +76,38 @@ define_class! { } Some(process_id) => { tracing::debug!("notification: {}, process: {process_id}", notif.name()); - if let Ok(notification) = - AppKitWorkspaceNotification::from_str(¬if.name().to_string()) - && let Some(event) = WindowManagerEvent::from_system_notification( - SystemNotification::AppKitWorkspace(notification), - process_id, - window_id, - ) - { - window_manager_event_listener::send_notification(event); - }; + match AppKitWorkspaceNotification::from_str(¬if.name().to_string()) { + Ok(AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification) => { + if application.is_some_and(|app| app.name().unwrap_or_default() == "loginwindow") { + window_manager_event_listener::send_notification( + WindowManagerEvent::ScreenLock( + SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification), + process_id + ) + ); + } + } + Ok(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification) => { + if application.is_some_and(|app| app.name().unwrap_or_default() == "loginwindow") { + window_manager_event_listener::send_notification( + WindowManagerEvent::ScreenUnlock( + SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification), + process_id + ) + ); + } + } + Ok(notification) => { + if let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::AppKitWorkspace(notification), + process_id, + window_id, + ) { + window_manager_event_listener::send_notification(event); + } + } + _ => {} + } } } } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index a2f9f5fa..dbfd859c 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -68,6 +68,22 @@ pub fn listen_for_events(wm: Arc>) { impl WindowManager { #[instrument(skip_all)] pub fn process_event(&mut self, event: WindowManagerEvent) -> eyre::Result<()> { + if matches!(event, WindowManagerEvent::ScreenLock(_, _)) { + let application = self.application(event.process_id())?; + if application.name().unwrap_or_default() == "loginwindow" { + tracing::debug!("pausing while screen is locked"); + self.is_paused = true; + } + } + + if matches!(event, WindowManagerEvent::ScreenUnlock(_, _)) { + let application = self.application(event.process_id())?; + if application.name().unwrap_or_default() == "loginwindow" { + tracing::debug!("unpausing on screen unlock"); + self.is_paused = false; + } + } + if self.is_paused { tracing::trace!("ignoring while paused"); return Ok(()); @@ -942,7 +958,10 @@ impl WindowManager { } } } - WindowManagerEvent::SpaceChange(_, _) => {} + // handled before this match + WindowManagerEvent::SpaceChange(_, _) + | WindowManagerEvent::ScreenLock(_, _) + | WindowManagerEvent::ScreenUnlock(_, _) => {} } self.update_known_window_ids(); diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs index 8f0f9d96..4ef8723f 100644 --- a/komorebi/src/reaper.rs +++ b/komorebi/src/reaper.rs @@ -57,8 +57,12 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> let receiver = event_rx(); - for notification in receiver { + 'notification: for notification in receiver { let mut wm = wm.lock(); + if wm.is_paused { + tracing::debug!("skipping reaper notification while wm is paused"); + continue 'notification; + } match notification { ReaperNotification::InvalidWindow(window_id) => { diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 75fb60f1..a13abe10 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -43,6 +43,8 @@ pub enum WindowManagerEvent { ResizeStart(SystemNotification, i32, u32), ResizeEnd(SystemNotification, i32, u32), SpaceChange(SystemNotification, i32), + ScreenLock(SystemNotification, i32), + ScreenUnlock(SystemNotification, i32), } impl WindowManagerEvent { @@ -143,6 +145,8 @@ impl WindowManagerEvent { | WindowManagerEvent::ResizeStart(_, process_id, _) | WindowManagerEvent::ResizeEnd(_, process_id, _) | WindowManagerEvent::SpaceChange(_, process_id) + | WindowManagerEvent::ScreenLock(_, process_id) + | WindowManagerEvent::ScreenUnlock(_, process_id) | WindowManagerEvent::Restore(_, process_id, _) => *process_id, } } @@ -160,6 +164,8 @@ impl WindowManagerEvent { | WindowManagerEvent::ResizeEnd(n, _, _) | WindowManagerEvent::Unmanage(n, _, _) | WindowManagerEvent::SpaceChange(n, _) + | WindowManagerEvent::ScreenLock(n, _) + | WindowManagerEvent::ScreenUnlock(n, _) | WindowManagerEvent::Restore(n, _, _) => match n { SystemNotification::Accessibility(a) => a.to_string(), SystemNotification::AppKitWorkspace(a) => a.to_string(), @@ -173,6 +179,8 @@ impl WindowManagerEvent { WindowManagerEvent::FocusChange(_, _, window_id) => *window_id, WindowManagerEvent::Show(_, _) | WindowManagerEvent::Destroy(_, _) + | WindowManagerEvent::ScreenLock(_, _) + | WindowManagerEvent::ScreenUnlock(_, _) | WindowManagerEvent::SpaceChange(_, _) => None, WindowManagerEvent::Minimize(_, _, window_id) | WindowManagerEvent::Manage(_, _, window_id) From aa718bf6e98f41494d681be812503abf07ebad4c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 10 Oct 2025 09:56:07 -0700 Subject: [PATCH 110/305] fix(wm): delegate all cmd+tab focus changes to ws reconciliator Mainly a cleanup PR - there were some subtle bugs introduced trying to exclude the ManualNotification for cmd+tab focus changes, but since this is all being delegated to the workspace reconciliator now, we can remove those confusing matches! guards and that variant all together. --- komorebi/src/process_command.rs | 14 +- komorebi/src/process_event.rs | 257 +++++++++++++-------------- komorebi/src/window_manager_event.rs | 10 +- 3 files changed, 135 insertions(+), 146 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 29421dd1..7a0e2a95 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -107,7 +107,7 @@ pub fn listen_for_commands(wm: Arc>) { } impl WindowManager { - #[tracing::instrument(skip(self, reply))] + #[tracing::instrument(skip(self, reply, message))] pub fn process_command( &mut self, message: SocketMessage, @@ -121,7 +121,11 @@ impl WindowManager { return Ok(()); } - tracing::info!("processing command: {message}"); + if matches!(message, SocketMessage::Theme(_)) { + tracing::trace!("processing command: {message}"); + } else { + tracing::info!("processing command: {message}"); + } #[allow(clippy::useless_asref)] // We don't have From implemented for &mut WindowManager @@ -1730,7 +1734,11 @@ impl WindowManager { border_manager::send_notification(None, None); - tracing::info!("processed"); + if matches!(message, SocketMessage::Theme(_)) { + tracing::trace!("processed command: {message}"); + } else { + tracing::info!("processed command: {message}"); + } Ok(()) } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index dbfd859c..bee13895 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -10,7 +10,6 @@ use crate::accessibility::AccessibilityApi; use crate::accessibility::error::AccessibilityApiError; use crate::accessibility::error::AccessibilityError; use crate::accessibility::notification_constants::AccessibilityNotification; -use crate::app_kit_notification_constants::AppKitWorkspaceNotification; use crate::border_manager; use crate::core::Sizing; use crate::core::WindowContainerBehaviour; @@ -178,16 +177,6 @@ impl WindowManager { self.enforce_workspace_rules()?; match event { - WindowManagerEvent::FocusChange( - SystemNotification::Manual(ManualNotification::FocusOnCmdTab), - _, - Some(window_id), - ) => { - let focused_workspace = self.focused_workspace_mut()?; - let container_idx = focused_workspace.container_idx_for_window(window_id); - focused_workspace.focus_container(container_idx.unwrap_or_default()); - self.update_focused_workspace(self.mouse_follows_focus, true)?; - } WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; let application_name = application.name().unwrap_or_default().clone(); @@ -196,35 +185,27 @@ impl WindowManager { let mut needs_reconciliation = false; if let Some(window_id) = application.main_window_id() - && matches!( - notification, - SystemNotification::Accessibility( - AccessibilityNotification::AXMainWindowChanged - ) | SystemNotification::AppKitWorkspace( - AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification - ) - ) && let Some(element) = application.main_window() - { - let workspace = self.focused_workspace_mut()?; + && let Some(element) = application.main_window() + { + let workspace = self.focused_workspace_mut()?; - let tabbed_applications = TABBED_APPLICATIONS.lock(); - if tabbed_applications.contains(&application_name) { - let mut first_tab_destroyed = false; + let tabbed_applications = TABBED_APPLICATIONS.lock(); + if tabbed_applications.contains(&application_name) { + let mut first_tab_destroyed = false; - for window in workspace.visible_windows() { - if let Some(window) = window - && window.application.name().unwrap_or_default() - == application_name - { - let tab_rect = MacosApi::window_rect(&element)?; - let main_rect = match MacosApi::window_rect(&window.element) { - Ok(rect) => rect, - Err(AccessibilityError::Api( - AccessibilityApiError::InvalidUIElement, - )) => { - // this means we have closed the 1st tab, so we need this window object to be reaped - // and for the new 1st tab to be the key element of the window struct - if let Some(event) = + for window in workspace.visible_windows() { + if let Some(window) = window + && window.application.name().unwrap_or_default() == application_name + { + let tab_rect = MacosApi::window_rect(&element)?; + let main_rect = match MacosApi::window_rect(&window.element) { + Ok(rect) => rect, + Err(AccessibilityError::Api( + AccessibilityApiError::InvalidUIElement, + )) => { + // this means we have closed the 1st tab, so we need this window object to be reaped + // and for the new 1st tab to be the key element of the window struct + if let Some(event) = WindowManagerEvent::from_system_notification( SystemNotification::Manual( ManualNotification::ShowOnFocusChangeFirstTabDestroyed, @@ -238,102 +219,103 @@ impl WindowManager { ); } - first_tab_destroyed = true; + first_tab_destroyed = true; - tracing::debug!( - "first tab of a native tabbed app was destroyed; reaping window and sending a new show event" - ); + tracing::debug!( + "first tab of a native tabbed app was destroyed; reaping window and sending a new show event" + ); - tab_rect - } - Err(error) => return Err(error.into()), - }; - - if tab_rect == main_rect { - tracing::debug!("ignoring focus change for tabbed window"); - tabbed_window = true; + tab_rect } - } - } + Err(error) => return Err(error.into()), + }; - if first_tab_destroyed { - self.reap_invalid_windows_for_application(process_id)?; + if tab_rect == main_rect { + tracing::debug!("ignoring focus change for tabbed window"); + tabbed_window = true; + } } } - drop(tabbed_applications); + if first_tab_destroyed { + self.reap_invalid_windows_for_application(process_id)?; + } + } - if !tabbed_window { - let is_known = self.known_window_ids.get(&window_id).cloned(); - let mut is_on_current_workspace = false; + drop(tabbed_applications); - // TODO: figure out if this applies on macOS too - // don't want to trigger the full workspace updates when there are no managed - // containers - this makes floating windows on empty workspaces go into very - // annoying focus change loops which prevents users from interacting with them - if !matches!( - self.focused_workspace()?.layout, - Layout::Default(DefaultLayout::Scrolling) - ) && !self.focused_workspace()?.containers().is_empty() { - self.update_focused_workspace(self.mouse_follows_focus, false)?; - } + if !tabbed_window { + let is_known = self.known_window_ids.get(&window_id).cloned(); + let mut is_on_current_workspace = false; - let workspace = self.focused_workspace_mut()?; - if workspace.contains_window(window_id) { - is_on_current_workspace = true; - } + // TODO: figure out if this applies on macOS too + // don't want to trigger the full workspace updates when there are no managed + // containers - this makes floating windows on empty workspaces go into very + // annoying focus change loops which prevents users from interacting with them + if !matches!( + self.focused_workspace()?.layout, + Layout::Default(DefaultLayout::Scrolling) + ) && !self.focused_workspace()?.containers().is_empty() + { + self.update_focused_workspace(self.mouse_follows_focus, false)?; + } - let floating_window_idx = workspace - .floating_windows() - .iter() - .position(|w| w.id == window_id); + let workspace = self.focused_workspace_mut()?; + if workspace.contains_window(window_id) { + is_on_current_workspace = true; + } - match floating_window_idx { - None => { - // if let Some(w) = workspace.maximized_window() { - // if w.hwnd == window_id { - // return Ok(()); - // } - // } + let floating_window_idx = workspace + .floating_windows() + .iter() + .position(|w| w.id == window_id); - if let Some(monocle) = &workspace.monocle_container { - if let Some(window) = monocle.focused_window() { - window.focus(false)?; - } - } else if !is_on_current_workspace && is_known.is_none() { - // thanks, I hate it - need to do this so that we don't mess up - // the workspace rules, but also don't miss events from dumb - // apps like notes, mail etc. - let mut has_matching_workspace_rule = false; - let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); - for rule in &*workspace_rules { - match &rule.matching_rule { - MatchingRule::Simple(r) => { - if r.id.trim_end_matches(".exe") == application_name + match floating_window_idx { + None => { + // if let Some(w) = workspace.maximized_window() { + // if w.hwnd == window_id { + // return Ok(()); + // } + // } + + if let Some(monocle) = &workspace.monocle_container { + if let Some(window) = monocle.focused_window() { + window.focus(false)?; + } + } else if !is_on_current_workspace && is_known.is_none() { + // thanks, I hate it - need to do this so that we don't mess up + // the workspace rules, but also don't miss events from dumb + // apps like notes, mail etc. + let mut has_matching_workspace_rule = false; + let workspace_rules = WORKSPACE_MATCHING_RULES.lock(); + for rule in &*workspace_rules { + match &rule.matching_rule { + MatchingRule::Simple(r) => { + if r.id.trim_end_matches(".exe") == application_name + { + has_matching_workspace_rule = true; + } + } + // TODO: this is pretty coarse + MatchingRule::Composite(rules) => { + for r in rules { + if r.id.trim_end_matches(".exe") + == application_name { has_matching_workspace_rule = true; } } - // TODO: this is pretty coarse - MatchingRule::Composite(rules) => { - for r in rules { - if r.id.trim_end_matches(".exe") - == application_name - { - has_matching_workspace_rule = true; - } - } - } } } + } - if !has_matching_workspace_rule - && workspace.focus_container_by_window(window_id).is_err() - { - // if this fails, the app was probably open but windowless when komorebi - // launched, so the window hasn't been registered - we should treat it - // as a "Show" event - if let Some(event) = + if !has_matching_workspace_rule + && workspace.focus_container_by_window(window_id).is_err() + { + // if this fails, the app was probably open but windowless when komorebi + // launched, so the window hasn't been registered - we should treat it + // as a "Show" event + if let Some(event) = WindowManagerEvent::from_system_notification( SystemNotification::Manual( ManualNotification::ShowOnFocusChangeWindowlessAppRestored, @@ -347,37 +329,36 @@ impl WindowManager { ); should_switch_workspace_layer_to_tiling = false; } - } - } else if is_on_current_workspace { - workspace.focus_container_by_window(window_id)?; - } - - if should_switch_workspace_layer_to_tiling { - workspace.layer = WorkspaceLayer::Tiling; - } - - if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) - && !self.focused_workspace()?.containers().is_empty() { - self.update_focused_workspace(self.mouse_follows_focus, false)?; } + } else if is_on_current_workspace { + workspace.focus_container_by_window(window_id)?; } - Some(idx) => { - if let Some(_window) = workspace.floating_windows().get(idx) { - workspace.layer = WorkspaceLayer::Floating; - } + + if should_switch_workspace_layer_to_tiling { + workspace.layer = WorkspaceLayer::Tiling; + } + + if matches!( + self.focused_workspace()?.layout, + Layout::Default(DefaultLayout::Scrolling) + ) && !self.focused_workspace()?.containers().is_empty() + { + self.update_focused_workspace(self.mouse_follows_focus, false)?; } } - - if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known - && matches!( - notification, - SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification) - ) { - workspace_reconciliator::send_notification(m_idx, w_idx, event); - needs_reconciliation = true; + Some(idx) => { + if let Some(_window) = workspace.floating_windows().get(idx) { + workspace.layer = WorkspaceLayer::Floating; } + } + } + + if !is_on_current_workspace && let Some((m_idx, w_idx)) = is_known { + workspace_reconciliator::send_notification(m_idx, w_idx, event); + needs_reconciliation = true; } } + } if matches!( notification, diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index a13abe10..72ec784b 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -24,7 +24,6 @@ pub enum ManualNotification { ShowOnFocusChangeWindowlessAppRestored, Manage, Unmanage, - FocusOnCmdTab, } #[derive(Debug, Copy, Clone, Serialize, Deserialize, Display)] @@ -60,10 +59,11 @@ impl WindowManagerEvent { ) | SystemNotification::AppKitWorkspace( AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification, - ) - | SystemNotification::Manual(ManualNotification::FocusOnCmdTab) => Some( - WindowManagerEvent::FocusChange(notification, process_id, window_id), - ), + ) => Some(WindowManagerEvent::FocusChange( + notification, + process_id, + window_id, + )), SystemNotification::Accessibility(AccessibilityNotification::AXWindowCreated) | SystemNotification::Accessibility(AccessibilityNotification::AXApplicationShown) | SystemNotification::AppKitWorkspace( From f729cc2b815446f7720a94047b7dcc4d6641445b Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 10 Oct 2025 14:25:14 -0700 Subject: [PATCH 111/305] docs(mkdocs): add notes about system configuration suggestions --- docs/installation.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 5e296b6a..9788e221 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -18,6 +18,20 @@ using keyboard shortcuts. At this time users must compile `komorebi` from source. +## System settings suggestions + +Go to `System Settings -> Desktop & Dock -> Mission Control -> Displays have +separate Spaces` and disable this option if you are using more than one monitor. + +`komorebi` is scoped to a single macOS space (the one that is active when the +process is started), which means that you can still use other Spaces as if +`komorebi` were not running at all. If you are using monitors with the above +option enabled, komorebi will only be listening to events from the Space on the +monitor which it was launched on. + +Go to `System Settings -> Desktop & Dock -> Mission Control -> Group windows +by application` and disable this option if you like to use mission control. + ## Building from source Make sure you have installed [`rustup`](https://rustup.rs), and a stable `rust` From c819907a4d2ef72ce09a985f16dd39aef66a3074 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Oct 2025 10:32:03 -0700 Subject: [PATCH 112/305] test(wm): migrate container test cases --- komorebi/src/container.rs | 150 ++++++++++++++++++++++++++++++++++- komorebi/src/core/pathext.rs | 26 ++++-- komorebi/src/window.rs | 13 +++ 3 files changed, 179 insertions(+), 10 deletions(-) diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index cadd6992..e4504992 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -84,12 +84,17 @@ impl Container { ) -> eyre::Result<()> { self.windows_mut().push_back(window.clone()); self.focus_window(self.windows().len().saturating_sub(1)); - let focused_window_idx = self.focused_window_idx(); - for (i, window) in self.windows_mut().iter_mut().enumerate() { - if i != focused_window_idx { - window.hide(hiding_position)?; + if !cfg!(test) { + let focused_window_idx = self.focused_window_idx(); + + for (i, window) in self.windows_mut().iter_mut().enumerate() { + if i != focused_window_idx { + window.hide(hiding_position)?; + } } + } else { + tracing::info!("not hiding windows to {hiding_position} during test execution") } Ok(()) @@ -158,3 +163,140 @@ impl Container { Ok(()) } } + +#[cfg(test)] +mod tests { + use super::*; + use serde_json; + + #[test] + fn test_contains_window() { + let mut container = Container::default(); + + for i in 0..3 { + container + .add_window(&Window::from(i), WindowHidingPosition::BottomLeft) + .unwrap(); + } + + // Should return true for existing windows + assert!(container.contains_window(1)); + assert_eq!(container.idx_for_window(1), Some(1)); + + // Should return false since window 4 doesn't exist + assert!(!container.contains_window(4)); + assert_eq!(container.idx_for_window(4), None); + } + + #[test] + fn test_remove_window_by_idx() { + let mut container = Container::default(); + + for i in 0..3 { + container + .add_window(&Window::from(i), WindowHidingPosition::BottomLeft) + .unwrap(); + } + + // Remove window 1 + container.remove_window_by_idx(1); + + // Should only have 2 windows left + assert_eq!(container.windows().len(), 2); + + // Should return false since window 1 was removed + assert!(!container.contains_window(1)); + } + + #[test] + fn test_remove_focused_window() { + let mut container = Container::default(); + + for i in 0..3 { + container + .add_window(&Window::from(i), WindowHidingPosition::BottomLeft) + .unwrap(); + } + + // Should be focused on the last created window + assert_eq!(container.focused_window_idx(), 2); + + // Remove the focused window + container.remove_focused_window(); + + // Should be focused on the window before the removed one + assert_eq!(container.focused_window_idx(), 1); + + // Should only have 2 windows left + assert_eq!(container.windows().len(), 2); + } + + #[test] + fn test_add_window() { + let mut container = Container::default(); + + container + .add_window(&Window::from(1), WindowHidingPosition::BottomLeft) + .unwrap(); + + assert_eq!(container.windows().len(), 1); + assert_eq!(container.focused_window_idx(), 0); + assert!(container.contains_window(1)); + } + + #[test] + fn test_focus_window() { + let mut container = Container::default(); + + for i in 0..3 { + container + .add_window(&Window::from(i), WindowHidingPosition::BottomLeft) + .unwrap(); + } + + // Should focus on the last created window + assert_eq!(container.focused_window_idx(), 2); + + // focus on the window at index 1 + container.focus_window(1); + + // Should be focused on window 1 + assert_eq!(container.focused_window_idx(), 1); + + // focus on the window at index 0 + container.focus_window(0); + + // Should be focused on window 0 + assert_eq!(container.focused_window_idx(), 0); + } + + #[test] + fn test_idx_for_window() { + let mut container = Container::default(); + + for i in 0..3 { + container + .add_window(&Window::from(i), WindowHidingPosition::BottomLeft) + .unwrap(); + } + + // Should return the index of the window + assert_eq!(container.idx_for_window(1), Some(1)); + + // Should return None since window 4 doesn't exist + assert_eq!(container.idx_for_window(4), None); + } + + #[test] + fn serializes_and_deserializes() { + let mut container = Container::default(); + container.set_locked(true); + + let serialized = serde_json::to_string(&container).expect("Should serialize"); + let deserialized: Container = + serde_json::from_str(&serialized).expect("Should deserialize"); + + assert!(deserialized.locked); + assert_eq!(deserialized.id, container.id); + } +} diff --git a/komorebi/src/core/pathext.rs b/komorebi/src/core/pathext.rs index ad383677..3713ac40 100644 --- a/komorebi/src/core/pathext.rs +++ b/komorebi/src/core/pathext.rs @@ -186,13 +186,27 @@ mod tests { ); assert_eq!(resolve("/path/$ASD/to/d"), expected("/path/$ASD/to/d")); - // Set a $env:USERPROFILE variable for testing - unsafe { - std::env::set_var("USERPROFILE", "C:\\Users\\user"); + #[cfg(target_os = "windows")] + { + // Set a $env:USERPROFILE variable for testing + unsafe { + std::env::set_var("USERPROFILE", "C:\\Users\\user"); + } + + // ~ and $HOME should be replaced with $Env:USERPROFILE + assert_eq!(resolve("~"), expected("C:\\Users\\user")); + assert_eq!(resolve("$HOME"), expected("C:\\Users\\user")); } - // ~ and $HOME should be replaced with $Env:USERPROFILE - assert_eq!(resolve("~"), expected("C:\\Users\\user")); - assert_eq!(resolve("$HOME"), expected("C:\\Users\\user")); + #[cfg(target_os = "macos")] + { + // Set a $env:USERPROFILE variable for testing + unsafe { + std::env::set_var("HOME", "/Users/user"); + } + + // ~ and $HOME should be replaced with $Env:USERPROFILE + assert_eq!(resolve("$HOME"), expected("/Users/user")); + } } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 82a75040..4765845c 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -192,6 +192,19 @@ pub struct Window { pub details: Option, } +#[cfg(test)] +impl From for Window { + fn from(id: u32) -> Self { + Self { + id, + element: Default::default(), + application: Default::default(), + observer: Default::default(), + details: None, + } + } +} + #[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct WindowDetails { From d08e0b0cd9900a45a65c185190b1a2e0615a33eb Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Oct 2025 10:40:37 -0700 Subject: [PATCH 113/305] test(wm): migrate workspace test cases --- komorebi/src/container.rs | 16 +- komorebi/src/workspace.rs | 813 +++++++++++++++++++++++++++++++++++++- 2 files changed, 822 insertions(+), 7 deletions(-) diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index e4504992..f0d3a945 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -115,12 +115,18 @@ impl Container { ) -> Result<(), AccessibilityError> { let focused_idx = self.focused_window_idx(); - for (i, window) in self.windows_mut().iter_mut().enumerate() { - if i == focused_idx { - window.restore()?; - } else { - window.hide(hiding_position)?; + if !cfg!(test) { + for (i, window) in self.windows_mut().iter_mut().enumerate() { + if i == focused_idx { + window.restore()?; + } else { + window.hide(hiding_position)?; + } } + } else { + tracing::info!( + "not hiding/restoring windows to/from {hiding_position} during test execution" + ) } Ok(()) diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index db579e9b..d1a6432f 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -270,8 +270,14 @@ impl Workspace { container.focus_window(window_idx); - if should_load { - container.load_focused_window(window_hiding_position)?; + if !cfg!(test) { + if should_load { + container.load_focused_window(window_hiding_position)?; + } + } else { + tracing::info!( + "skipping loading of focused window from {window_hiding_position} ({should_load:?}) during test execution" + ); } self.focus_container(container_idx); @@ -1584,3 +1590,806 @@ impl Workspace { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::container::Container; + use crate::window::Window; + use std::collections::HashMap; + + #[test] + fn test_locked_containers_with_new_window() { + let mut ws = Workspace::default(); + + let mut state = HashMap::new(); + + // add 4 containers + for i in 0..4 { + let mut container = Container::default(); + if i == 3 { + container.locked = true; // set index 3 locked + } + state.insert(i, container.id.to_string()); + ws.add_container_to_back(container); + } + assert_eq!(ws.containers().len(), 4); + + // focus container at index 2 + ws.focus_container(2); + + // simulate a new window being launched on this workspace + ws.new_container_for_window(&Window::from(123)).unwrap(); + + // new length should be 5, with the focus on the new window at index 4 + assert_eq!(ws.containers().len(), 5); + assert_eq!(ws.focused_container_idx(), 4); + assert_eq!( + ws.focused_container().unwrap().focused_window().unwrap().id, + 123 + ); + + // when inserting a new container at index 0, index 3's container should not change + ws.focus_container(0); + ws.new_container_for_window(&Window::from(234)).unwrap(); + assert_eq!( + ws.containers()[3].id.to_string(), + state.get(&3).unwrap().to_string() + ); + } + + #[test] + fn test_locked_containers_remove_window() { + let mut ws = Workspace::default(); + + // add 4 containers + for i in 0..4 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + if i == 1 { + container.locked = true; + } + ws.add_container_to_back(container); + } + assert_eq!(ws.containers().len(), 4); + + ws.remove_window(0).unwrap(); + assert_eq!(ws.containers()[0].focused_window().unwrap().id, 2); + // index 1 should still be the same + assert_eq!(ws.containers()[1].focused_window().unwrap().id, 1); + assert_eq!(ws.containers()[2].focused_window().unwrap().id, 3); + } + + #[test] + fn test_locked_containers_toggle_float() { + let mut ws = Workspace::default(); + + // add 4 containers + for i in 0..4 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + if i == 1 { + container.locked = true; + } + ws.add_container_to_back(container); + } + assert_eq!(ws.containers().len(), 4); + + // set index 0 focused + ws.focus_container(0); + + // float index 0 + ws.new_floating_window().unwrap(); + + assert_eq!(ws.containers()[0].focused_window().unwrap().id, 2); + // index 1 should still be the same + assert_eq!(ws.containers()[1].focused_window().unwrap().id, 1); + assert_eq!(ws.containers()[2].focused_window().unwrap().id, 3); + + // unfloat - have to do this semi-manually becuase of calls to WindowsApi in + // new_container_for_floating_window which usually handles unfloating + let window = ws.floating_windows_mut().pop_back().unwrap(); + let mut container = Container::default(); + container + .add_window(&window, WindowHidingPosition::BottomLeft) + .unwrap(); + ws.insert_container_at_idx(ws.focused_container_idx(), container); + + // all indexes should be at their original position + for i in 0..4 { + assert_eq!(ws.containers()[i].focused_window().unwrap().id, i as u32); + } + } + + #[test] + fn test_locked_containers_stack() { + let mut ws = Workspace::default(); + + // add 6 containers + for i in 0..6 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + if i == 4 { + container.locked = true; + } + ws.add_container_to_back(container); + } + assert_eq!(ws.containers().len(), 6); + + // set index 3 focused + ws.focus_container(3); + + // stack index 3 on top of index 2 + ws.move_window_to_container(2).unwrap(); + + assert_eq!(ws.containers()[0].focused_window().unwrap().id, 0); + assert_eq!(ws.containers()[1].focused_window().unwrap().id, 1); + assert_eq!(ws.containers()[2].windows().len(), 2); + assert_eq!(ws.containers()[3].focused_window().unwrap().id, 5); + // index 4 should still be the same + assert_eq!(ws.containers()[4].focused_window().unwrap().id, 4); + + // unstack + ws.new_container_for_focused_window().unwrap(); + + // all indexes should be at their original position + for i in 0..6 { + assert_eq!(ws.containers()[i].focused_window().unwrap().id, i as u32) + } + } + + #[test] + fn test_contains_window() { + // Create default workspace + let mut workspace = Workspace::default(); + + // Add a window to the container + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(0)); + + // Add container + workspace.add_container_to_back(container); + + // Should be true + assert!(workspace.contains_window(0)); + + // Should be false + assert!(!workspace.is_empty()) + } + + #[test] + fn test_add_container_to_back() { + let mut workspace = Workspace::default(); + + { + // Container with 3 windows + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + { + // Container with 1 window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + } + // Should have 2 containers + assert_eq!(workspace.containers().len(), 2); + + // Get focused container. Should be the index of the last container added + let container = workspace.focused_container_mut().unwrap(); + + // Should be focused on the container with 1 window + assert_eq!(container.windows().len(), 1); + } + + #[test] + fn test_add_container_to_front() { + let mut workspace = Workspace::default(); + + { + // Container with 1 window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_front(container); + } + + { + // Container with 3 windows + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_front(container); + } + // Should have 2 containers + assert_eq!(workspace.containers().len(), 2); + + // Get focused container. Should be the index of the last container added + let container = workspace.focused_container_mut().unwrap(); + + // Should be focused on the container with 3 windows + assert_eq!(container.windows().len(), 3); + } + + #[test] + fn test_remove_non_existent_window() { + let mut workspace = Workspace::default(); + + { + // Add a container with one window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + } + + // Attempt to remove a non-existent window + let result = workspace.remove_window(2); + + // Should return an error + assert!( + result.is_err(), + "Expected an error when removing a non-existent window" + ); + + // Get focused container. Should be the index of the last container added + let container = workspace.focused_container_mut().unwrap(); + + // Should still have 1 window + assert_eq!(container.windows().len(), 1); + } + + #[test] + fn test_remove_focused_container() { + let mut workspace = Workspace::default(); + + { + // Container with 1 window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + } + + { + // Container with 1 window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + } + // Should have 2 containers + assert_eq!(workspace.containers().len(), 2); + + // Should be focused on the container at index 1 + assert_eq!(workspace.focused_container_idx(), 1); + + // Store the container at index 1 before removal + let container_to_remove = workspace.containers().get(1).cloned(); + workspace.remove_focused_container(); + + // Should only have 1 container + assert_eq!(workspace.containers().len(), 1); + + // Should be focused on the container at index 0 + assert_eq!(workspace.focused_container_idx(), 0); + + // Ensure the container at index 1 before removal is no longer present + assert!(container_to_remove.is_some()); + assert!( + !workspace + .containers() + .contains(&container_to_remove.unwrap()) + ); + } + + #[test] + fn test_insert_container_at_idx() { + let mut workspace = Workspace::default(); + + for i in 0..4 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + + // Should have 4 containers + assert_eq!(workspace.containers().len(), 4); + + // Should be focused on the last container + assert_eq!(workspace.focused_container_idx(), 3); + + // Insert a container at index 4 + workspace.insert_container_at_idx(4, Container::default()); + + // Should have 5 containers + assert_eq!(workspace.containers().len(), 5); + + // Should be focused on the newly inserted container + assert_eq!(workspace.focused_container_idx(), 4); + } + + #[test] + fn test_remove_container_by_idx() { + let mut workspace = Workspace::default(); + + for i in 0..3 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + + // Should have 3 containers + assert_eq!(workspace.containers().len(), 3); + + // Should be focused on the last container + assert_eq!(workspace.focused_container_idx(), 2); + + // Store the container at index 1 before removal + let container_to_remove = workspace.containers().get(1).cloned(); + + // Remove the container at index 1 + workspace.remove_container_by_idx(1); + + // Should have 2 containers + assert_eq!(workspace.containers().len(), 2); + + // Ensure the container at index 1 before removal is no longer present + assert!(container_to_remove.is_some()); + assert!( + !workspace + .containers() + .contains(&container_to_remove.unwrap()) + ); + } + + #[test] + fn test_remove_container() { + let mut workspace = Workspace::default(); + + for i in 0..3 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + + // Should have 3 containers + assert_eq!(workspace.containers().len(), 3); + + // Should be focused on the last container + assert_eq!(workspace.focused_container_idx(), 2); + + // Store the container at index 2 before removal + let container_to_remove = workspace.containers().get(2).cloned(); + + // Remove the container at index 2 + workspace.remove_container(2); + + // Should be focused on the previous container which is index 1 + assert_eq!(workspace.focused_container_idx(), 1); + + // Should have 2 containers + assert_eq!(workspace.containers().len(), 2); + + // Ensure the container at index 1 before removal is no longer present + assert!(container_to_remove.is_some()); + assert!( + !workspace + .containers() + .contains(&container_to_remove.unwrap()) + ); + } + + #[test] + fn test_focus_container() { + let mut workspace = Workspace::default(); + + for i in 0..3 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + + // Should have 3 containers + assert_eq!(workspace.containers().len(), 3); + + // Should be focused on the last container + assert_eq!(workspace.focused_container_idx(), 2); + + // Focus on container 1 + workspace.focus_container(1); + assert_eq!(workspace.focused_container_idx(), 1); + + // Focus on container 0 + workspace.focus_container(0); + assert_eq!(workspace.focused_container_idx(), 0); + + // Focus on container 2 + workspace.focus_container(2); + assert_eq!(workspace.focused_container_idx(), 2); + } + + #[test] + fn test_focus_previous_container() { + let mut workspace = Workspace::default(); + + for i in 0..3 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + + // Should have 3 containers + assert_eq!(workspace.containers().len(), 3); + + // Should be focused on the last container + assert_eq!(workspace.focused_container_idx(), 2); + + // Focus on the previous container + workspace.focus_previous_container(); + + // Should be focused on container 1 + assert_eq!(workspace.focused_container_idx(), 1); + } + + #[test] + fn test_focus_last_container() { + let mut workspace = Workspace::default(); + + for i in 0..3 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + + // Should have 3 containers + assert_eq!(workspace.containers().len(), 3); + + // Change focus to the first container for the test + workspace.focus_container(0); + assert_eq!(workspace.focused_container_idx(), 0); + + // Focus on the last container + workspace.focus_last_container(); + + // Should be focused on container 1 + assert_eq!(workspace.focused_container_idx(), 2); + } + + #[test] + fn test_focus_first_container() { + let mut workspace = Workspace::default(); + + for i in 0..3 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + + // Should have 3 containers + assert_eq!(workspace.containers().len(), 3); + + // Should be focused on the last container + assert_eq!(workspace.focused_container_idx(), 2); + + // Focus on the first container + workspace.focus_first_container(); + + // Should be focused on container 1 + assert_eq!(workspace.focused_container_idx(), 0); + } + + #[test] + fn test_swap_containers() { + let mut workspace = Workspace::default(); + + { + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + } + + // Should have 2 containers + assert_eq!(workspace.containers().len(), 2); + + { + // Should be focused on container 1 + assert_eq!(workspace.focused_container_idx(), 1); + + // Should have 1 window + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 1); + } + + // Swap containers 0 and 1 + workspace.swap_containers(0, 1); + + { + // Should be focused on container 0 + assert_eq!(workspace.focused_container_idx(), 1); + + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 3); + } + } + + #[test] + fn test_new_container_for_window() { + let mut workspace = Workspace::default(); + + { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + } + + // Add new window to container + workspace + .new_container_for_window(&Window::from(2)) + .unwrap(); + + // Container 0 should have 1 window + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 1); + + // Should return true that window 2 exists + assert!(workspace.contains_window(2)); + } + + #[test] + fn test_move_window_to_container() { + let mut workspace = Workspace::default(); + + { + // Container with 0 windows + let container = Container::default(); + workspace.add_container_to_back(container); + } + + { + // Container with 3 windows + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + // Move A Window from container 1 to container 0 + workspace.move_window_to_container(0).unwrap(); + + // Focus on container 0 + workspace.focus_container(0); + + // Container 0 should have 1 window + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 1); + } + + #[test] + fn test_move_window_to_non_existent_container() { + let mut workspace = Workspace::default(); + + // Add a container with one window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + + // Try to move window to a non-existent container + let result = workspace.move_window_to_container(8); + + // Should return an error + assert!( + result.is_err(), + "Expected an error when moving a window to a non-existent container" + ); + } + + #[test] + fn test_remove_window() { + let mut workspace = Workspace::default(); + + { + // Container with 1 window + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + // Remove window 1 + workspace.remove_window(1).ok(); + + // Should have 2 windows + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 2); + + // Check that window 1 is removed + assert!(!workspace.contains_window(1)); + } + + #[test] + fn test_new_container_for_focused_window() { + let mut workspace = Workspace::default(); + + { + // Container with 1 window + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + // Add focused window to new container + workspace.new_container_for_focused_window().ok(); + + // Should have 2 containers + assert_eq!(workspace.containers().len(), 2); + + { + // Inspect new container. Should contain 1 window. Window name should be 0 + workspace.focus_container(1); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 1); + assert!(workspace.contains_window(0)); + } + } + + #[test] + fn test_focus_container_by_window() { + let mut workspace = Workspace::default(); + + { + // Container with 3 windows + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + { + // Container with 1 window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(4)); + workspace.add_container_to_back(container); + } + + // Focus container by window + workspace.focus_container_by_window(1).unwrap(); + + // Should be focused on workspace 0 + assert_eq!(workspace.focused_container_idx(), 0); + + // Should be focused on window 1 and hwnd should be 1 + let focused_container = workspace.focused_container_mut().unwrap(); + assert_eq!(focused_container.focused_window().unwrap().id, 1); + assert_eq!(focused_container.focused_window_idx(), 1); + } + + #[test] + fn test_contains_managed_window() { + let mut workspace = Workspace::default(); + + { + // Container with 3 windows + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + { + // Container with 1 window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(4)); + workspace.add_container_to_back(container); + } + + // Should return true, window is in container 1 + assert!(workspace.contains_managed_window(4)); + + // Should return true, all the windows are in container 0 + for i in 0..3 { + assert!(workspace.contains_managed_window(i)); + } + + // Should return false since window was never added + assert!(!workspace.contains_managed_window(5)); + } + + #[test] + fn test_new_floating_window() { + let mut workspace = Workspace::default(); + + { + // Container with 3 windows + let mut container = Container::default(); + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + workspace.add_container_to_back(container); + } + + // Add window to floating_windows + workspace.new_floating_window().ok(); + + // Should have 1 floating window + assert_eq!(workspace.floating_windows().len(), 1); + + // Should have only 2 windows now + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 2); + + // Should contain hwnd 0 since this is the first window in the container + let floating_windows = workspace.floating_windows_mut(); + let mut contains = false; + for w in floating_windows { + if w.id == 0 { + contains = true; + } + } + assert!(contains); + } + + #[test] + fn test_visible_windows() { + let mut workspace = Workspace::default(); + + { + // Create and add a default Container with 2 windows + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(100)); + container.windows_mut().push_back(Window::from(200)); + workspace.add_container_to_back(container); + } + + { + // visible_windows should return None and 100 + let visible_windows = workspace.visible_windows(); + assert_eq!(visible_windows.len(), 2); + assert!(visible_windows[0].is_none()); + assert_eq!(visible_windows[1].unwrap().id, 100); + } + + { + // Create and add a default Container with 1 window + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(300)); + workspace.add_container_to_back(container); + } + + { + // visible_windows should return None, 100, and 300 + let visible_windows = workspace.visible_windows(); + assert_eq!(visible_windows.len(), 3); + assert!(visible_windows[0].is_none()); + assert_eq!(visible_windows[1].unwrap().id, 100); + assert_eq!(visible_windows[2].unwrap().id, 300); + } + + // // Maximize window 200 + // workspace.maximized_window = Some(Window { hwnd: 200 }); + // + // { + // // visible_windows should return 200, 100, and 300 + // let visible_windows = workspace.visible_windows(); + // assert_eq!(visible_windows.len(), 3); + // assert_eq!(visible_windows[0].unwrap().hwnd, 200); + // assert_eq!(visible_windows[1].unwrap().hwnd, 100); + // assert_eq!(visible_windows[2].unwrap().hwnd, 300); + // } + } +} From ca9a624018fc8b4cff836196ed5ba2b2a6320f77 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Oct 2025 10:45:52 -0700 Subject: [PATCH 114/305] test(wm): migrate monitor test cases --- komorebi/src/monitor.rs | 296 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 294 insertions(+), 2 deletions(-) diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 43dd9b35..63641121 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -255,8 +255,12 @@ impl Monitor { // eyre::bail!("cannot move native maximized window to another monitor or workspace"); // } - let foreground_hwnd = - MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?; + let foreground_hwnd = if !cfg!(test) { + MacosApi::foreground_window_id().ok_or_eyre("no foreground window")? + } else { + 0 + }; + let floating_window_index = workspace .floating_windows() .iter() @@ -537,3 +541,291 @@ impl Monitor { }) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_add_container() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + // Add container to the default workspace + m.add_container(Container::default(), Some(0)).unwrap(); + + // Should contain a container in the current focused workspace + let workspace = m.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 1); + } + + #[test] + fn test_remove_workspace_by_idx() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + let new_workspace_index = m.new_workspace_idx(); + assert_eq!(new_workspace_index, 1); + + // Create workspace 2 + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces + assert_eq!(m.workspaces().len(), 2); + + // Create workspace 3 + m.focus_workspace(new_workspace_index + 1).unwrap(); + + // Should have 3 workspaces + assert_eq!(m.workspaces().len(), 3); + + // Remove workspace 1 + m.remove_workspace_by_idx(1); + + // Should have only 2 workspaces + assert_eq!(m.workspaces().len(), 2); + } + + #[test] + fn test_remove_workspaces() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + let new_workspace_index = m.new_workspace_idx(); + assert_eq!(new_workspace_index, 1); + + // Create workspace 2 + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces + assert_eq!(m.workspaces().len(), 2); + + // Create workspace 3 + m.focus_workspace(new_workspace_index + 1).unwrap(); + + // Should have 3 workspaces + assert_eq!(m.workspaces().len(), 3); + + // Remove all workspaces + m.remove_workspaces(); + + // All workspaces should be removed + assert_eq!(m.workspaces().len(), 0); + } + + #[test] + fn test_remove_nonexistent_workspace() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + // Try to remove a workspace that doesn't exist + let removed_workspace = m.remove_workspace_by_idx(1); + + // Should return None since there is no workspace at index 1 + assert!(removed_workspace.is_none()); + } + + #[test] + fn test_focus_workspace() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + let new_workspace_index = m.new_workspace_idx(); + assert_eq!(new_workspace_index, 1); + + // Focus workspace 2 + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces + assert_eq!(m.workspaces().len(), 2); + + // Should be focused on workspace 2 + assert_eq!(m.focused_workspace_idx(), 1); + } + + #[test] + fn test_new_workspace_idx() { + let m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + let new_workspace_index = m.new_workspace_idx(); + + // Should be the last workspace index: 1 + assert_eq!(new_workspace_index, 1); + } + + #[test] + fn test_move_container_to_workspace() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + let new_workspace_index = m.new_workspace_idx(); + assert_eq!(new_workspace_index, 1); + + { + // Create workspace 1 and add 3 containers + let workspace = m.focused_workspace_mut().unwrap(); + for _ in 0..3 { + let container = Container::default(); + workspace.add_container_to_back(container); + } + + // Should have 3 containers in workspace 1 + assert_eq!(m.focused_workspace().unwrap().containers().len(), 3); + } + + // Create and focus workspace 2 + m.focus_workspace(new_workspace_index).unwrap(); + + // Focus workspace 1 + m.focus_workspace(0).unwrap(); + + // Move container to workspace 2 + m.move_container_to_workspace(1, true, None).unwrap(); + + // Should be focused on workspace 2 + assert_eq!(m.focused_workspace_idx(), 1); + + // Workspace 2 should have 1 container now + assert_eq!(m.focused_workspace().unwrap().containers().len(), 1); + + // Move to workspace 1 + m.focus_workspace(0).unwrap(); + + // Workspace 1 should have 2 containers + assert_eq!(m.focused_workspace().unwrap().containers().len(), 2); + + // Move a another container from workspace 1 to workspace 2 without following + m.move_container_to_workspace(1, false, None).unwrap(); + + // Should have 1 container + assert_eq!(m.focused_workspace().unwrap().containers().len(), 1); + + // Should still be focused on workspace 1 + assert_eq!(m.focused_workspace_idx(), 0); + + // Switch to workspace 2 + m.focus_workspace(1).unwrap(); + + // Workspace 2 should now have 2 containers + assert_eq!(m.focused_workspace().unwrap().containers().len(), 2); + } + + #[test] + fn test_move_container_to_nonexistent_workspace() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + { + // Create workspace 1 and add 3 containers + let workspace = m.focused_workspace_mut().unwrap(); + for _ in 0..3 { + let container = Container::default(); + workspace.add_container_to_back(container); + } + + // Should have 3 containers in workspace 1 + assert_eq!(m.focused_workspace().unwrap().containers().len(), 3); + } + + // Should only have 1 workspace + assert_eq!(m.workspaces().len(), 1); + + // Try to move a container to a workspace that doesn't exist + m.move_container_to_workspace(8, true, None).unwrap(); + + // Should have 9 workspaces now + assert_eq!(m.workspaces().len(), 9); + + // Should be focused on workspace 8 + assert_eq!(m.focused_workspace_idx(), 8); + + // Should have 1 container in workspace 8 + assert_eq!(m.focused_workspace().unwrap().containers().len(), 1); + } + + #[test] + fn test_ensure_workspace_count_workspace_contains_two_workspaces() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + // Create and focus another workspace + let new_workspace_index = m.new_workspace_idx(); + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces now + assert_eq!(m.workspaces().len(), 2, "Monitor should have 2 workspaces"); + + // Ensure the monitor has at least 5 workspaces + m.ensure_workspace_count(5); + + // Monitor should have 5 workspaces + assert_eq!(m.workspaces().len(), 5, "Monitor should have 5 workspaces"); + } + + #[test] + fn test_ensure_workspace_count_only_default_workspace() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestDevice", + "TestDeviceId", + ); + + // Ensure the monitor has at least 5 workspaces + m.ensure_workspace_count(5); + + // Monitor should have 5 workspaces + assert_eq!(m.workspaces().len(), 5, "Monitor should have 5 workspaces"); + + // Try to call the ensure workspace count again to ensure it doesn't change + m.ensure_workspace_count(3); + assert_eq!(m.workspaces().len(), 5, "Monitor should have 5 workspaces"); + } +} From 7b65a24ea412f116e723e23f9a5f0c1a77dcbe7e Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Oct 2025 10:52:53 -0700 Subject: [PATCH 115/305] test(wm): migrate process command test cases --- Cargo.lock | 12 ++++++ komorebi/Cargo.toml | 3 ++ komorebi/src/process_command.rs | 74 +++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 2bebf1ba..69ef9596 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2861,6 +2861,7 @@ dependencies = [ "tracing", "tracing-appender", "tracing-subscriber", + "uuid", ] [[package]] @@ -6310,6 +6311,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +dependencies = [ + "getrandom 0.3.3", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "v_frame" version = "0.3.9" diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 71e0228b..3d06d2ba 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -47,6 +47,9 @@ tracing-subscriber = { workspace = true } [build-dependencies] shadow-rs = { workspace = true } +[dev-dependencies] +uuid = { version = "1", features = ["v4"] } + [features] default = ["schemars"] deadlock_detection = ["parking_lot/deadlock_detection"] diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7a0e2a95..89b38d92 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1783,3 +1783,77 @@ pub fn read_commands_uds( Ok(()) } + +#[cfg(test)] +mod tests { + use crate::SocketMessage; + use crate::WindowManagerEvent; + use crate::core::rect::Rect; + use crate::monitor; + use crate::window_manager::WindowManager; + use crossbeam_channel::Receiver; + use crossbeam_channel::Sender; + use crossbeam_channel::bounded; + use objc2_core_foundation::CFRunLoop; + use std::io::BufRead; + use std::io::BufReader; + use std::io::Write; + use std::os::unix::net::UnixStream; + use std::path::PathBuf; + use std::str::FromStr; + use std::time::Duration; + use uuid::Uuid; + + fn send_socket_message(socket: &PathBuf, message: SocketMessage) { + let mut stream = UnixStream::connect(socket).unwrap(); + stream + .set_write_timeout(Some(Duration::from_secs(1))) + .unwrap(); + stream + .write_all(serde_json::to_string(&message).unwrap().as_bytes()) + .unwrap(); + } + + #[test] + fn test_receive_socket_message() { + let (_sender, receiver): (Sender, Receiver) = + bounded(1); + let socket_name = format!("komorebi-test-{}.sock", Uuid::new_v4()); + let socket_path = PathBuf::from(&socket_name); + let mut wm = WindowManager::new( + &CFRunLoop::main().unwrap(), + receiver, + Some(socket_path.clone()), + ) + .unwrap(); + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + wm.monitors_mut().push_back(m); + + // send a message + send_socket_message(&socket_path, SocketMessage::FocusWorkspaceNumber(5)); + + let (stream, _) = wm.command_listener.accept().unwrap(); + let reader = BufReader::new(stream.try_clone().unwrap()); + let next = reader.lines().next(); + + // read and deserialize the message + let message_string = next.unwrap().unwrap(); + let message = SocketMessage::from_str(&message_string).unwrap(); + assert!(matches!(message, SocketMessage::FocusWorkspaceNumber(5))); + + // process the message + wm.process_command(message, stream).unwrap(); + + // check the updated window manager state + assert_eq!(wm.focused_workspace_idx().unwrap(), 5); + + std::fs::remove_file(socket_path).unwrap(); + } +} From 5c663d2ceae0fd02f4fae0de959caedfea1455ee Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Oct 2025 11:02:26 -0700 Subject: [PATCH 116/305] test(wm): migrate window manager test cases --- komorebi/src/window_manager.rs | 2032 ++++++++++++++++++++++++++++++++ 1 file changed, 2032 insertions(+) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 5b14a9b9..31538ac7 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -3118,6 +3118,81 @@ impl WindowManager { Ok(()) } + #[tracing::instrument(skip(self))] + pub fn swap_containers( + &mut self, + origin: (usize, usize, usize), + target: (usize, usize, usize), + ) -> eyre::Result<()> { + let (origin_monitor_idx, origin_workspace_idx, origin_container_idx) = origin; + let (target_monitor_idx, target_workspace_idx, target_container_idx) = target; + + let origin_container_is_valid = self + .monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(origin_workspace_idx) + .ok_or_eyre("there is no workspace at this index")? + .containers() + .get(origin_container_idx) + .is_some(); + + let target_container_is_valid = self + .monitors_mut() + .get_mut(target_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(target_workspace_idx) + .ok_or_eyre("there is no workspace at this index")? + .containers() + .get(origin_container_idx) + .is_some(); + + if origin_container_is_valid && target_container_is_valid { + let origin_container = self + .monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(origin_workspace_idx) + .ok_or_eyre("there is no workspace at this index")? + .remove_container(origin_container_idx) + .ok_or_eyre("there is no container at this index")?; + + let target_container = self + .monitors_mut() + .get_mut(target_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(target_workspace_idx) + .ok_or_eyre("there is no workspace at this index")? + .remove_container(target_container_idx); + + self.monitors_mut() + .get_mut(target_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(target_workspace_idx) + .ok_or_eyre("there is no workspace at this index")? + .containers_mut() + .insert(target_container_idx, origin_container); + + if let Some(target_container) = target_container { + self.monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_eyre("there is no monitor at this index")? + .workspaces_mut() + .get_mut(origin_workspace_idx) + .ok_or_eyre("there is no workspace at this index")? + .containers_mut() + .insert(origin_container_idx, target_container); + } + } + + Ok(()) + } + #[tracing::instrument(skip(self))] pub fn transfer_container( &mut self, @@ -3176,3 +3251,1960 @@ impl WindowManager { workspace.apply_wallpaper(monitor_id, &monitor_wp) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::monitor; + use crossbeam_channel::Sender; + use crossbeam_channel::bounded; + use std::path::PathBuf; + use uuid::Uuid; + + struct TestContext { + socket_path: Option, + } + + impl Drop for TestContext { + fn drop(&mut self) { + if let Some(socket_path) = &self.socket_path { + // Clean up the socket file + std::fs::remove_file(socket_path).unwrap(); + } + } + } + + fn setup_window_manager() -> (WindowManager, TestContext) { + let (_sender, receiver): (Sender, Receiver) = + bounded(1); + + // Temporary socket path for testing + let socket_name = format!("komorebi-test-{}.sock", Uuid::new_v4()); + let socket_path = PathBuf::from(socket_name); + + // Create a new WindowManager instance + let wm = WindowManager::new( + &CFRunLoop::main().unwrap(), + receiver, + Some(socket_path.clone()), + ); + + // Window Manager should be created successfully + assert!(wm.is_ok()); + + ( + wm.unwrap(), + TestContext { + socket_path: Some(socket_path), + }, + ) + } + + #[test] + fn test_create_window_manager() { + let (_wm, _test_context) = setup_window_manager(); + } + + #[test] + fn test_focus_workspace() { + let (mut wm, _test_context) = setup_window_manager(); + + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // a new monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // the next index on the monitor should be the not-yet-created second workspace + let new_workspace_index = m.new_workspace_idx(); + assert_eq!(new_workspace_index, 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + + { + // focusing a workspace which doesn't yet exist should create it + let monitor = wm.focused_monitor_mut().unwrap(); + monitor.focus_workspace(new_workspace_index).unwrap(); + assert_eq!(monitor.workspaces().len(), 2); + } + assert_eq!(wm.focused_workspace_idx().unwrap(), 1); + + { + // focusing a workspace many indices ahead should create all workspaces + // required along the way + let monitor = wm.focused_monitor_mut().unwrap(); + monitor.focus_workspace(new_workspace_index + 2).unwrap(); + assert_eq!(monitor.workspaces().len(), 4); + } + assert_eq!(wm.focused_workspace_idx().unwrap(), 3); + + // we should be able to successfully focus an existing workspace too + wm.focus_workspace(0).unwrap(); + assert_eq!(wm.focused_workspace_idx().unwrap(), 0); + } + + #[test] + fn test_remove_focused_workspace() { + let (mut wm, _context) = setup_window_manager(); + + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // a new monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // the next index on the monitor should be the not-yet-created second workspace + let new_workspace_index = m.new_workspace_idx(); + assert_eq!(new_workspace_index, 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + + { + // focus a workspace which doesn't yet exist should create it + let monitor = wm.focused_monitor_mut().unwrap(); + monitor.focus_workspace(new_workspace_index + 1).unwrap(); + + // Monitor focused workspace should be 2 + assert_eq!(monitor.focused_workspace_idx(), 2); + + // Should have 3 Workspaces + assert_eq!(monitor.workspaces().len(), 3); + } + + // Remove the focused workspace + wm.remove_focused_workspace().unwrap(); + + { + let monitor = wm.focused_monitor_mut().unwrap(); + monitor.focus_workspace(new_workspace_index).unwrap(); + + // Should be focused on workspace 1 + assert_eq!(monitor.focused_workspace_idx(), 1); + + // Should have 2 Workspaces + assert_eq!(monitor.workspaces().len(), 2); + } + } + + #[test] + fn test_set_workspace_name() { + let (mut wm, _test_context) = setup_window_manager(); + + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // a new monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // create a new workspace + let new_workspace_index = m.new_workspace_idx(); + assert_eq!(new_workspace_index, 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + + { + // focusing a workspace which doesn't yet exist should create it + let monitor = wm.focused_monitor_mut().unwrap(); + monitor.focus_workspace(new_workspace_index).unwrap(); + assert_eq!(monitor.workspaces().len(), 2); + } + assert_eq!(wm.focused_workspace_idx().unwrap(), 1); + + // set the name of the first workspace + wm.set_workspace_name(0, 0, "workspace1".to_string()) + .unwrap(); + + // monitor_workspace_index_by_name should return the index of the workspace with the name "workspace1" + let workspace_index = wm.monitor_workspace_index_by_name("workspace1").unwrap(); + + // workspace index 0 should now have the name "workspace1" + assert_eq!(workspace_index.1, 0); + } + + #[test] + fn test_switch_focus_monitors() { + let (mut wm, _test_context) = setup_window_manager(); + + { + // Create a first monitor + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + assert_eq!(wm.monitors().len(), 1); + + { + // Create a second monitor + let m = monitor::new( + 1, + Rect::default(), + Rect::default(), + "TestMonitor2".to_string(), + "TestDeviceID2".to_string(), + ); + + // monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + assert_eq!(wm.monitors().len(), 2); + + { + // Create a third monitor + let m = monitor::new( + 2, + Rect::default(), + Rect::default(), + "TestMonitor3".to_string(), + "TestDeviceID3".to_string(), + ); + + // monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + assert_eq!(wm.monitors().len(), 3); + + { + // Set the first monitor as focused and check if it is focused + wm.focus_monitor(0).unwrap(); + let current_monitor_idx = wm.monitors.focused_idx(); + assert_eq!(current_monitor_idx, 0); + } + + { + // Set the second monitor as focused and check if it is focused + wm.focus_monitor(1).unwrap(); + let current_monitor_idx = wm.monitors.focused_idx(); + assert_eq!(current_monitor_idx, 1); + } + + { + // Set the third monitor as focused and check if it is focused + wm.focus_monitor(2).unwrap(); + let current_monitor_idx = wm.monitors.focused_idx(); + assert_eq!(current_monitor_idx, 2); + } + + // Switch back to the first monitor + wm.focus_monitor(0).unwrap(); + let current_monitor_idx = wm.monitors.focused_idx(); + assert_eq!(current_monitor_idx, 0); + } + + #[test] + fn test_switch_focus_to_nonexistent_monitor() { + let (mut wm, _test_context) = setup_window_manager(); + + { + // Create a first monitor + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Should have 1 monitor and the monitor index should be 0 + assert_eq!(wm.monitors().len(), 1); + assert_eq!(wm.focused_monitor_idx(), 0); + + // Should receive an error when trying to focus a non-existent monitor + let result = wm.focus_monitor(1); + assert!( + result.is_err(), + "Expected an error when focusing a non-existent monitor" + ); + + // Should still be focused on the first monitor + assert_eq!(wm.focused_monitor_idx(), 0); + } + + #[test] + fn test_focused_monitor_size() { + let (mut wm, _test_context) = setup_window_manager(); + + { + // Create a first monitor + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // monitor should have a single workspace + assert_eq!(m.workspaces().len(), 1); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + assert_eq!(wm.monitors().len(), 1); + + { + // Set the first monitor as focused and check if it is focused + wm.focus_monitor(0).unwrap(); + let current_monitor_size = wm.focused_monitor_size().unwrap(); + assert_eq!(current_monitor_size, Rect::default()); + } + } + + #[test] + fn test_focus_container_in_cycle_direction() { + let (mut wm, _test_context) = setup_window_manager(); + + // Create a monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + let workspace = m.focused_workspace_mut().unwrap(); + workspace.layer = WorkspaceLayer::Tiling; + + for i in 0..4 { + let mut container = Container::default(); + container.windows_mut().push_back(Window::from(i)); + workspace.add_container_to_back(container); + } + assert_eq!(workspace.containers().len(), 4); + + workspace.focus_container(0); + + // add the monitor to the window manager + wm.monitors_mut().push_back(m); + + // container focus should be on the second container + wm.focus_container_in_cycle_direction(CycleDirection::Next) + .ok(); + assert_eq!(wm.focused_container_idx().unwrap(), 1); + + // container focus should be on the third container + wm.focus_container_in_cycle_direction(CycleDirection::Next) + .ok(); + assert_eq!(wm.focused_container_idx().unwrap(), 2); + + // container focus should be on the second container + wm.focus_container_in_cycle_direction(CycleDirection::Previous) + .ok(); + assert_eq!(wm.focused_container_idx().unwrap(), 1); + + // container focus should be on the first container + wm.focus_container_in_cycle_direction(CycleDirection::Previous) + .ok(); + assert_eq!(wm.focused_container_idx().unwrap(), 0); + } + + #[test] + fn test_transfer_window() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let workspace = m.focused_workspace_mut().unwrap(); + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(0)); + workspace.add_container_to_back(container); + + // Should contain 1 container + assert_eq!(workspace.containers().len(), 1); + + wm.monitors_mut().push_back(m); + } + + { + // Create a second monitor + let mut m = monitor::new( + 1, + Rect::default(), + Rect::default(), + "TestMonitor2".to_string(), + "TestDeviceID2".to_string(), + ); + + // Create a container + let workspace = m.focused_workspace_mut().unwrap(); + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + + // Should contain 1 container + assert_eq!(workspace.containers().len(), 1); + + wm.monitors_mut().push_back(m); + } + + // Should contain 2 monitors + assert_eq!(wm.monitors().len(), 2); + + { + // Monitor 0, Workspace 0, Window 0 + let origin = (0, 0, 0); + + // Monitor 1, Workspace 0, Window 0 + let target = (1, 0, 0); + + // Transfer the window from monitor 0 to monitor 1 + wm.transfer_window(origin, target).unwrap(); + + // Monitor 1 should contain 0 containers + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 0); + + // Monitor 2 should contain 2 containers + wm.focus_monitor(1).unwrap(); + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 2); + } + + { + // Monitor 1, Workspace 0, Window 0 + let origin = (1, 0, 0); + + // Monitor 0, Workspace 0, Window 0 + let target = (0, 0, 0); + + // Transfer the window from monitor 1 back to monitor 0 + wm.transfer_window(origin, target).unwrap(); + + // Monitor 2 should contain 1 containers + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 1); + + // Monitor 1 should contain 1 containers + wm.focus_monitor(0).unwrap(); + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 1); + } + } + + #[test] + fn test_transfer_window_to_nonexistent_monitor() { + // NOTE: transfer_window is primarily used when a window is being dragged by a mouse. The + // transfer_window function does return an error when the target monitor doesn't exist but + // there is a bug where the window isn't in the container after the window fails to + // transfer. The test will test for the result of the transfer_window function but not if + // the window is in the container after the transfer fails. + + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let workspace = m.focused_workspace_mut().unwrap(); + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(0)); + workspace.add_container_to_back(container); + + // Should contain 1 container + assert_eq!(workspace.containers().len(), 1); + + wm.monitors_mut().push_back(m); + } + + { + // Monitor 0, Workspace 0, Window 0 + let origin = (0, 0, 0); + + // Monitor 1, Workspace 0, Window 0 + // + let target = (1, 0, 0); + + // Attempt to transfer the window from monitor 0 to a non-existent monitor + let result = wm.transfer_window(origin, target); + + // Result should be an error since the monitor doesn't exist + assert!( + result.is_err(), + "Expected an error when transferring to a non-existent monitor" + ); + + assert_eq!(wm.focused_container_idx().unwrap(), 0); + assert_eq!(wm.focused_workspace_idx().unwrap(), 0); + } + } + + #[test] + fn test_transfer_container() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let workspace = m.focused_workspace_mut().unwrap(); + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(0)); + workspace.add_container_to_back(container); + + // Should contain 1 container + assert_eq!(workspace.containers().len(), 1); + + wm.monitors_mut().push_back(m); + } + + { + // Create a second monitor + let mut m = monitor::new( + 1, + Rect::default(), + Rect::default(), + "TestMonitor2".to_string(), + "TestDeviceID2".to_string(), + ); + + // Create a container + let workspace = m.focused_workspace_mut().unwrap(); + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + + // Should contain 1 container + assert_eq!(workspace.containers().len(), 1); + + wm.monitors_mut().push_back(m); + } + + // Should contain 2 monitors + assert_eq!(wm.monitors().len(), 2); + + { + // Monitor 0, Workspace 0, Window 0 + let origin = (0, 0, 0); + + // Monitor 1, Workspace 0, Window 0 + let target = (1, 0, 0); + + // Transfer the window from monitor 0 to monitor 1 + wm.transfer_container(origin, target).unwrap(); + + // Monitor 1 should contain 0 containers + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 0); + + // Monitor 2 should contain 2 containers + wm.focus_monitor(1).unwrap(); + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 2); + } + + { + // Monitor 1, Workspace 0, Window 0 + let origin = (1, 0, 0); + + // Monitor 0, Workspace 0, Window 0 + let target = (0, 0, 0); + + // Transfer the window from monitor 1 back to monitor 0 + wm.transfer_container(origin, target).unwrap(); + + // Monitor 2 should contain 1 containers + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 1); + + // Monitor 1 should contain 1 containers + wm.focus_monitor(0).unwrap(); + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 1); + } + } + + #[test] + fn test_remove_window_from_container() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor1".to_string(), + "TestDeviceID1".to_string(), + ); + + // Create a container + let mut container = Container::default(); + + // Add three windows to the container + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 3); + + // Focus last window + container.focus_window(2); + + // Should be focused on the 2nd window + assert_eq!(container.focused_window_idx(), 2); + + // Add the container to a workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Remove the focused window from the container + wm.remove_window_from_container().ok(); + + { + // Should have 2 containers in the workspace + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.containers().len(), 2); + + // Should contain 1 window in the new container + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 1); + } + + { + // Switch to the old container + let workspace = wm.focused_workspace_mut().unwrap(); + workspace.focus_container(0); + + // Should contain 2 windows in the old container + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 2); + } + } + + #[test] + fn test_remove_nonexistent_window_from_container() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor1".to_string(), + "TestDeviceID1".to_string(), + ); + + // Create a container + let container = Container::default(); + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 0); + + // Add the container to a workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Should receive an error when trying to remove a window from an empty container + let result = wm.remove_window_from_container(); + assert!( + result.is_err(), + "Expected an error when trying to remove a window from an empty container" + ); + } + + #[test] + fn cycle_container_window_in_direction() { + let (mut wm, _context) = setup_window_manager(); + + { + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + let workspace = m.focused_workspace_mut().unwrap(); + + { + let mut container = Container::default(); + + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 3); + + // Add container to workspace + workspace.add_container_to_back(container); + } + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Cycle to the next window + wm.cycle_container_window_in_direction(CycleDirection::Next) + .ok(); + + { + // Should be on Window 1 + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.focused_window_idx(), 1); + } + + // Cycle to the next window + wm.cycle_container_window_in_direction(CycleDirection::Next) + .ok(); + + { + // Should be on Window 2 + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.focused_window_idx(), 2); + } + + // Cycle to the previous window + wm.cycle_container_window_in_direction(CycleDirection::Previous) + .ok(); + + { + // Should be on Window 1 + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.focused_window_idx(), 1); + } + } + + #[test] + fn test_cycle_nonexistent_windows() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor1".to_string(), + "TestDeviceID1".to_string(), + ); + + // Create a container + let container = Container::default(); + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 0); + + // Add the container to a workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Should return an error when trying to cycle through windows in an empty container + let result = wm.cycle_container_window_in_direction(CycleDirection::Next); + assert!( + result.is_err(), + "Expected an error when cycling through windows in an empty container" + ); + } + + #[test] + fn test_cycle_container_window_index_in_direction() { + let (mut wm, _context) = setup_window_manager(); + + { + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + let workspace = m.focused_workspace_mut().unwrap(); + + { + let mut container = Container::default(); + + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 3); + + // Add container to workspace + workspace.add_container_to_back(container); + } + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Cycle to the next window + wm.cycle_container_window_index_in_direction(CycleDirection::Next) + .ok(); + + { + // Should be on Window 1 + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.focused_window_idx(), 1); + } + + // Cycle to the next window + wm.cycle_container_window_index_in_direction(CycleDirection::Next) + .ok(); + + { + // Should be on Window 2 + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.focused_window_idx(), 2); + } + + // Cycle to the Previous window + wm.cycle_container_window_index_in_direction(CycleDirection::Previous) + .ok(); + + { + // Should be on Window 1 + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.focused_window_idx(), 1); + } + } + + #[test] + fn test_swap_containers() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let mut container = Container::default(); + + // Add three windows to the container + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 3); + + // Add the container to the workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + { + // Create a second monitor + let mut m = monitor::new( + 1, + Rect::default(), + Rect::default(), + "TestMonitor2".to_string(), + "TestDeviceID2".to_string(), + ); + + // Create a container + let workspace = m.focused_workspace_mut().unwrap(); + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + + // Should contain 1 container + assert_eq!(workspace.containers().len(), 1); + + wm.monitors_mut().push_back(m); + } + + // Should contain 2 monitors + assert_eq!(wm.monitors().len(), 2); + + // Monitor 0, Workspace 0, Window 0 + let origin = (0, 0, 0); + + // Monitor 1, Workspace 0, Window 0 + let target = (1, 0, 0); + + wm.swap_containers(origin, target).unwrap(); + + { + // Monitor 0 Workspace 0 container 0 should contain 1 container + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 1); + } + + wm.focus_monitor(1).unwrap(); + + { + // Monitor 1 Workspace 0 container 0 should contain 3 containers + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 3); + } + } + + // #[test] + // fn test_swap_container_with_nonexistent_container() { + // let (mut wm, _context) = setup_window_manager(); + // + // { + // // Create a first monitor + // let mut m = monitor::new( + // 0, + // Rect::default(), + // Rect::default(), + // "TestMonitor".to_string(), + // "TestDeviceID".to_string(), + // ); + // + // // Create a container + // let mut container = Container::default(); + // + // // Add three windows to the container + // for i in 0..3 { + // container.windows_mut().push_back(Window::from(i)); + // } + // + // // Should have 3 windows in the container + // assert_eq!(container.windows().len(), 3); + // + // // Add the container to the workspace + // let workspace = m.focused_workspace_mut().unwrap(); + // workspace.add_container_to_back(container); + // + // // Add monitor to the window manager + // wm.monitors_mut().push_back(m); + // } + // + // // Monitor 0, Workspace 0, Window 0 + // let origin = (0, 0, 0); + // + // // Monitor 1, Workspace 0, Window 0 + // let target = (0, 3, 0); + // + // // Should be focused on the first container + // assert_eq!(wm.focused_container_idx().unwrap(), 0); + // + // // Should return an error since there is only one container in the workspace + // let result = wm.swap_containers(origin, target); + // assert!( + // result.is_err(), + // "Expected an error when swapping with a non-existent container" + // ); + // + // // Should still be focused on the first container + // assert_eq!(wm.focused_container_idx().unwrap(), 0); + // + // { + // // Should still have 1 container in the workspace + // let workspace = wm.focused_workspace_mut().unwrap(); + // assert_eq!(workspace.containers().len(), 1); + // + // // Container should still have 3 windows + // let container = workspace.focused_container_mut().unwrap(); + // assert_eq!(container.windows().len(), 3); + // } + // } + + #[test] + fn test_swap_monitor_workspaces() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let mut container = Container::default(); + + // Add three windows to the container + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 3); + + // Add the container to the workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + { + // Create a second monitor + let mut m = monitor::new( + 1, + Rect::default(), + Rect::default(), + "TestMonitor2".to_string(), + "TestDeviceID2".to_string(), + ); + + // Create a container + let workspace = m.focused_workspace_mut().unwrap(); + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(1)); + workspace.add_container_to_back(container); + + // Should contain 1 container + assert_eq!(workspace.containers().len(), 1); + + // Add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Swap the workspaces between Monitor 0 and Monitor 1 + wm.swap_monitor_workspaces(0, 1).ok(); + + { + // The focused workspace container in Monitor 0 should contain 3 containers + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 1); + } + + // Switch to Monitor 1 + wm.focus_monitor(1).unwrap(); + assert_eq!(wm.focused_monitor_idx(), 1); + + { + // The focused workspace container in Monitor 1 should contain 3 containers + let workspace = wm.focused_workspace_mut().unwrap(); + let container = workspace.focused_container_mut().unwrap(); + assert_eq!(container.windows().len(), 3); + } + } + + #[test] + fn test_swap_workspace_with_nonexistent_monitor() { + let (mut wm, _context) = setup_window_manager(); + + { + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Add another workspace + let new_workspace_index = m.new_workspace_idx(); + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces + assert_eq!(m.workspaces().len(), 2); + + // Add monitor to window manager + wm.monitors_mut().push_back(m); + } + + // Should be an error since Monitor 1 does not exist + let result = wm.swap_monitor_workspaces(1, 0); + assert!( + result.is_err(), + "Expected an error when swapping with a non-existent monitor" + ); + + { + // Should still have 2 workspaces in Monitor 0 + let monitor = wm.monitors().front().unwrap(); + let workspaces = monitor.workspaces(); + assert_eq!( + workspaces.len(), + 2, + "Expected 2 workspaces after swap attempt" + ); + assert_eq!(wm.focused_monitor_idx(), 0); + } + } + + #[test] + fn test_move_workspace_to_monitor() { + let (mut wm, _context) = setup_window_manager(); + + { + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Add another workspace + let new_workspace_index = m.new_workspace_idx(); + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces + assert_eq!(m.workspaces().len(), 2); + + // Add monitor to window manager + wm.monitors_mut().push_back(m); + } + + { + let m = monitor::new( + 1, + Rect::default(), + Rect::default(), + "TestMonitor2".to_string(), + "TestDeviceID2".to_string(), + ); + + // Should contain 1 workspace + assert_eq!(m.workspaces().len(), 1); + + // Add monitor to workspace + wm.monitors_mut().push_back(m); + } + + // Should contain 2 monitors + assert_eq!(wm.monitors().len(), 2); + + // Move a workspace from Monitor 0 to Monitor 1 + wm.move_workspace_to_monitor(1).ok(); + + { + // Should be focused on Monitor 1 + assert_eq!(wm.focused_monitor_idx(), 1); + + // Should contain 2 workspaces + let monitor = wm.focused_monitor_mut().unwrap(); + assert_eq!(monitor.workspaces().len(), 2); + } + + { + // Switch to Monitor 0 + wm.focus_monitor(0).unwrap(); + + // Should contain 1 workspace + let monitor = wm.focused_monitor_mut().unwrap(); + assert_eq!(monitor.workspaces().len(), 1); + } + } + + #[test] + fn test_move_workspace_to_nonexistent_monitor() { + let (mut wm, _context) = setup_window_manager(); + + { + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Add another workspace + let new_workspace_index = m.new_workspace_idx(); + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces + assert_eq!(m.workspaces().len(), 2); + + // Add monitor to window manager + wm.monitors_mut().push_back(m); + } + + // Attempt to move a workspace to a non-existent monitor + let result = wm.move_workspace_to_monitor(1); + + // Should be an error since Monitor 1 does not exist + assert!( + result.is_err(), + "Expected an error when moving to a non-existent monitor" + ); + } + + #[test] + fn test_toggle_tiling() { + let (mut wm, _context) = setup_window_manager(); + + { + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Set Workspace Layer to Tiling + let workspace = m.focused_workspace_mut().unwrap(); + workspace.layer = WorkspaceLayer::Tiling; + + // Tiling state should be true + assert!(workspace.tile); + + // Add monitor to workspace + wm.monitors_mut().push_back(m); + } + + { + // Tiling state should be false + wm.toggle_tiling().unwrap(); + let workspace = wm.focused_workspace_mut().unwrap(); + assert!(!workspace.tile); + } + + { + // Tiling state should be true + wm.toggle_tiling().unwrap(); + let workspace = wm.focused_workspace_mut().unwrap(); + assert!(workspace.tile); + } + } + + #[test] + fn test_toggle_lock() { + let (mut wm, _context) = setup_window_manager(); + + { + // Add monitor with default workspace to + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + let workspace = m.focused_workspace_mut().unwrap(); + + // Create containers to add to the workspace + for _ in 0..3 { + let container = Container::default(); + workspace.add_container_to_back(container); + } + + wm.monitors_mut().push_back(m); + } + + { + // Ensure container 2 is not locked + let workspace = wm.focused_workspace_mut().unwrap(); + assert_eq!(workspace.focused_container_idx(), 2); + assert!(!workspace.focused_container().unwrap().locked); + } + + // Toggle lock on focused container + wm.toggle_lock().unwrap(); + + { + // Ensure container 2 is locked + let workspace = wm.focused_workspace_mut().unwrap(); + assert!(workspace.focused_container().unwrap().locked); + } + + // Toggle lock on focused container + wm.toggle_lock().unwrap(); + + { + // Ensure container 2 is not locked + let workspace = wm.focused_workspace_mut().unwrap(); + assert!(!workspace.focused_container().unwrap().locked); + } + } + + #[test] + fn test_float_window() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let mut container = Container::default(); + + // Add three windows to the container + for i in 0..3 { + container.windows_mut().push_back(Window::from(i)); + } + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 3); + + // Add the container to the workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Add focused window to floating window list + wm.float_window().ok(); + + { + let workspace = wm.focused_workspace().unwrap(); + let floating_windows = workspace.floating_windows(); + let container = workspace.focused_container().unwrap(); + + // Hwnd 0 should be added to floating_windows + assert_eq!(floating_windows[0].id, 0); + + // Should have a length of 1 + assert_eq!(floating_windows.len(), 1); + + // Should have 2 windows in the container + assert_eq!(container.windows().len(), 2); + + // Should be focused on window 1 + assert_eq!(container.focused_window().unwrap().id, 1); + } + + // Add focused window to floating window list + wm.float_window().ok(); + + { + let workspace = wm.focused_workspace().unwrap(); + let floating_windows = workspace.floating_windows(); + let container = workspace.focused_container().unwrap(); + + // Hwnd 1 should be added to floating_windows + assert_eq!(floating_windows[1].id, 1); + + // Should have a length of 2 + assert_eq!(floating_windows.len(), 2); + + // Should have 1 window in the container + assert_eq!(container.windows().len(), 1); + + // Should be focused on window 2 + assert_eq!(container.focused_window().unwrap().id, 2); + } + } + + #[test] + fn test_float_nonexistent_window() { + let (mut wm, _context) = setup_window_manager(); + + { + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Add another workspace + let new_workspace_index = m.new_workspace_idx(); + m.focus_workspace(new_workspace_index).unwrap(); + + // Should have 2 workspaces + assert_eq!(m.workspaces().len(), 2); + + // Add monitor to window manager + wm.monitors_mut().push_back(m); + } + + // Should return an error when trying to float a non-existent window + let result = wm.float_window(); + assert!( + result.is_err(), + "Expected an error when trying to float a non-existent window" + ); + } + + // #[test] + // fn test_maximize_and_unmaximize_window() { + // let (mut wm, _context) = setup_window_manager(); + // + // { + // // Create a monitor + // let mut m = monitor::new( + // 0, + // Rect::default(), + // Rect::default(), + // "TestMonitor".to_string(), + // "TestDeviceID".to_string(), + // ); + // + // // Create a container + // let mut container = Container::default(); + // + // // Add three windows to the container + // for i in 0..3 { + // container.windows_mut().push_back(Window::from(i)); + // } + // + // // Should have 3 windows in the container + // assert_eq!(container.windows().len(), 3); + // + // // Add the container to the workspace + // let workspace = m.focused_workspace_mut().unwrap(); + // workspace.add_container_to_back(container); + // + // // Add monitor to the window manager + // wm.monitors_mut().push_back(m); + // } + // + // { + // // No windows should be maximized + // let workspace = wm.focused_workspace().unwrap(); + // let maximized_window = workspace.maximized_window; + // assert_eq!(maximized_window, None); + // } + // + // // Maximize the focused window + // wm.maximize_window().ok(); + // + // { + // // Window 0 should be maximized + // let workspace = wm.focused_workspace().unwrap(); + // let maximized_window = workspace.maximized_window; + // assert_eq!(maximized_window, Some(Window::from(0))); + // } + // + // wm.unmaximize_window().ok(); + // + // { + // // No windows should be maximized + // let workspace = wm.focused_workspace().unwrap(); + // let maximized_window = workspace.maximized_window; + // assert_eq!(maximized_window, None); + // } + // + // // Focus container at index 1 + // wm.focused_workspace_mut().unwrap().focus_container(1); + // + // { + // // Focus the window at index 1 + // let container = wm.focused_container_mut().unwrap(); + // container.focus_window(1); + // } + // + // // Maximize the focused window + // wm.maximize_window().ok(); + // + // { + // // Window 2 should be maximized + // let workspace = wm.focused_workspace().unwrap(); + // let maximized_window = workspace.maximized_window; + // assert_eq!(maximized_window, Some(Window::from(2))); + // } + // + // wm.unmaximize_window().ok(); + // + // { + // // No windows should be maximized + // let workspace = wm.focused_workspace().unwrap(); + // let maximized_window = workspace.maximized_window; + // assert_eq!(maximized_window, None); + // } + // } + + // #[test] + // fn test_toggle_maximize() { + // let (mut wm, _context) = setup_window_manager(); + // + // { + // // Create a monitor + // let mut m = monitor::new( + // 0, + // Rect::default(), + // Rect::default(), + // "TestMonitor".to_string(), + // "TestDevice".to_string(), + // "TestDeviceID".to_string(), + // Some("TestMonitorID".to_string()), + // ); + // + // // Create a container + // let mut container = Container::default(); + // + // // Add three windows to the container + // for i in 0..3 { + // container.windows_mut().push_back(Window::from(i)); + // } + // + // // Should have 3 windows in the container + // assert_eq!(container.windows().len(), 3); + // + // // Add the container to the workspace + // let workspace = m.focused_workspace_mut().unwrap(); + // workspace.add_container_to_back(container); + // + // // Add monitor to the window manager + // wm.monitors_mut().push_back(m); + // } + // + // // Toggle maximize on + // wm.toggle_maximize().ok(); + // + // { + // // Window 0 should be maximized + // let workspace = wm.focused_workspace().unwrap(); + // let maximized_window = workspace.maximized_window; + // assert_eq!(maximized_window, Some(Window::from(0))); + // } + // + // // Toggle maximize off + // wm.toggle_maximize().ok(); + // + // { + // // No windows should be maximized + // let workspace = wm.focused_workspace().unwrap(); + // let maximized_window = workspace.maximized_window; + // assert_eq!(maximized_window, None); + // } + // } + + // #[test] + // fn test_toggle_maximize_nonexistent_window() { + // let (mut wm, _context) = setup_window_manager(); + // + // { + // // Create a monitor + // let mut m = monitor::new( + // 0, + // Rect::default(), + // Rect::default(), + // "TestMonitor".to_string(), + // "TestDevice".to_string(), + // "TestDeviceID".to_string(), + // Some("TestMonitorID".to_string()), + // ); + // + // // Create a container + // let container = Container::default(); + // + // // Add the container to the workspace + // let workspace = m.focused_workspace_mut().unwrap(); + // workspace.add_container_to_back(container); + // + // // Add monitor to the window manager + // wm.monitors_mut().push_back(m); + // } + // + // // Should return an error when trying to toggle maximize on a non-existent window + // let result = wm.toggle_maximize(); + // assert!( + // result.is_err(), + // "Expected an error when trying to toggle maximize on a non-existent window" + // ); + // } + + #[test] + fn test_monocle_on_and_monocle_off() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(1)); + + // Should have 1 window in the container + assert_eq!(container.windows().len(), 1); + + // Add the container to the workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Move container to monocle container + wm.monocle_on().ok(); + + { + // Container should be a monocle container + let monocle_container = wm + .focused_workspace() + .unwrap() + .monocle_container + .as_ref() + .unwrap(); + assert_eq!(monocle_container.windows().len(), 1); + assert_eq!(monocle_container.windows()[0].id, 1); + } + + { + // Should not have any containers + let container = wm.focused_workspace().unwrap(); + assert_eq!(container.containers().len(), 0); + } + + // Move monocle container to regular container + wm.monocle_off().ok(); + + { + // Should have 1 container in the workspace + let container = wm.focused_workspace().unwrap(); + assert_eq!(container.containers().len(), 1); + assert_eq!(container.containers()[0].windows()[0].id, 1); + } + + { + // No windows should be in the monocle container + let monocle_container = &wm.focused_workspace().unwrap().monocle_container; + assert_eq!(*monocle_container, None); + } + } + + #[test] + fn test_monocle_on_and_off_nonexistent_container() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Should return an error when trying to move a non-existent container to monocle + let result = wm.monocle_on(); + assert!( + result.is_err(), + "Expected an error when trying to move a non-existent container to monocle" + ); + + // Should return an error when trying to restore a non-existent container from monocle + let result = wm.monocle_off(); + assert!( + result.is_err(), + "Expected an error when trying to restore a non-existent container from monocle" + ); + } + + #[test] + fn test_toggle_monocle() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Create a container + let mut container = Container::default(); + + // Add a window to the container + container.windows_mut().push_back(Window::from(1)); + + // Should have 1 window in the container + assert_eq!(container.windows().len(), 1); + + // Add the container to the workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Toggle monocle on + wm.toggle_monocle().ok(); + + { + // Container should be a monocle container + let monocle_container = wm + .focused_workspace() + .unwrap() + .monocle_container + .as_ref() + .unwrap(); + assert_eq!(monocle_container.windows().len(), 1); + assert_eq!(monocle_container.windows()[0].id, 1); + } + + { + // Should not have any containers + let container = wm.focused_workspace().unwrap(); + assert_eq!(container.containers().len(), 0); + } + + // Toggle monocle off + wm.toggle_monocle().ok(); + + { + // Should have 1 container in the workspace + let container = wm.focused_workspace().unwrap(); + assert_eq!(container.containers().len(), 1); + assert_eq!(container.containers()[0].windows()[0].id, 1); + } + + { + // No windows should be in the monocle container + let monocle_container = &wm.focused_workspace().unwrap().monocle_container; + assert_eq!(*monocle_container, None); + } + } + + #[test] + fn test_toggle_monocle_nonexistent_container() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Should return an error when trying to toggle monocle on a non-existent container + let result = wm.toggle_monocle(); + assert!( + result.is_err(), + "Expected an error when trying to toggle monocle on a non-existent container" + ); + } + + #[test] + fn test_ensure_named_workspace_for_monitor() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDeviceID".to_string(), + ); + + // Add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + + { + // Create a monitor + let m = monitor::new( + 1, + Rect::default(), + Rect::default(), + "TestMonitor1".to_string(), + "TestDeviceID1".to_string(), + ); + + // Add the monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Workspace names list + let mut workspace_names = vec!["Workspace".to_string(), "Workspace1".to_string()]; + + // Ensure workspaces for monitor 1 + wm.ensure_named_workspaces_for_monitor(1, &workspace_names) + .ok(); + + { + // Monitor 1 should have 2 workspaces with names "Workspace" and "Workspace1" + let monitor = wm.monitors().get(1).unwrap(); + let workspaces = monitor.workspaces(); + assert_eq!(workspaces.len(), workspace_names.len()); + for (i, workspace) in workspaces.iter().enumerate() { + assert_eq!(workspace.name, Some(workspace_names[i].clone())); + } + } + + // Add more workspaces to list + workspace_names.push("Workspace2".to_string()); + workspace_names.push("Workspace3".to_string()); + + // Ensure workspaces for monitor 0 + wm.ensure_named_workspaces_for_monitor(0, &workspace_names) + .ok(); + + { + // Monitor 0 should have 4 workspaces with names "Workspace", "Workspace1", + // "Workspace2" and "Workspace3" + let monitor = wm.monitors().front().unwrap(); + let workspaces = monitor.workspaces(); + assert_eq!(workspaces.len(), workspace_names.len()); + for (i, workspace) in workspaces.iter().enumerate() { + assert_eq!(workspace.name, Some(workspace_names[i].clone())); + } + } + } + + #[test] + fn test_add_window_handle_to_move_based_on_workspace_rule() { + let (wm, _context) = setup_window_manager(); + + // Mock Data representing a window and its workspace/movement details + let window_title = String::from("TestWindow"); + let window_id = 12345; + let origin_monitor_idx = 0; + let origin_workspace_idx = 0; + let target_monitor_idx = 2; + let target_workspace_idx = 3; + let floating = false; + + // Empty vector to hold workspace rule enforcement operations + let mut to_move: Vec = Vec::new(); + + // Call the function to add a window movement operation based on workspace rules + wm.add_window_handle_to_move_based_on_workspace_rule( + &window_title, + window_id, + origin_monitor_idx, + origin_workspace_idx, + target_monitor_idx, + target_workspace_idx, + floating, + &mut to_move, + ); + + // Verify that the vector contains the expected operation with the correct values + assert_eq!(to_move.len(), 1); + let op = &to_move[0]; + assert_eq!(op.window_id, window_id); // 12345 + assert_eq!(op.origin_monitor_idx, origin_monitor_idx); // 0 + assert_eq!(op.origin_workspace_idx, origin_workspace_idx); // 0 + assert_eq!(op.target_monitor_idx, target_monitor_idx); // 2 + assert_eq!(op.target_workspace_idx, target_workspace_idx); // 3 + assert_eq!(op.floating, floating); // false + } +} From 6869805b82a74dfd4e075f1ee84b0dfec9596c19 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Oct 2025 13:16:20 -0700 Subject: [PATCH 117/305] feat(cli): add completions cmd Add a new "completions" command which takes a supported shell as an argument. This command outputs a completions file to stdout, which can be redirected to a file. --- Cargo.lock | 77 ++++++++++++++++++++++++------------------- dependencies.json | 53 +++++++++++++++-------------- komorebic/Cargo.toml | 1 + komorebic/src/main.rs | 12 +++++++ shell.nix | 1 + 5 files changed, 87 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 69ef9596..9bff7d41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -837,9 +837,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.40" +version = "1.2.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb" +checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" dependencies = [ "find-msvc-tools", "jobserver", @@ -931,6 +931,15 @@ dependencies = [ "terminal_size", ] +[[package]] +name = "clap_complete" +version = "4.5.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75bf0b32ad2e152de789bb635ea4d3078f6b838ad7974143e99b99f45a04af4a" +dependencies = [ + "clap", +] + [[package]] name = "clap_derive" version = "4.5.47" @@ -1761,9 +1770,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" [[package]] name = "fixedbitset" @@ -2233,13 +2242,14 @@ dependencies = [ [[package]] name = "half" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" +checksum = "e54c115d4f30f52c67202f079c5f9d8b49db4691f460fdb0b4c2e838261b2ba5" dependencies = [ "cfg-if", "crunchy", "num-traits", + "zerocopy", ] [[package]] @@ -2934,6 +2944,7 @@ version = "0.1.0" dependencies = [ "chrono", "clap", + "clap_complete", "color-eyre", "dirs 6.0.0", "fs-tail", @@ -2987,9 +2998,9 @@ checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" [[package]] name = "libc" -version = "0.2.176" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libfuzzer-sys" @@ -3290,9 +3301,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cc7d85f3d741164e8972ad355e26ac6e51b20fcae5f911c7da8f2d8bbbb3f33" +checksum = "c588e11a3082784af229e23e8e4ecf5bcc6fbe4f69101e0421ce8d79da7f0b40" dependencies = [ "num-traits", "pxfm", @@ -3538,11 +3549,11 @@ dependencies = [ [[package]] name = "nu-ansi-term" -version = "0.50.1" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4523,7 +4534,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit 0.23.6", + "toml_edit 0.23.7", ] [[package]] @@ -4556,9 +4567,9 @@ dependencies = [ [[package]] name = "pxfm" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83f9b339b02259ada5c0f4a389b7fb472f933aa17ce176fd2ad98f28bb401fde" +checksum = "a3cbdf373972bf78df4d3b518d07003938e2c7d1fb5891e55f9cb6df57009d84" dependencies = [ "num-traits", ] @@ -4922,9 +4933,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.3" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c" +checksum = "4a52d8d02cacdb176ef4678de6c052efb4b3da14b78e4db683a4252762be5433" dependencies = [ "aho-corasick", "memchr", @@ -4934,9 +4945,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad" +checksum = "722166aa0d7438abbaa4d5cc2c649dac844e8c56d82fb3d33e9c34b5cd268fc6" dependencies = [ "aho-corasick", "memchr", @@ -4945,9 +4956,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +checksum = "c3160422bbd54dd5ecfdca71e5fd59b7b8fe2b1697ab2baf64f6d05dcc66d298" [[package]] name = "renderdoc-sys" @@ -5567,9 +5578,9 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "starship-battery" @@ -6008,9 +6019,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" dependencies = [ "serde_core", ] @@ -6030,21 +6041,21 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.23.6" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b" +checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ "indexmap 2.11.4", - "toml_datetime 0.7.2", + "toml_datetime 0.7.3", "toml_parser", "winnow", ] [[package]] name = "toml_parser" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ "winnow", ] @@ -6206,9 +6217,9 @@ checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "tz-rs" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1450bf2b99397e72070e7935c89facaa80092ac812502200375f1f7d33c71a1" +checksum = "14eff19b8dc1ace5bf7e4d920b2628ae3837f422ff42210cb1567cbf68b5accf" [[package]] name = "tzdb" diff --git a/dependencies.json b/dependencies.json index 02a2c4d5..804332c7 100644 --- a/dependencies.json +++ b/dependencies.json @@ -40,13 +40,14 @@ "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.40 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.41 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.58 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -97,7 +98,7 @@ "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", - "find-msvc-tools 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.4 registry+https://github.com/rust-lang/crates.io-index", "flate2 1.1.4 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.3.2 registry+https://github.com/rust-lang/crates.io-index", @@ -121,7 +122,7 @@ "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "glutin 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "half 2.6.0 registry+https://github.com/rust-lang/crates.io-index", + "half 2.7.0 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", @@ -151,7 +152,7 @@ "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "libc 0.2.176 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.177 registry+https://github.com/rust-lang/crates.io-index", "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", @@ -166,7 +167,7 @@ "minimal-lexical 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.6 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.7 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", @@ -214,7 +215,7 @@ "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", "profiling-procmacros 1.0.17 registry+https://github.com/rust-lang/crates.io-index", - "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index", + "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", "qoi 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", @@ -231,9 +232,9 @@ "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", - "regex 1.11.3 registry+https://github.com/rust-lang/crates.io-index", - "regex-automata 0.4.11 registry+https://github.com/rust-lang/crates.io-index", - "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.12.1 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "regex-syntax 0.8.7 registry+https://github.com/rust-lang/crates.io-index", "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", @@ -262,7 +263,7 @@ "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", - "stable_deref_trait 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", @@ -281,7 +282,7 @@ "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "typenum 1.19.0 registry+https://github.com/rust-lang/crates.io-index", - "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", + "tz-rs 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", @@ -300,6 +301,7 @@ "winit 0.30.12 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", @@ -326,7 +328,8 @@ "mach2 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "rav1e 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "v_frame 0.3.9 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index" + "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -340,8 +343,8 @@ "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", "exr 1.73.0 registry+https://github.com/rust-lang/crates.io-index", "lebe 0.5.3 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.6 registry+https://github.com/rust-lang/crates.io-index", - "pxfm 0.1.24 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.7 registry+https://github.com/rust-lang/crates.io-index", + "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", "ravif 0.11.20 registry+https://github.com/rust-lang/crates.io-index" ] ], @@ -413,7 +416,7 @@ "calm_io 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "calmio_filters 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "catppuccin-egui 5.6.0 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.40 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.41 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", @@ -421,6 +424,7 @@ "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.58 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -480,7 +484,7 @@ "fax_derive 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", - "find-msvc-tools 0.1.3 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.4 registry+https://github.com/rust-lang/crates.io-index", "flate2 1.1.4 registry+https://github.com/rust-lang/crates.io-index", "flavours 0.7.2 git+https://github.com/LGUG2Z/flavours", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", @@ -509,7 +513,7 @@ "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "glutin-winit 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "h2 0.4.12 registry+https://github.com/rust-lang/crates.io-index", - "half 2.6.0 registry+https://github.com/rust-lang/crates.io-index", + "half 2.7.0 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", @@ -544,7 +548,7 @@ "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "libc 0.2.176 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.177 registry+https://github.com/rust-lang/crates.io-index", "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", @@ -574,7 +578,7 @@ "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "nom 7.1.3 registry+https://github.com/rust-lang/crates.io-index", "noop_proc_macro 0.3.0 registry+https://github.com/rust-lang/crates.io-index", - "nu-ansi-term 0.50.1 registry+https://github.com/rust-lang/crates.io-index", + "nu-ansi-term 0.50.3 registry+https://github.com/rust-lang/crates.io-index", "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "num-bigint 0.4.6 registry+https://github.com/rust-lang/crates.io-index", "num-complex 0.4.6 registry+https://github.com/rust-lang/crates.io-index", @@ -655,9 +659,9 @@ "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", - "regex 1.11.3 registry+https://github.com/rust-lang/crates.io-index", - "regex-automata 0.4.11 registry+https://github.com/rust-lang/crates.io-index", - "regex-syntax 0.8.6 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.12.1 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "regex-syntax 0.8.7 registry+https://github.com/rust-lang/crates.io-index", "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", "rgb 0.8.52 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", @@ -694,7 +698,7 @@ "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", - "stable_deref_trait 1.2.0 registry+https://github.com/rust-lang/crates.io-index", + "stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "strsim 0.11.1 registry+https://github.com/rust-lang/crates.io-index", "strum 0.27.2 registry+https://github.com/rust-lang/crates.io-index", @@ -734,7 +738,7 @@ "try-lock 0.2.5 registry+https://github.com/rust-lang/crates.io-index", "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "typenum 1.19.0 registry+https://github.com/rust-lang/crates.io-index", - "tz-rs 0.7.0 registry+https://github.com/rust-lang/crates.io-index", + "tz-rs 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", @@ -754,6 +758,7 @@ "which 7.0.3 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index 289980d5..ccbec568 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -8,6 +8,7 @@ edition = "2024" komorebi-client = { path = "../komorebi-client", default-features = false } clap = { workspace = true } +clap_complete = "4" chrono = { workspace = true } color-eyre = { workspace = true } dirs = { workspace = true } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 20a23933..db404e40 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -647,6 +647,12 @@ struct BorderOffset { offset: i32, } +#[derive(Parser)] +struct Completions { + #[clap(value_enum)] + shell: clap_complete::Shell, +} + #[derive(Parser)] #[clap(author, about, version = build::CLAP_LONG_VERSION)] struct Opts { @@ -658,6 +664,8 @@ struct Opts { enum SubCommand { #[clap(hide = true)] Docgen, + /// Generate komorebic CLI completions for the target shell + Completions(Completions), /// Gather example configurations for a new-user quickstart Quickstart, /// Start komorebi as a background process @@ -1220,6 +1228,10 @@ fn main() -> eyre::Result<()> { } } } + SubCommand::Completions(arg) => { + let mut cli = Opts::command(); + clap_complete::generate(arg.shell, &mut cli, "komorebic", &mut std::io::stdout()); + } SubCommand::Quickstart => { fn write_file_with_prompt( path: &PathBuf, diff --git a/shell.nix b/shell.nix index f0cd3500..32a27942 100644 --- a/shell.nix +++ b/shell.nix @@ -9,6 +9,7 @@ with pkgs; alejandra cargo-deny cargo-udeps + cargo-nextest gcc jq just From 791208a13056702843b5a7b5a578aad92c0ce8b6 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Oct 2025 14:03:38 -0700 Subject: [PATCH 118/305] feat(wm): add opt to keep focused column centered on scrolling layout This commit adds a new option under layout_options.scrolling - "center_focused_column", which defaults to false. When set to true, and when the number of scrolling columns is an odd number >=3, komorebi will, if there are enough windows being managed on the workspace, and if the focused window is not too close to either the beginning or the end of the workspace ring, keep the focused window in a centered position in the layout --- komorebi/src/core/arrangement.rs | 50 ++++++++++++++++++++--------- komorebi/src/core/default_layout.rs | 2 ++ komorebi/src/process_command.rs | 1 + schema.json | 4 +++ 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/komorebi/src/core/arrangement.rs b/komorebi/src/core/arrangement.rs index 6f9c9410..be877a4a 100644 --- a/komorebi/src/core/arrangement.rs +++ b/komorebi/src/core/arrangement.rs @@ -72,6 +72,13 @@ impl Arrangement for DefaultLayout { // treat >= column_count as scrolling len => { let visible_columns = area.right / column_width; + let keep_centered = layout_options + .and_then(|o| { + o.scrolling + .map(|s| s.center_focused_column.unwrap_or_default()) + }) + .unwrap_or(false); + let first_visible: isize = if focused_idx == 0 { // if focused idx is 0, we are at the beginning of the scrolling strip 0 @@ -89,24 +96,35 @@ impl Arrangement for DefaultLayout { let focused_idx = focused_idx as isize; - if focused_idx < previous_first_visible { - // focused window is off the left edge, we need to scroll left - focused_idx - } else if focused_idx - >= previous_first_visible + visible_columns as isize - { - // focused window is off the right edge, we need to scroll right - // and make sure it's the last visible window - (focused_idx + 1 - visible_columns as isize).max(0) + // if center_focused_column is enabled, and we have an odd number of visible columns, + // center the focused window column + if keep_centered && visible_columns % 2 == 1 { + let center_offset = visible_columns as isize / 2; + (focused_idx - center_offset).max(0).min( + (len as isize) + .saturating_sub(visible_columns as isize) + .max(0), + ) } else { - // focused window is already visible, we don't need to scroll - previous_first_visible + if focused_idx < previous_first_visible { + // focused window is off the left edge, we need to scroll left + focused_idx + } else if focused_idx + >= previous_first_visible + visible_columns as isize + { + // focused window is off the right edge, we need to scroll right + // and make sure it's the last visible window + (focused_idx + 1 - visible_columns as isize).max(0) + } else { + // focused window is already visible, we don't need to scroll + previous_first_visible + } + .min( + (len as isize) + .saturating_sub(visible_columns as isize) + .max(0), + ) } - .min( - (len as isize) - .saturating_sub(visible_columns as isize) - .max(0), - ) }; for i in 0..len { diff --git a/komorebi/src/core/default_layout.rs b/komorebi/src/core/default_layout.rs index aa71fbf5..a363559e 100644 --- a/komorebi/src/core/default_layout.rs +++ b/komorebi/src/core/default_layout.rs @@ -36,6 +36,8 @@ pub struct LayoutOptions { pub struct ScrollingLayoutOptions { /// Desired number of visible columns (default: 3) pub columns: usize, + /// With an odd number of visible columns, keep the focused window column centered + pub center_focused_column: Option, } impl DefaultLayout { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 89b38d92..71b80552 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1456,6 +1456,7 @@ impl WindowManager { None => LayoutOptions { scrolling: Some(ScrollingLayoutOptions { columns: count.into(), + center_focused_column: Default::default(), }), }, }; diff --git a/schema.json b/schema.json index 94e9029b..43bbcf0a 100644 --- a/schema.json +++ b/schema.json @@ -1459,6 +1459,10 @@ "columns" ], "properties": { + "center_focused_column": { + "description": "With an odd number of visible columns, keep the focused window column centered", + "type": "boolean" + }, "columns": { "description": "Desired number of visible columns (default: 3)", "type": "integer", From 21321fd36546391f9c1f391f673519f23b7ef18f Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 14 Oct 2025 12:52:24 -0700 Subject: [PATCH 119/305] fix(bar): match default interface by name This commit fixes a difference between netdev on Windows and macOS, where matching needs to be done against the Friendly Name of an interface on Windows, but against the Name on macOS. --- komorebi-bar/src/widgets/network.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/komorebi-bar/src/widgets/network.rs b/komorebi-bar/src/widgets/network.rs index 25c4b6ed..4f8960a1 100644 --- a/komorebi-bar/src/widgets/network.rs +++ b/komorebi-bar/src/widgets/network.rs @@ -134,12 +134,13 @@ impl Network { if let Ok(interface) = netdev::get_default_interface() && let Some(friendly_name) = &interface.friendly_name { + let target_name = interface.name.clone(); self.default_interface.clone_from(friendly_name); self.networks_network_activity.refresh(true); for (interface_name, data) in &self.networks_network_activity { - if friendly_name.eq(interface_name) { + if interface_name.eq(&target_name) { if self.show_activity { let received = Self::to_pretty_bytes(data.received(), self.data_refresh_interval); From c2557728972265c738cded0666bf3e6d7547ff61 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 16 Oct 2025 10:09:30 -0700 Subject: [PATCH 120/305] fix(wm): add generic window validity check to reaper Calibre was being very weird and failing layout updates when a menu button was clicked (#justcalibrethings) so I've added a final window validity escape hatch check to the reaper for now. --- komorebi/src/reaper.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs index 4ef8723f..642f4fe9 100644 --- a/komorebi/src/reaper.rs +++ b/komorebi/src/reaper.rs @@ -132,6 +132,12 @@ pub fn notify_on_error( should_reap = false; } + // calibre does some weird stuff when pressing on the menu options which cause + // layout updates to fail, I guess we should also do a generic is_valid check here + if window.is_valid() { + should_reap = false; + } + if should_reap { send_notification(ReaperNotification::InvalidWindow(window.id)); } From f848c1d8f003a96b7769353b438cfc127fb8b510 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 17 Oct 2025 10:29:25 -0700 Subject: [PATCH 121/305] feat(wm): add opt to constrain grid layout by rows This commit adds a new LayoutOptions option, GridLayoutOptions, currently with a single configurable "rows" opt which can be use to constrain the grid by number of rows. --- komorebi/src/core/arrangement.rs | 16 +++- komorebi/src/core/default_layout.rs | 9 ++ komorebi/src/core/direction.rs | 102 +++++++++++++++++------ komorebi/src/core/operation_direction.rs | 4 +- komorebi/src/process_command.rs | 1 + komorebi/src/window_manager.rs | 2 + komorebi/src/workspace.rs | 1 + schema.json | 15 ++++ 8 files changed, 121 insertions(+), 29 deletions(-) diff --git a/komorebi/src/core/arrangement.rs b/komorebi/src/core/arrangement.rs index be877a4a..9396035b 100644 --- a/komorebi/src/core/arrangement.rs +++ b/komorebi/src/core/arrangement.rs @@ -536,14 +536,26 @@ impl Arrangement for DefaultLayout { let len = len as i32; - let num_cols = (len as f32).sqrt().ceil() as i32; + let row_constraint = layout_options.and_then(|o| o.grid.map(|g| g.rows)); + + let num_cols = if let Some(rows) = row_constraint { + ((len as f32) / (rows as f32)).ceil() as i32 + } else { + (len as f32).sqrt().ceil() as i32 + }; + let mut iter = layouts.iter_mut().enumerate().peekable(); for col in 0..num_cols { let iter_peek = iter.peek().map(|x| x.0).unwrap_or_default() as i32; let remaining_windows = len - iter_peek; let remaining_columns = num_cols - col; - let num_rows_in_this_col = remaining_windows / remaining_columns; + + let num_rows_in_this_col = if let Some(rows) = row_constraint { + (remaining_windows / remaining_columns).min(rows as i32) + } else { + remaining_windows / remaining_columns + }; let win_height = area.bottom / num_rows_in_this_col; let win_width = area.right / num_cols; diff --git a/komorebi/src/core/default_layout.rs b/komorebi/src/core/default_layout.rs index a363559e..264bb7e1 100644 --- a/komorebi/src/core/default_layout.rs +++ b/komorebi/src/core/default_layout.rs @@ -29,6 +29,8 @@ pub enum DefaultLayout { pub struct LayoutOptions { /// Options related to the Scrolling layout pub scrolling: Option, + /// Options related to the Grid layout + pub grid: Option, } #[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] @@ -40,6 +42,13 @@ pub struct ScrollingLayoutOptions { pub center_focused_column: Option, } +#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct GridLayoutOptions { + /// Maximum number of rows per grid column + pub rows: usize, +} + impl DefaultLayout { pub fn leftmost_index(&self, len: usize) -> usize { match self { diff --git a/komorebi/src/core/direction.rs b/komorebi/src/core/direction.rs index 6df24716..39560cc9 100644 --- a/komorebi/src/core/direction.rs +++ b/komorebi/src/core/direction.rs @@ -1,4 +1,5 @@ use crate::core::default_layout::DefaultLayout; +use crate::core::default_layout::LayoutOptions; use crate::core::operation_direction::OperationDirection; pub trait Direction { @@ -7,6 +8,7 @@ pub trait Direction { op_direction: OperationDirection, idx: usize, count: usize, + layout_options: Option, ) -> Option; fn is_valid_direction( @@ -14,30 +16,35 @@ pub trait Direction { op_direction: OperationDirection, idx: usize, count: usize, + layout_options: Option, ) -> bool; fn up_index( &self, op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize; fn down_index( &self, op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize; fn left_index( &self, op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize; fn right_index( &self, op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize; } @@ -47,32 +54,53 @@ impl Direction for DefaultLayout { op_direction: OperationDirection, idx: usize, count: usize, + layout_options: Option, ) -> Option { match op_direction { OperationDirection::Left => { - if self.is_valid_direction(op_direction, idx, count) { - Option::from(self.left_index(Some(op_direction), idx, Some(count))) + if self.is_valid_direction(op_direction, idx, count, layout_options) { + Option::from(self.left_index( + Some(op_direction), + idx, + Some(count), + layout_options, + )) } else { None } } OperationDirection::Right => { - if self.is_valid_direction(op_direction, idx, count) { - Option::from(self.right_index(Some(op_direction), idx, Some(count))) + if self.is_valid_direction(op_direction, idx, count, layout_options) { + Option::from(self.right_index( + Some(op_direction), + idx, + Some(count), + layout_options, + )) } else { None } } OperationDirection::Up => { - if self.is_valid_direction(op_direction, idx, count) { - Option::from(self.up_index(Some(op_direction), idx, Some(count))) + if self.is_valid_direction(op_direction, idx, count, layout_options) { + Option::from(self.up_index( + Some(op_direction), + idx, + Some(count), + layout_options, + )) } else { None } } OperationDirection::Down => { - if self.is_valid_direction(op_direction, idx, count) { - Option::from(self.down_index(Some(op_direction), idx, Some(count))) + if self.is_valid_direction(op_direction, idx, count, layout_options) { + Option::from(self.down_index( + Some(op_direction), + idx, + Some(count), + layout_options, + )) } else { None } @@ -85,6 +113,7 @@ impl Direction for DefaultLayout { op_direction: OperationDirection, idx: usize, count: usize, + layout_options: Option, ) -> bool { if count < 2 { return false; @@ -97,7 +126,7 @@ impl Direction for DefaultLayout { Self::Rows | Self::HorizontalStack => idx != 0, Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != 1, Self::UltrawideVerticalStack => idx > 2, - Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Grid => !is_grid_edge(op_direction, idx, count, layout_options), Self::Scrolling => false, }, OperationDirection::Down => match self { @@ -107,7 +136,7 @@ impl Direction for DefaultLayout { Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != count - 1, Self::HorizontalStack => idx == 0, Self::UltrawideVerticalStack => idx > 1 && idx != count - 1, - Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Grid => !is_grid_edge(op_direction, idx, count, layout_options), Self::Scrolling => false, }, OperationDirection::Left => match self { @@ -117,7 +146,7 @@ impl Direction for DefaultLayout { Self::Rows => false, Self::HorizontalStack => idx != 0 && idx != 1, Self::UltrawideVerticalStack => idx != 1, - Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Grid => !is_grid_edge(op_direction, idx, count, layout_options), Self::Scrolling => idx != 0, }, OperationDirection::Right => match self { @@ -131,7 +160,7 @@ impl Direction for DefaultLayout { 2 => idx != 0, _ => idx < 2, }, - Self::Grid => !is_grid_edge(op_direction, idx, count), + Self::Grid => !is_grid_edge(op_direction, idx, count, layout_options), Self::Scrolling => idx != count - 1, }, } @@ -142,6 +171,7 @@ impl Direction for DefaultLayout { op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize { match self { Self::BSP => { @@ -157,7 +187,7 @@ impl Direction for DefaultLayout { | Self::UltrawideVerticalStack | Self::RightMainVerticalStack => idx - 1, Self::HorizontalStack => 0, - Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Grid => grid_neighbor(op_direction, idx, count, layout_options), Self::Scrolling => unreachable!(), } } @@ -167,6 +197,7 @@ impl Direction for DefaultLayout { op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize { match self { Self::BSP @@ -176,7 +207,7 @@ impl Direction for DefaultLayout { | Self::RightMainVerticalStack => idx + 1, Self::Columns => unreachable!(), Self::HorizontalStack => 1, - Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Grid => grid_neighbor(op_direction, idx, count, layout_options), Self::Scrolling => unreachable!(), } } @@ -186,6 +217,7 @@ impl Direction for DefaultLayout { op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize { match self { Self::BSP => { @@ -204,7 +236,7 @@ impl Direction for DefaultLayout { 1 => unreachable!(), _ => 0, }, - Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Grid => grid_neighbor(op_direction, idx, count, layout_options), Self::Scrolling => idx - 1, } } @@ -214,6 +246,7 @@ impl Direction for DefaultLayout { op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize { match self { Self::BSP | Self::Columns | Self::HorizontalStack => idx + 1, @@ -225,7 +258,7 @@ impl Direction for DefaultLayout { 0 => 2, _ => unreachable!(), }, - Self::Grid => grid_neighbor(op_direction, idx, count), + Self::Grid => grid_neighbor(op_direction, idx, count, layout_options), Self::Scrolling => idx + 1, } } @@ -256,21 +289,32 @@ struct GridTouchingEdges { clippy::cast_precision_loss, clippy::cast_sign_loss )] -fn get_grid_item(idx: usize, count: usize) -> GridItem { - let num_cols = (count as f32).sqrt().ceil() as usize; +fn get_grid_item(idx: usize, count: usize, layout_options: Option) -> GridItem { + let row_constraint = layout_options.and_then(|o| o.grid.map(|g| g.rows)); + let num_cols = if let Some(rows) = row_constraint { + ((count as f32) / (rows as f32)).ceil() as i32 + } else { + (count as f32).sqrt().ceil() as i32 + }; + let mut iter = 0; for col in 0..num_cols { - let remaining_windows = count - iter; + let remaining_windows = (count - iter) as i32; let remaining_columns = num_cols - col; - let num_rows_in_this_col = remaining_windows / remaining_columns; + + let num_rows_in_this_col = if let Some(rows) = row_constraint { + (remaining_windows / remaining_columns).min(rows as i32) + } else { + remaining_windows / remaining_columns + }; for row in 0..num_rows_in_this_col { if iter == idx { return GridItem { state: GridItemState::Valid, - row: row + 1, - num_rows: num_rows_in_this_col, + row: (row + 1) as usize, + num_rows: num_rows_in_this_col as usize, touching_edges: GridTouchingEdges { left: col == 0, right: col == num_cols - 1, @@ -297,8 +341,13 @@ fn get_grid_item(idx: usize, count: usize) -> GridItem { } } -fn is_grid_edge(op_direction: OperationDirection, idx: usize, count: usize) -> bool { - let item = get_grid_item(idx, count); +fn is_grid_edge( + op_direction: OperationDirection, + idx: usize, + count: usize, + layout_options: Option, +) -> bool { + let item = get_grid_item(idx, count, layout_options); match item.state { GridItemState::Invalid => false, @@ -315,6 +364,7 @@ fn grid_neighbor( op_direction: Option, idx: usize, count: Option, + layout_options: Option, ) -> usize { let Some(op_direction) = op_direction else { return 0; @@ -324,11 +374,11 @@ fn grid_neighbor( return 0; }; - let item = get_grid_item(idx, count); + let item = get_grid_item(idx, count, layout_options); match op_direction { OperationDirection::Left => { - let item_from_prev_col = get_grid_item(idx - item.row, count); + let item_from_prev_col = get_grid_item(idx - item.row, count, layout_options); if item.touching_edges.up && item.num_rows != item_from_prev_col.num_rows { return idx - (item.num_rows - 1); diff --git a/komorebi/src/core/operation_direction.rs b/komorebi/src/core/operation_direction.rs index bb9d68eb..f29ca763 100644 --- a/komorebi/src/core/operation_direction.rs +++ b/komorebi/src/core/operation_direction.rs @@ -1,4 +1,5 @@ use crate::core::arrangement::Axis; +use crate::core::default_layout::LayoutOptions; use crate::core::direction::Direction; use clap::ValueEnum; use serde::Deserialize; @@ -53,7 +54,8 @@ impl OperationDirection { layout_flip: Option, idx: usize, len: NonZeroUsize, + layout_options: Option, ) -> Option { - layout.index_in_direction(self.flip(layout_flip), idx, len.get()) + layout.index_in_direction(self.flip(layout_flip), idx, len.get(), layout_options) } } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 71b80552..19200fce 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1458,6 +1458,7 @@ impl WindowManager { columns: count.into(), center_focused_column: Default::default(), }), + grid: None, }, }; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 31538ac7..e38f2d2c 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1082,6 +1082,7 @@ impl WindowManager { workspace.layout_flip, workspace.focused_container_idx(), len, + workspace.layout_options, ) .is_some(); @@ -1486,6 +1487,7 @@ impl WindowManager { workspace.layout_flip, focused_idx, len, + workspace.layout_options, ) .is_some() { diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index d1a6432f..9fc537bb 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -225,6 +225,7 @@ impl Workspace { self.layout_flip, self.focused_container_idx(), len, + self.layout_options, ) } diff --git a/schema.json b/schema.json index 43bbcf0a..442b7857 100644 --- a/schema.json +++ b/schema.json @@ -1452,6 +1452,21 @@ "description": "Layout-specific options (default: None)", "type": "object", "properties": { + "grid": { + "description": "Options related to the Grid layout", + "type": "object", + "required": [ + "rows" + ], + "properties": { + "rows": { + "description": "Maximum number of rows per grid column", + "type": "integer", + "format": "uint", + "minimum": 0.0 + } + } + }, "scrolling": { "description": "Options related to the Scrolling layout", "type": "object", From 573469d1c39076e4356030ac4ce41c197c9f4e73 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 19 Oct 2025 10:37:03 -0700 Subject: [PATCH 122/305] ci(github): add build workflow --- .github/dependabot.yml | 21 +++++++++++ .github/workflows/macos.yaml | 70 ++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/macos.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..92e09e76 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + assignees: + - "LGUG2Z" + commit-message: + prefix: chore + include: scope + + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + assignees: + - "LGUG2Z" + commit-message: + prefix: chore + include: scope \ No newline at end of file diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml new file mode 100644 index 00000000..4798c22d --- /dev/null +++ b/.github/workflows/macos.yaml @@ -0,0 +1,70 @@ +# Adapted from https://github.com/rust-lang/rustup/blob/master/.github/workflows/windows-builds-on-master.yaml + +name: macOS + +on: + pull_request: + branches: + - "*" + push: + branches: + - master + - feature/* + - hotfix/* + tags: + - v* + schedule: + - cron: "30 0 * * 0" # Every day at 00:30 UTC + workflow_dispatch: + +jobs: + cargo-deny: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: EmbarkStudios/cargo-deny-action@v2 + + build: + strategy: + fail-fast: true + matrix: + platform: + - os-name: darwin-x86_64 + runs-on: macos-latest + target: x86_64-apple-darwin + - os-name: darwin-aarch64 + runs-on: macos-latest + target: aarch64-apple-darwin + runs-on: ${{ matrix.platform.runs-on }} + permissions: write-all + env: + RUSTFLAGS: -Ctarget-feature=+crt-static -Dwarnings + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - run: rustup toolchain install stable --profile minimal + - run: rustup component add --toolchain stable clippy + - run: rustup toolchain install nightly --allow-downgrade -c rustfmt + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: "true" + cache-all-crates: "true" + key: ${{ matrix.platform.target }} + - run: cargo +nightly fmt --check + - run: cargo clippy + - run: cargo test + - uses: houseabsolute/actions-rust-cross@v1 + with: + command: "build" + target: ${{ matrix.platform.target }} + args: "--locked --release" + - uses: actions/upload-artifact@v4 + with: + name: komorebi-${{ matrix.platform.target }}-${{ github.sha }} + path: | + target/${{ matrix.platform.target }}/release/komorebi* + retention-days: 90 \ No newline at end of file From a9029fee41d5d43684e43d80fa04eaca2a19b13e Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 19 Oct 2025 11:24:24 -0700 Subject: [PATCH 123/305] build(nix): separate targets and add flake overlays --- flake.nix | 126 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 38 deletions(-) diff --git a/flake.nix b/flake.nix index 17d16f8a..2f98ee00 100644 --- a/flake.nix +++ b/flake.nix @@ -7,53 +7,103 @@ }; outputs = inputs: - with inputs; - flake-utils.lib.eachDefaultSystem ( - system: let - overlays = [ - (import rust-overlay) + with inputs; let + komorebiBuild = system: let + overlays = [ + (import rust-overlay) + ]; + + pkgs = (import nixpkgs) { + inherit system overlays; + }; + + inherit (pkgs) lib; + + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + + src = lib.cleanSourceWith { + src = ./.; + filter = path: type: + (craneLib.filterCargoSources path type) + || (lib.hasInfix "/docs/" path) + || (builtins.match ".*/docs/.*" path != null); + }; + + version = "0.1.0"; + pname = "komorebi"; + + commonArgs = { + inherit src version pname; + nativeBuildInputs = with pkgs; []; + doCheck = false; + buildInputs = with pkgs; [ + gcc + libiconv ]; + }; - pkgs = (import nixpkgs) { - inherit system overlays; - }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + in { + komorebi = craneLib.buildPackage ( + commonArgs + // { + cargoExtraArgs = "-p komorebi"; + } + ); - inherit (pkgs) lib; + komorebic = craneLib.buildPackage ( + commonArgs + // { + cargoExtraArgs = "-p komorebic"; + } + ); - toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; - craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + komorebi-bar = craneLib.buildPackage ( + commonArgs + // { + cargoExtraArgs = "-p komorebi-bar"; + } + ); - src = craneLib.cleanCargoSource ./.; - version = "0.1.0"; - pname = "komorebi"; - - commonArgs = { - inherit src version pname; - nativeBuildInputs = with pkgs; []; - doCheck = false; - buildInputs = with pkgs; [ - gcc - libiconv - ]; - }; - - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - - komorebi = craneLib.buildPackage ( - commonArgs - // { - cargoExtraArgs = "-p komorebi -p komorebic"; - } - ); + komorebi-full = craneLib.buildPackage ( + commonArgs + // { + cargoExtraArgs = "-p komorebi -p komorebic -p komorebi-bar"; + } + ); + }; + in + (flake-utils.lib.eachDefaultSystem ( + system: let + packages = komorebiBuild system; in { devShells = flake-utils.lib.flattenTree { - default = import ./shell.nix {inherit pkgs;}; + default = import ./shell.nix { + pkgs = (import nixpkgs) { + inherit system; + overlays = [(import rust-overlay)]; + }; + }; }; - packages = flake-utils.lib.flattenTree rec { - inherit komorebi; - default = komorebi; + packages = flake-utils.lib.flattenTree { + inherit (packages) komorebi komorebic komorebi-bar komorebi-full; + default = packages.komorebi-full; }; } - ); + )) + // { + overlays.default = final: prev: let + packages = komorebiBuild final.system; + in { + inherit (packages) komorebi komorebic komorebi-bar komorebi-full; + }; + + overlays.komorebi = final: prev: let + packages = komorebiBuild final.system; + in { + inherit (packages) komorebi komorebic komorebi-bar komorebi-full; + }; + }; } From 3ab47e8a9ccc9819ae26a53dcd5322d29b072bf6 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 19 Oct 2025 11:24:48 -0700 Subject: [PATCH 124/305] chore(deps): cargo update --- Cargo.lock | 269 ++++++++++++++++++++++++----------------------------- 1 file changed, 124 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bff7d41..4126130b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,7 +142,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", "version_check", "zerocopy", @@ -316,7 +316,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -439,7 +439,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -474,7 +474,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -760,7 +760,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -865,9 +865,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -910,9 +910,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.48" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae" +checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f" dependencies = [ "clap_builder", "clap_derive", @@ -920,9 +920,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.48" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9" +checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730" dependencies = [ "anstream", "anstyle", @@ -933,30 +933,30 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.58" +version = "4.5.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75bf0b32ad2e152de789bb635ea4d3078f6b838ad7974143e99b99f45a04af4a" +checksum = "2348487adcd4631696ced64ccdb40d38ac4d31cae7f2eec8817fcea1b9d1c43c" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.5.47" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "clap_lex" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "clipboard-win" @@ -1236,7 +1236,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1247,7 +1247,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1346,7 +1346,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1581,7 +1581,7 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1631,7 +1631,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1735,7 +1735,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1864,7 +1864,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1960,7 +1960,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -1994,12 +1994,12 @@ dependencies = [ [[package]] name = "gethostname" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc257fdb4038301ce4b9cd1b3b51704509692bb3ff716a410cbd07925d9dae55" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ "rustix 1.1.2", - "windows-targets 0.52.6", + "windows-link 0.2.1", ] [[package]] @@ -2026,14 +2026,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.7+wasi-0.2.4", + "wasip2", ] [[package]] @@ -2233,7 +2233,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.11.4", + "indexmap 2.12.0", "slab", "tokio", "tokio-util", @@ -2242,9 +2242,9 @@ dependencies = [ [[package]] name = "half" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54c115d4f30f52c67202f079c5f9d8b49db4691f460fdb0b4c2e838261b2ba5" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" dependencies = [ "cfg-if", "crunchy", @@ -2667,9 +2667,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.11.4" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", "hashbrown 0.16.0", @@ -2705,18 +2705,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", -] - -[[package]] -name = "io-uring" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" -dependencies = [ - "bitflags 2.9.4", - "cfg-if", - "libc", + "syn 2.0.107", ] [[package]] @@ -2790,7 +2779,7 @@ version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "libc", ] @@ -3129,7 +3118,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3290,13 +3279,13 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" dependencies = [ "libc", "wasi 0.11.1+wasi-snapshot-preview1", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3323,7 +3312,7 @@ dependencies = [ "half", "hashbrown 0.15.5", "hexf-parse", - "indexmap 2.11.4", + "indexmap 2.12.0", "log", "num-traits", "once_cell", @@ -3603,7 +3592,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -3660,9 +3649,9 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" +checksum = "b1207a7e20ad57b847bbddc6776b968420d38292bbfe2089accff5e19e82454c" dependencies = [ "num_enum_derive", "rustversion", @@ -3670,14 +3659,14 @@ dependencies = [ [[package]] name = "num_enum_derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" +checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4161,9 +4150,9 @@ checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" [[package]] name = "openssl" -version = "0.10.73" +version = "0.10.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654" dependencies = [ "bitflags 2.9.4", "cfg-if", @@ -4182,7 +4171,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4193,9 +4182,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.109" +version = "0.9.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2" dependencies = [ "cc", "libc", @@ -4332,7 +4321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.11.4", + "indexmap 2.12.0", ] [[package]] @@ -4408,7 +4397,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4447,7 +4436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3af6b589e163c5a788fab00ce0c0366f6efbb9959c2f9874b224936af7fce7e1" dependencies = [ "base64", - "indexmap 2.11.4", + "indexmap 2.12.0", "quick-xml 0.38.3", "serde", "time", @@ -4562,7 +4551,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -4755,7 +4744,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", ] [[package]] @@ -4928,14 +4917,14 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] name = "regex" -version = "1.12.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a52d8d02cacdb176ef4678de6c052efb4b3da14b78e4db683a4252762be5433" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -4945,9 +4934,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722166aa0d7438abbaa4d5cc2c649dac844e8c56d82fb3d33e9c34b5cd268fc6" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -4956,9 +4945,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3160422bbd54dd5ecfdca71e5fd59b7b8fe2b1697ab2baf64f6d05dcc66d298" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "renderdoc-sys" @@ -4968,9 +4957,9 @@ checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "reqwest" -version = "0.12.23" +version = "0.12.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" dependencies = [ "base64", "bytes", @@ -5077,9 +5066,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.32" +version = "0.23.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40" +checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c" dependencies = [ "once_cell", "rustls-pki-types", @@ -5183,7 +5172,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5267,7 +5256,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5278,7 +5267,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5314,7 +5303,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5357,7 +5346,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.11.4", + "indexmap 2.12.0", "schemars 0.8.22", "schemars 0.9.0", "schemars 1.0.4", @@ -5376,7 +5365,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5559,12 +5548,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -5646,7 +5635,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5658,7 +5647,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5680,9 +5669,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b" dependencies = [ "proc-macro2", "quote", @@ -5706,7 +5695,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5770,7 +5759,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", "rustix 1.1.2", "windows-sys 0.61.2", @@ -5821,7 +5810,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5832,7 +5821,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -5939,19 +5928,16 @@ dependencies = [ [[package]] name = "tokio" -version = "1.47.1" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ - "backtrace", "bytes", - "io-uring", "libc", - "mio 1.0.4", + "mio 1.1.0", "pin-project-lite", - "slab", "socket2", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -6032,7 +6018,7 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.0", "serde", "serde_spanned", "toml_datetime 0.6.11", @@ -6045,7 +6031,7 @@ version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.0", "toml_datetime 0.7.3", "toml_parser", "winnow", @@ -6136,7 +6122,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -6328,8 +6314,9 @@ version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "js-sys", + "serde", "wasm-bindgen", ] @@ -6399,15 +6386,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasi" -version = "0.14.7+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" -dependencies = [ - "wasip2", -] - [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -6440,7 +6418,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "wasm-bindgen-shared", ] @@ -6475,7 +6453,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6620,9 +6598,9 @@ dependencies = [ [[package]] name = "webbrowser" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf4f3c0ba838e82b4e5ccc4157003fb8c324ee24c058470ffb82820becbde98" +checksum = "00f1243ef785213e3a32fa0396093424a3a6ea566f9948497e5a2309261a4c97" dependencies = [ "core-foundation 0.10.1", "jni", @@ -6681,7 +6659,7 @@ dependencies = [ "cfg_aliases", "document-features", "hashbrown 0.15.5", - "indexmap 2.11.4", + "indexmap 2.12.0", "log", "naga", "once_cell", @@ -6920,7 +6898,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -6931,7 +6909,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -6942,7 +6920,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -6953,7 +6931,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -7521,15 +7499,15 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "synstructure", ] [[package]] name = "zbus" -version = "5.11.0" +version = "5.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d07e46d035fb8e375b2ce63ba4e4ff90a7f73cf2ffb0138b29e1158d2eaadf7" +checksum = "b622b18155f7a93d1cd2dc8c01d2d6a44e08fb9ebb7b3f9e6ed101488bad6c91" dependencies = [ "async-broadcast", "async-executor", @@ -7551,7 +7529,8 @@ dependencies = [ "serde_repr", "tracing", "uds_windows", - "windows-sys 0.60.2", + "uuid", + "windows-sys 0.61.2", "winnow", "zbus_macros", "zbus_names", @@ -7576,7 +7555,7 @@ checksum = "dc6821851fa840b708b4cbbaf6241868cabc85a2dc22f426361b0292bfc0b836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "zbus-lockstep", "zbus_xml", "zvariant", @@ -7584,14 +7563,14 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "5.11.0" +version = "5.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e797a9c847ed3ccc5b6254e8bcce056494b375b511b3d6edcec0aeb4defaca" +checksum = "1cdb94821ca8a87ca9c298b5d1cbd80e2a8b67115d99f6e4551ac49e42b6a314" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "zbus_names", "zvariant", "zvariant_utils", @@ -7639,7 +7618,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -7659,7 +7638,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "synstructure", ] @@ -7699,7 +7678,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", ] [[package]] @@ -7728,9 +7707,9 @@ dependencies = [ [[package]] name = "zvariant" -version = "5.7.0" +version = "5.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "999dd3be73c52b1fccd109a4a81e4fcd20fab1d3599c8121b38d04e1419498db" +checksum = "2be61892e4f2b1772727be11630a62664a1826b62efa43a6fe7449521cb8744c" dependencies = [ "endi", "enumflags2", @@ -7742,14 +7721,14 @@ dependencies = [ [[package]] name = "zvariant_derive" -version = "5.7.0" +version = "5.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6643fd0b26a46d226bd90d3f07c1b5321fe9bb7f04673cb37ac6d6883885b68e" +checksum = "da58575a1b2b20766513b1ec59d8e2e68db2745379f961f86650655e862d2006" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.107", "zvariant_utils", ] @@ -7762,6 +7741,6 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.106", + "syn 2.0.107", "winnow", ] From 8a9a9fe6618eaa3b218f1e8c440eaad86ca4f073 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 19 Oct 2025 11:25:35 -0700 Subject: [PATCH 125/305] chore(deps): flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/1e7905b1eb1b551aade75169940557b6c51ed920' (2025-10-05) → 'github:ipetkov/crane/1979a2524cb8c801520bd94c38bb3d5692419d93' (2025-10-08) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/7df7ff7d8e00218376575f0acdcc5d66741351ee' (2025-10-02) → 'github:nixos/nixpkgs/544961dfcce86422ba200ed9a0b00dd4b1486ec5' (2025-10-15) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/edea9f33f9a03f615ad3609a40fbcefe0ec835ca' (2025-10-06) → 'github:oxalica/rust-overlay/a9121dc4ccd63e0309426b91bd7a494189516274' (2025-10-19) --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 292e9f2c..c16827ee 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1759691647, - "narHash": "sha256-OnyPw3KaXL909I+FNyD6jfkAP/gdL/K0iitMHxo7ieM=", + "lastModified": 1759893430, + "narHash": "sha256-yAy4otLYm9iZ+NtQwTMEbqHwswSFUbhn7x826RR6djw=", "owner": "ipetkov", "repo": "crane", - "rev": "1e7905b1eb1b551aade75169940557b6c51ed920", + "rev": "1979a2524cb8c801520bd94c38bb3d5692419d93", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1759381078, - "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", + "lastModified": 1760524057, + "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", + "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5", "type": "github" }, "original": { @@ -78,11 +78,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1759718104, - "narHash": "sha256-TbkLsgdnXHUXR4gOQBmhxkEE9ne+eHmX1chZHWRogy0=", + "lastModified": 1760841560, + "narHash": "sha256-NVOl5Lk1QD+i4I4My4f85yjXBinu+OXOUWskPNtzKHs=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "edea9f33f9a03f615ad3609a40fbcefe0ec835ca", + "rev": "a9121dc4ccd63e0309426b91bd7a494189516274", "type": "github" }, "original": { From 1abdf0a032f5185bb0b51bd7aab921566e9575a4 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 19 Oct 2025 11:44:41 -0700 Subject: [PATCH 126/305] chore(deps): bump block2, netdev and which --- Cargo.lock | 99 +++++------------------------------------ Cargo.toml | 2 +- komorebi-bar/Cargo.toml | 3 +- komorebi/Cargo.toml | 3 +- 4 files changed, 13 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4126130b..9df6e116 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -660,25 +660,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "block-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" -dependencies = [ - "objc-sys", -] - -[[package]] -name = "block2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" -dependencies = [ - "block-sys", - "objc2 0.4.1", -] - [[package]] name = "block2" version = "0.5.1" @@ -1584,12 +1565,6 @@ dependencies = [ "syn 2.0.107", ] -[[package]] -name = "env_home" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" - [[package]] name = "epaint" version = "0.32.3" @@ -2823,7 +2798,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" name = "komorebi" version = "0.1.0" dependencies = [ - "block2 0.3.0", + "block2 0.6.2", "clap", "color-eyre", "crossbeam-channel", @@ -2846,7 +2821,6 @@ dependencies = [ "objc2-quartz-core 0.3.2", "parking_lot", "pastey", - "quick-xml 0.38.3", "quickxml_to_serde", "regex", "schemars 0.8.22", @@ -2899,7 +2873,6 @@ dependencies = [ "sysinfo", "tracing", "tracing-subscriber", - "which", ] [[package]] @@ -3390,9 +3363,9 @@ dependencies = [ [[package]] name = "netdev" -version = "0.36.0" +version = "0.38.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862209dce034f82a44c95ce2b5183730d616f2a68746b9c1959aa2572e77c0a1" +checksum = "67ab878b4c90faf36dab10ea51d48c69ae9019bcca47c048a7c9b273d5d7a823" dependencies = [ "dlopen2", "ipnet", @@ -3407,40 +3380,23 @@ dependencies = [ [[package]] name = "netlink-packet-core" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4" +checksum = "3463cbb78394cb0141e2c926b93fc2197e473394b761986eca3b9da2c63ae0f4" dependencies = [ - "anyhow", - "byteorder", - "netlink-packet-utils", + "paste", ] [[package]] name = "netlink-packet-route" -version = "0.22.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0e7987b28514adf555dc1f9a5c30dfc3e50750bbaffb1aec41ca7b23dcd8e4" +checksum = "3ec2f5b6839be2a19d7fa5aab5bc444380f6311c2b693551cb80f45caaa7b5ef" dependencies = [ - "anyhow", "bitflags 2.9.4", - "byteorder", "libc", "log", "netlink-packet-core", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-utils" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" -dependencies = [ - "anyhow", - "byteorder", - "paste", - "thiserror 1.0.69", ] [[package]] @@ -3693,16 +3649,6 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" -[[package]] -name = "objc2" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" -dependencies = [ - "objc-sys", - "objc2-encode 3.0.0", -] - [[package]] name = "objc2" version = "0.5.2" @@ -3710,7 +3656,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" dependencies = [ "objc-sys", - "objc2-encode 4.1.0", + "objc2-encode", ] [[package]] @@ -3719,7 +3665,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05" dependencies = [ - "objc2-encode 4.1.0", + "objc2-encode", ] [[package]] @@ -3937,12 +3883,6 @@ dependencies = [ "objc2-metal 0.3.2", ] -[[package]] -name = "objc2-encode" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" - [[package]] name = "objc2-encode" version = "4.1.0" @@ -4613,7 +4553,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" dependencies = [ "memchr", - "serde", ] [[package]] @@ -6765,18 +6704,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "which" -version = "7.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762" -dependencies = [ - "either", - "env_home", - "rustix 1.1.2", - "winsafe", -] - [[package]] name = "winapi" version = "0.3.9" @@ -7389,12 +7316,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winsafe" -version = "0.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" - [[package]] name = "wit-bindgen" version = "0.46.0" diff --git a/Cargo.toml b/Cargo.toml index a2b24a80..1750d1a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,4 +33,4 @@ thiserror = "2" tracing = "0.1" tracing-appender = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -which = "7" +which = "8" diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 1d9361d7..7f572478 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -23,7 +23,7 @@ hotwatch = { workspace = true } icns = "0.3" image = "0.25" lazy_static = { workspace = true } -netdev = "0.36" +netdev = "0.38" num = "0.4" num-derive = "0.4" num-traits = "0.2" @@ -39,7 +39,6 @@ starship-battery = "0.10" sysinfo = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } -which = { workspace = true } [features] default = ["schemars"] diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 3d06d2ba..1b3843a8 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -8,7 +8,7 @@ edition = "2024" komorebi-themes = { workspace = true } quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } -block2 = "0.3" +block2 = "0.6" clap = { workspace = true } color-eyre = { workspace = true } crossbeam-channel = { workspace = true } @@ -30,7 +30,6 @@ objc2-foundation = "0.3" objc2-quartz-core = "0.3" parking_lot = { workspace = true } pastey = { workspace = true } -quick-xml = { version = "0.38", features = ["serialize"] } regex = "1" schemars = { workspace = true, optional = true } serde = { workspace = true } From 0b88af0fee51a0a9930cfb58c0d8ab0464cd861f Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 20 Oct 2025 08:11:17 -0700 Subject: [PATCH 127/305] ci(github): switch to self-hosted runners --- .github/workflows/macos.yaml | 38 +++++++----------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index 4798c22d..dcb15634 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -13,31 +13,15 @@ on: - hotfix/* tags: - v* - schedule: - - cron: "30 0 * * 0" # Every day at 00:30 UTC +# schedule: +# - cron: "30 0 * * 0" # Every day at 00:30 UTC workflow_dispatch: jobs: - cargo-deny: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - uses: EmbarkStudios/cargo-deny-action@v2 - build: strategy: fail-fast: true - matrix: - platform: - - os-name: darwin-x86_64 - runs-on: macos-latest - target: x86_64-apple-darwin - - os-name: darwin-aarch64 - runs-on: macos-latest - target: aarch64-apple-darwin - runs-on: ${{ matrix.platform.runs-on }} + runs-on: self-hosted permissions: write-all env: RUSTFLAGS: -Ctarget-feature=+crt-static -Dwarnings @@ -49,22 +33,14 @@ jobs: - run: rustup toolchain install stable --profile minimal - run: rustup component add --toolchain stable clippy - run: rustup toolchain install nightly --allow-downgrade -c rustfmt - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: "true" - cache-all-crates: "true" - key: ${{ matrix.platform.target }} - run: cargo +nightly fmt --check + - run: cargo deny check - run: cargo clippy - run: cargo test - - uses: houseabsolute/actions-rust-cross@v1 - with: - command: "build" - target: ${{ matrix.platform.target }} - args: "--locked --release" + - run: cargo build --locked --release - uses: actions/upload-artifact@v4 with: - name: komorebi-${{ matrix.platform.target }}-${{ github.sha }} + name: komorebi-aarch64-apple-darwin-${{ github.sha }} path: | - target/${{ matrix.platform.target }}/release/komorebi* + target/release/komorebi* retention-days: 90 \ No newline at end of file From a2831d2b7f0db0d3d6caaa1c083f042960aabe00 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 20 Oct 2025 15:37:56 -0700 Subject: [PATCH 128/305] ci(github): run checks and build with nix --- .github/workflows/{macos.yaml => nix.yaml} | 21 +- Cargo.toml | 10 +- deny.toml | 56 +++--- flake.lock | 12 +- flake.nix | 224 +++++++++++++++------ komorebi-bar/Cargo.toml | 6 +- komorebi/Cargo.toml | 5 +- rust-toolchain.toml | 2 +- rustfmt.toml | 2 +- 9 files changed, 214 insertions(+), 124 deletions(-) rename .github/workflows/{macos.yaml => nix.yaml} (53%) diff --git a/.github/workflows/macos.yaml b/.github/workflows/nix.yaml similarity index 53% rename from .github/workflows/macos.yaml rename to .github/workflows/nix.yaml index dcb15634..8d8cd7e7 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/nix.yaml @@ -1,6 +1,6 @@ # Adapted from https://github.com/rust-lang/rustup/blob/master/.github/workflows/windows-builds-on-master.yaml -name: macOS +name: nix on: pull_request: @@ -13,8 +13,8 @@ on: - hotfix/* tags: - v* -# schedule: -# - cron: "30 0 * * 0" # Every day at 00:30 UTC + # schedule: + # - cron: "30 0 * * 0" # Every day at 00:30 UTC workflow_dispatch: jobs: @@ -24,23 +24,16 @@ jobs: runs-on: self-hosted permissions: write-all env: - RUSTFLAGS: -Ctarget-feature=+crt-static -Dwarnings GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v5 with: fetch-depth: 0 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add --toolchain stable clippy - - run: rustup toolchain install nightly --allow-downgrade -c rustfmt - - run: cargo +nightly fmt --check - - run: cargo deny check - - run: cargo clippy - - run: cargo test - - run: cargo build --locked --release + - run: nix flake check + - run: nix build - uses: actions/upload-artifact@v4 with: name: komorebi-aarch64-apple-darwin-${{ github.sha }} path: | - target/release/komorebi* - retention-days: 90 \ No newline at end of file + result/bin/komorebi* + retention-days: 90 diff --git a/Cargo.toml b/Cargo.toml index 1750d1a5..8202d407 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,10 @@ [workspace] resolver = "2" -members = [ - "komorebi", "komorebi-client", - "komorebic", "komorebi-bar" -] +members = ["komorebi", "komorebi-bar", "komorebi-client", "komorebic"] +[workspace.package] +version = "0.1.0" [workspace.dependencies] komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "1c23439f959bcfddf0f71918fc03a97dd4f30727" } @@ -34,3 +33,6 @@ tracing = "0.1" tracing-appender = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } which = "8" + +[workspace.metadata.crane] +name = "komorebi-workspace" diff --git a/deny.toml b/deny.toml index d97cd110..7a56b2a8 100644 --- a/deny.toml +++ b/deny.toml @@ -1,7 +1,5 @@ [graph] -targets = [ - "aarch64-apple-darwin", -] +targets = ["aarch64-apple-darwin"] all-features = false no-default-features = false @@ -10,32 +8,32 @@ feature-depth = 1 [advisories] ignore = [ - { id = "RUSTSEC-2024-0436", reason = "paste is fine" }, - { id = "RUSTSEC-2024-0320", reason = "not using any yaml features from this library" }, - { id = "RUSTSEC-2025-0056", reason = "only used for colour palette generation" }, + { id = "RUSTSEC-2024-0436", reason = "paste is fine" }, + { id = "RUSTSEC-2024-0320", reason = "not using any yaml features from this library" }, + { id = "RUSTSEC-2025-0056", reason = "only used for colour palette generation" }, ] [licenses] allow = [ - "0BSD", - "Apache-2.0", - "Artistic-2.0", - "BSD-2-Clause", - "BSD-3-Clause", - "CC0-1.0", - "ISC", - "MIT", - "MPL-2.0", - "OFL-1.1", - "Ubuntu-font-1.0", - "Unicode-3.0", - "Zlib", + "0BSD", + "Apache-2.0", + "Artistic-2.0", + "BSD-2-Clause", + "BSD-3-Clause", + "CC0-1.0", + "ISC", + "MIT", + "MPL-2.0", + "OFL-1.1", + "Ubuntu-font-1.0", + "Unicode-3.0", + "Zlib", - "LicenseRef-Komorebi-2.0", - # these are also ok, but not yet used + "LicenseRef-Komorebi-2.0", + # these are also ok, but not yet used - # "BSL-1.0", - # "MIT-0", + # "BSL-1.0", + # "MIT-0", ] confidence-threshold = 0.8 @@ -81,10 +79,10 @@ unknown-registry = "deny" unknown-git = "deny" allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-git = [ - "https://github.com/LGUG2Z/quickxml_to_serde", - "https://github.com/LGUG2Z/base16-egui-themes", - "https://github.com/LGUG2Z/flavours", - "https://github.com/LGUG2Z/komorebi", - "https://github.com/LGUG2Z/base16_color_scheme", + "https://github.com/LGUG2Z/quickxml_to_serde", + "https://github.com/LGUG2Z/base16-egui-themes", + "https://github.com/LGUG2Z/flavours", + "https://github.com/LGUG2Z/komorebi", + "https://github.com/LGUG2Z/base16_color_scheme", -] \ No newline at end of file +] diff --git a/flake.lock b/flake.lock index c16827ee..bf4252ff 100644 --- a/flake.lock +++ b/flake.lock @@ -35,16 +35,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1760524057, - "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=", - "owner": "nixos", + "lastModified": 1760934318, + "narHash": "sha256-/oUYsC0lUCBory65VK+UHqCCsCspbL1Vgfcf1KUYqVw=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5", + "rev": "87848bf0cc4f87717fc813a4575f07330c3e743c", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 2f98ee00..ef4f7694 100644 --- a/flake.nix +++ b/flake.nix @@ -1,109 +1,199 @@ { + description = "Build komorebi workspace"; + inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + crane.url = "github:ipetkov/crane"; flake-utils.url = "github:numtide/flake-utils"; rust-overlay.url = "github:oxalica/rust-overlay"; - crane.url = "github:ipetkov/crane"; }; - outputs = inputs: - with inputs; let - komorebiBuild = system: let - overlays = [ - (import rust-overlay) + outputs = { + nixpkgs, + crane, + flake-utils, + rust-overlay, + ... + }: let + komorebiBuild = system: let + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + inherit (pkgs) lib; + + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + version = "0.1.0"; + + src = lib.cleanSourceWith { + src = ./.; + filter = path: type: + (craneLib.filterCargoSources path type) + || (lib.hasInfix "/docs/" path) + || (builtins.match ".*/docs/.*" path != null); + }; + + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + + commonArgs = { + inherit src version cargoArtifacts; + strictDeps = true; + + buildInputs = [ + pkgs.gcc + pkgs.libiconv ]; + }; - pkgs = (import nixpkgs) { - inherit system overlays; - }; - - inherit (pkgs) lib; - - toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; - craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; - - src = lib.cleanSourceWith { - src = ./.; - filter = path: type: - (craneLib.filterCargoSources path type) - || (lib.hasInfix "/docs/" path) - || (builtins.match ".*/docs/.*" path != null); - }; - - version = "0.1.0"; - pname = "komorebi"; - - commonArgs = { - inherit src version pname; - nativeBuildInputs = with pkgs; []; + individualCrateArgs = + commonArgs + // { doCheck = false; - buildInputs = with pkgs; [ - gcc - libiconv - ]; }; - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - in { + packages = { komorebi = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebi"; cargoExtraArgs = "-p komorebi"; } ); komorebic = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebic"; cargoExtraArgs = "-p komorebic"; } ); komorebi-bar = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebi-bar"; cargoExtraArgs = "-p komorebi-bar"; } ); komorebi-full = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebi-full"; cargoExtraArgs = "-p komorebi -p komorebic -p komorebi-bar"; } ); }; in - (flake-utils.lib.eachDefaultSystem ( - system: let - packages = komorebiBuild system; - in { - devShells = flake-utils.lib.flattenTree { - default = import ./shell.nix { - pkgs = (import nixpkgs) { - inherit system; - overlays = [(import rust-overlay)]; - }; - }; - }; - - packages = flake-utils.lib.flattenTree { - inherit (packages) komorebi komorebic komorebi-bar komorebi-full; - default = packages.komorebi-full; - }; - } - )) + packages // { - overlays.default = final: prev: let - packages = komorebiBuild final.system; - in { - inherit (packages) komorebi komorebic komorebi-bar komorebi-full; + inherit + pkgs + craneLib + commonArgs + cargoArtifacts + individualCrateArgs + src + ; + }; + in + flake-utils.lib.eachSystem ["aarch64-darwin"] ( + system: let + buildResult = komorebiBuild system; + inherit + (buildResult) + komorebi + komorebic + komorebi-bar + komorebi-full + pkgs + craneLib + commonArgs + src + ; + in { + checks = { + komorebi-workspace-clippy = craneLib.cargoClippy ( + commonArgs + // { + cargoClippyExtraArgs = "--all-targets -- --deny warnings"; + } + ); + + komorebi-workspace-fmt = craneLib.cargoFmt { + inherit src; + }; + + komorebi-workspace-toml-fmt = craneLib.taploFmt { + src = pkgs.lib.sources.sourceFilesBySuffices src [".toml"]; + }; + + komorebi-workspace-deny = craneLib.cargoDeny { + inherit src; + }; + + komorebi-workspace-nextest = craneLib.cargoNextest commonArgs; }; - overlays.komorebi = final: prev: let - packages = komorebiBuild final.system; - in { - inherit (packages) komorebi komorebic komorebi-bar komorebi-full; + packages = { + inherit + komorebi + komorebic + komorebi-bar + komorebi-full + ; + default = komorebi-full; }; + + apps = { + komorebi = flake-utils.lib.mkApp { + drv = komorebi; + }; + komorebic = flake-utils.lib.mkApp { + drv = komorebic; + }; + komorebi-bar = flake-utils.lib.mkApp { + drv = komorebi-bar; + }; + default = flake-utils.lib.mkApp { + drv = komorebi-full; + }; + }; + + devShells.default = import ./shell.nix { + inherit pkgs; + }; + } + ) + // { + overlays.default = final: _: let + buildResult = komorebiBuild final.system; + in { + inherit + (buildResult) + komorebi + komorebic + komorebi-bar + komorebi-full + ; }; + + overlays.komorebi = final: _: let + buildResult = komorebiBuild final.system; + in { + inherit + (buildResult) + komorebi + komorebic + komorebi-bar + komorebi-full + ; + }; + }; } diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 7f572478..091672c0 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -42,4 +42,8 @@ tracing-subscriber = { workspace = true } [features] default = ["schemars"] -schemars = ["dep:schemars", "komorebi-client/default", "komorebi-themes/default"] +schemars = [ + "dep:schemars", + "komorebi-client/default", + "komorebi-themes/default", +] diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 1b3843a8..5136281f 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -22,7 +22,10 @@ nanoid = "0.4" objc2 = "0.6" objc2-app-kit = "0.3" objc2-application-services = "0.3" -objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } +objc2-core-foundation = { version = "0.3", features = [ + "CFDictionary", + "CFString", +] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } objc2-core-services = "0.3" objc2-core-video = "0.3" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 31578d3b..292fe499 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "stable" \ No newline at end of file +channel = "stable" diff --git a/rustfmt.toml b/rustfmt.toml index 74c8af67..63df91e0 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1 @@ -imports_granularity = "Item" \ No newline at end of file +imports_granularity = "Item" From d62f824d2b5ecfa6cc9dc90b1d03a12d650c998e Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 25 Oct 2025 11:16:45 -0700 Subject: [PATCH 129/305] ci(github): publish nightly releases --- .github/workflows/nix.yaml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index 8d8cd7e7..e7ff679e 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -13,14 +13,12 @@ on: - hotfix/* tags: - v* - # schedule: - # - cron: "30 0 * * 0" # Every day at 00:30 UTC + schedule: + - cron: "30 0 * * 0" # Every day at 00:30 UTC workflow_dispatch: jobs: build: - strategy: - fail-fast: true runs-on: self-hosted permissions: write-all env: @@ -37,3 +35,27 @@ jobs: path: | result/bin/komorebi* retention-days: 90 + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} + run: echo "VERSION=nightly" >> $GITHUB_ENV + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} + run: | + zip -j komorebi-${VERSION}-aarch64-apple-darwin.zip result/bin/* + echo "$(sha256sum komorebi-${VERSION}-aarch64-apple-darwin.zip | cut -d' ' -f1) komorebi-${VERSION}-aarch64-apple-darwin.zip" > checksums.txt + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} + run: | + git tag -d nightly || true + git tag nightly + kokai release --no-emoji --add-links github:commits,issues --ref nightly >"CHANGELOG.md" + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} + shell: bash + run: | + gh release delete nightly --yes || true + git push origin :nightly || true + + gh release create nightly \ + --target $GITHUB_SHA \ + --prerelease \ + --title "komorebi for Mac nightly (${GITHUB_SHA})" \ + --notes-file CHANGELOG.md \ + komorebi-nightly-aarch64-apple-darwin.zip \ + checksums.txt From f93cf44aba7ff41d7e1b76a212d8371cb208b747 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 26 Oct 2025 12:05:46 -0700 Subject: [PATCH 130/305] ci(github): attach homebrew formula to nightly release --- .github/workflows/nix.yaml | 33 ++++++++++++++++++++++++++++++++- formula.template.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 formula.template.rb diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index e7ff679e..a316dbda 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -46,7 +46,7 @@ jobs: git tag -d nightly || true git tag nightly kokai release --no-emoji --add-links github:commits,issues --ref nightly >"CHANGELOG.md" - - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) && github.repository == 'KomoCorp/komorebi-for-mac' }} shell: bash run: | gh release delete nightly --yes || true @@ -59,3 +59,34 @@ jobs: --notes-file CHANGELOG.md \ komorebi-nightly-aarch64-apple-darwin.zip \ checksums.txt + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) && github.repository == 'KomoCorp/komorebi-for-mac' }} + shell: bash + run: | + ASSET_ID=$(gh api repos/${{ github.repository }}/releases/tags/nightly \ + --jq '.assets[] | select(.name=="komorebi-nightly-aarch64-apple-darwin.zip") | .id') + + SHA256=$(cat checksums.txt | cut -d' ' -f1) + + echo "ASSET_ID=$ASSET_ID" >> $GITHUB_ENV + echo "SHA256=$SHA256" >> $GITHUB_ENV + + echo "Asset ID: $ASSET_ID" + echo "SHA256: $SHA256" + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) && github.repository == 'KomoCorp/komorebi-for-mac' }} + shell: bash + env: + GIT_AUTHOR_NAME: "JeezyBot" + GIT_AUTHOR_EMAIL: "lgug2z@fastmail.com" + GIT_COMMITTER_NAME: "JeezyBot" + GIT_COMMITTER_EMAIL: "lgug2z@fastmail.com" + run: | + sed "s/REPLACE_ASSET_ID/$ASSET_ID/g; s/REPLACE_SHA_256/$SHA256/g" formula.template.rb > komorebi-for-mac-nightly.rb + cat komorebi-for-mac-nightly.rb + gh release upload nightly komorebi-for-mac-nightly.rb + + git clone https://x-access-token:${{ secrets.GH_USER_API_TOKEN }}@github.com/LGUG2Z/homebrew-tap + cd homebrew-tap + cp ../komorebi-for-mac-nightly.rb ./Formula + git add . + git commit -m "Update komorebi-for-mac-nightly to $ASSET_ID ($SHA256)" + git push diff --git a/formula.template.rb b/formula.template.rb new file mode 100644 index 00000000..118951e6 --- /dev/null +++ b/formula.template.rb @@ -0,0 +1,30 @@ +class KomorebiForMacNightly < Formula + desc "Tiling window manager for macOS (nightly build)" + homepage "https://github.com/KomoCorp/komorebi-for-mac" + url "https://api.github.com/repos/KomoCorp/komorebi-for-mac/releases/assets/REPLACE_ASSET_ID", + headers: [ + "Accept: application/octet-stream", + "X-GitHub-Api-Version: 2022-11-28", + "Authorization: bearer #{ENV.fetch("HOMEBREW_GITHUB_API_TOKEN")}", + ] + version "nightly" + sha256 "REPLACE_SHA_256" + license "Komorebi License 2.0.0" + + def install + bin.install Dir["*"] + end + + def caveats + <<~EOS + This formula requires access to a private GitHub repository. + Make sure you have set your GitHub token: + + export HOMEBREW_GITHUB_API_TOKEN=your_token_here + EOS + end + + test do + system "#{bin}/komorebi", "--help" + end +end From 2e4660dc125de8c18dce447d4f1ee6d968b862d3 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 26 Oct 2025 19:37:37 -0700 Subject: [PATCH 131/305] fix(wm): ensure border resource cleanups This commit wraps the various lifecycle methods for border creation, update and destruction in autoreleasepools to ensure that WindowServer memory doesn't balloon. --- komorebi/src/border_manager/border.rs | 25 +++-- komorebi/src/border_manager/ns_window.rs | 126 ++++++++++++----------- 2 files changed, 80 insertions(+), 71 deletions(-) diff --git a/komorebi/src/border_manager/border.rs b/komorebi/src/border_manager/border.rs index a1dc2c84..e933cfaa 100644 --- a/komorebi/src/border_manager/border.rs +++ b/komorebi/src/border_manager/border.rs @@ -16,6 +16,7 @@ use crate::macos_api::MacosApi; use color_eyre::eyre; use dispatch2::DispatchQueue; use komorebi_themes::colour::Rgb; +use objc2::rc::autoreleasepool; use objc2_application_services::AXObserver; use objc2_application_services::AXUIElement; use objc2_core_foundation::CFString; @@ -141,19 +142,23 @@ impl Border { } pub fn update(&self) { - let colour = Rgb::from(window_kind_colour(self.window_kind)); + autoreleasepool(|_| { + let colour = Rgb::from(window_kind_colour(self.window_kind)); - CATransaction::begin(); - CATransaction::setDisableActions(true); - self.ns_window.set_border_color(colour); - self.ns_window - .set_border_width(BORDER_WIDTH.load(Ordering::Relaxed) as f64); - // TODO: why does this crash? - // self.ns_window.window.setFrame_display(ns_rect, true); - CATransaction::commit(); + CATransaction::begin(); + CATransaction::setDisableActions(true); + self.ns_window.set_border_color(colour); + self.ns_window + .set_border_width(BORDER_WIDTH.load(Ordering::Relaxed) as f64); + // TODO: why does this crash? + // self.ns_window.window.setFrame_display(ns_rect, true); + CATransaction::commit(); + }) } pub fn destroy(&self) { - self.ns_window.window.close(); + autoreleasepool(|_| { + self.ns_window.window.close(); + }) } } diff --git a/komorebi/src/border_manager/ns_window.rs b/komorebi/src/border_manager/ns_window.rs index 4dc47c39..b43dde86 100644 --- a/komorebi/src/border_manager/ns_window.rs +++ b/komorebi/src/border_manager/ns_window.rs @@ -9,6 +9,7 @@ use objc2::MainThreadMarker; use objc2::MainThreadOnly; use objc2::msg_send; use objc2::rc::Retained; +use objc2::rc::autoreleasepool; use objc2_app_kit::NSBackingStoreType; use objc2_app_kit::NSColor; use objc2_app_kit::NSNormalWindowLevel; @@ -47,81 +48,84 @@ impl NsWindow { let (tx, rx) = mpsc::channel(); DispatchQueue::main().exec_async(move || { - let mtm = unsafe { MainThreadMarker::new_unchecked() }; + autoreleasepool(|_| { + let mtm = unsafe { MainThreadMarker::new_unchecked() }; - // Create window - let window_frame = ns_rect; + // Create window + let window_frame = ns_rect; - let window = unsafe { - let window = NSWindow::alloc(mtm); - NSWindow::initWithContentRect_styleMask_backing_defer( - window, - window_frame, - NSWindowStyleMask::Borderless, - NSBackingStoreType::Buffered, - false, - ) - }; + let window = unsafe { + let window = NSWindow::alloc(mtm); + NSWindow::initWithContentRect_styleMask_backing_defer( + window, + window_frame, + NSWindowStyleMask::Borderless, + NSBackingStoreType::Buffered, + false, + ) + }; - // Make transparent - window.setBackgroundColor(Some(&NSColor::clearColor())); - window.setAnimationBehavior(NSWindowAnimationBehavior::None); - window.disableSnapshotRestoration(); - window.setPreservesContentDuringLiveResize(false); - window.setRestorable(false); + // Make transparent + window.setBackgroundColor(Some(&NSColor::clearColor())); + window.setAnimationBehavior(NSWindowAnimationBehavior::None); + window.disableSnapshotRestoration(); + window.setPreservesContentDuringLiveResize(false); + window.setRestorable(false); - window.setHasShadow(false); - window.setOpaque(false); - window.setLevel(NSNormalWindowLevel); - window.setIgnoresMouseEvents(true); + window.setHasShadow(false); + window.setOpaque(false); + window.setLevel(NSNormalWindowLevel); + window.setIgnoresMouseEvents(true); - window.setCollectionBehavior( - NSWindowCollectionBehavior::CanJoinAllSpaces | - NSWindowCollectionBehavior::Stationary | - NSWindowCollectionBehavior::IgnoresCycle | - NSWindowCollectionBehavior::Transient - ); + window.setCollectionBehavior( + NSWindowCollectionBehavior::CanJoinAllSpaces | + NSWindowCollectionBehavior::Stationary | + NSWindowCollectionBehavior::IgnoresCycle | + NSWindowCollectionBehavior::Transient + ); - let content_view = { - let view = NSView::alloc(mtm); - NSView::initWithFrame(view, window_frame) - }; + let content_view = { + let view = NSView::alloc(mtm); + NSView::initWithFrame(view, window_frame) + }; - content_view.setWantsLayer(true); - content_view.setAutoresizesSubviews(false); + content_view.setWantsLayer(true); + content_view.setAutoresizesSubviews(false); - // Create and configure the layer for the border - let layer = { - let layer = CALayer::new(); - layer.setFrame(ns_rect); - layer.setActions(Some(&NSDictionary::new())); + // Create and configure the layer for the border + let layer = { + let layer = CALayer::new(); + layer.setFrame(ns_rect); + layer.setActions(Some(&NSDictionary::new())); - unsafe { - // transparent - let clear = CGColor::new_generic_rgb(0.0, 0.0, 0.0, 0.0); - let clear_ptr = clear.deref() as *const _; - let _: () = msg_send![&layer, setBackgroundColor: clear_ptr]; + unsafe { + // transparent + let clear = CGColor::new_generic_rgb(0.0, 0.0, 0.0, 0.0); + let clear_ptr = clear.deref() as *const _; + let _: () = msg_send![&layer, setBackgroundColor: clear_ptr]; - let red = CGColor::new_generic_rgb(1.0, 0.0, 0.0, 1.0); - let red_ptr = red.deref() as *const _; - let _: () = msg_send![&layer, setBorderColor: red_ptr]; - let _: () = msg_send![&layer, setBorderWidth: BORDER_WIDTH.load(Ordering::Relaxed) as f64]; + let red = CGColor::new_generic_rgb(1.0, 0.0, 0.0, 1.0); + let red_ptr = red.deref() as *const _; + let _: () = msg_send![&layer, setBorderColor: red_ptr]; + let _: () = msg_send![&layer, setBorderWidth: BORDER_WIDTH.load(Ordering::Relaxed) as f64]; - let corner_radius: f64 = BORDER_RADIUS.load(Ordering::Relaxed) as f64; - let _: () = msg_send![&layer, setCornerRadius: corner_radius]; + let corner_radius: f64 = BORDER_RADIUS.load(Ordering::Relaxed) as f64; + let _: () = msg_send![&layer, setCornerRadius: corner_radius]; - layer + layer + } + }; + + content_view.setLayer(Some(&layer)); + + window.setContentView(Some(&content_view)); + window.setMovableByWindowBackground(false); + window.makeKeyAndOrderFront(None); + if let Err(error) = tx.send(NsWindow { window, layer }) { + tracing::error!("could not send NSWindow created for border: {error}") } - }; - content_view.setLayer(Some(&layer)); - - window.setContentView(Some(&content_view)); - window.setMovableByWindowBackground(false); - window.makeKeyAndOrderFront(None); - if let Err(error) = tx.send(NsWindow { window, layer }) { - tracing::error!("could not send NSWindow created for border: {error}") - } + }) }); rx.recv() From 4d25d4efb02a41320b69366a1b19c28de6b63720 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 26 Oct 2025 19:51:27 -0700 Subject: [PATCH 132/305] fix(wm): add hack to manage activity monitor on start I was running into this a lot when debugging the WindowServer memory ballooning issue fixed in the last commit - the title returned by CGWindowListCopyWindowInfo and the title returned by kAXWindowsAttribute for Activity Monitor differs, so when restarting komorebi, if Activity Monitor is open, it wouldn't get managed. Added a little hack as a workaround for now. --- komorebi/src/application.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index be344fdb..d7b33071 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -188,7 +188,10 @@ impl Application { let window = Window::new(element, self.clone()).ok()?; if let Some(window_title) = window.title() - && window_title.eq(title) + && (window_title.eq(title) + // TODO: find a better way to deal with these hacks + || (self.name().unwrap_or_default() == "Activity Monitor" + && window_title.starts_with(title))) { target = Some(window); } From b892504f9e78aec2af8d445e7cbed0bd54b981b2 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 27 Oct 2025 08:15:58 -0700 Subject: [PATCH 133/305] chore(deps): cargo update + bump actions/upload-artifact --- .github/workflows/nix.yaml | 2 +- Cargo.lock | 307 +++++++++++++++++++------------------ 2 files changed, 159 insertions(+), 150 deletions(-) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index a316dbda..96e4620c 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -29,7 +29,7 @@ jobs: fetch-depth: 0 - run: nix flake check - run: nix build - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 with: name: komorebi-aarch64-apple-darwin-${{ github.sha }} path: | diff --git a/Cargo.lock b/Cargo.lock index 9df6e116..ca0b2307 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" dependencies = [ "android-properties", - "bitflags 2.9.4", + "bitflags 2.10.0", "cc", "cesu8", "jni", @@ -316,7 +316,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -439,7 +439,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -474,7 +474,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -541,14 +541,14 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "av1-grain" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3efb2ca85bc610acfa917b5aaa36f3fcbebed5b3182d7f877b02531c4b80c8" +checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8" dependencies = [ "anyhow", "arrayvec", "log", - "nom", + "nom 8.0.0", "num-rational 0.4.2", "v_frame", ] @@ -595,7 +595,7 @@ version = "0.3.2" source = "git+https://github.com/LGUG2Z/base16_color_scheme#c32a9e290f0997eacba3e74bba2442667b5fc478" dependencies = [ "hex", - "nom", + "nom 7.1.3", "ramhorns", "serde", ] @@ -641,11 +641,11 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -741,7 +741,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -768,7 +768,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "log", "polling", "rustix 0.38.44", @@ -818,9 +818,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.41" +version = "1.2.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" +checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2" dependencies = [ "find-msvc-tools", "jobserver", @@ -891,9 +891,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.49" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f" +checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" dependencies = [ "clap_builder", "clap_derive", @@ -901,9 +901,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.49" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730" +checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" dependencies = [ "anstream", "anstyle", @@ -930,7 +930,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1217,7 +1217,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1228,7 +1228,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1243,9 +1243,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" dependencies = [ "powerfmt", "serde_core", @@ -1313,7 +1313,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "libc", "objc2 0.6.3", @@ -1327,7 +1327,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1352,9 +1352,9 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" dependencies = [ "litrs", ] @@ -1437,7 +1437,7 @@ checksum = "5d5d0306cd61ca75e29682926d71f2390160247f135965242e904a636f51c0dc" dependencies = [ "accesskit", "ahash", - "bitflags 2.9.4", + "bitflags 2.10.0", "emath", "epaint", "log", @@ -1562,7 +1562,7 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1606,7 +1606,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1710,7 +1710,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1757,9 +1757,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" +checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb" dependencies = [ "crc32fast", "miniz_oxide 0.8.9", @@ -1839,7 +1839,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -1935,7 +1935,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -2043,7 +2043,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "libc", "libgit2-sys", "log", @@ -2085,7 +2085,7 @@ version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg_aliases", "cgl", "dispatch2", @@ -2151,7 +2151,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "gpu-alloc-types", ] @@ -2161,7 +2161,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", ] [[package]] @@ -2182,7 +2182,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "gpu-descriptor-types", "hashbrown 0.15.5", ] @@ -2193,7 +2193,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", ] [[package]] @@ -2680,7 +2680,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -2707,9 +2707,9 @@ checksum = "1fe266d2e243c931d8190177f20bf7f24eed45e96f39e87dc49a27b32d12d407" [[package]] name = "is_terminal_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" @@ -3008,7 +3008,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "libc", "redox_syscall 0.5.18", ] @@ -3051,9 +3051,9 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "litrs" -version = "0.4.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" [[package]] name = "lock_api" @@ -3091,7 +3091,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -3157,9 +3157,9 @@ checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "memmap2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843a98750cd611cc2965a8213b53b43e715f13c37a9e096c6408e69990961db7" +checksum = "744133e4a0e0a658e1374cf3bf8e415c4052a15a111acd372764c55b4177d490" dependencies = [ "libc", ] @@ -3179,7 +3179,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block", "core-graphics-types", "foreign-types 0.5.0", @@ -3263,9 +3263,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c588e11a3082784af229e23e8e4ecf5bcc6fbe4f69101e0421ce8d79da7f0b40" +checksum = "692af879e4d9383c0fd9dec15524af6b6977c8bf1c6b278a4526d5341347c574" dependencies = [ "num-traits", "pxfm", @@ -3279,7 +3279,7 @@ checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg_aliases", "codespan-reporting", "half", @@ -3328,7 +3328,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "jni-sys", "log", "ndk-sys 0.6.0+11769913", @@ -3393,7 +3393,7 @@ version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ec2f5b6839be2a19d7fa5aab5bc444380f6311c2b693551cb80f45caaa7b5ef" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "libc", "log", "netlink-packet-core", @@ -3422,7 +3422,7 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg-if", "cfg_aliases", "libc", @@ -3445,6 +3445,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + [[package]] name = "noop_proc_macro" version = "0.3.0" @@ -3457,7 +3466,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "crossbeam-channel", "filetime", "fsevent-sys", @@ -3548,7 +3557,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -3622,7 +3631,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -3674,7 +3683,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -3690,7 +3699,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "libc", "objc2 0.6.3", @@ -3711,7 +3720,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69282c2b5bc58fba07cb9de2113619532eb551e98efe3d8d695509ef45fbd53b" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "libc", "objc2 0.6.3", "objc2-core-foundation", @@ -3726,7 +3735,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", @@ -3739,7 +3748,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "objc2 0.6.3", "objc2-foundation 0.3.2", ] @@ -3761,7 +3770,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -3773,7 +3782,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "objc2 0.6.3", "objc2-foundation 0.3.2", ] @@ -3784,7 +3793,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "dispatch2", "libc", @@ -3797,7 +3806,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "dispatch2", "libc", @@ -3847,7 +3856,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583300ad934cba24ff5292aee751ecc070f7ca6b39a574cc21b7b5e588e06a0b" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "dispatch2", "libc", @@ -3862,7 +3871,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "objc2 0.6.3", "objc2-core-foundation", "objc2-core-graphics", @@ -3874,7 +3883,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "objc2 0.6.3", "objc2-core-foundation", @@ -3895,7 +3904,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "dispatch", "libc", @@ -3908,7 +3917,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "libc", "objc2 0.6.3", @@ -3931,7 +3940,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "objc2 0.6.3", "objc2-core-foundation", ] @@ -3954,7 +3963,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -3966,7 +3975,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "objc2 0.6.3", "objc2-foundation 0.3.2", ] @@ -3977,7 +3986,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -3990,7 +3999,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.6.2", "libc", "objc2 0.6.3", @@ -4007,7 +4016,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "objc2 0.6.3", "objc2-core-foundation", ] @@ -4028,7 +4037,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "objc2 0.5.2", "objc2-cloud-kit 0.2.2", @@ -4060,7 +4069,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", @@ -4084,9 +4093,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "once_cell_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openssl" @@ -4094,7 +4103,7 @@ version = "0.10.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg-if", "foreign-types 0.3.2", "libc", @@ -4111,7 +4120,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -4337,7 +4346,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -4400,7 +4409,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97baced388464909d42d89643fe4361939af9b7ce7a31ee32a168f832a70f2a0" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "crc32fast", "fdeflate", "flate2", @@ -4468,9 +4477,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] @@ -4491,7 +4500,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -4814,7 +4823,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", ] [[package]] @@ -4856,7 +4865,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -4983,7 +4992,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys 0.4.15", @@ -4996,7 +5005,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys 0.11.0", @@ -5005,9 +5014,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.33" +version = "0.23.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c" +checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7" dependencies = [ "once_cell", "rustls-pki-types", @@ -5018,9 +5027,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" dependencies = [ "zeroize", ] @@ -5111,7 +5120,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5151,7 +5160,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -5195,7 +5204,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5206,7 +5215,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5242,7 +5251,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5277,9 +5286,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.15.0" +version = "3.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093cd8c01b25262b84927e0f7151692158fab02d961e04c979d3903eba7ecc5" +checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04" dependencies = [ "base64", "chrono", @@ -5297,14 +5306,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.15.0" +version = "3.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e6c180db0816026a61afa1cff5344fb7ebded7e4d3062772179f2501481c27" +checksum = "b91a903660542fced4e99881aa481bdbaec1634568ee02e0b8bd57c64cb38955" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5446,7 +5455,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "calloop", "calloop-wayland-source", "cursor-icon", @@ -5501,7 +5510,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", ] [[package]] @@ -5574,7 +5583,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5586,7 +5595,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5608,9 +5617,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.107" +version = "2.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" dependencies = [ "proc-macro2", "quote", @@ -5634,7 +5643,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5657,7 +5666,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -5749,7 +5758,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -5760,7 +5769,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -6006,7 +6015,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "bytes", "futures-util", "http", @@ -6061,7 +6070,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -6185,9 +6194,9 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-ident" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" [[package]] name = "unicode-segmentation" @@ -6357,7 +6366,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", "wasm-bindgen-shared", ] @@ -6392,7 +6401,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6426,7 +6435,7 @@ version = "0.31.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c66a47e840dc20793f2264eb4b3e4ecb4b75d91c0dd4af04b456128e0bdd449d" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "rustix 1.1.2", "wayland-backend", "wayland-scanner", @@ -6438,7 +6447,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cursor-icon", "wayland-backend", ] @@ -6460,7 +6469,7 @@ version = "0.32.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efa790ed75fbfd71283bd2521a1cfdc022aabcc28bdcff00851f9e4ae88d9901" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "wayland-backend", "wayland-client", "wayland-scanner", @@ -6472,7 +6481,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a07a14257c077ab3279987c4f8bb987851bf57081b93710381daea94f2c2c032" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6485,7 +6494,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efd94963ed43cf9938a090ca4f7da58eb55325ec8200c3848963e98dc25b78ec" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6564,7 +6573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8fb398f119472be4d80bc3647339f56eb63b2a331f6a3d16e25d8144197dd9" dependencies = [ "arrayvec", - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg_aliases", "document-features", "hashbrown 0.15.5", @@ -6594,7 +6603,7 @@ dependencies = [ "arrayvec", "bit-set", "bit-vec", - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg_aliases", "document-features", "hashbrown 0.15.5", @@ -6653,7 +6662,7 @@ dependencies = [ "arrayvec", "ash", "bit-set", - "bitflags 2.9.4", + "bitflags 2.10.0", "block", "bytemuck", "cfg-if", @@ -6696,7 +6705,7 @@ version = "25.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aa49460c2a8ee8edba3fca54325540d904dd85b2e086ada762767e17d06e8bc" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "bytemuck", "js-sys", "log", @@ -6825,7 +6834,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -6836,7 +6845,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -6847,7 +6856,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -6858,7 +6867,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -7264,7 +7273,7 @@ dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.9.4", + "bitflags 2.10.0", "block2 0.5.1", "bytemuck", "calloop", @@ -7372,7 +7381,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "dlib", "log", "once_cell", @@ -7420,7 +7429,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", "synstructure", ] @@ -7476,7 +7485,7 @@ checksum = "dc6821851fa840b708b4cbbaf6241868cabc85a2dc22f426361b0292bfc0b836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", "zbus-lockstep", "zbus_xml", "zvariant", @@ -7491,7 +7500,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", "zbus_names", "zvariant", "zvariant_utils", @@ -7539,7 +7548,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -7559,7 +7568,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", "synstructure", ] @@ -7599,7 +7608,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", ] [[package]] @@ -7649,7 +7658,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.108", "zvariant_utils", ] @@ -7662,6 +7671,6 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.107", + "syn 2.0.108", "winnow", ] From b2dd82ba4d7291d0a2475062b7935d5d893d4d54 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 27 Oct 2025 08:20:00 -0700 Subject: [PATCH 134/305] ci(github): publish schema.json to a public gist --- .github/workflows/nix.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index 96e4620c..51741a91 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -35,6 +35,12 @@ jobs: path: | result/bin/komorebi* retention-days: 90 + - if: ${{ github.repository == 'KomoCorp/komorebi-for-mac' }} + uses: exuanbo/actions-deploy-gist@v1 + with: + token: ${{ secrets.GH_USER_API_TOKEN }} + gist_id: 78b3dd12a7b7069f1d1c60621fe50730 + file_path: schema.json - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} run: echo "VERSION=nightly" >> $GITHUB_ENV - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} From e16a885a5ea84f675a2bb6352bba8c7249acd2b9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 27 Oct 2025 08:28:53 -0700 Subject: [PATCH 135/305] feat(config): add border radius option This commit adds a border_radius configuratino option which defaults to 10, which matches the uniform radius on Sequoia. Tahoe is a mess, but people can at least specify their own preferred border radius value now. Eventually we should look up the radius of each individual window when creating the borders like JankyBorders does (I think?) --- komorebi/src/static_config.rs | 7 ++++++- schema.json | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index f2dc18cc..b2a51846 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -425,7 +425,10 @@ pub struct StaticConfig { #[serde(skip_serializing_if = "Option::is_none")] #[serde(alias = "active_window_border_offset")] pub border_offset: Option, - /// Display an active window border (default: true) + /// Radius of the window border (default: 10) + #[serde(skip_serializing_if = "Option::is_none")] + pub border_radius: Option, + /// Display window borders (default: true) #[serde(skip_serializing_if = "Option::is_none")] #[serde(alias = "active_window_border")] pub border: Option, @@ -754,6 +757,7 @@ impl From<&WindowManager> for StaticConfig { app_specific_configuration_path: None, border_width: Option::from(border_manager::BORDER_WIDTH.load(Ordering::SeqCst)), border_offset: Option::from(border_manager::BORDER_OFFSET.load(Ordering::SeqCst)), + border_radius: Option::from(border_manager::BORDER_RADIUS.load(Ordering::SeqCst)), border: Option::from(border_manager::BORDER_ENABLED.load(Ordering::SeqCst)), border_colours, // transparency: Option::from( @@ -881,6 +885,7 @@ impl StaticConfig { border_manager::BORDER_WIDTH.store(self.border_width.unwrap_or(6), Ordering::SeqCst); border_manager::BORDER_OFFSET.store(self.border_offset.unwrap_or(5), Ordering::SeqCst); + border_manager::BORDER_RADIUS.store(self.border_radius.unwrap_or(10), Ordering::SeqCst); border_manager::BORDER_ENABLED.store(self.border.unwrap_or(true), Ordering::SeqCst); if let Some(colours) = &self.border_colours { diff --git a/schema.json b/schema.json index 442b7857..9b42c2a5 100644 --- a/schema.json +++ b/schema.json @@ -21,7 +21,7 @@ ] }, "border": { - "description": "Display an active window border (default: true)", + "description": "Display window borders (default: true)", "type": "boolean" }, "border_colours": { @@ -352,6 +352,11 @@ ] } }, + "border_radius": { + "description": "Radius of the window border (default: 10)", + "type": "integer", + "format": "int32" + }, "border_width": { "description": "Width of the window border (default: 6)", "type": "integer", From fc9659d116b845f2eef608536310f7c141679d08 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 27 Oct 2025 08:38:43 -0700 Subject: [PATCH 136/305] build(github): only publish gist from master branch --- .github/workflows/nix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index 51741a91..b8e415bf 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -35,7 +35,7 @@ jobs: path: | result/bin/komorebi* retention-days: 90 - - if: ${{ github.repository == 'KomoCorp/komorebi-for-mac' }} + - if: ${{ github.ref == 'refs/heads/master' && github.repository == 'KomoCorp/komorebi-for-mac' }} uses: exuanbo/actions-deploy-gist@v1 with: token: ${{ secrets.GH_USER_API_TOKEN }} From 2ecc2819ec27efde5036eda0cc1ae5e6a4dc1443 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 27 Oct 2025 09:22:46 -0700 Subject: [PATCH 137/305] feat(wm): order borders relative to tracking windows --- komorebi/src/border_manager/border.rs | 2 +- komorebi/src/border_manager/ns_window.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/komorebi/src/border_manager/border.rs b/komorebi/src/border_manager/border.rs index e933cfaa..984696bf 100644 --- a/komorebi/src/border_manager/border.rs +++ b/komorebi/src/border_manager/border.rs @@ -117,7 +117,7 @@ impl Border { monitor_idx, observer: observer.clone(), tracking_element: element.clone(), - ns_window: NsWindow::new(ns_rect)?, + ns_window: NsWindow::new(ns_rect, tracking_window_id)?, window_kind: WindowKind::Unfocused, }); diff --git a/komorebi/src/border_manager/ns_window.rs b/komorebi/src/border_manager/ns_window.rs index b43dde86..dee7d339 100644 --- a/komorebi/src/border_manager/ns_window.rs +++ b/komorebi/src/border_manager/ns_window.rs @@ -7,6 +7,7 @@ use dispatch2::DispatchQueue; use komorebi_themes::colour::Rgb; use objc2::MainThreadMarker; use objc2::MainThreadOnly; +use objc2::ffi::NSInteger; use objc2::msg_send; use objc2::rc::Retained; use objc2::rc::autoreleasepool; @@ -17,6 +18,7 @@ use objc2_app_kit::NSView; use objc2_app_kit::NSWindow; use objc2_app_kit::NSWindowAnimationBehavior; use objc2_app_kit::NSWindowCollectionBehavior; +use objc2_app_kit::NSWindowOrderingMode; use objc2_app_kit::NSWindowStyleMask; use objc2_core_graphics::CGColor; use objc2_foundation::NSDictionary; @@ -35,7 +37,7 @@ pub struct NsWindow { unsafe impl Send for NsWindow {} impl NsWindow { - pub fn new(ns_rect: NSRect) -> eyre::Result { + pub fn new(ns_rect: NSRect, target_window_id: u32) -> eyre::Result { let offset = BORDER_OFFSET.load(Ordering::Relaxed) as f64; let mut ns_rect = ns_rect; @@ -121,6 +123,7 @@ impl NsWindow { window.setContentView(Some(&content_view)); window.setMovableByWindowBackground(false); window.makeKeyAndOrderFront(None); + window.orderWindow_relativeTo(NSWindowOrderingMode::Below, NSInteger::from(target_window_id as i16)); if let Err(error) = tx.send(NsWindow { window, layer }) { tracing::error!("could not send NSWindow created for border: {error}") } From 202238aecd04028a42e08852250c1395bfeef396 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 27 Oct 2025 12:06:59 -0700 Subject: [PATCH 138/305] docs(mkdocs): add homebrew installation instructions --- docs/example-configurations.md | 5 ++- docs/installation.md | 74 +++++++++++++++++++++++++++++++++- docs/komorebi.example.json | 2 +- komorebic/src/main.rs | 6 ++- 4 files changed, 81 insertions(+), 6 deletions(-) diff --git a/docs/example-configurations.md b/docs/example-configurations.md index 507d87ad..973ff6ce 100644 --- a/docs/example-configurations.md +++ b/docs/example-configurations.md @@ -19,8 +19,9 @@ komorebic quickstart ### Granting Permissions -The `quickstart` command will also prompt you to grant komorebi the permissions -it requires to run, and will open the following System Settings tabs for you: +The `quickstart` command will also prompt you to grant komorebi and the terminal +emulator you are start komorebi with the permissions it requires to run, and +will open the following System Settings tabs for you: * Settings -> Privacy & Security -> Accessibility * Settings -> Privacy & Security -> Screen & System Audio Recording diff --git a/docs/installation.md b/docs/installation.md index 9788e221..c8b3512d 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -16,7 +16,12 @@ using keyboard shortcuts. ## Installation -At this time users must compile `komorebi` from source. +Nightly builds are available to install +via [Homebrew](https://github.com/LGUG2Z/homebrew-tap), and you may also build +from source if you would prefer. + +- [Homebrew](#homebrew) +- [Building from source](#building-from-source) ## System settings suggestions @@ -32,6 +37,73 @@ monitor which it was launched on. Go to `System Settings -> Desktop & Dock -> Mission Control -> Group windows by application` and disable this option if you like to use mission control. +## Homebrew + +First add the `lgug2z/tap` Homebrew Tap + +```shell +brew tap lgug2z/tap +``` + +Then install the `komorebi-for-mac-nightly` package + +```shell +brew install lgug2z/tap/komorebi-for-mac-nightly +``` + +You may also optionally install the `skhd` package + +```shell +brew install skhd +``` + +## Nix Flake + +Ensure that your system Flake is configured to use your GitHub token so that you can add a private repository as an input + +```nix +{ + nix = { + settings = { + access-tokens = [ + "github.com=YOUR ACCESS TOKEN" + ]; + }; + }; +} +``` + +Add the repository as an input + +```nix +{ + inputs.komorebi-for-mac.url = "github:KomoCorp/komorebi-for-mac"; +} +``` + +Add the overlay to your system's nixpkgs configuration + +```nix +{ + pkgs = import nixpkgs { + inherit system; + overlays = [ komorebi-for-mac.overlays.default ]; + # the rest of your pkgs configuration + }; +} +``` + +Add `pkgs.komorebi-full` to `environment.systemPackages` (you may also add +`pkgs.komorebi`, `pkgs.komorebic` and `pkgs.komorebi-bar` individually) + +```nix +{ + environment.systemPackages = [ + pkgs.komorebi-full + ]; +} +``` + ## Building from source Make sure you have installed [`rustup`](https://rustup.rs), and a stable `rust` diff --git a/docs/komorebi.example.json b/docs/komorebi.example.json index 8b0ec992..b4338193 100644 --- a/docs/komorebi.example.json +++ b/docs/komorebi.example.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.38/schema.json", + "$schema": "https://gist.githubusercontent.com/LGUG2Z/78b3dd12a7b7069f1d1c60621fe50730/raw", "app_specific_configuration_path": "$HOME/.config/komorebi/applications.json", "cross_monitor_move_behaviour": "Insert", "default_workspace_padding": 15, diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index db404e40..217f6cbc 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1302,8 +1302,10 @@ fn main() -> eyre::Result<()> { current_exe.pop(); let komorebi_exe = current_exe.join("komorebi"); + let term_program = std::env::var("TERM_PROGRAM").unwrap_or_default(); + println!( - "\nPlease grant Accessibility permissions to \"{}\"", + "\nPlease grant Accessibility permissions to \"{}\" and \"{term_program}\"", komorebi_exe.display() ); println!("Accessibility permissions are required for komorebi to to manage windows"); @@ -1319,7 +1321,7 @@ fn main() -> eyre::Result<()> { std::io::stdin().read_line(&mut input)?; println!( - "Please grant Screen Recording permissions to \"{}\"", + "Please grant Screen Recording permissions to \"{}\" and \"{term_program}\"", komorebi_exe.display() ); println!( From 9dbae50909b189e1e1a46f2d1c066cbb83783dd1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 27 Oct 2025 16:46:09 -0700 Subject: [PATCH 139/305] feat(wm): add a splash screen for mdm devices A little nudge for people to do the right thing, 1990s vibes. --- Cargo.lock | 341 +++++++++++++++++++++++++-------- dependencies.json | 201 ++++++++++--------- docs/cli/border-colour.md | 26 +++ docs/cli/border-offset.md | 16 ++ docs/cli/border-width.md | 16 ++ docs/cli/border.md | 16 ++ docs/cli/completions.md | 16 ++ docs/cli/license.md | 16 ++ docs/cli/start.md | 3 + docs/cli/stop.md | 5 +- docs/example-configurations.md | 17 +- justfile | 8 +- komorebi-client/src/lib.rs | 1 + komorebi/Cargo.toml | 6 +- komorebi/src/lib.rs | 23 ++- komorebi/src/main.rs | 10 +- komorebi/src/process_event.rs | 21 ++ komorebi/src/splash.rs | 210 ++++++++++++++++++++ komorebic/src/main.rs | 64 ++++++- mkdocs.yml | 6 + 20 files changed, 831 insertions(+), 191 deletions(-) create mode 100644 docs/cli/border-colour.md create mode 100644 docs/cli/border-offset.md create mode 100644 docs/cli/border-width.md create mode 100644 docs/cli/border.md create mode 100644 docs/cli/completions.md create mode 100644 docs/cli/license.md create mode 100644 komorebi/src/splash.rs diff --git a/Cargo.lock b/Cargo.lock index ca0b2307..bbe798f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -600,12 +600,24 @@ dependencies = [ "serde", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" + [[package]] name = "beef" version = "0.5.2" @@ -660,6 +672,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "block2" version = "0.5.1" @@ -1035,6 +1056,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const_format" version = "0.2.35" @@ -1130,6 +1157,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.5.0" @@ -1179,6 +1215,16 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "ctrlc" version = "3.5.0" @@ -1196,6 +1242,33 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + [[package]] name = "darling" version = "0.21.3" @@ -1241,6 +1314,16 @@ dependencies = [ "byteorder", ] +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "deranged" version = "0.5.5" @@ -1251,6 +1334,16 @@ dependencies = [ "serde_core", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dirs" version = "3.0.2" @@ -1393,6 +1486,30 @@ dependencies = [ "emath", ] +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "serde", + "sha2", + "subtle", + "zeroize", +] + [[package]] name = "eframe" version = "0.32.3" @@ -1722,6 +1839,12 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "file-id" version = "0.1.0" @@ -1967,6 +2090,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "gethostname" version = "1.1.0" @@ -2397,7 +2530,7 @@ version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "futures-channel", "futures-core", @@ -2453,9 +2586,9 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" dependencies = [ "displaydoc", "potential_utf", @@ -2466,9 +2599,9 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" dependencies = [ "displaydoc", "litemap", @@ -2479,11 +2612,10 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" dependencies = [ - "displaydoc", "icu_collections", "icu_normalizer_data", "icu_properties", @@ -2494,42 +2626,38 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] name = "icu_properties" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" dependencies = [ - "displaydoc", "icu_collections", "icu_locale_core", "icu_properties_data", "icu_provider", - "potential_utf", "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" +checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" [[package]] name = "icu_provider" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" dependencies = [ "displaydoc", "icu_locale_core", - "stable_deref_trait", - "tinystr", "writeable", "yoke", "zerofrom", @@ -2769,9 +2897,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.81" +version = "0.3.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305" +checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" dependencies = [ "once_cell", "wasm-bindgen", @@ -2798,7 +2926,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" name = "komorebi" version = "0.1.0" dependencies = [ + "base64 0.21.7", "block2 0.6.2", + "chrono", "clap", "color-eyre", "crossbeam-channel", @@ -2806,6 +2936,7 @@ dependencies = [ "ctrlc", "dirs 6.0.0", "dispatch2", + "ed25519-dalek", "hotwatch", "komorebi-themes", "lazy_static", @@ -2823,6 +2954,7 @@ dependencies = [ "pastey", "quickxml_to_serde", "regex", + "reqwest", "schemars 0.8.22", "serde", "serde_json_lenient", @@ -3045,9 +3177,9 @@ checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "litemap" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" [[package]] name = "litrs" @@ -3114,9 +3246,9 @@ dependencies = [ [[package]] name = "mach2" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +checksum = "6a1b95cd5421ec55b445b5ae102f5ea0e768de1f82bd3001e11f426c269c3aea" dependencies = [ "libc", ] @@ -3263,9 +3395,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692af879e4d9383c0fd9dec15524af6b6977c8bf1c6b278a4526d5341347c574" +checksum = "0fbdd3d7436f8b5e892b8b7ea114271ff0fa00bc5acae845d53b07d498616ef6" dependencies = [ "num-traits", "pxfm", @@ -4372,6 +4504,16 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.32" @@ -4380,11 +4522,11 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plist" -version = "1.7.4" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3af6b589e163c5a788fab00ce0c0366f6efbb9959c2f9874b224936af7fce7e1" +checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" dependencies = [ - "base64", + "base64 0.22.1", "indexmap 2.12.0", "quick-xml 0.38.3", "serde", @@ -4438,9 +4580,9 @@ checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] name = "potential_utf" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" dependencies = [ "zerovec", ] @@ -4909,7 +5051,7 @@ version = "0.12.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "encoding_rs", "futures-channel", @@ -4986,6 +5128,15 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.38.44" @@ -5036,9 +5187,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.7" +version = "0.103.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" dependencies = [ "ring", "rustls-pki-types", @@ -5177,6 +5328,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + [[package]] name = "serde" version = "1.0.228" @@ -5237,6 +5394,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e033097bf0d2b59a62b42c18ebbb797503839b26afdda2c4e1415cb6c813540" dependencies = [ + "indexmap 2.12.0", "itoa", "memchr", "ryu", @@ -5290,7 +5448,7 @@ version = "3.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04" dependencies = [ - "base64", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", @@ -5349,6 +5507,17 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shadow-rs" version = "1.4.0" @@ -5401,6 +5570,15 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -5513,6 +5691,16 @@ dependencies = [ "bitflags 2.10.0", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -5521,9 +5709,9 @@ checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "starship-battery" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b781e3db6801873ce18c19041da668920c46223cdc7059ea20e2f8fe1ba85a2" +checksum = "fd0efc2c44c92705be724265a0c758e3b7c120ea63817d2d684bab86fbeced9a" dependencies = [ "cfg-if", "core-foundation 0.10.1", @@ -5534,7 +5722,7 @@ dependencies = [ "num-traits", "plist", "uom", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -5866,9 +6054,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" dependencies = [ "displaydoc", "zerovec", @@ -6345,9 +6533,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" +checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" dependencies = [ "cfg-if", "once_cell", @@ -6356,25 +6544,11 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn 2.0.108", - "wasm-bindgen-shared", -] - [[package]] name = "wasm-bindgen-futures" -version = "0.4.54" +version = "0.4.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c" +checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" dependencies = [ "cfg-if", "js-sys", @@ -6385,9 +6559,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119" +checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6395,22 +6569,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" +checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn 2.0.108", - "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1" +checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" dependencies = [ "unicode-ident", ] @@ -6526,9 +6700,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.81" +version = "0.3.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120" +checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" dependencies = [ "js-sys", "wasm-bindgen", @@ -7333,9 +7507,9 @@ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "writeable" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" [[package]] name = "x11-dl" @@ -7396,9 +7570,9 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" [[package]] name = "xml-rs" -version = "0.8.27" +version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd8403733700263c6eb89f192880191f1b83e332f7a20371ddcf421c4a337c7" +checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" [[package]] name = "yaml-rust" @@ -7411,11 +7585,10 @@ dependencies = [ [[package]] name = "yoke" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" dependencies = [ - "serde", "stable_deref_trait", "yoke-derive", "zerofrom", @@ -7423,9 +7596,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", @@ -7580,9 +7753,9 @@ checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" [[package]] name = "zerotrie" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" dependencies = [ "displaydoc", "yoke", @@ -7591,9 +7764,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" dependencies = [ "yoke", "zerofrom", @@ -7602,9 +7775,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", diff --git a/dependencies.json b/dependencies.json index 804332c7..29afd345 100644 --- a/dependencies.json +++ b/dependencies.json @@ -32,24 +32,26 @@ "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", + "base64 0.21.7 registry+https://github.com/rust-lang/crates.io-index", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", - "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "bitflags 2.10.0 registry+https://github.com/rust-lang/crates.io-index", "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", + "block-buffer 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.41 registry+https://github.com/rust-lang/crates.io-index", - "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.43 registry+https://github.com/rust-lang/crates.io-index", + "cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", - "clap_complete 4.5.58 registry+https://github.com/rust-lang/crates.io-index", - "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", - "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.50 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.50 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.59 registry+https://github.com/rust-lang/crates.io-index", + "clap_derive 4.5.49 registry+https://github.com/rust-lang/crates.io-index", + "clap_lex 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "colorchoice 1.0.4 registry+https://github.com/rust-lang/crates.io-index", @@ -60,15 +62,18 @@ "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "core-text 19.2.0 registry+https://github.com/rust-lang/crates.io-index", + "cpufeatures 0.2.17 registry+https://github.com/rust-lang/crates.io-index", "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", + "crypto-common 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "deflate 0.8.6 registry+https://github.com/rust-lang/crates.io-index", - "deranged 0.5.4 registry+https://github.com/rust-lang/crates.io-index", + "deranged 0.5.5 registry+https://github.com/rust-lang/crates.io-index", + "digest 0.10.7 registry+https://github.com/rust-lang/crates.io-index", "dirs 3.0.2 registry+https://github.com/rust-lang/crates.io-index", "dirs 4.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", @@ -76,11 +81,12 @@ "dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index", - "document-features 0.2.11 registry+https://github.com/rust-lang/crates.io-index", + "document-features 0.2.12 registry+https://github.com/rust-lang/crates.io-index", "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", "ecolor 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "ed25519 2.2.3 registry+https://github.com/rust-lang/crates.io-index", "eframe 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "egui 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "egui-phosphor 0.10.0 registry+https://github.com/rust-lang/crates.io-index", @@ -89,7 +95,6 @@ "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", "emath 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "env_home 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "epaint 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", @@ -99,7 +104,7 @@ "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "find-msvc-tools 0.1.4 registry+https://github.com/rust-lang/crates.io-index", - "flate2 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "flate2 1.1.5 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -114,7 +119,7 @@ "futures-util 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.1.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", - "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", "gif 0.13.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", @@ -122,7 +127,7 @@ "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "glutin 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "half 2.7.0 registry+https://github.com/rust-lang/crates.io-index", + "half 2.7.1 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", @@ -142,11 +147,11 @@ "imgref 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", - "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 2.12.0 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", - "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", + "is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index", "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", @@ -156,18 +161,18 @@ "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", - "litrs 0.4.2 registry+https://github.com/rust-lang/crates.io-index", + "litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", - "mach2 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "mach2 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "mime 0.3.17 registry+https://github.com/rust-lang/crates.io-index", "minimal-lexical 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.7 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.9 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", @@ -212,7 +217,7 @@ "png 0.18.0 registry+https://github.com/rust-lang/crates.io-index", "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", - "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", + "proc-macro2 1.0.103 registry+https://github.com/rust-lang/crates.io-index", "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", "profiling-procmacros 1.0.17 registry+https://github.com/rust-lang/crates.io-index", "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", @@ -232,17 +237,19 @@ "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", - "regex 1.12.1 registry+https://github.com/rust-lang/crates.io-index", - "regex-automata 0.4.12 registry+https://github.com/rust-lang/crates.io-index", - "regex-syntax 0.8.7 registry+https://github.com/rust-lang/crates.io-index", - "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.12.2 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.13 registry+https://github.com/rust-lang/crates.io-index", + "regex-syntax 0.8.8 registry+https://github.com/rust-lang/crates.io-index", + "reqwest 0.12.24 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "rustc_version 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", - "rustls-pki-types 1.12.0 registry+https://github.com/rust-lang/crates.io-index", + "rustls-pki-types 1.13.0 registry+https://github.com/rust-lang/crates.io-index", "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", "security-framework-sys 2.15.0 registry+https://github.com/rust-lang/crates.io-index", + "semver 1.0.27 registry+https://github.com/rust-lang/crates.io-index", "serde 1.0.228 registry+https://github.com/rust-lang/crates.io-index", "serde_core 1.0.228 registry+https://github.com/rust-lang/crates.io-index", "serde_derive 1.0.228 registry+https://github.com/rust-lang/crates.io-index", @@ -251,22 +258,24 @@ "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.15.0 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.15.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.15.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.15.1 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", + "sha2 0.10.9 registry+https://github.com/rust-lang/crates.io-index", "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "signature 2.2.0 registry+https://github.com/rust-lang/crates.io-index", "siphasher 0.3.11 registry+https://github.com/rust-lang/crates.io-index", "siphasher 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", - "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "socket2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", - "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.108 registry+https://github.com/rust-lang/crates.io-index", "sync_wrapper 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", @@ -286,7 +295,7 @@ "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.20 registry+https://github.com/rust-lang/crates.io-index", "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", "uom 0.37.0 registry+https://github.com/rust-lang/crates.io-index", @@ -296,7 +305,7 @@ "vcpkg 0.2.15 registry+https://github.com/rust-lang/crates.io-index", "version_check 0.9.5 registry+https://github.com/rust-lang/crates.io-index", "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", - "webbrowser 1.0.5 registry+https://github.com/rust-lang/crates.io-index", + "webbrowser 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "weezl 0.1.10 registry+https://github.com/rust-lang/crates.io-index", "winit 0.30.12 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", @@ -324,8 +333,8 @@ [ "BSD-2-Clause", [ - "av1-grain 0.2.4 registry+https://github.com/rust-lang/crates.io-index", - "mach2 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "av1-grain 0.2.5 registry+https://github.com/rust-lang/crates.io-index", + "mach2 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "rav1e 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "v_frame 0.3.9 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", @@ -340,12 +349,15 @@ "avif-serialize 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "brotli 8.0.2 registry+https://github.com/rust-lang/crates.io-index", "brotli-decompressor 5.0.0 registry+https://github.com/rust-lang/crates.io-index", + "curve25519-dalek 4.1.3 registry+https://github.com/rust-lang/crates.io-index", + "ed25519-dalek 2.2.0 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", "exr 1.73.0 registry+https://github.com/rust-lang/crates.io-index", "lebe 0.5.3 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.7 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.9 registry+https://github.com/rust-lang/crates.io-index", "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", - "ravif 0.11.20 registry+https://github.com/rust-lang/crates.io-index" + "ravif 0.11.20 registry+https://github.com/rust-lang/crates.io-index", + "subtle 2.6.1 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -368,7 +380,7 @@ "ISC", [ "libloading 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "starship-battery 0.10.2 registry+https://github.com/rust-lang/crates.io-index" + "starship-battery 0.10.3 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -395,14 +407,14 @@ "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", + "base64 0.21.7 registry+https://github.com/rust-lang/crates.io-index", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", - "bitflags 2.9.4 registry+https://github.com/rust-lang/crates.io-index", + "bitflags 2.10.0 registry+https://github.com/rust-lang/crates.io-index", "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", - "block-sys 0.2.1 registry+https://github.com/rust-lang/crates.io-index", - "block2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", + "block-buffer 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "block2 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "block2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "brotli 8.0.2 registry+https://github.com/rust-lang/crates.io-index", @@ -416,17 +428,17 @@ "calm_io 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "calmio_filters 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "catppuccin-egui 5.6.0 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.41 registry+https://github.com/rust-lang/crates.io-index", - "cfg-if 1.0.3 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.43 registry+https://github.com/rust-lang/crates.io-index", + "cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.48 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.48 registry+https://github.com/rust-lang/crates.io-index", - "clap_complete 4.5.58 registry+https://github.com/rust-lang/crates.io-index", - "clap_derive 4.5.47 registry+https://github.com/rust-lang/crates.io-index", - "clap_lex 0.7.5 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.50 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.50 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.59 registry+https://github.com/rust-lang/crates.io-index", + "clap_derive 4.5.49 registry+https://github.com/rust-lang/crates.io-index", + "clap_lex 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", "color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "color-thief 0.2.2 registry+https://github.com/rust-lang/crates.io-index", @@ -439,18 +451,21 @@ "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "core-text 19.2.0 registry+https://github.com/rust-lang/crates.io-index", + "cpufeatures 0.2.17 registry+https://github.com/rust-lang/crates.io-index", "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", + "crypto-common 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "darling 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "darling_core 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "darling_macro 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "deflate 0.8.6 registry+https://github.com/rust-lang/crates.io-index", - "deranged 0.5.4 registry+https://github.com/rust-lang/crates.io-index", + "deranged 0.5.5 registry+https://github.com/rust-lang/crates.io-index", + "digest 0.10.7 registry+https://github.com/rust-lang/crates.io-index", "dirs 3.0.2 registry+https://github.com/rust-lang/crates.io-index", "dirs 4.0.0 registry+https://github.com/rust-lang/crates.io-index", "dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index", @@ -459,10 +474,11 @@ "dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "dispatch2 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index", - "document-features 0.2.11 registry+https://github.com/rust-lang/crates.io-index", + "document-features 0.2.12 registry+https://github.com/rust-lang/crates.io-index", "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", "ecolor 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "ed25519 2.2.3 registry+https://github.com/rust-lang/crates.io-index", "eframe 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "egui 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "egui-phosphor 0.10.0 registry+https://github.com/rust-lang/crates.io-index", @@ -471,7 +487,6 @@ "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", "emath 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "env_home 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "epaint 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "equator 0.4.2 registry+https://github.com/rust-lang/crates.io-index", @@ -485,7 +500,7 @@ "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", "find-msvc-tools 0.1.4 registry+https://github.com/rust-lang/crates.io-index", - "flate2 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "flate2 1.1.5 registry+https://github.com/rust-lang/crates.io-index", "flavours 0.7.2 git+https://github.com/LGUG2Z/flavours", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "font-loader 0.11.0 registry+https://github.com/rust-lang/crates.io-index", @@ -502,9 +517,10 @@ "futures-sink 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-task 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-util 0.3.31 registry+https://github.com/rust-lang/crates.io-index", + "generic-array 0.14.9 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.1.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", - "getrandom 0.3.3 registry+https://github.com/rust-lang/crates.io-index", + "getrandom 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", "gif 0.13.3 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", @@ -513,7 +529,7 @@ "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "glutin-winit 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "h2 0.4.12 registry+https://github.com/rust-lang/crates.io-index", - "half 2.7.0 registry+https://github.com/rust-lang/crates.io-index", + "half 2.7.1 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", @@ -538,11 +554,11 @@ "image-webp 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", - "indexmap 2.11.4 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 2.12.0 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", - "is_terminal_polyfill 1.70.1 registry+https://github.com/rust-lang/crates.io-index", + "is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index", "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", @@ -552,14 +568,14 @@ "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", - "litrs 0.4.2 registry+https://github.com/rust-lang/crates.io-index", + "litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "loop9 0.1.5 registry+https://github.com/rust-lang/crates.io-index", - "mach2 0.4.3 registry+https://github.com/rust-lang/crates.io-index", + "mach2 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "maybe-rayon 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "memchr 2.7.6 registry+https://github.com/rust-lang/crates.io-index", @@ -569,14 +585,15 @@ "miniz_oxide 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "mio 1.0.4 registry+https://github.com/rust-lang/crates.io-index", + "mio 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "nanoid 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", - "netdev 0.36.0 registry+https://github.com/rust-lang/crates.io-index", + "netdev 0.38.2 registry+https://github.com/rust-lang/crates.io-index", "new_debug_unreachable 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "nom 7.1.3 registry+https://github.com/rust-lang/crates.io-index", + "nom 8.0.0 registry+https://github.com/rust-lang/crates.io-index", "noop_proc_macro 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "nu-ansi-term 0.50.3 registry+https://github.com/rust-lang/crates.io-index", "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", @@ -591,7 +608,6 @@ "num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index", "num_threads 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "objc-sys 0.3.5 registry+https://github.com/rust-lang/crates.io-index", - "objc2 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "objc2 0.6.3 registry+https://github.com/rust-lang/crates.io-index", "objc2-app-kit 0.2.2 registry+https://github.com/rust-lang/crates.io-index", @@ -605,7 +621,6 @@ "objc2-core-services 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-text 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-core-video 0.3.2 registry+https://github.com/rust-lang/crates.io-index", - "objc2-encode 3.0.0 registry+https://github.com/rust-lang/crates.io-index", "objc2-encode 4.1.0 registry+https://github.com/rust-lang/crates.io-index", "objc2-foundation 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index", @@ -636,13 +651,12 @@ "png 0.18.0 registry+https://github.com/rust-lang/crates.io-index", "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "ppv-lite86 0.2.21 registry+https://github.com/rust-lang/crates.io-index", - "proc-macro2 1.0.101 registry+https://github.com/rust-lang/crates.io-index", + "proc-macro2 1.0.103 registry+https://github.com/rust-lang/crates.io-index", "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", "profiling-procmacros 1.0.17 registry+https://github.com/rust-lang/crates.io-index", "qoi 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", - "quick-xml 0.38.3 registry+https://github.com/rust-lang/crates.io-index", "quickxml_to_serde 0.6.1 git+https://github.com/LGUG2Z/quickxml_to_serde.git", "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", @@ -659,14 +673,15 @@ "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", - "regex 1.12.1 registry+https://github.com/rust-lang/crates.io-index", - "regex-automata 0.4.12 registry+https://github.com/rust-lang/crates.io-index", - "regex-syntax 0.8.7 registry+https://github.com/rust-lang/crates.io-index", - "reqwest 0.12.23 registry+https://github.com/rust-lang/crates.io-index", + "regex 1.12.2 registry+https://github.com/rust-lang/crates.io-index", + "regex-automata 0.4.13 registry+https://github.com/rust-lang/crates.io-index", + "regex-syntax 0.8.8 registry+https://github.com/rust-lang/crates.io-index", + "reqwest 0.12.24 registry+https://github.com/rust-lang/crates.io-index", "rgb 0.8.52 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", + "rustc_version 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", - "rustls-pki-types 1.12.0 registry+https://github.com/rust-lang/crates.io-index", + "rustls-pki-types 1.13.0 registry+https://github.com/rust-lang/crates.io-index", "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "schemars 0.8.22 registry+https://github.com/rust-lang/crates.io-index", "schemars_derive 0.8.22 registry+https://github.com/rust-lang/crates.io-index", @@ -674,6 +689,7 @@ "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", "security-framework-sys 2.15.0 registry+https://github.com/rust-lang/crates.io-index", + "semver 1.0.27 registry+https://github.com/rust-lang/crates.io-index", "serde 1.0.228 registry+https://github.com/rust-lang/crates.io-index", "serde_core 1.0.228 registry+https://github.com/rust-lang/crates.io-index", "serde_derive 1.0.228 registry+https://github.com/rust-lang/crates.io-index", @@ -682,14 +698,16 @@ "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.15.0 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.15.0 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.15.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.15.1 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", + "sha2 0.10.9 registry+https://github.com/rust-lang/crates.io-index", "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", + "signature 2.2.0 registry+https://github.com/rust-lang/crates.io-index", "simd-adler32 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "simd_helpers 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "siphasher 0.3.11 registry+https://github.com/rust-lang/crates.io-index", @@ -697,14 +715,14 @@ "slab 0.4.11 registry+https://github.com/rust-lang/crates.io-index", "smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index", "smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index", - "socket2 0.6.0 registry+https://github.com/rust-lang/crates.io-index", + "socket2 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "strsim 0.11.1 registry+https://github.com/rust-lang/crates.io-index", "strum 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", - "syn 2.0.106 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.108 registry+https://github.com/rust-lang/crates.io-index", "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", "sysinfo 0.37.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", @@ -720,7 +738,7 @@ "tiff 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "time 0.3.44 registry+https://github.com/rust-lang/crates.io-index", "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", - "tokio 1.47.1 registry+https://github.com/rust-lang/crates.io-index", + "tokio 1.48.0 registry+https://github.com/rust-lang/crates.io-index", "tokio-native-tls 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "tokio-util 0.7.16 registry+https://github.com/rust-lang/crates.io-index", "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", @@ -741,7 +759,7 @@ "tz-rs 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.20 registry+https://github.com/rust-lang/crates.io-index", "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", "uom 0.37.0 registry+https://github.com/rust-lang/crates.io-index", @@ -753,9 +771,8 @@ "walkdir 2.5.0 registry+https://github.com/rust-lang/crates.io-index", "want 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", - "webbrowser 1.0.5 registry+https://github.com/rust-lang/crates.io-index", + "webbrowser 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "weezl 0.1.10 registry+https://github.com/rust-lang/crates.io-index", - "which 7.0.3 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index", @@ -795,25 +812,25 @@ [ "Unicode-3.0", [ - "icu_collections 2.0.0 registry+https://github.com/rust-lang/crates.io-index", - "icu_locale_core 2.0.0 registry+https://github.com/rust-lang/crates.io-index", - "icu_normalizer 2.0.0 registry+https://github.com/rust-lang/crates.io-index", - "icu_normalizer_data 2.0.0 registry+https://github.com/rust-lang/crates.io-index", - "icu_properties 2.0.1 registry+https://github.com/rust-lang/crates.io-index", - "icu_properties_data 2.0.1 registry+https://github.com/rust-lang/crates.io-index", - "icu_provider 2.0.0 registry+https://github.com/rust-lang/crates.io-index", - "litemap 0.8.0 registry+https://github.com/rust-lang/crates.io-index", - "potential_utf 0.1.3 registry+https://github.com/rust-lang/crates.io-index", - "tinystr 0.8.1 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.19 registry+https://github.com/rust-lang/crates.io-index", - "writeable 0.6.1 registry+https://github.com/rust-lang/crates.io-index", - "yoke 0.8.0 registry+https://github.com/rust-lang/crates.io-index", - "yoke-derive 0.8.0 registry+https://github.com/rust-lang/crates.io-index", + "icu_collections 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_locale_core 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_normalizer 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_normalizer_data 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_properties 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_properties_data 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_provider 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "litemap 0.8.1 registry+https://github.com/rust-lang/crates.io-index", + "potential_utf 0.1.4 registry+https://github.com/rust-lang/crates.io-index", + "tinystr 0.8.2 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "writeable 0.6.2 registry+https://github.com/rust-lang/crates.io-index", + "yoke 0.8.1 registry+https://github.com/rust-lang/crates.io-index", + "yoke-derive 0.8.1 registry+https://github.com/rust-lang/crates.io-index", "zerofrom 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "zerofrom-derive 0.1.6 registry+https://github.com/rust-lang/crates.io-index", - "zerotrie 0.2.2 registry+https://github.com/rust-lang/crates.io-index", - "zerovec 0.11.4 registry+https://github.com/rust-lang/crates.io-index", - "zerovec-derive 0.11.1 registry+https://github.com/rust-lang/crates.io-index" + "zerotrie 0.2.3 registry+https://github.com/rust-lang/crates.io-index", + "zerovec 0.11.5 registry+https://github.com/rust-lang/crates.io-index", + "zerovec-derive 0.11.2 registry+https://github.com/rust-lang/crates.io-index" ] ], [ diff --git a/docs/cli/border-colour.md b/docs/cli/border-colour.md new file mode 100644 index 00000000..170f7cf1 --- /dev/null +++ b/docs/cli/border-colour.md @@ -0,0 +1,26 @@ +# border-colour + +``` +Set the colour for a window border kind + +Usage: komorebic border-colour [OPTIONS] + +Arguments: + + Red + + + Green + + + Blue + +Options: + -w, --window-kind + [default: single] + [possible values: single, stack, monocle, unfocused, unfocused-locked, floating] + + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/border-offset.md b/docs/cli/border-offset.md new file mode 100644 index 00000000..a94674be --- /dev/null +++ b/docs/cli/border-offset.md @@ -0,0 +1,16 @@ +# border-offset + +``` +Set the border offset + +Usage: komorebic border-offset + +Arguments: + + Desired offset of the window border + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/border-width.md b/docs/cli/border-width.md new file mode 100644 index 00000000..d30cfbc6 --- /dev/null +++ b/docs/cli/border-width.md @@ -0,0 +1,16 @@ +# border-width + +``` +Set the border width + +Usage: komorebic border-width + +Arguments: + + Desired width of the window border + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/border.md b/docs/cli/border.md new file mode 100644 index 00000000..d88fb4a8 --- /dev/null +++ b/docs/cli/border.md @@ -0,0 +1,16 @@ +# border + +``` +Enable or disable borders + +Usage: komorebic border + +Arguments: + + [possible values: enable, disable] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/completions.md b/docs/cli/completions.md new file mode 100644 index 00000000..0f757a0f --- /dev/null +++ b/docs/cli/completions.md @@ -0,0 +1,16 @@ +# completions + +``` +Generate komorebic CLI completions for the target shell + +Usage: komorebic completions + +Arguments: + + [possible values: bash, elvish, fish, powershell, zsh] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/license.md b/docs/cli/license.md new file mode 100644 index 00000000..4a279841 --- /dev/null +++ b/docs/cli/license.md @@ -0,0 +1,16 @@ +# license + +``` +Specify an email associated with an Individual Commercial Use License + +Usage: komorebic license + +Arguments: + + Email address associated with an Individual Commercial Use License + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/start.md b/docs/cli/start.md index 144873d1..8c927f37 100644 --- a/docs/cli/start.md +++ b/docs/cli/start.md @@ -9,6 +9,9 @@ Options: -c, --config Path to a static configuration JSON file + --bar + Start komorebi-bar in a background process + -h, --help Print help diff --git a/docs/cli/stop.md b/docs/cli/stop.md index 29a02cd4..f99df376 100644 --- a/docs/cli/stop.md +++ b/docs/cli/stop.md @@ -3,9 +3,12 @@ ``` Stop the komorebi process and restore all hidden windows -Usage: komorebic stop +Usage: komorebic stop [OPTIONS] Options: + --bar + Stop komorebi-bar if it is running as a background process + -h, --help Print help diff --git a/docs/example-configurations.md b/docs/example-configurations.md index 973ff6ce..f01ce562 100644 --- a/docs/example-configurations.md +++ b/docs/example-configurations.md @@ -16,7 +16,6 @@ the example files have been downloaded. For most new users this will be in the komorebic quickstart ``` - ### Granting Permissions The `quickstart` command will also prompt you to grant komorebi and the terminal @@ -26,6 +25,19 @@ will open the following System Settings tabs for you: * Settings -> Privacy & Security -> Accessibility * Settings -> Privacy & Security -> Screen & System Audio Recording +### Corporate Devices Enrolled in MDM + +If you are using `komorebi` on a corporate device enrolled in mobile device +management, you will receive a pop-up when you run `komorebic start` reminding +you that the [Komorebi License](https://github.com/LGUG2Z/komorebi-license) does +not permit any kind of commercial use. + +You can remove this pop-up by running `komorebic license ` with the email +associated with your Individual Commercial Use License. A single HTTP request +will be sent with the given email address to verify license validity. + +## Starting komorebi + With the example configurations downloaded and permissions granted, you can now start `komorebi`: @@ -39,6 +51,9 @@ Alternatively, if you also want to start with the status bar, you can run: komorebic start --bar ``` +Before running the status bar, it is recommended to set the system's status bar +to autohide. + ## komorebi.json The example window manager configuration sets some sane defaults and provides diff --git a/justfile b/justfile index d51aed82..97516fb8 100644 --- a/justfile +++ b/justfile @@ -27,16 +27,16 @@ build target: run target: cargo +stable run --bin {{ target }} --locked -warn target $RUST_LOG="warn": +warn target $RUST_LOG="komorebi=warn": just run {{ target }} -info target $RUST_LOG="info": +info target $RUST_LOG="komorebi=info": just run {{ target }} -debug target $RUST_LOG="debug": +debug target $RUST_LOG="komorebi=debug": just run {{ target }} -trace target $RUST_LOG="trace": +trace target $RUST_LOG="komorebi=trace": just run {{ target }} deadlock $RUST_LOG="trace": diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 215fcae8..578e3fec 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -20,6 +20,7 @@ pub use komorebi::core::pathext::PathExt; pub use komorebi::core::pathext::replace_env_in_path; pub use komorebi::core::rect::Rect; pub use komorebi::monitor_reconciliator::MonitorNotification; +pub use komorebi::splash; pub use komorebi::state::State; pub use komorebi::static_config::KomorebiTheme; pub use komorebi::static_config::StaticConfig; diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 5136281f..2d87c3b1 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -8,14 +8,17 @@ edition = "2024" komorebi-themes = { workspace = true } quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } +base64 = "0.21" block2 = "0.6" clap = { workspace = true } +chrono = { workspace = true } color-eyre = { workspace = true } crossbeam-channel = { workspace = true } crossbeam-utils = { workspace = true } ctrlc = { version = "3", features = ["termination"] } dirs = { workspace = true } dispatch2 = "0.3" +ed25519-dalek = "2" hotwatch = { workspace = true } lazy_static = { workspace = true } nanoid = "0.4" @@ -34,9 +37,10 @@ objc2-quartz-core = "0.3" parking_lot = { workspace = true } pastey = { workspace = true } regex = "1" +reqwest = { version = "0.12", features = ["blocking"] } schemars = { workspace = true, optional = true } serde = { workspace = true } -serde_json = { workspace = true } +serde_json = { workspace = true, features = ["preserve_order"] } serde_with = { version = "3", features = ["schemars_0_8"] } shadow-rs = { workspace = true } strum = { version = "0.27", features = ["derive"] } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 408315f3..4a00c5d9 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -64,6 +64,7 @@ pub mod process_command; pub mod process_event; pub mod reaper; pub mod skylight; +pub mod splash; pub mod state; pub mod static_config; pub mod theme_manager; @@ -140,8 +141,11 @@ lazy_static! { "Finder".to_string(), "Ghostty".to_string() ])); - static ref DO_NOT_OBSERVE_APPLICATIONS: Arc>> = - Arc::new(Mutex::new(vec!["Spotlight".to_string(),])); + static ref DO_NOT_OBSERVE_APPLICATIONS: Arc>> = Arc::new(Mutex::new(vec![ + "Spotlight".to_string(), + "komorebi".to_string(), + "komorebic".to_string() + ])); static ref UNMANAGED_WINDOW_IDS: Arc>> = Arc::new(Mutex::new(vec![])); } @@ -150,6 +154,21 @@ shadow_rs::shadow!(build); pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(5); +pub const PUBLIC_KEY: [u8; 32] = [ + 0x5a, 0x69, 0x4a, 0xe1, 0x3c, 0x4b, 0xc8, 0x4e, 0xc3, 0x79, 0x0f, 0xab, 0x27, 0x6b, 0x7e, 0xdd, + 0x6b, 0x39, 0x6f, 0xa2, 0xc3, 0x9f, 0x3d, 0x48, 0xf2, 0x72, 0x56, 0x41, 0x1b, 0xc8, 0x08, 0xdb, +]; + +#[derive(Default, Debug, Clone, PartialEq, Deserialize)] +pub struct License { + #[serde(rename = "hasValidSubscription")] + pub has_valid_subscription: bool, + pub timestamp: i64, + #[serde(rename = "currentEndPeriod")] + pub current_end_period: Option, + pub signature: String, +} + #[must_use] pub fn current_space_id() -> Option { panic::catch_unwind(|| unsafe { skylight::CGSGetActiveSpace(skylight::CGSMainConnectionID()) }) diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 4f26514a..9e851504 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -74,11 +74,11 @@ fn setup(log_level: LogLevel) -> eyre::Result<(WorkerGuard, WorkerGuard)> { std::env::set_var( "RUST_LOG", match log_level { - LogLevel::Error => "error", - LogLevel::Warn => "warn", - LogLevel::Info => "info", - LogLevel::Debug => "debug", - LogLevel::Trace => "trace", + LogLevel::Error => "komorebi=error", + LogLevel::Warn => "komorebi=warn", + LogLevel::Info => "komorebi=info", + LogLevel::Debug => "komorebi=debug", + LogLevel::Trace => "komorebi=trace", }, ); } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index bee13895..24638cd0 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -22,6 +22,8 @@ use crate::core::rect::Rect; use crate::current_space_id; use crate::macos_api::MacosApi; use crate::notify_subscribers; +use crate::splash; +use crate::splash::mdm_enrollment; use crate::state::State; use crate::window::AdhocWindow; use crate::window::RuleDebug; @@ -37,6 +39,7 @@ use crate::workspace_reconciliator; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use parking_lot::Mutex; +use std::process::Command; use std::sync::Arc; use tracing::instrument; @@ -44,6 +47,24 @@ use tracing::instrument; pub fn listen_for_events(wm: Arc>) { let receiver = wm.lock().incoming_events.clone(); + std::thread::spawn(|| { + loop { + if let Ok((mdm, server)) = mdm_enrollment() { + #[allow(clippy::collapsible_if)] + if mdm && splash::should().unwrap_or(true) { + let mut args = vec!["splash".to_string()]; + if let Some(server) = server { + args.push(server); + } + + let _ = Command::new("komorebic").args(&args).spawn(); + } + } + + std::thread::sleep(std::time::Duration::from_secs(14400)); + } + }); + std::thread::spawn(move || { tracing::info!("listening"); loop { diff --git a/komorebi/src/splash.rs b/komorebi/src/splash.rs new file mode 100644 index 00000000..46514a78 --- /dev/null +++ b/komorebi/src/splash.rs @@ -0,0 +1,210 @@ +use crate::DATA_DIR; +use crate::License; +use crate::PUBLIC_KEY; +use base64::Engine; +use base64::engine::general_purpose; +use chrono::Duration; +use chrono::TimeZone; +use chrono::Utc; +use color_eyre::eyre; +use color_eyre::eyre::OptionExt; +use ed25519_dalek::Verifier; +use ed25519_dalek::VerifyingKey; +use objc2::MainThreadMarker; +use objc2::msg_send; +use objc2::rc::autoreleasepool; +use objc2_app_kit::NSAlert; +use objc2_app_kit::NSAlertStyle; +use objc2_app_kit::NSApplication; +use objc2_app_kit::NSFloatingWindowLevel; +use objc2_app_kit::NSWorkspace; +use objc2_foundation::NSString; +use objc2_foundation::NSURL; +use std::process::Command; + +pub fn mdm_enrollment() -> eyre::Result<(bool, Option)> { + let mut command = Command::new("/usr/bin/profiles"); + command.args(["status", "-type", "enrollment"]); + let stdout = command.output()?.stdout; + let output = std::str::from_utf8(&stdout)?; + if output.contains("MDM enrollment: No") { + return Ok((false, None)); + } + + let mut server = None; + + for line in output.lines() { + if line.starts_with("MDM server") { + server = Some(line.trim_start_matches("MDM server: ").to_string()) + } + } + + Ok((true, server)) +} + +fn is_valid_payload(raw: &str, fresh: bool) -> eyre::Result { + let mut validation_successful = false; + + let payload = serde_json::from_str::(raw)?; + + let signature = ed25519_dalek::Signature::from_slice( + general_purpose::STANDARD + .decode(&payload.signature)? + .as_slice(), + )?; + + let mut value: serde_json::Value = serde_json::from_str(raw)?; + if let serde_json::Value::Object(ref mut map) = value { + map.remove("signature"); + } + + let message_to_verify = serde_json::to_string(&value)?; + let verifying_key = VerifyingKey::from_bytes(&PUBLIC_KEY)?; + + if verifying_key + .verify(message_to_verify.as_bytes(), &signature) + .is_ok() + { + if fresh { + let timestamp = Utc + .timestamp_opt(payload.timestamp, 0) + .single() + .ok_or_eyre("invalid timestamp")?; + + let valid_duration = Utc::now() - Duration::minutes(5); + + if timestamp <= valid_duration { + tracing::debug!("individual commercial use license verification payload was stale"); + return Ok(true); + } + } + + if payload.has_valid_subscription + && let Some(current_end_period) = payload.current_end_period + { + let subscription_valid_until = Utc + .timestamp_opt(current_end_period, 0) + .single() + .ok_or_eyre("invalid timestamp")?; + + if Utc::now() <= subscription_valid_until { + tracing::debug!( + "individual commercial use license verification - subscription valid until: {subscription_valid_until}", + ); + + validation_successful = true; + } + } + } + + Ok(validation_successful) +} + +pub fn should() -> eyre::Result { + let icul_validation = DATA_DIR.join("icul.validation"); + if icul_validation.exists() { + tracing::debug!("found local individual commercial use license validation payload"); + let raw_payload = std::fs::read_to_string(&icul_validation)?; + if is_valid_payload(&raw_payload, false)? { + return Ok(false); + } else { + std::fs::remove_file(&icul_validation)?; + } + } + + let icul = DATA_DIR.join("icul"); + if !icul.exists() { + return Ok(true); + } + + let email = std::fs::read_to_string(icul)?; + tracing::debug!("found individual commercial use license email: {}", email); + + let client = reqwest::blocking::Client::new(); + let response = match client + .get("https://km-icul.lgug2z.com") + .query(&[("email", email.trim())]) + .send() + { + Ok(response) => response, + Err(error) => { + tracing::error!("{error}"); + return Ok(true); + } + }; + + let raw_payload = response.text()?; + if is_valid_payload(&raw_payload, true)? { + std::fs::write(icul_validation, &raw_payload)?; + Ok(false) + } else { + Ok(true) + } +} + +pub fn show(server: Option) -> eyre::Result<()> { + autoreleasepool(|_| { + let mtm = MainThreadMarker::new().unwrap(); + + let app = NSApplication::sharedApplication(mtm); + let alert = NSAlert::new(mtm); + alert.setAlertStyle(NSAlertStyle::Critical); + alert.setMessageText(&NSString::from_str("MDM Enrollment Detected")); + let informative_text = match server { + None => { + "It looks like you are using a corporate device enrolled in mobile device management\n\n\ + The Komorebi License does not permit any kind of commercial use\n\n\ + A dedicated Individual Commercial Use License is available if you wish to use this software at work\n\n\ + You are strongly encouraged to make your employer pay for your license, either directly or via reimbursement\n\n\ + To remove this popup in the future, run \"komorebic license \" using the email address associated with your license".to_string() + } + Some(server) => { + format!( + "It looks like you are using a corporate device enrolled in mobile device management ({server})\n\n\ + The Komorebi License does not permit any kind of commercial use\n\n\ + A dedicated Individual Commercial Use License is available if you wish to use this software at work\n\n\ + You are strongly encouraged to make your employer pay for your license, either directly or via reimbursement\n\n\ + To remove this popup in the future you can run \"komorebic license \" using the email address associated with your license" + ) + } + }; + + alert.setInformativeText(&NSString::from_str(&informative_text)); + alert.addButtonWithTitle(&NSString::from_str("Purchase License")); + alert.addButtonWithTitle(&NSString::from_str("Dismiss")); + + let window = alert.window(); + + window.center(); + window.setLevel(NSFloatingWindowLevel); + window.setHidesOnDeactivate(true); + window.makeKeyAndOrderFront(None); + window.orderFrontRegardless(); + + app.activate(); + + let response = alert.runModal(); + + if response == 1000 { + let _ = open_url_in_browser("https://lgug2z.com/software/komorebi"); + } + }); + + Ok(()) +} + +fn open_url_in_browser(url_string: &str) -> eyre::Result<()> { + unsafe { + let workspace = NSWorkspace::sharedWorkspace(); + let url_ns_string = NSString::from_str(url_string); + let url = NSURL::URLWithString(&url_ns_string).ok_or_eyre("failed to create NSURL")?; + + let success: bool = msg_send![&*workspace, openURL: &*url]; + + if !success { + tracing::error!("failed to open URL: {}", url_string); + } + + Ok(()) + } +} diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 217f6cbc..9fa2b1c7 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -22,6 +22,7 @@ use komorebi_client::WindowKind; use komorebi_client::replace_env_in_path; use komorebi_client::send_message; use komorebi_client::send_query; +use komorebi_client::splash; use lazy_static::lazy_static; use std::fs::File; use std::fs::OpenOptions; @@ -653,6 +654,17 @@ struct Completions { shell: clap_complete::Shell, } +#[derive(Parser)] +struct License { + /// Email address associated with an Individual Commercial Use License + email: String, +} + +#[derive(Parser)] +struct Splash { + mdm_server: Option, +} + #[derive(Parser)] #[clap(author, about, version = build::CLAP_LONG_VERSION)] struct Opts { @@ -664,10 +676,16 @@ struct Opts { enum SubCommand { #[clap(hide = true)] Docgen, + #[clap(hide = true)] + Splash(Splash), /// Generate komorebic CLI completions for the target shell + #[clap(arg_required_else_help = true)] Completions(Completions), /// Gather example configurations for a new-user quickstart Quickstart, + /// Specify an email associated with an Individual Commercial Use License + #[clap(arg_required_else_help = true)] + License(License), /// Start komorebi as a background process Start(Start), /// Stop the komorebi process and restore all hidden windows @@ -1228,10 +1246,17 @@ fn main() -> eyre::Result<()> { } } } + SubCommand::Splash(arg) => { + splash::show(arg.mdm_server)?; + } SubCommand::Completions(arg) => { let mut cli = Opts::command(); clap_complete::generate(arg.shell, &mut cli, "komorebic", &mut std::io::stdout()); } + SubCommand::License(arg) => { + std::fs::write(DATA_DIR.join("icul"), arg.email)?; + splash::should()?; + } SubCommand::Quickstart => { fn write_file_with_prompt( path: &PathBuf, @@ -1338,6 +1363,30 @@ fn main() -> eyre::Result<()> { let mut input = String::new(); std::io::stdin().read_line(&mut input)?; + if let Ok((mdm, server)) = splash::mdm_enrollment() + && mdm + { + if let Some(server) = server { + println!( + "\nIt looks like you are using a corporate device enrolled in mobile device management ({server})" + ); + } else { + println!( + "\nIt looks like you are using a corporate device enrolled in mobile device management" + ); + } + println!("The Komorebi License does not permit any kind of commercial use"); + println!( + "A dedicated Individual Commercial Use License is available if you wish to use this software at work" + ); + println!( + "You are strongly encouraged to make your employer pay for your license, either directly or via reimbursement" + ); + println!( + "If you already have a license, you can run \"komorebic license \" with the email address your license is associated with" + ); + } + println!("You can now run: komorebic start"); println!( "\nIf you have skhd hotkey daemon installed, you can also run: skhd --config {}", @@ -1509,12 +1558,25 @@ fn main() -> eyre::Result<()> { println!("\nThank you for using komorebi!\n"); println!("# Commercial Use License"); + if let Ok((mdm, server)) = splash::mdm_enrollment() + && mdm + { + if let Some(server) = server { + println!( + "* It looks like you are using a corporate device enrolled in mobile device management ({server})" + ); + } else { + println!( + "* It looks like you are using a corporate device enrolled in mobile device management" + ); + } + } println!( "* View licensing options https://lgug2z.com/software/komorebi - A commercial use license is required to use komorebi at work" ); println!("\n# Personal Use Sponsorship"); println!( - "* Become a sponsor https://github.com/sponsors/LGUG2Z - $5/month makes a big difference" + "* Become a sponsor https://github.com/sponsors/LGUG2Z - $10/month makes a big difference" ); println!("* Leave a tip https://ko-fi.com/lgug2z - An alternative to GitHub Sponsors"); println!("\n# Community"); diff --git a/mkdocs.yml b/mkdocs.yml index 5c01fb8e..c2719bf9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -65,7 +65,9 @@ nav: - Komorebi Configuration: - Schema: https://komorebi.lgug2z.com/schema - CLI reference: + - cli/completions.md - cli/quickstart.md + - cli/license.md - cli/start.md - cli/stop.md - cli/configuration.md @@ -189,6 +191,10 @@ nav: - cli/clear-named-workspace-rules.md - cli/clear-all-workspace-rules.md - cli/enforce-workspace-rules.md + - cli/border.md + - cli/border-colour.md + - cli/border-width.md + - cli/border-offset.md - cli/mouse-follows-focus.md - cli/toggle-mouse-follows-focus.md - cli/fetch-app-specific-configuration.md From 9711a00cd018937503cfddb934a8091e8286dd0f Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 29 Oct 2025 08:39:23 -0700 Subject: [PATCH 140/305] feat(cli): add feedback to the license cmd --- komorebi/src/process_event.rs | 2 +- komorebi/src/splash.rs | 33 ++++++++++++++++++++++++++------- komorebic/src/main.rs | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 24638cd0..a4d2f6fc 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -51,7 +51,7 @@ pub fn listen_for_events(wm: Arc>) { loop { if let Ok((mdm, server)) = mdm_enrollment() { #[allow(clippy::collapsible_if)] - if mdm && splash::should().unwrap_or(true) { + if mdm && splash::should().map(|f| f.into()).unwrap_or(true) { let mut args = vec!["splash".to_string()]; if let Some(server) = server { args.push(server); diff --git a/komorebi/src/splash.rs b/komorebi/src/splash.rs index 46514a78..84905de2 100644 --- a/komorebi/src/splash.rs +++ b/komorebi/src/splash.rs @@ -20,6 +20,7 @@ use objc2_app_kit::NSFloatingWindowLevel; use objc2_app_kit::NSWorkspace; use objc2_foundation::NSString; use objc2_foundation::NSURL; +use std::path::PathBuf; use std::process::Command; pub fn mdm_enrollment() -> eyre::Result<(bool, Option)> { @@ -100,13 +101,31 @@ fn is_valid_payload(raw: &str, fresh: bool) -> eyre::Result { Ok(validation_successful) } -pub fn should() -> eyre::Result { +pub enum ValidationFeedback { + Successful(PathBuf), + Unsuccessful(String), + NoEmail, + NoConnectivity, +} + +impl From for bool { + fn from(value: ValidationFeedback) -> Self { + match value { + ValidationFeedback::Successful(_) => false, + ValidationFeedback::Unsuccessful(_) + | ValidationFeedback::NoEmail + | ValidationFeedback::NoConnectivity => true, + } + } +} + +pub fn should() -> eyre::Result { let icul_validation = DATA_DIR.join("icul.validation"); if icul_validation.exists() { tracing::debug!("found local individual commercial use license validation payload"); let raw_payload = std::fs::read_to_string(&icul_validation)?; if is_valid_payload(&raw_payload, false)? { - return Ok(false); + return Ok(ValidationFeedback::Successful(icul_validation)); } else { std::fs::remove_file(&icul_validation)?; } @@ -114,7 +133,7 @@ pub fn should() -> eyre::Result { let icul = DATA_DIR.join("icul"); if !icul.exists() { - return Ok(true); + return Ok(ValidationFeedback::NoEmail); } let email = std::fs::read_to_string(icul)?; @@ -129,16 +148,16 @@ pub fn should() -> eyre::Result { Ok(response) => response, Err(error) => { tracing::error!("{error}"); - return Ok(true); + return Ok(ValidationFeedback::NoConnectivity); } }; let raw_payload = response.text()?; if is_valid_payload(&raw_payload, true)? { - std::fs::write(icul_validation, &raw_payload)?; - Ok(false) + std::fs::write(&icul_validation, &raw_payload)?; + Ok(ValidationFeedback::Successful(icul_validation)) } else { - Ok(true) + Ok(ValidationFeedback::Unsuccessful(raw_payload)) } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 9fa2b1c7..264cfaf8 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -23,6 +23,7 @@ use komorebi_client::replace_env_in_path; use komorebi_client::send_message; use komorebi_client::send_query; use komorebi_client::splash; +use komorebi_client::splash::ValidationFeedback; use lazy_static::lazy_static; use std::fs::File; use std::fs::OpenOptions; @@ -1254,8 +1255,35 @@ fn main() -> eyre::Result<()> { clap_complete::generate(arg.shell, &mut cli, "komorebic", &mut std::io::stdout()); } SubCommand::License(arg) => { - std::fs::write(DATA_DIR.join("icul"), arg.email)?; - splash::should()?; + let _ = std::fs::remove_file(DATA_DIR.join("icul.validation")); + std::fs::write(DATA_DIR.join("icul"), &arg.email)?; + match splash::should()? { + ValidationFeedback::Successful(icul_validation) => { + println!("Individual commercial use license validation successful"); + println!( + "Local validation file saved to {}", + icul_validation.display() + ); + println!("\n{}", std::fs::read_to_string(&icul_validation)?); + } + ValidationFeedback::Unsuccessful(invalid_payload) => { + println!( + "No active individual commercial use license found for {}", + arg.email + ); + println!("\n{invalid_payload}"); + println!( + "\nYou can purchase an individual commercial use license at https://lgug2z.com/software/komorebi" + ); + } + ValidationFeedback::NoEmail => {} + ValidationFeedback::NoConnectivity => { + println!( + "Could not make a connection to validate an individual commercial use license for {}", + arg.email + ); + } + } } SubCommand::Quickstart => { fn write_file_with_prompt( From 2eea8b79a48b9c8fa3060e52dd6c493600e3b63a Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 29 Oct 2025 17:22:29 -0700 Subject: [PATCH 141/305] feat(wm): improve scrolling layout window hiding This commit makes a small improvement to the Scrolling layout by hiding windows to which layouts which are not contained within the horizontal bounds of the work area would otherwise be applied. This should also allow this layout to now be useable on configurations using multiple monitors. --- komorebi/src/core/rect.rs | 6 ++++++ komorebi/src/static_config.rs | 11 ----------- komorebi/src/window_manager.rs | 8 -------- komorebi/src/workspace.rs | 12 ++++++++++-- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/komorebi/src/core/rect.rs b/komorebi/src/core/rect.rs index 67cc33ec..c16d3371 100644 --- a/komorebi/src/core/rect.rs +++ b/komorebi/src/core/rect.rs @@ -69,6 +69,12 @@ impl Rect { CoreGraphicsApi::contains_rect(other.into(), self.into()) } + pub fn contains_within_horizontal_bounds(&self, other: &Rect) -> bool { + let within_left_bound = other.left >= self.left; + let within_right_bound = other.left < self.left + self.right; + within_left_bound && within_right_bound + } + /// Decrease the size of self by the padding amount. pub fn add_padding(&mut self, padding: T) where diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index b2a51846..4a960b33 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -1212,8 +1212,6 @@ impl StaticConfig { workspace_matching_rules.clear(); drop(workspace_matching_rules); - let monitor_count = wm.monitors().len(); - let offset = wm.work_area_offset; for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() { let preferred_config_idx = { @@ -1268,15 +1266,6 @@ impl StaticConfig { monitor.update_workspaces_globals(offset); for (j, ws) in monitor.workspaces_mut().iter_mut().enumerate() { if let Some(workspace_config) = monitor_config.workspaces.get_mut(j) { - if monitor_count > 1 - && matches!(workspace_config.layout, Some(DefaultLayout::Scrolling)) - { - tracing::warn!( - "scrolling layout is only supported for a single monitor; falling back to columns layout" - ); - workspace_config.layout = Some(DefaultLayout::Columns); - } - ws.load_static_config(workspace_config)?; } } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index e38f2d2c..93a46e43 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -881,16 +881,8 @@ impl WindowManager { pub fn change_workspace_layout_default(&mut self, layout: DefaultLayout) -> eyre::Result<()> { tracing::info!("changing layout"); - let monitor_count = self.monitors().len(); let workspace = self.focused_workspace_mut()?; - if monitor_count > 1 && matches!(layout, DefaultLayout::Scrolling) { - tracing::warn!( - "scrolling layout is only supported for a single monitor; not changing layout" - ); - return Ok(()); - } - workspace.layout = Layout::Default(layout); self.update_focused_workspace(self.mouse_follows_focus, false) } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 9fc537bb..1541afbb 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1133,6 +1133,9 @@ impl Workspace { &self.latest_layout, ); + let is_scrolling = matches!(self.layout, Layout::Default(DefaultLayout::Scrolling)); + let window_hiding_position = self.globals.window_hiding_position; + let containers = self.containers_mut(); for (i, container) in containers.iter_mut().enumerate() { @@ -1140,8 +1143,13 @@ impl Workspace { layout.add_padding(border_offset); layout.add_padding(border_width); - for window in container.windows() { - if let Err(error) = window.set_position(layout) { + for window in container.windows_mut() { + if is_scrolling && !work_area.contains_within_horizontal_bounds(layout) + { + if let Err(error) = window.hide(window_hiding_position) { + tracing::warn!("failed to set window position: {error}") + } + } else if let Err(error) = window.set_position(layout) { tracing::warn!("failed to set window position: {error}") } } From 270e0847c2dad63b3068ebca8eb490c2280aaadf Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 30 Oct 2025 13:45:22 -0700 Subject: [PATCH 142/305] fix(wm): account for partially-shown scrolling windows This commit makes some small tweaks to account for the hiding and showing of partially visible windows on the Scrolling layout. This can happen when resize dimensions have been applied which leaves only a certain percentage of the window within the work area. If a window is only partially within the work area, the call to hide will silently fail. In order to deal with this there is some jank added when hiding workspaces and updating workspaces to see if we are leaving a Scrolling workspace with a partially-visible window, and if we are, to reposition that window to be fully on within the work area before hiding it. --- komorebi/src/core/rect.rs | 15 +++++++++++---- komorebi/src/monitor.rs | 9 ++++++++- komorebi/src/workspace.rs | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/komorebi/src/core/rect.rs b/komorebi/src/core/rect.rs index c16d3371..2c63395a 100644 --- a/komorebi/src/core/rect.rs +++ b/komorebi/src/core/rect.rs @@ -69,10 +69,17 @@ impl Rect { CoreGraphicsApi::contains_rect(other.into(), self.into()) } - pub fn contains_within_horizontal_bounds(&self, other: &Rect) -> bool { - let within_left_bound = other.left >= self.left; - let within_right_bound = other.left < self.left + self.right; - within_left_bound && within_right_bound + pub fn percentage_within_horizontal_bounds(&self, other: &Rect) -> f64 { + let overlap_left = self.left.max(other.left); + let overlap_right = (self.left + self.right).min(other.left + other.right); + + let overlap_width = overlap_right - overlap_left; + + if overlap_width <= 0 { + 0.0 + } else { + (overlap_width as f64) / (other.right as f64) * 100.0 + } } /// Decrease the size of self by the padding amount. diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 63641121..8d3e8270 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -225,14 +225,21 @@ impl Monitor { let focused_idx = self.focused_workspace_idx(); let monitor_id = self.id; let monitor_wp = self.wallpaper.clone(); + + let mut restore = None; + for (i, workspace) in self.workspaces_mut().iter_mut().enumerate() { if i == focused_idx { - workspace.restore(mouse_follows_focus, monitor_id, &monitor_wp)?; + restore = Some(workspace); } else { workspace.hide(None)?; } } + if let Some(workspace) = restore { + workspace.restore(mouse_follows_focus, monitor_id, &monitor_wp)?; + } + Ok(()) } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 1541afbb..d26bb43e 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -690,10 +690,25 @@ impl Workspace { } } + let mut resize_dimensions = None; + if matches!(self.layout, Layout::Default(DefaultLayout::Scrolling)) + && self.resize_dimensions.iter().any(|r| r.is_some()) + { + resize_dimensions = Some(self.resize_dimensions.clone()); + self.resize_dimensions = Vec::new(); + if let Err(error) = self.update() { + tracing::error!("{error}"); + } + } + for container in self.containers_mut() { container.hide(window_hiding_position, omit)?; } + if let Some(resize_dimensions) = resize_dimensions { + self.resize_dimensions = resize_dimensions; + } + // if let Some(window) = self.maximized_window() { // window.hide(); // } @@ -1135,6 +1150,7 @@ impl Workspace { let is_scrolling = matches!(self.layout, Layout::Default(DefaultLayout::Scrolling)); let window_hiding_position = self.globals.window_hiding_position; + let resize_dimensions_is_empty = self.resize_dimensions.is_empty(); let containers = self.containers_mut(); @@ -1144,11 +1160,25 @@ impl Workspace { layout.add_padding(border_width); for window in container.windows_mut() { - if is_scrolling && !work_area.contains_within_horizontal_bounds(layout) - { + let current_percentage = work_area.percentage_within_horizontal_bounds( + &Rect::from(MacosApi::window_rect(&window.element)?), + ); + let proposed_percentage = + work_area.percentage_within_horizontal_bounds(layout); + + let percentage_override = proposed_percentage == 0.0 + && current_percentage > 0.1 + && current_percentage < 100.0 + && resize_dimensions_is_empty; + + if is_scrolling && proposed_percentage < 0.1 && !percentage_override { if let Err(error) = window.hide(window_hiding_position) { - tracing::warn!("failed to set window position: {error}") + tracing::warn!( + "failed to set hide window for scrolling layout: {error}" + ) } + } else if percentage_override { + window.center(&work_area, false)?; } else if let Err(error) = window.set_position(layout) { tracing::warn!("failed to set window position: {error}") } From 29d9f9ecaa598eb09181066bf85915a786eb01a5 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 31 Oct 2025 13:47:20 -0700 Subject: [PATCH 143/305] fix(wm): add ws reconciliator cooldown period I was running komorebi on a MacBook Pro today and ended up quite quickly being able to reproduce the ws switching loops that I thought I had fixed (well, I still can't reproduce them on my Mac Mini). This commit adds an additional cooldown period of 1s to workspace_reconciliator::send_notification, which seems to do the trick for me on the MacBook Pro. --- komorebi/src/workspace_reconciliator.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/komorebi/src/workspace_reconciliator.rs b/komorebi/src/workspace_reconciliator.rs index 36842236..add059ee 100644 --- a/komorebi/src/workspace_reconciliator.rs +++ b/komorebi/src/workspace_reconciliator.rs @@ -8,7 +8,10 @@ use parking_lot::Mutex; use std::sync::Arc; use std::sync::OnceLock; use std::sync::atomic::AtomicBool; +use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering; +use std::time::SystemTime; +use std::time::UNIX_EPOCH; #[derive(Copy, Clone, Debug)] pub struct Notification { @@ -18,6 +21,8 @@ pub struct Notification { } static RECONCILIATION_IN_PROGRESS: AtomicBool = AtomicBool::new(false); +static LAST_RECONCILIATION: AtomicU64 = AtomicU64::new(0); +const COOLDOWN_MS: u64 = 1000; // 1 second cooldown static CHANNEL: OnceLock<(Sender, Receiver)> = OnceLock::new(); @@ -38,6 +43,16 @@ pub fn send_notification( workspace_idx: usize, triggered_by: WindowManagerEvent, ) { + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_millis() as u64; + + if now - LAST_RECONCILIATION.load(Ordering::SeqCst) < COOLDOWN_MS { + tracing::debug!("within cooldown period, dropping notification"); + return; + } + if !RECONCILIATION_IN_PROGRESS.load(Ordering::Relaxed) { tracing::debug!("sending reconciliation request"); if event_tx() @@ -101,6 +116,12 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result } } + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_millis() as u64; + + LAST_RECONCILIATION.store(now, Ordering::SeqCst); RECONCILIATION_IN_PROGRESS.store(false, Ordering::Relaxed); } From 3128968634c0b47dc9d53201d7bb58f7f6681aa0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 31 Oct 2025 14:28:33 -0700 Subject: [PATCH 144/305] feat(wm): add direction preselection This commit adds a new feature to preselect the direction of the next spawned window with a corresponding komorebic preselect-direction command which takes an OperationDirection. If the OperationDirection is valid from the current position, it will be stored in the Workspace state, and then read, applied, and deleted when the next manage-able window is spawned. --- docs/cli/preselect-direction.md | 16 +++++++++++ komorebi/src/core/mod.rs | 1 + komorebi/src/process_command.rs | 6 ++++ komorebi/src/state.rs | 1 + komorebi/src/window_manager.rs | 49 +++++++++++++++++++++++++++++++++ komorebi/src/workspace.rs | 13 ++++++++- komorebic/src/main.rs | 8 ++++++ mkdocs.yml | 1 + 8 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 docs/cli/preselect-direction.md diff --git a/docs/cli/preselect-direction.md b/docs/cli/preselect-direction.md new file mode 100644 index 00000000..118d56f3 --- /dev/null +++ b/docs/cli/preselect-direction.md @@ -0,0 +1,16 @@ +# preselect-direction + +``` +Preselect the specified direction for the next window to be spawned on supported layouts + +Usage: komorebic preselect-direction + +Arguments: + + [possible values: left, right, up, down] + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 432d4976..fe6220a3 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -256,6 +256,7 @@ pub enum SocketMessage { // Window / Container Commands FocusWindow(OperationDirection), MoveWindow(OperationDirection), + PreselectDirection(OperationDirection), CycleFocusWindow(CycleDirection), CycleMoveWindow(CycleDirection), StackWindow(OperationDirection), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 19200fce..78b3a664 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -226,6 +226,12 @@ impl WindowManager { } } } + SocketMessage::PreselectDirection(direction) => { + let focused_workspace = self.focused_workspace()?; + if matches!(focused_workspace.layer, WorkspaceLayer::Tiling) { + self.preselect_container_in_direction(direction)?; + } + } SocketMessage::MoveWindow(direction) => { let focused_workspace = self.focused_workspace()?; match focused_workspace.layer { diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs index f36850cc..7c30ac1c 100644 --- a/komorebi/src/state.rs +++ b/komorebi/src/state.rs @@ -140,6 +140,7 @@ impl From<&WindowManager> for State { globals: workspace.globals, wallpaper: workspace.wallpaper.clone(), workspace_config: None, + preselected_container_idx: None, }) .collect::>(); ws.focus(monitor.workspaces.focused_idx()); diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 93a46e43..7d59f8c4 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -446,6 +446,55 @@ impl WindowManager { Ok(()) } + #[tracing::instrument(skip(self))] + pub fn preselect_container_in_direction( + &mut self, + direction: OperationDirection, + ) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + let focused_idx = workspace.focused_container_idx(); + + if matches!(workspace.layout, Layout::Default(DefaultLayout::Grid)) { + tracing::warn!("preselection is not supported on the grid layout"); + return Ok(()); + } + + tracing::info!("preselecting container"); + + let new_idx = + if workspace.maximized_window.is_some() || workspace.monocle_container.is_some() { + None + } else { + workspace.new_idx_for_direction(direction) + }; + + match new_idx { + Some(new_idx) => { + let adjusted_idx = match direction { + OperationDirection::Left | OperationDirection::Up => { + if focused_idx.abs_diff(new_idx) == 1 { + new_idx + 1 + } else { + new_idx + } + } + + _ => new_idx, + }; + + workspace.preselect_container_index(adjusted_idx); + } + + None => { + tracing::debug!( + "this is not a valid preselection direction from the current position" + ) + } + } + + Ok(()) + } + #[tracing::instrument(skip(self))] pub fn focus_container_in_direction( &mut self, diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index d26bb43e..c9b22f38 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -65,6 +65,8 @@ pub struct Workspace { pub wallpaper: Option, #[serde(skip_serializing_if = "Option::is_none")] pub workspace_config: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub preselected_container_idx: Option, } #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] @@ -116,6 +118,7 @@ impl Default for Workspace { floating_layer_behaviour: None, wallpaper: None, workspace_config: None, + preselected_container_idx: None, } } } @@ -217,6 +220,10 @@ impl Workspace { self.focus_container(j); } + pub fn preselect_container_index(&mut self, insertion_index: usize) { + self.preselected_container_idx = Some(insertion_index); + } + pub fn new_idx_for_direction(&self, direction: OperationDirection) -> Option { let len = NonZeroUsize::new(self.containers().len())?; @@ -287,7 +294,11 @@ impl Workspace { } pub fn new_container_for_window(&mut self, window: &Window) -> eyre::Result<()> { - let next_idx = if self.containers().is_empty() { + let next_idx = if let Some(idx) = self.preselected_container_idx { + let next = idx; + self.preselected_container_idx = None; + next + } else if self.containers().is_empty() { 0 } else { self.focused_container_idx() + 1 diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 264cfaf8..a39eb49e 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -96,6 +96,7 @@ macro_rules! gen_enum_subcommand_args { gen_enum_subcommand_args! { Focus: OperationDirection, Move: OperationDirection, + PreselectDirection: OperationDirection, CycleFocus: CycleDirection, CycleMove: CycleDirection, CycleMoveToWorkspace: CycleDirection, @@ -760,6 +761,9 @@ enum SubCommand { /// Move the focused window in the specified direction #[clap(arg_required_else_help = true)] Move(Move), + /// Preselect the specified direction for the next window to be spawned on supported layouts + #[clap(arg_required_else_help = true)] + PreselectDirection(PreselectDirection), /// Minimize the focused window Minimize, /// Close the focused window @@ -1224,6 +1228,7 @@ fn main() -> eyre::Result<()> { let ignore = [ "docgen", + "splash", "alt-focus-hack", "identify-border-overflow-application", "load-custom-layout", @@ -1672,6 +1677,9 @@ fn main() -> eyre::Result<()> { SubCommand::Move(arg) => { send_message(&SocketMessage::MoveWindow(arg.operation_direction))?; } + SubCommand::PreselectDirection(arg) => { + send_message(&SocketMessage::PreselectDirection(arg.operation_direction))?; + } SubCommand::CycleFocus(arg) => { send_message(&SocketMessage::CycleFocusWindow(arg.cycle_direction))?; } diff --git a/mkdocs.yml b/mkdocs.yml index c2719bf9..9e466335 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -86,6 +86,7 @@ nav: - cli/load-resize.md - cli/focus.md - cli/move.md + - cli/preselect-direction.md - cli/minimize.md - cli/close.md - cli/cycle-focus.md From fe8dbca2043e26dc67512798ee14d93043fdf5d7 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 31 Oct 2025 19:16:53 -0700 Subject: [PATCH 145/305] fix(wm): expand hack from 4d25d4e for chrome This commit expands the hack introduced in 4d25d4e which deals with inconsistent window titles returned by apps from different macOS APIs. The same issue that was happening with Activity Monitor was also happening with Google Chrome, so this hack has been updated to a more general "contains" check. --- komorebi/src/application.rs | 6 +++--- komorebi/src/macos_api.rs | 1 + komorebi/src/workspace.rs | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index d7b33071..f34b3b61 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -189,9 +189,9 @@ impl Application { if let Some(window_title) = window.title() && (window_title.eq(title) - // TODO: find a better way to deal with these hacks - || (self.name().unwrap_or_default() == "Activity Monitor" - && window_title.starts_with(title))) + // a hack for handling already-launched apps with inconsistent titles when + // komorebi launches, such as Activity Monitor, Google Chrome, and counting... + || window_title.contains(title)) { target = Some(window); } diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index c58221c3..dfe13e08 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -371,6 +371,7 @@ impl MacosApi { )?) } + // #[track_caller] // use this to with std::panic::Location::caller() to debug failures #[tracing::instrument(skip_all)] pub fn window_rect(element: &AXUIElement) -> Result { let mut position_receiver = std::ptr::null(); diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index c9b22f38..79449a82 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1171,9 +1171,10 @@ impl Workspace { layout.add_padding(border_width); for window in container.windows_mut() { - let current_percentage = work_area.percentage_within_horizontal_bounds( - &Rect::from(MacosApi::window_rect(&window.element)?), - ); + let current_rect = + MacosApi::window_rect(&window.element).unwrap_or_default(); + let current_percentage = work_area + .percentage_within_horizontal_bounds(&Rect::from(current_rect)); let proposed_percentage = work_area.percentage_within_horizontal_bounds(layout); From 34db2e2c90c79b9d47f917b4e89b05a84dc064c6 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 2 Nov 2025 10:24:17 -0800 Subject: [PATCH 146/305] feat(wm): add visual feedback for preselections This commit adds visual feedback in the form of a ghost tile for preselections made by the preselect-direction command. A container with the id "PRESELECT" will be added to the workspace, and replaced when the next manage-able window is spawned. A new command, cancel-preselect has been added to remove both the preselection index and the ghost tile if the user changes their mind. --- docs/cli/cancel-preselect.md | 12 ++++++++++++ komorebi/src/container.rs | 12 ++++++++++++ komorebi/src/core/mod.rs | 1 + komorebi/src/process_command.rs | 18 +++++++++++++++++- komorebi/src/window_manager.rs | 2 +- komorebi/src/workspace.rs | 16 +++++++++++++--- komorebic/src/main.rs | 5 +++++ mkdocs.yml | 1 + 8 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 docs/cli/cancel-preselect.md diff --git a/docs/cli/cancel-preselect.md b/docs/cli/cancel-preselect.md new file mode 100644 index 00000000..6e5a880c --- /dev/null +++ b/docs/cli/cancel-preselect.md @@ -0,0 +1,12 @@ +# cancel-preselect + +``` +Cancel a workspace preselect set by the preselect-direction command, if one exists + +Usage: komorebic cancel-preselect + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index f0d3a945..1cf9c48a 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -40,6 +40,18 @@ impl Lockable for Container { } impl Container { + pub fn preselect() -> Self { + Self { + id: "PRESELECT".to_string(), + locked: false, + windows: Default::default(), + } + } + + pub fn is_preselect(&self) -> bool { + self.id == "PRESELECT" + } + pub fn idx_from_exe(&self, exe: &str) -> Option { for (idx, window) in self.windows().iter().enumerate() { if let Some(window_exe) = window.exe() diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index fe6220a3..d40724fe 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -257,6 +257,7 @@ pub enum SocketMessage { FocusWindow(OperationDirection), MoveWindow(OperationDirection), PreselectDirection(OperationDirection), + CancelPreselect, CycleFocusWindow(CycleDirection), CycleMoveWindow(CycleDirection), StackWindow(OperationDirection), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 78b3a664..3fa2842d 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -228,9 +228,25 @@ impl WindowManager { } SocketMessage::PreselectDirection(direction) => { let focused_workspace = self.focused_workspace()?; - if matches!(focused_workspace.layer, WorkspaceLayer::Tiling) { + let mut update = false; + + if focused_workspace.preselected_container_idx.is_some() { + tracing::warn!( + "ignoring command as this workspace already has a direction preselect set" + ); + } else if matches!(focused_workspace.layer, WorkspaceLayer::Tiling) { self.preselect_container_in_direction(direction)?; + update = true; } + + if update { + self.focused_workspace_mut()?.update()?; + } + } + SocketMessage::CancelPreselect => { + let focused_workspace = self.focused_workspace_mut()?; + focused_workspace.cancel_preselect(); + focused_workspace.update()?; } SocketMessage::MoveWindow(direction) => { let focused_workspace = self.focused_workspace()?; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 7d59f8c4..6ce82a8c 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -482,7 +482,7 @@ impl WindowManager { _ => new_idx, }; - workspace.preselect_container_index(adjusted_idx); + workspace.preselect_container_idx(adjusted_idx); } None => { diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 79449a82..e7794bfe 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -220,8 +220,16 @@ impl Workspace { self.focus_container(j); } - pub fn preselect_container_index(&mut self, insertion_index: usize) { - self.preselected_container_idx = Some(insertion_index); + pub fn preselect_container_idx(&mut self, insertion_idx: usize) { + self.preselected_container_idx = Some(insertion_idx); + self.insert_container_at_idx(insertion_idx, Container::preselect()); + } + + pub fn cancel_preselect(&mut self) { + if let Some(idx) = self.preselected_container_idx { + self.containers_mut().remove_respecting_locks(idx); + self.preselected_container_idx = None; + } } pub fn new_idx_for_direction(&self, direction: OperationDirection) -> Option { @@ -297,6 +305,7 @@ impl Workspace { let next_idx = if let Some(idx) = self.preselected_container_idx { let next = idx; self.preselected_container_idx = None; + self.remove_container_by_idx(next); next } else if self.containers().is_empty() { 0 @@ -1055,7 +1064,8 @@ impl Workspace { // make sure we are never holding on to empty containers self.prune_duplicate_windows()?; let focused_container_idx = self.focused_container_idx(); - self.containers_mut().retain(|c| !c.windows().is_empty()); + self.containers_mut() + .retain(|c| c.is_preselect() || !c.windows().is_empty()); // make sure we are never focused on a no longer existent final empty container if focused_container_idx >= self.containers().len() { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index a39eb49e..dd7ed95c 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -764,6 +764,8 @@ enum SubCommand { /// Preselect the specified direction for the next window to be spawned on supported layouts #[clap(arg_required_else_help = true)] PreselectDirection(PreselectDirection), + /// Cancel a workspace preselect set by the preselect-direction command, if one exists + CancelPreselect, /// Minimize the focused window Minimize, /// Close the focused window @@ -1680,6 +1682,9 @@ fn main() -> eyre::Result<()> { SubCommand::PreselectDirection(arg) => { send_message(&SocketMessage::PreselectDirection(arg.operation_direction))?; } + SubCommand::CancelPreselect => { + send_message(&SocketMessage::CancelPreselect)?; + } SubCommand::CycleFocus(arg) => { send_message(&SocketMessage::CycleFocusWindow(arg.cycle_direction))?; } diff --git a/mkdocs.yml b/mkdocs.yml index 9e466335..0b47fb4b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -87,6 +87,7 @@ nav: - cli/focus.md - cli/move.md - cli/preselect-direction.md + - cli/cancel-preselect.md - cli/minimize.md - cli/close.md - cli/cycle-focus.md From 4c0f34d7ef3d083a3db21820b3803c5fb273a528 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 2 Nov 2025 10:32:56 -0800 Subject: [PATCH 147/305] fix(wm): simplify stack-all command Implements the equivalent of https://github.com/LGUG2Z/komorebi/commit/18ee6678962bc31a39ce59fd4a1f6a9ee752ac5c This commit makes the `stack-all` command simpler, by simply making a `VecDeque` with all the tiled windows of the workspace, then it creates a new container with that `VecDeque` and changes the workspace containers to be just this new container which has all the windows in it. Then and only then do we focus and show the previously focused window and hide all the rest. This way we don't have a bunch of `FocusChange`/`Cloak`/`Uncloak` events coming up which might conflict with each other when the user has transparency and animations enabled. With this commit, there will only be one focus event for the focused window and one cloak event for each of the other windows. --- komorebi/src/window_manager.rs | 35 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 6ce82a8c..34a3f1c4 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -50,6 +50,7 @@ use objc2_core_foundation::CFRunLoop; use parking_lot::Mutex; use std::collections::HashMap; use std::collections::HashSet; +use std::collections::VecDeque; use std::collections::hash_map::Entry; use std::io::ErrorKind; use std::net::Shutdown; @@ -2279,29 +2280,39 @@ impl WindowManager { #[tracing::instrument(skip(self))] pub fn stack_all(&mut self) -> eyre::Result<()> { - self.unstack_all(false)?; - tracing::info!("stacking all windows on workspace"); let workspace = self.focused_workspace_mut()?; + let window_hiding_position = workspace.globals.window_hiding_position; - let mut focused_window_id = None; + let mut focused_hwnd = None; if let Some(container) = workspace.focused_container() && let Some(window) = container.focused_window() { - focused_window_id = Some(window.id); + focused_hwnd = Some(window.id); } - workspace.focus_container(workspace.containers().len().saturating_sub(1)); - while workspace.focused_container_idx() > 0 { - workspace.move_window_to_container(0)?; - workspace.focus_container(workspace.containers().len().saturating_sub(1)); - } + let workspace_hwnds = + workspace + .containers() + .iter() + .fold(VecDeque::new(), |mut hwnds, c| { + hwnds.extend(c.windows().clone()); + hwnds + }); - if let Some(window_id) = focused_window_id { - workspace.focus_container_by_window(window_id)?; - } + let mut container = Container::default(); + *container.windows_mut() = workspace_hwnds; + *workspace.containers_mut() = VecDeque::from([container]); + workspace.focus_container(0); + if let Some(hwnd) = focused_hwnd + && let Some(c) = workspace.focused_container_mut() + && let Some(w_idx_to_focus) = c.idx_for_window(hwnd) + { + c.focus_window(w_idx_to_focus); + c.load_focused_window(window_hiding_position)?; + } self.update_focused_workspace(self.mouse_follows_focus, true) } From b09e979af5eb1b115069bb58805ec887a2ab51f9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 4 Nov 2025 07:52:13 -0800 Subject: [PATCH 148/305] feat(wm): promote containers by swapping indices This commit adds a new SocketMessage variant PromoteSwap and corresponding komorebic promote-swap command. PromoteSwap will also promote the focused window container to the largest tile in the layout, but instead of removing the focused container x from the Ring and inserting it into position 0, possibly changing the positions of other windows between 0 and x, the indices x and 0 in the Ring will be swapped directly. --- docs/cli/promote-focus.md | 2 +- docs/cli/promote-swap.md | 12 ++++++++++++ docs/cli/promote.md | 2 +- komorebi/src/core/mod.rs | 1 + komorebi/src/process_command.rs | 1 + komorebi/src/window_manager.rs | 18 ++++++++++++++++++ komorebic/src/main.rs | 9 +++++++-- mkdocs.yml | 1 + 8 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 docs/cli/promote-swap.md diff --git a/docs/cli/promote-focus.md b/docs/cli/promote-focus.md index dcbd198d..95e0fd4b 100644 --- a/docs/cli/promote-focus.md +++ b/docs/cli/promote-focus.md @@ -1,7 +1,7 @@ # promote-focus ``` -Promote the user focus to the top of the tree +Promote the user focus to the largest window container Usage: komorebic promote-focus diff --git a/docs/cli/promote-swap.md b/docs/cli/promote-swap.md new file mode 100644 index 00000000..c0430ae0 --- /dev/null +++ b/docs/cli/promote-swap.md @@ -0,0 +1,12 @@ +# promote-swap + +``` +Promote the focused window to the largest tile by swapping container indices with the largest tile + +Usage: komorebic promote-swap + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/promote.md b/docs/cli/promote.md index ddf40bde..831a9d88 100644 --- a/docs/cli/promote.md +++ b/docs/cli/promote.md @@ -1,7 +1,7 @@ # promote ``` -Promote the focused window to the top of the tree +Promote the focused window to the largest tile via container removal and re-insertion Usage: komorebic promote diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index d40724fe..7aea3eb6 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -290,6 +290,7 @@ pub enum SocketMessage { Close, Minimize, Promote, + PromoteSwap, PromoteFocus, PromoteWindow(OperationDirection), EagerFocus(String), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 3fa2842d..4ebe8eeb 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -135,6 +135,7 @@ impl WindowManager { match message { SocketMessage::Promote => self.promote_container_to_front()?, + SocketMessage::PromoteSwap => self.promote_container_swap()?, SocketMessage::PromoteFocus => self.promote_focus_to_front()?, SocketMessage::PromoteWindow(direction) => { self.focus_container_in_direction(direction)?; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 34a3f1c4..5819abf8 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1652,6 +1652,24 @@ impl WindowManager { self.update_focused_workspace(self.mouse_follows_focus, true) } + #[tracing::instrument(skip(self))] + pub fn promote_container_swap(&mut self) -> eyre::Result<()> { + let workspace = self.focused_workspace_mut()?; + let focused_container_idx = workspace.focused_container_idx(); + let primary_idx = match workspace.layout { + Layout::Default(_) => 0, + }; + + if matches!(workspace.layout, Layout::Default(DefaultLayout::Grid)) { + tracing::debug!("ignoring promote-swap command for grid layout"); + return Ok(()); + } + + workspace.swap_containers(focused_container_idx, primary_idx); + + self.update_focused_workspace(self.mouse_follows_focus, true) + } + #[tracing::instrument(skip(self))] pub fn promote_focus_to_front(&mut self) -> eyre::Result<()> { let workspace = self.focused_workspace_mut()?; diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index dd7ed95c..2a898158 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -932,9 +932,11 @@ enum SubCommand { /// Flip the layout on the focused workspace #[clap(arg_required_else_help = true)] FlipLayout(FlipLayout), - /// Promote the focused window to the top of the tree + /// Promote the focused window to the largest tile via container removal and re-insertion Promote, - /// Promote the user focus to the top of the tree + /// Promote the focused window to the largest tile by swapping container indices with the largest tile + PromoteSwap, + /// Promote the user focus to the largest window container PromoteFocus, /// Promote the window in the specified direction PromoteWindow(PromoteWindow), @@ -1760,6 +1762,9 @@ fn main() -> eyre::Result<()> { SubCommand::Promote => { send_message(&SocketMessage::Promote)?; } + SubCommand::PromoteSwap => { + send_message(&SocketMessage::PromoteSwap)?; + } SubCommand::PromoteFocus => { send_message(&SocketMessage::PromoteFocus)?; } diff --git a/mkdocs.yml b/mkdocs.yml index 0b47fb4b..a77cb832 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -145,6 +145,7 @@ nav: - cli/scrolling-layout-columns.md - cli/flip-layout.md - cli/promote.md + - cli/promote-swap.md - cli/promote-focus.md - cli/promote-window.md - cli/retile.md From 6454393cb2a092cd572cd1f37c2297435d4eeaa4 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 4 Nov 2025 13:14:30 -0800 Subject: [PATCH 149/305] feat(wm): make promote-swap reversible This commit makes the komorebic promote-swap command reversible by storing the previous container index in the Workspace state. If the current container index is the same as the layout's primary index, and there is a previous promotion swap container index available, the two containers at those indices will be swapped, effectively making a second call to promote-swap an undo. --- komorebi/src/state.rs | 1 + komorebi/src/window_manager.rs | 10 +++++++++- komorebi/src/workspace.rs | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/komorebi/src/state.rs b/komorebi/src/state.rs index 7c30ac1c..81d12019 100644 --- a/komorebi/src/state.rs +++ b/komorebi/src/state.rs @@ -141,6 +141,7 @@ impl From<&WindowManager> for State { wallpaper: workspace.wallpaper.clone(), workspace_config: None, preselected_container_idx: None, + promotion_swap_container_idx: None, }) .collect::>(); ws.focus(monitor.workspaces.focused_idx()); diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 5819abf8..00c03171 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1656,6 +1656,7 @@ impl WindowManager { pub fn promote_container_swap(&mut self) -> eyre::Result<()> { let workspace = self.focused_workspace_mut()?; let focused_container_idx = workspace.focused_container_idx(); + let primary_idx = match workspace.layout { Layout::Default(_) => 0, }; @@ -1665,7 +1666,14 @@ impl WindowManager { return Ok(()); } - workspace.swap_containers(focused_container_idx, primary_idx); + let primary_tile_is_focused = focused_container_idx == primary_idx; + + if primary_tile_is_focused && let Some(swap_idx) = workspace.promotion_swap_container_idx { + workspace.swap_containers(focused_container_idx, swap_idx); + } else { + workspace.promotion_swap_container_idx = Some(focused_container_idx); + workspace.swap_containers(focused_container_idx, primary_idx); + } self.update_focused_workspace(self.mouse_follows_focus, true) } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index e7794bfe..09852097 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -67,6 +67,8 @@ pub struct Workspace { pub workspace_config: Option, #[serde(skip_serializing_if = "Option::is_none")] pub preselected_container_idx: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub promotion_swap_container_idx: Option, } #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] @@ -119,6 +121,7 @@ impl Default for Workspace { wallpaper: None, workspace_config: None, preselected_container_idx: None, + promotion_swap_container_idx: None, } } } From 39e0ac31bdaaa80687505af069018ce9b529f354 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 5 Nov 2025 08:36:27 -0800 Subject: [PATCH 150/305] ci(github): add nightly version timestamp to brew formula --- .github/workflows/nix.yaml | 2 +- formula.template.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index b8e415bf..01fbb899 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -86,7 +86,7 @@ jobs: GIT_COMMITTER_NAME: "JeezyBot" GIT_COMMITTER_EMAIL: "lgug2z@fastmail.com" run: | - sed "s/REPLACE_ASSET_ID/$ASSET_ID/g; s/REPLACE_SHA_256/$SHA256/g" formula.template.rb > komorebi-for-mac-nightly.rb + sed "s/REPLACE_ASSET_ID/$ASSET_ID/g; s/REPLACE_SHA_256/$SHA256/g; s/REPLACE_NIGHTLY/0.1.0-nightly-$(date +%Y-%m-%d-%H:%M:%S)/g" formula.template.rb > komorebi-for-mac-nightly.rb cat komorebi-for-mac-nightly.rb gh release upload nightly komorebi-for-mac-nightly.rb diff --git a/formula.template.rb b/formula.template.rb index 118951e6..fe565495 100644 --- a/formula.template.rb +++ b/formula.template.rb @@ -7,7 +7,7 @@ class KomorebiForMacNightly < Formula "X-GitHub-Api-Version: 2022-11-28", "Authorization: bearer #{ENV.fetch("HOMEBREW_GITHUB_API_TOKEN")}", ] - version "nightly" + version "REPLACE_NIGHTLY" sha256 "REPLACE_SHA_256" license "Komorebi License 2.0.0" From 909b8b5df09936a3803a8e6cc2a202c7d576f63e Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 5 Nov 2025 08:43:43 -0800 Subject: [PATCH 151/305] ci(github): add @acsandmann's codesigning trick to brew template --- formula.template.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/formula.template.rb b/formula.template.rb index fe565495..d2b29b95 100644 --- a/formula.template.rb +++ b/formula.template.rb @@ -13,6 +13,10 @@ class KomorebiForMacNightly < Formula def install bin.install Dir["*"] + + system "codesign", "--force", "-s", "-", "#{bin}/komorebi" + system "codesign", "--force", "-s", "-", "#{bin}/komorebic" + system "codesign", "--force", "-s", "-", "#{bin}/komorebi-bar" end def caveats From db8cf858ff1ba5a6a454fa2e6a8732578f212f3c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 6 Nov 2025 13:44:35 -0800 Subject: [PATCH 152/305] build(nix): pull git rev info from flake inputs This commit adds a new workspace crate, version, which is consumed by komorebi and komorebic. If either of those binaries are being built by the Nix Flake, the git rev info will be pulled from inputs.self.rev instead of querying the git repo, because the git files are not passed to the derivation. The build.rs for the version crate decides if the build is happening by querying the shadow-rs build output for BRANCH, which will always be empty when a "nix build" is running. Cargo builds will use the standard git information retrieval mechanisms in shadow-rs. The information in both cases is exposed as version::LONG_VERSION, and passed to clap as the string to return when either binary is called with the --version flag. --- Cargo.lock | 9 +++++ Cargo.toml | 8 +++- deny.toml | 5 +++ flake.nix | 68 +++++++++++++-------------------- justfile | 3 +- komorebi/Cargo.toml | 4 +- komorebi/build.rs | 5 --- komorebi/src/lib.rs | 2 - komorebi/src/main.rs | 2 +- komorebi/src/process_command.rs | 2 +- komorebic/Cargo.toml | 1 + komorebic/build.rs | 4 -- komorebic/src/main.rs | 4 +- shell.nix | 3 +- version/Cargo.toml | 10 +++++ version/build.rs | 42 ++++++++++++++++++++ version/src/lib.rs | 3 ++ 17 files changed, 112 insertions(+), 63 deletions(-) delete mode 100644 komorebi/build.rs create mode 100644 version/Cargo.toml create mode 100644 version/build.rs create mode 100644 version/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index bbe798f2..fce2c79f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2967,6 +2967,7 @@ dependencies = [ "tracing-appender", "tracing-subscriber", "uuid", + "version", ] [[package]] @@ -3050,6 +3051,7 @@ dependencies = [ "serde_json_lenient", "shadow-rs", "sysinfo", + "version", ] [[package]] @@ -6479,6 +6481,13 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version" +version = "0.1.0" +dependencies = [ + "shadow-rs", +] + [[package]] name = "version-compare" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 8202d407..c51b83b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,13 @@ [workspace] resolver = "2" -members = ["komorebi", "komorebi-bar", "komorebi-client", "komorebic"] +members = [ + "komorebi", + "komorebi-bar", + "komorebi-client", + "komorebic", + "version", +] [workspace.package] version = "0.1.0" diff --git a/deny.toml b/deny.toml index 7a56b2a8..8b01210d 100644 --- a/deny.toml +++ b/deny.toml @@ -62,6 +62,11 @@ crate = "komorebi-themes" expression = "LicenseRef-Komorebi-2.0" license-files = [] +[[licenses.clarify]] +crate = "version" +expression = "LicenseRef-Komorebi-2.0" +license-files = [] + [[licenses.clarify]] crate = "base16-egui-themes" expression = "MIT" diff --git a/flake.nix b/flake.nix index ef4f7694..994950e3 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,7 @@ }; outputs = { + self, nixpkgs, crane, flake-utils, @@ -35,60 +36,50 @@ || (builtins.match ".*/docs/.*" path != null); }; - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - commonArgs = { - inherit src version cargoArtifacts; + inherit src version; strictDeps = true; + COMMIT_HASH = self.rev or (lib.removeSuffix "-dirty" self.dirtyRev); + buildInputs = [ pkgs.gcc pkgs.libiconv ]; }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + individualCrateArgs = commonArgs // { + inherit cargoArtifacts; doCheck = false; + doDoc = false; }; - packages = { - komorebi = craneLib.buildPackage ( + packages = let + fullBuild = craneLib.buildPackage ( individualCrateArgs // { - inherit version; - pname = "komorebi"; - cargoExtraArgs = "-p komorebi"; + pname = "komorebi-workspace"; } ); - komorebic = craneLib.buildPackage ( - individualCrateArgs - // { - inherit version; - pname = "komorebic"; - cargoExtraArgs = "-p komorebic"; + extractBinary = binaryName: + pkgs.runCommand "komorebi-${binaryName}" + { + meta = fullBuild.meta // {}; } - ); - - komorebi-bar = craneLib.buildPackage ( - individualCrateArgs - // { - inherit version; - pname = "komorebi-bar"; - cargoExtraArgs = "-p komorebi-bar"; - } - ); - - komorebi-full = craneLib.buildPackage ( - individualCrateArgs - // { - inherit version; - pname = "komorebi-full"; - cargoExtraArgs = "-p komorebi -p komorebic -p komorebi-bar"; - } - ); + '' + mkdir -p $out/bin + cp ${fullBuild}/bin/${binaryName} $out/bin/ + ''; + in { + komorebi-full = fullBuild; + komorebi = extractBinary "komorebi"; + komorebic = extractBinary "komorebic"; + komorebi-bar = extractBinary "komorebi-bar"; }; in packages @@ -108,23 +99,18 @@ buildResult = komorebiBuild system; inherit (buildResult) + individualCrateArgs komorebi komorebic komorebi-bar komorebi-full pkgs craneLib - commonArgs src ; in { checks = { - komorebi-workspace-clippy = craneLib.cargoClippy ( - commonArgs - // { - cargoClippyExtraArgs = "--all-targets -- --deny warnings"; - } - ); + komorebi-workspace-clippy = craneLib.cargoClippy individualCrateArgs; komorebi-workspace-fmt = craneLib.cargoFmt { inherit src; @@ -138,7 +124,7 @@ inherit src; }; - komorebi-workspace-nextest = craneLib.cargoNextest commonArgs; + komorebi-workspace-nextest = craneLib.cargoNextest individualCrateArgs; }; packages = { diff --git a/justfile b/justfile index 97516fb8..46bc15af 100644 --- a/justfile +++ b/justfile @@ -4,6 +4,7 @@ fmt: test -z "$(rg 'eyre!' --type rust)" || (echo "eyre! macro not allowed"; false) test -z "$(rg 'dbg!' --type rust)" || (echo "dbg! macro not allowed"; false) test -z "$(rg 'println!' --type rust ./komorebi)" || (echo "println! macro not allowed"; false) + taplo fmt Cargo.toml */Cargo.toml cargo +nightly fmt cargo +stable clippy alejandra . @@ -56,4 +57,4 @@ depgen: push: git push origin master - git push komocorp master \ No newline at end of file + git push komocorp master diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 2d87c3b1..ae779f00 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" [dependencies] komorebi-themes = { workspace = true } quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } +version = { path = "../version" } base64 = "0.21" block2 = "0.6" @@ -50,9 +51,6 @@ tracing = { workspace = true } tracing-appender = { workspace = true } tracing-subscriber = { workspace = true } -[build-dependencies] -shadow-rs = { workspace = true } - [dev-dependencies] uuid = { version = "1", features = ["v4"] } diff --git a/komorebi/build.rs b/komorebi/build.rs deleted file mode 100644 index 44fad00f..00000000 --- a/komorebi/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -use shadow_rs::ShadowBuilder; - -fn main() { - ShadowBuilder::builder().build().unwrap(); -} diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 4a00c5d9..87fbbc4e 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -149,8 +149,6 @@ lazy_static! { static ref UNMANAGED_WINDOW_IDS: Arc>> = Arc::new(Mutex::new(vec![])); } -shadow_rs::shadow!(build); - pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 = AtomicI32::new(5); pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(5); diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 9e851504..7cccd778 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -173,7 +173,7 @@ enum LogLevel { } #[derive(Parser)] -#[clap(author, about, version = komorebi::build::CLAP_LONG_VERSION)] +#[clap(author, about, version = version::LONG_VERSION)] struct Opts { /// Path to a static configuration JSON file #[clap(short, long)] diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 4ebe8eeb..d4f13b7a 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -12,7 +12,6 @@ use crate::WORKSPACE_MATCHING_RULES; use crate::accessibility::AccessibilityApi; use crate::application::Application; use crate::border_manager; -use crate::build; use crate::cf_array_as; use crate::core::ApplicationIdentifier; use crate::core::MoveBehaviour; @@ -64,6 +63,7 @@ use std::str::FromStr; use std::sync::Arc; use std::sync::atomic::Ordering; use std::time::Duration; +use version::build; #[tracing::instrument] pub fn listen_for_commands(wm: Arc>) { diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index ccbec568..3817caa4 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -6,6 +6,7 @@ edition = "2024" [dependencies] komorebi-client = { path = "../komorebi-client", default-features = false } +version = { path = "../version" } clap = { workspace = true } clap_complete = "4" diff --git a/komorebic/build.rs b/komorebic/build.rs index 6da11b8a..b7c1f27e 100644 --- a/komorebic/build.rs +++ b/komorebic/build.rs @@ -1,5 +1,3 @@ -use shadow_rs::ShadowBuilder; - fn main() { if std::fs::metadata("applications.json").is_err() { let applications_json = reqwest::blocking::get( @@ -7,6 +5,4 @@ fn main() { ).unwrap().text().unwrap(); std::fs::write("applications.json", applications_json).unwrap(); } - - ShadowBuilder::builder().build().unwrap(); } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 2a898158..1770d847 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -61,8 +61,6 @@ lazy_static! { .join("komorebi"); } -shadow_rs::shadow!(build); - #[derive(Copy, Clone, ValueEnum)] enum BooleanState { Enable, @@ -668,7 +666,7 @@ struct Splash { } #[derive(Parser)] -#[clap(author, about, version = build::CLAP_LONG_VERSION)] +#[clap(author, about, version = version::LONG_VERSION)] struct Opts { #[clap(subcommand)] subcmd: SubCommand, diff --git a/shell.nix b/shell.nix index 32a27942..fb685225 100644 --- a/shell.nix +++ b/shell.nix @@ -8,13 +8,14 @@ with pkgs; buildInputs = [ alejandra cargo-deny - cargo-udeps cargo-nextest + cargo-udeps gcc jq just libiconv prettier + taplo python311Packages.mkdocs-material python311Packages.mkdocs-macros diff --git a/version/Cargo.toml b/version/Cargo.toml new file mode 100644 index 00000000..ac610fad --- /dev/null +++ b/version/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "version" +edition = "2024" +version.workspace = true + +[dependencies] +shadow-rs = { workspace = true } + +[build-dependencies] +shadow-rs = { workspace = true } diff --git a/version/build.rs b/version/build.rs new file mode 100644 index 00000000..6c2f158a --- /dev/null +++ b/version/build.rs @@ -0,0 +1,42 @@ +use std::fs::File; +use std::io::Write; + +use shadow_rs::SdResult; +use shadow_rs::ShadowBuilder; + +fn main() { + let is_flake_build = ShadowBuilder::builder() + .build() + .unwrap() + .map + .get("BRANCH") + .map_or_else(|| true, |entry| entry.v.is_empty()); + + if is_flake_build { + ShadowBuilder::builder().hook(flake_hook).build().unwrap(); + } else { + ShadowBuilder::builder().hook(raw_hook).build().unwrap(); + } +} + +const RAW_VERSION_CONST: &str = r##"pub const LONG_VERSION:&str = shadow_rs::formatcp!(r#"{} +branch:{} +commit_hash:{} +build_env:{},{}"#,PKG_VERSION, BRANCH, COMMIT_HASH, RUST_VERSION, RUST_CHANNEL +); +"##; + +fn raw_hook(mut file: &File) -> SdResult<()> { + writeln!(file, "{RAW_VERSION_CONST}")?; + Ok(()) +} + +const FLAKE_VERSION_CONST: &str = r##"pub const LONG_VERSION:&str = shadow_rs::formatcp!(r#"{} +commit_hash:{} +build_env:{},{}"#,PKG_VERSION, env!("COMMIT_HASH"), RUST_VERSION, RUST_CHANNEL +);"##; + +fn flake_hook(mut file: &File) -> SdResult<()> { + writeln!(file, "{FLAKE_VERSION_CONST}")?; + Ok(()) +} diff --git a/version/src/lib.rs b/version/src/lib.rs new file mode 100644 index 00000000..b537c9ce --- /dev/null +++ b/version/src/lib.rs @@ -0,0 +1,3 @@ +shadow_rs::shadow!(build); + +pub use build::LONG_VERSION; From 8e7913c5ae09a69ac20057e7b1c9177dd7635268 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 6 Nov 2025 19:06:04 -0800 Subject: [PATCH 153/305] chore(deps): cargo update --- Cargo.lock | 255 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 167 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fce2c79f..e9b39ae4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] @@ -316,7 +316,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -439,7 +439,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -474,7 +474,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -762,7 +762,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -797,18 +797,43 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "calloop" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb9f6e1368bd4621d2c86baa7e37de77a938adf5221e5dd3d6133340101b309e" +dependencies = [ + "bitflags 2.10.0", + "polling", + "rustix 1.1.2", + "slab", + "tracing", +] + [[package]] name = "calloop-wayland-source" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" dependencies = [ - "calloop", + "calloop 0.13.0", "rustix 0.38.44", "wayland-backend", "wayland-client", ] +[[package]] +name = "calloop-wayland-source" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" +dependencies = [ + "calloop 0.14.3", + "rustix 1.1.2", + "wayland-backend", + "wayland-client", +] + [[package]] name = "calm_io" version = "0.1.1" @@ -839,9 +864,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.43" +version = "1.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2" +checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3" dependencies = [ "find-msvc-tools", "jobserver", @@ -912,9 +937,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.50" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" +checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" dependencies = [ "clap_builder", "clap_derive", @@ -922,9 +947,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.50" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" +checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" dependencies = [ "anstream", "anstyle", @@ -935,9 +960,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.59" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2348487adcd4631696ced64ccdb40d38ac4d31cae7f2eec8817fcea1b9d1c43c" +checksum = "8e602857739c5a4291dfa33b5a298aeac9006185229a700e5810a3ef7272d971" dependencies = [ "clap", ] @@ -951,7 +976,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1227,11 +1252,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.5.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881c5d0a13b2f1498e2306e82cbada78390e152d4b1378fb28a84f4dcd0dc4f3" +checksum = "73736a89c4aff73035ba2ed2e565061954da00d4970fc9ac25dcc85a2a20d790" dependencies = [ - "dispatch", + "dispatch2", "nix", "windows-sys 0.61.2", ] @@ -1266,7 +1291,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1290,7 +1315,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1301,7 +1326,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1420,7 +1445,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1679,7 +1704,7 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1723,7 +1748,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1827,7 +1852,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -1962,7 +1987,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -2058,7 +2083,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -2808,7 +2833,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -2819,9 +2844,9 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "iri-string" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" dependencies = [ "memchr", "serde", @@ -3225,7 +3250,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -3691,7 +3716,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -3765,7 +3790,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -4254,7 +4279,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -4283,9 +4308,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orbclient" -version = "0.3.48" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba0b26cec2e24f08ed8bb31519a9333140a6599b867dac464bb150bdb796fd43" +checksum = "247ad146e19b9437f8604c21f8652423595cf710ad108af40e77d3ae6e96b827" dependencies = [ "libredox", ] @@ -4480,7 +4505,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -4644,7 +4669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -4722,9 +4747,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.41" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] @@ -5009,7 +5034,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5167,9 +5192,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.34" +version = "0.23.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7" +checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f" dependencies = [ "once_cell", "rustls-pki-types", @@ -5254,9 +5279,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" dependencies = [ "dyn-clone", "ref-cast", @@ -5273,7 +5298,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5303,7 +5328,7 @@ dependencies = [ "ab_glyph", "log", "memmap2", - "smithay-client-toolkit", + "smithay-client-toolkit 0.19.2", "tiny-skia", ] @@ -5363,7 +5388,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5374,7 +5399,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5411,7 +5436,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5457,7 +5482,7 @@ dependencies = [ "indexmap 2.12.0", "schemars 0.8.22", "schemars 0.9.0", - "schemars 1.0.4", + "schemars 1.1.0", "serde_core", "serde_json", "serde_with_macros", @@ -5473,7 +5498,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5636,8 +5661,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ "bitflags 2.10.0", - "calloop", - "calloop-wayland-source", + "calloop 0.13.0", + "calloop-wayland-source 0.3.0", "cursor-icon", "libc", "log", @@ -5655,13 +5680,40 @@ dependencies = [ ] [[package]] -name = "smithay-clipboard" -version = "0.7.2" +name = "smithay-client-toolkit" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc8216eec463674a0e90f29e0ae41a4db573ec5b56b1c6c1c71615d249b6d846" +checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" +dependencies = [ + "bitflags 2.10.0", + "calloop 0.14.3", + "calloop-wayland-source 0.4.1", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 1.1.2", + "thiserror 2.0.17", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-experimental", + "wayland-protocols-misc", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-clipboard" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71704c03f739f7745053bde45fa203a46c58d25bc5c4efba1d9a60e9dba81226" dependencies = [ "libc", - "smithay-client-toolkit", + "smithay-client-toolkit 0.20.0", "wayland-backend", ] @@ -5773,7 +5825,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5785,7 +5837,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5807,9 +5859,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.108" +version = "2.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" +checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f" dependencies = [ "proc-macro2", "quote", @@ -5833,7 +5885,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5948,7 +6000,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -5959,7 +6011,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -6100,9 +6152,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" dependencies = [ "bytes", "futures-core", @@ -6235,6 +6287,7 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -6260,7 +6313,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -6384,9 +6437,9 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-ident" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-segmentation" @@ -6490,9 +6543,9 @@ dependencies = [ [[package]] name = "version-compare" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" +checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" [[package]] name = "version_check" @@ -6585,7 +6638,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", "wasm-bindgen-shared", ] @@ -6658,6 +6711,32 @@ dependencies = [ "wayland-scanner", ] +[[package]] +name = "wayland-protocols-experimental" +version = "20250721.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" +dependencies = [ + "bitflags 2.10.0", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-misc" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfe33d551eb8bffd03ff067a8b44bb963919157841a99957151299a6307d19c" +dependencies = [ + "bitflags 2.10.0", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + [[package]] name = "wayland-protocols-plasma" version = "0.3.9" @@ -7017,7 +7096,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -7028,7 +7107,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -7039,7 +7118,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -7050,7 +7129,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -7459,7 +7538,7 @@ dependencies = [ "bitflags 2.10.0", "block2 0.5.1", "bytemuck", - "calloop", + "calloop 0.13.0", "cfg_aliases", "concurrent-queue", "core-foundation 0.9.4", @@ -7481,7 +7560,7 @@ dependencies = [ "redox_syscall 0.4.1", "rustix 0.38.44", "sctk-adwaita", - "smithay-client-toolkit", + "smithay-client-toolkit 0.19.2", "smol_str", "tracing", "unicode-segmentation", @@ -7611,7 +7690,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", "synstructure", ] @@ -7667,7 +7746,7 @@ checksum = "dc6821851fa840b708b4cbbaf6241868cabc85a2dc22f426361b0292bfc0b836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", "zbus-lockstep", "zbus_xml", "zvariant", @@ -7682,7 +7761,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", "zbus_names", "zvariant", "zvariant_utils", @@ -7730,7 +7809,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -7750,7 +7829,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", "synstructure", ] @@ -7790,7 +7869,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", ] [[package]] @@ -7840,7 +7919,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.109", "zvariant_utils", ] @@ -7853,6 +7932,6 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.108", + "syn 2.0.109", "winnow", ] From 4e8caf2b2a777cf8dbc75fbaa87d98406e6bc390 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 6 Nov 2025 19:06:46 -0800 Subject: [PATCH 154/305] chore(deps): flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/1979a2524cb8c801520bd94c38bb3d5692419d93' (2025-10-08) → 'github:ipetkov/crane/50700219af884287ad7c85507e2f163b23a027a9' (2025-11-03) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/87848bf0cc4f87717fc813a4575f07330c3e743c' (2025-10-20) → 'github:NixOS/nixpkgs/ffcdcf99d65c61956d882df249a9be53e5902ea5' (2025-11-05) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/a9121dc4ccd63e0309426b91bd7a494189516274' (2025-10-19) → 'github:oxalica/rust-overlay/9de55b59b6aaadbd9dbf223765a835239b767ee5' (2025-11-07) --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index bf4252ff..a88daaff 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1759893430, - "narHash": "sha256-yAy4otLYm9iZ+NtQwTMEbqHwswSFUbhn7x826RR6djw=", + "lastModified": 1762189950, + "narHash": "sha256-aotggLUXjlDGqKWibGPQcMZJGgdr79S21ISrv1Wz6RI=", "owner": "ipetkov", "repo": "crane", - "rev": "1979a2524cb8c801520bd94c38bb3d5692419d93", + "rev": "50700219af884287ad7c85507e2f163b23a027a9", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1760934318, - "narHash": "sha256-/oUYsC0lUCBory65VK+UHqCCsCspbL1Vgfcf1KUYqVw=", + "lastModified": 1762361079, + "narHash": "sha256-lz718rr1BDpZBYk7+G8cE6wee3PiBUpn8aomG/vLLiY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "87848bf0cc4f87717fc813a4575f07330c3e743c", + "rev": "ffcdcf99d65c61956d882df249a9be53e5902ea5", "type": "github" }, "original": { @@ -78,11 +78,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1760841560, - "narHash": "sha256-NVOl5Lk1QD+i4I4My4f85yjXBinu+OXOUWskPNtzKHs=", + "lastModified": 1762483116, + "narHash": "sha256-Z8EVsTH10BjCdFyPxbUu5jBV+HGL39rh9+beQcnNRm0=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a9121dc4ccd63e0309426b91bd7a494189516274", + "rev": "9de55b59b6aaadbd9dbf223765a835239b767ee5", "type": "github" }, "original": { From a830cfe58a0efdfb9de8185c6c930ba823e127b6 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 7 Nov 2025 14:40:23 -0800 Subject: [PATCH 155/305] build(rust): avoid calling shadow-rs twice --- version/build.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/version/build.rs b/version/build.rs index 6c2f158a..1b80c0a1 100644 --- a/version/build.rs +++ b/version/build.rs @@ -5,17 +5,15 @@ use shadow_rs::SdResult; use shadow_rs::ShadowBuilder; fn main() { - let is_flake_build = ShadowBuilder::builder() - .build() - .unwrap() + let shadow_build = ShadowBuilder::builder().hook(raw_hook).build().unwrap(); + + let is_flake_build = shadow_build .map .get("BRANCH") .map_or_else(|| true, |entry| entry.v.is_empty()); if is_flake_build { ShadowBuilder::builder().hook(flake_hook).build().unwrap(); - } else { - ShadowBuilder::builder().hook(raw_hook).build().unwrap(); } } From 66b8f838bd3053b4da33dfbb9f96657c1166c33a Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 12 Nov 2025 16:29:06 -0800 Subject: [PATCH 156/305] chore(deps): handle egui-related upgrades --- Cargo.lock | 391 ++++++++++++++++++++-------------------- Cargo.toml | 6 +- deny.toml | 3 +- dependencies.json | 123 +++++++------ komorebi-bar/Cargo.toml | 4 +- komorebi/Cargo.toml | 2 +- 6 files changed, 264 insertions(+), 265 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9b39ae4..db8075f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,15 +20,15 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "accesskit" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25ae84c0260bdf5df07796d7cc4882460de26a2b406ec0e6c42461a723b271b" +checksum = "cf203f9d3bd8f29f98833d1fbef628df18f759248a547e7e01cfbf63cda36a99" [[package]] name = "accesskit_atspi_common" -version = "0.12.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bd41de2e54451a8ca0dd95ebf45b54d349d29ebceb7f20be264eee14e3d477" +checksum = "890d241cf51fc784f0ac5ac34dfc847421f8d39da6c7c91a0fcc987db62a8267" dependencies = [ "accesskit", "accesskit_consumer", @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bfae7c152994a31dc7d99b8eeac7784a919f71d1b306f4b83217e110fd3824c" +checksum = "db81010a6895d8707f9072e6ce98070579b43b717193d2614014abd5cb17dd43" dependencies = [ "accesskit", "hashbrown 0.15.5", @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "accesskit_macos" -version = "0.20.0" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692dd318ff8a7a0ffda67271c4bd10cf32249656f4e49390db0b26ca92b095f2" +checksum = "a0089e5c0ac0ca281e13ea374773898d9354cc28d15af9f0f7394d44a495b575" dependencies = [ "accesskit", "accesskit_consumer", @@ -64,9 +64,9 @@ dependencies = [ [[package]] name = "accesskit_unix" -version = "0.15.0" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f7474c36606d0fe4f438291d667bae7042ea2760f506650ad2366926358fc8" +checksum = "301e55b39cfc15d9c48943ce5f572204a551646700d0e8efa424585f94fec528" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "accesskit_windows" -version = "0.27.0" +version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a042b62c9c05bf7b616f015515c17d2813f3ba89978d6f4fc369735d60700a" +checksum = "d2d63dd5041e49c363d83f5419a896ecb074d309c414036f616dc0b04faca971" dependencies = [ "accesskit", "accesskit_consumer", @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "accesskit_winit" -version = "0.27.0" +version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1f0d3d13113d8857542a4f8d1a1c24d1dc1527b77aee8426127f4901588708" +checksum = "c8cfabe59d0eaca7412bfb1f70198dd31e3b0496fee7e15b066f9c36a1a140a0" dependencies = [ "accesskit", "accesskit_macos", @@ -197,7 +197,7 @@ dependencies = [ "log", "ndk", "ndk-context", - "ndk-sys 0.6.0+11769913", + "ndk-sys", "num_enum", "thiserror 1.0.69", ] @@ -316,7 +316,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -439,7 +439,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -474,7 +474,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -580,13 +580,13 @@ dependencies = [ [[package]] name = "base16-egui-themes" version = "0.1.0" -source = "git+https://github.com/LGUG2Z/base16-egui-themes?rev=c9008bd5cfa288c926e9ea3aa18c92073f9281bd#c9008bd5cfa288c926e9ea3aa18c92073f9281bd" +source = "git+https://github.com/LGUG2Z/base16-egui-themes?rev=5472b1ab825c48af1a1726e324cfa13b7c385135#5472b1ab825c48af1a1726e324cfa13b7c385135" dependencies = [ "egui", "schemars 0.8.22", "serde", - "strum 0.27.2", - "strum_macros 0.27.2", + "strum", + "strum_macros", ] [[package]] @@ -600,12 +600,6 @@ dependencies = [ "serde", ] -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -656,9 +650,6 @@ name = "bitflags" version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" -dependencies = [ - "serde_core", -] [[package]] name = "bitstream-io" @@ -762,7 +753,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -856,17 +847,16 @@ dependencies = [ [[package]] name = "catppuccin-egui" version = "5.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62cca484c0a36096745da413bacbd290322fd194eb1ed2d9910deec392649f2a" +source = "git+https://github.com/LGUG2Z/catppuccin-egui?rev=b2f95cbf441d1dd99f3c955ef10dcb84ce23c20a#b2f95cbf441d1dd99f3c955ef10dcb84ce23c20a" dependencies = [ "egui", ] [[package]] name = "cc" -version = "1.2.44" +version = "1.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3" +checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe" dependencies = [ "find-msvc-tools", "jobserver", @@ -976,7 +966,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1141,7 +1131,7 @@ checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" dependencies = [ "bitflags 1.3.2", "core-foundation 0.9.4", - "core-graphics-types", + "core-graphics-types 0.1.3", "foreign-types 0.3.2", "libc", ] @@ -1154,7 +1144,7 @@ checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", "core-foundation 0.9.4", - "core-graphics-types", + "core-graphics-types 0.1.3", "foreign-types 0.5.0", "libc", ] @@ -1170,6 +1160,17 @@ dependencies = [ "libc", ] +[[package]] +name = "core-graphics-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" +dependencies = [ + "bitflags 2.10.0", + "core-foundation 0.10.1", + "libc", +] + [[package]] name = "core-text" version = "19.2.0" @@ -1242,9 +1243,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -1291,7 +1292,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1315,7 +1316,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1326,7 +1327,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1445,7 +1446,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1503,9 +1504,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bdf37f8d5bd9aa7f753573fdda9cf7343afa73dd28d7bfe9593bd9798fc07e" +checksum = "adf31f99fad93fe83c1055b92b5c1b135f1ecfa464789817c372000e768d4bd1" dependencies = [ "bytemuck", "emath", @@ -1537,9 +1538,9 @@ dependencies = [ [[package]] name = "eframe" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d1c15e7bd136b309bd3487e6ffe5f668b354cd9768636a836dd738ac90eb0b" +checksum = "b829d302a09deb4acde242262a1840ba14fadd0371980ebf713060077a1987bc" dependencies = [ "ahash", "bytemuck", @@ -1566,16 +1567,15 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "web-time", - "winapi", - "windows-sys 0.59.0", + "windows-sys 0.61.2", "winit", ] [[package]] name = "egui" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5d0306cd61ca75e29682926d71f2390160247f135965242e904a636f51c0dc" +checksum = "ab9b5d3376c79439f53a78bf7da1e3c0b862ffa3e29f46ab0f3e107430f2e576" dependencies = [ "accesskit", "ahash", @@ -1592,17 +1592,16 @@ dependencies = [ [[package]] name = "egui-phosphor" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80049258178b29a9807b15b5bcf3d60722a22a91d03bc9316935dec5ed5ed2e0" +source = "git+https://github.com/amPerl/egui-phosphor?rev=d13688738478ecd12b426e3e74c59d6577a85b59#d13688738478ecd12b426e3e74c59d6577a85b59" dependencies = [ "egui", ] [[package]] name = "egui-wgpu" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c12eca13293f8eba27a32aaaa1c765bfbf31acd43e8d30d5881dcbe5e99ca0c7" +checksum = "cef1fe83ba30b3d045814b2d811804f2a7e50a832034c975408f71c20df596e4" dependencies = [ "ahash", "bytemuck", @@ -1611,7 +1610,7 @@ dependencies = [ "epaint", "log", "profiling", - "thiserror 1.0.69", + "thiserror 2.0.17", "type-map", "web-time", "wgpu", @@ -1620,16 +1619,18 @@ dependencies = [ [[package]] name = "egui-winit" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95d0a91f9cb0dc2e732d49c2d521ac8948e1f0b758f306fb7b14d6f5db3927f" +checksum = "bb4ea8cb063c00d8f23ce11279c01eb63a195a72be0e21d429148246dab7983e" dependencies = [ "accesskit_winit", - "ahash", "arboard", "bytemuck", "egui", "log", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-ui-kit", "profiling", "raw-window-handle", "smithay-clipboard", @@ -1640,11 +1641,10 @@ dependencies = [ [[package]] name = "egui_glow" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7037813341727937f9e22f78d912f3e29bc3c46e2f40a9e82bb51cbf5e4cfb" +checksum = "668c0d4f726cc33838f0915f6b8c00af0ca0910e975ab58cf34b3e39c614552c" dependencies = [ - "ahash", "bytemuck", "egui", "glow", @@ -1664,9 +1664,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "emath" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45fd7bc25f769a3c198fe1cf183124bf4de3bd62ef7b4f1eaf6b08711a3af8db" +checksum = "c615516cdceec867065f20d7db13d8eb8aedd65c9e32cc0c7c379380fa42e6e8" dependencies = [ "bytemuck", ] @@ -1704,14 +1704,14 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] name = "epaint" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63adcea970b7a13094fe97a36ab9307c35a750f9e24bf00bb7ef3de573e0fddb" +checksum = "9926b9500ccb917adb070207ec722dd8ea78b8321f94a85ebec776f501f2930c" dependencies = [ "ab_glyph", "ahash", @@ -1727,9 +1727,9 @@ dependencies = [ [[package]] name = "epaint_default_fonts" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1537accc50c9cab5a272c39300bdd0dd5dca210f6e5e8d70be048df9596e7ca2" +checksum = "66054d943c66715c6003a27a3dc152d87cadf714ef2597ccd79f550413009b97" [[package]] name = "equator" @@ -1748,7 +1748,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1806,9 +1806,9 @@ dependencies = [ [[package]] name = "exr" -version = "1.73.0" +version = "1.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" +checksum = "4300e043a56aa2cb633c01af81ca8f699a321879a7854d3896a0ba89056363be" dependencies = [ "bit_field", "half", @@ -1852,7 +1852,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1947,6 +1947,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "font-loader" version = "0.11.0" @@ -1987,7 +1993,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2083,7 +2089,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2117,9 +2123,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -2397,7 +2403,7 @@ version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ - "foldhash", + "foldhash 0.1.5", ] [[package]] @@ -2405,6 +2411,9 @@ name = "hashbrown" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +dependencies = [ + "foldhash 0.2.0", +] [[package]] name = "heck" @@ -2497,9 +2506,9 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "1744436df46f0bde35af3eda22aeaba453aada65d8f1c171cd8a5f59030bd69f" dependencies = [ "atomic-waker", "bytes", @@ -2555,7 +2564,7 @@ version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "futures-channel", "futures-core", @@ -2833,7 +2842,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2951,7 +2960,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" name = "komorebi" version = "0.1.0" dependencies = [ - "base64 0.21.7", + "base64", "block2 0.6.2", "chrono", "clap", @@ -2985,7 +2994,7 @@ dependencies = [ "serde_json_lenient", "serde_with", "shadow-rs", - "strum 0.27.2", + "strum", "sysinfo", "thiserror 2.0.17", "tracing", @@ -3045,7 +3054,7 @@ dependencies = [ [[package]] name = "komorebi-themes" version = "0.1.39" -source = "git+https://github.com/LGUG2Z/komorebi?rev=1c23439f959bcfddf0f71918fc03a97dd4f30727#1c23439f959bcfddf0f71918fc03a97dd4f30727" +source = "git+https://github.com/LGUG2Z/komorebi?rev=c8c4c3507c3cb9cdd94e1a40d366320531455d75#c8c4c3507c3cb9cdd94e1a40d366320531455d75" dependencies = [ "base16-egui-themes", "catppuccin-egui", @@ -3055,7 +3064,7 @@ dependencies = [ "schemars 0.8.22", "serde", "serde_variant", - "strum 0.27.2", + "strum", ] [[package]] @@ -3174,9 +3183,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.22" +version = "1.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" +checksum = "15d118bbf3771060e7311cc7bb0545b01d08a8b4a7de949198dec1fa0ca1c0f7" dependencies = [ "cc", "libc", @@ -3250,7 +3259,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3271,6 +3280,12 @@ dependencies = [ "imgref", ] +[[package]] +name = "mac-addr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3d25b0e0b648a86960ac23b7ad4abb9717601dec6f66c165f5b037f3f03065f" + [[package]] name = "mach2" version = "0.5.0" @@ -3334,13 +3349,13 @@ dependencies = [ [[package]] name = "metal" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e" +checksum = "00c15a6f673ff72ddcc22394663290f870fb224c1bfce55734a75c414150e605" dependencies = [ "bitflags 2.10.0", "block", - "core-graphics-types", + "core-graphics-types 0.2.0", "foreign-types 0.5.0", "log", "objc", @@ -3432,25 +3447,26 @@ dependencies = [ [[package]] name = "naga" -version = "25.0.1" +version = "27.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632" +checksum = "066cf25f0e8b11ee0df221219010f213ad429855f57c494f995590c861a9a7d8" dependencies = [ "arrayvec", "bit-set", "bitflags 2.10.0", + "cfg-if", "cfg_aliases", "codespan-reporting", "half", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "hexf-parse", "indexmap 2.12.0", + "libm", "log", "num-traits", "once_cell", "rustc-hash 1.1.0", "spirv", - "strum 0.26.3", "thiserror 2.0.17", "unicode-ident", ] @@ -3490,7 +3506,7 @@ dependencies = [ "bitflags 2.10.0", "jni-sys", "log", - "ndk-sys 0.6.0+11769913", + "ndk-sys", "num_enum", "raw-window-handle", "thiserror 1.0.69", @@ -3502,15 +3518,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" -[[package]] -name = "ndk-sys" -version = "0.5.0+25.2.9519653" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" -dependencies = [ - "jni-sys", -] - [[package]] name = "ndk-sys" version = "0.6.0+11769913" @@ -3522,13 +3529,14 @@ dependencies = [ [[package]] name = "netdev" -version = "0.38.2" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ab878b4c90faf36dab10ea51d48c69ae9019bcca47c048a7c9b273d5d7a823" +checksum = "35a703aa1a87cd885b9f674922445a42dbb0c0f4f1b28fef21b227ae32375d21" dependencies = [ "dlopen2", "ipnet", "libc", + "mac-addr", "netlink-packet-core", "netlink-packet-route", "netlink-sys", @@ -3716,7 +3724,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3790,7 +3798,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4258,9 +4266,9 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openssl" -version = "0.10.74" +version = "0.10.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" dependencies = [ "bitflags 2.10.0", "cfg-if", @@ -4279,7 +4287,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4290,9 +4298,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.110" +version = "0.9.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" dependencies = [ "cc", "libc", @@ -4317,9 +4325,9 @@ dependencies = [ [[package]] name = "ordered-float" -version = "4.6.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +checksum = "7f4779c6901a562440c3786d08192c6fbda7c1c2060edd10006b05ee35d10f2d" dependencies = [ "num-traits", ] @@ -4505,7 +4513,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4553,9 +4561,9 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" dependencies = [ - "base64 0.22.1", + "base64", "indexmap 2.12.0", - "quick-xml 0.38.3", + "quick-xml 0.38.4", "serde", "time", ] @@ -4605,6 +4613,15 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "potential_utf" version = "0.1.4" @@ -4669,7 +4686,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4726,9 +4743,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.38.3" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" +checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c" dependencies = [ "memchr", ] @@ -5034,7 +5051,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5078,7 +5095,7 @@ version = "0.12.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "encoding_rs", "futures-channel", @@ -5298,7 +5315,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5388,7 +5405,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5399,7 +5416,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5436,7 +5453,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5475,7 +5492,7 @@ version = "3.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04" dependencies = [ - "base64 0.22.1", + "base64", "chrono", "hex", "indexmap 1.9.3", @@ -5498,7 +5515,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5797,35 +5814,13 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "strum" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" -dependencies = [ - "strum_macros 0.26.4", -] - [[package]] name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ - "strum_macros 0.27.2", -] - -[[package]] -name = "strum_macros" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.109", + "strum_macros", ] [[package]] @@ -5837,7 +5832,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5859,9 +5854,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.109" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", @@ -5885,7 +5880,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6000,7 +5995,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6011,7 +6006,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6313,7 +6308,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6638,7 +6633,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "wasm-bindgen-shared", ] @@ -6824,21 +6819,22 @@ dependencies = [ [[package]] name = "weezl" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a751b3277700db47d3e574514de2eced5e54dc8a5436a3bf7a0b248b2cee16f3" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" [[package]] name = "wgpu" -version = "25.0.2" +version = "27.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8fb398f119472be4d80bc3647339f56eb63b2a331f6a3d16e25d8144197dd9" +checksum = "bfe68bac7cde125de7a731c3400723cadaaf1703795ad3f4805f187459cd7a77" dependencies = [ "arrayvec", "bitflags 2.10.0", + "cfg-if", "cfg_aliases", "document-features", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "js-sys", "log", "naga", @@ -6858,17 +6854,18 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "25.0.2" +version = "27.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b882196f8368511d613c6aeec80655160db6646aebddf8328879a88d54e500" +checksum = "27a75de515543b1897b26119f93731b385a19aea165a1ec5f0e3acecc229cae7" dependencies = [ "arrayvec", "bit-set", "bit-vec", "bitflags 2.10.0", + "bytemuck", "cfg_aliases", "document-features", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "indexmap 2.12.0", "log", "naga", @@ -6889,36 +6886,36 @@ dependencies = [ [[package]] name = "wgpu-core-deps-apple" -version = "25.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd488b3239b6b7b185c3b045c39ca6bf8af34467a4c5de4e0b1a564135d093d" +checksum = "0772ae958e9be0c729561d5e3fd9a19679bcdfb945b8b1a1969d9bfe8056d233" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-core-deps-emscripten" -version = "25.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09ad7aceb3818e52539acc679f049d3475775586f3f4e311c30165cf2c00445" +checksum = "b06ac3444a95b0813ecfd81ddb2774b66220b264b3e2031152a4a29fda4da6b5" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-core-deps-windows-linux-android" -version = "25.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cba5fb5f7f9c98baa7c889d444f63ace25574833df56f5b817985f641af58e46" +checksum = "71197027d61a71748e4120f05a9242b2ad142e3c01f8c1b47707945a879a03c3" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-hal" -version = "25.0.2" +version = "27.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f968767fe4d3d33747bbd1473ccd55bf0f6451f55d733b5597e67b5deab4ad17" +checksum = "5b21cb61c57ee198bc4aff71aeadff4cbb80b927beb912506af9c780d64313ce" dependencies = [ "android_system_properties", "arrayvec", @@ -6929,13 +6926,13 @@ dependencies = [ "bytemuck", "cfg-if", "cfg_aliases", - "core-graphics-types", + "core-graphics-types 0.2.0", "glow", "glutin_wgl_sys", "gpu-alloc", "gpu-allocator", "gpu-descriptor", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "js-sys", "khronos-egl", "libc", @@ -6943,11 +6940,13 @@ dependencies = [ "log", "metal", "naga", - "ndk-sys 0.5.0+25.2.9519653", + "ndk-sys", "objc", + "once_cell", "ordered-float", "parking_lot", "portable-atomic", + "portable-atomic-util", "profiling", "range-alloc", "raw-window-handle", @@ -6963,9 +6962,9 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "25.0.0" +version = "27.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aa49460c2a8ee8edba3fca54325540d904dd85b2e086ada762767e17d06e8bc" +checksum = "afdcf84c395990db737f2dd91628706cb31e86d72e53482320d368e52b5da5eb" dependencies = [ "bitflags 2.10.0", "bytemuck", @@ -7096,7 +7095,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7107,7 +7106,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7118,7 +7117,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7129,7 +7128,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7690,7 +7689,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "synstructure", ] @@ -7746,7 +7745,7 @@ checksum = "dc6821851fa840b708b4cbbaf6241868cabc85a2dc22f426361b0292bfc0b836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "zbus-lockstep", "zbus_xml", "zvariant", @@ -7761,7 +7760,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "zbus_names", "zvariant", "zvariant_utils", @@ -7809,7 +7808,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7829,7 +7828,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "synstructure", ] @@ -7869,7 +7868,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7919,7 +7918,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "zvariant_utils", ] @@ -7932,6 +7931,6 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.109", + "syn 2.0.110", "winnow", ] diff --git a/Cargo.toml b/Cargo.toml index c51b83b5..a5db3503 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ version = "0.1.0" [workspace.dependencies] -komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "1c23439f959bcfddf0f71918fc03a97dd4f30727" } +komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "c8c4c3507c3cb9cdd94e1a40d366320531455d75" } chrono = "0.4" chrono-tz = "0.10" @@ -23,8 +23,8 @@ crossbeam-channel = "0.5" crossbeam-utils = "0.8" dirs = "6" dunce = "1" -eframe = "0.32" -egui_extras = "0.32" +eframe = "0.33" +egui_extras = "0.33" hotwatch = "0.5" lazy_static = "1" parking_lot = "0.12" diff --git a/deny.toml b/deny.toml index 8b01210d..0be4ca3f 100644 --- a/deny.toml +++ b/deny.toml @@ -89,5 +89,6 @@ allow-git = [ "https://github.com/LGUG2Z/flavours", "https://github.com/LGUG2Z/komorebi", "https://github.com/LGUG2Z/base16_color_scheme", - + "https://github.com/LGUG2Z/catppuccin-egui", + "https://github.com/amPerl/egui-phosphor", ] diff --git a/dependencies.json b/dependencies.json index 29afd345..19f9c691 100644 --- a/dependencies.json +++ b/dependencies.json @@ -12,10 +12,10 @@ [ "ab_glyph 0.2.32 registry+https://github.com/rust-lang/crates.io-index", "ab_glyph_rasterizer 0.1.10 registry+https://github.com/rust-lang/crates.io-index", - "accesskit 0.19.0 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_consumer 0.28.0 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_macos 0.20.0 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_winit 0.27.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit 0.21.1 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_consumer 0.31.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_macos 0.22.2 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_winit 0.29.2 registry+https://github.com/rust-lang/crates.io-index", "addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", @@ -32,7 +32,6 @@ "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", - "base64 0.21.7 registry+https://github.com/rust-lang/crates.io-index", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", @@ -42,14 +41,14 @@ "block-buffer 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.43 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.45 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.50 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.50 registry+https://github.com/rust-lang/crates.io-index", - "clap_complete 4.5.59 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.51 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.51 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.60 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.49 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -68,8 +67,8 @@ "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", - "crypto-common 0.1.6 registry+https://github.com/rust-lang/crates.io-index", - "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "crypto-common 0.1.7 registry+https://github.com/rust-lang/crates.io-index", + "ctrlc 3.5.1 registry+https://github.com/rust-lang/crates.io-index", "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "deflate 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "deranged 0.5.5 registry+https://github.com/rust-lang/crates.io-index", @@ -85,18 +84,18 @@ "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", - "ecolor 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "ed25519 2.2.3 registry+https://github.com/rust-lang/crates.io-index", - "eframe 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "egui 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "egui-phosphor 0.10.0 registry+https://github.com/rust-lang/crates.io-index", - "egui-winit 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "egui_glow 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui-phosphor 0.10.0 git+https://github.com/amPerl/egui-phosphor?rev=d13688738478ecd12b426e3e74c59d6577a85b59", + "egui-winit 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", - "emath 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "epaint 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", @@ -149,7 +148,7 @@ "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", "indexmap 2.12.0 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", - "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", + "iri-string 0.7.9 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index", "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", @@ -159,7 +158,7 @@ "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "libc 0.2.177 registry+https://github.com/rust-lang/crates.io-index", "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", - "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", + "libz-sys 1.1.23 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", "litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", @@ -223,7 +222,7 @@ "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", "qoi 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", - "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", + "quote 1.0.42 registry+https://github.com/rust-lang/crates.io-index", "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", "rand 0.9.2 registry+https://github.com/rust-lang/crates.io-index", @@ -275,7 +274,7 @@ "stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", - "syn 2.0.108 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.110 registry+https://github.com/rust-lang/crates.io-index", "sync_wrapper 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", @@ -295,7 +294,7 @@ "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.22 registry+https://github.com/rust-lang/crates.io-index", "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", "uom 0.37.0 registry+https://github.com/rust-lang/crates.io-index", @@ -306,7 +305,7 @@ "version_check 0.9.5 registry+https://github.com/rust-lang/crates.io-index", "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "webbrowser 1.0.6 registry+https://github.com/rust-lang/crates.io-index", - "weezl 0.1.10 registry+https://github.com/rust-lang/crates.io-index", + "weezl 0.1.12 registry+https://github.com/rust-lang/crates.io-index", "winit 0.30.12 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", @@ -352,7 +351,7 @@ "curve25519-dalek 4.1.3 registry+https://github.com/rust-lang/crates.io-index", "ed25519-dalek 2.2.0 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "exr 1.73.0 registry+https://github.com/rust-lang/crates.io-index", + "exr 1.74.0 registry+https://github.com/rust-lang/crates.io-index", "lebe 0.5.3 registry+https://github.com/rust-lang/crates.io-index", "moxcms 0.7.9 registry+https://github.com/rust-lang/crates.io-index", "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", @@ -386,14 +385,14 @@ [ "MIT", [ - "accesskit 0.19.0 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_consumer 0.28.0 registry+https://github.com/rust-lang/crates.io-index", - "accesskit_macos 0.20.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit 0.21.1 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_consumer 0.31.0 registry+https://github.com/rust-lang/crates.io-index", + "accesskit_macos 0.22.2 registry+https://github.com/rust-lang/crates.io-index", "addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", - "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", + "aho-corasick 1.1.4 registry+https://github.com/rust-lang/crates.io-index", "aligned-vec 0.6.4 registry+https://github.com/rust-lang/crates.io-index", "anstream 0.6.21 registry+https://github.com/rust-lang/crates.io-index", "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", @@ -407,7 +406,6 @@ "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", - "base64 0.21.7 registry+https://github.com/rust-lang/crates.io-index", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", "beef 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", @@ -427,16 +425,16 @@ "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "calm_io 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "calmio_filters 0.1.0 registry+https://github.com/rust-lang/crates.io-index", - "catppuccin-egui 5.6.0 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.43 registry+https://github.com/rust-lang/crates.io-index", + "catppuccin-egui 5.6.0 git+https://github.com/LGUG2Z/catppuccin-egui?rev=b2f95cbf441d1dd99f3c955ef10dcb84ce23c20a", + "cc 1.2.45 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.50 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.50 registry+https://github.com/rust-lang/crates.io-index", - "clap_complete 4.5.59 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.51 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.51 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.60 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.49 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -457,8 +455,8 @@ "crossbeam-deque 0.8.6 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index", - "crypto-common 0.1.6 registry+https://github.com/rust-lang/crates.io-index", - "ctrlc 3.5.0 registry+https://github.com/rust-lang/crates.io-index", + "crypto-common 0.1.7 registry+https://github.com/rust-lang/crates.io-index", + "ctrlc 3.5.1 registry+https://github.com/rust-lang/crates.io-index", "cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "darling 0.21.3 registry+https://github.com/rust-lang/crates.io-index", "darling_core 0.21.3 registry+https://github.com/rust-lang/crates.io-index", @@ -477,18 +475,18 @@ "document-features 0.2.12 registry+https://github.com/rust-lang/crates.io-index", "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", - "ecolor 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "ed25519 2.2.3 registry+https://github.com/rust-lang/crates.io-index", - "eframe 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "egui 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "egui-phosphor 0.10.0 registry+https://github.com/rust-lang/crates.io-index", - "egui-winit 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "egui_glow 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui-phosphor 0.10.0 git+https://github.com/amPerl/egui-phosphor?rev=d13688738478ecd12b426e3e74c59d6577a85b59", + "egui-winit 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", - "emath 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "epaint 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index", "equator 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "equator-macro 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", @@ -517,7 +515,7 @@ "futures-sink 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-task 0.3.31 registry+https://github.com/rust-lang/crates.io-index", "futures-util 0.3.31 registry+https://github.com/rust-lang/crates.io-index", - "generic-array 0.14.9 registry+https://github.com/rust-lang/crates.io-index", + "generic-array 0.14.7 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.1.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.4 registry+https://github.com/rust-lang/crates.io-index", @@ -541,7 +539,7 @@ "http-body 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "http-body-util 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "httparse 1.10.1 registry+https://github.com/rust-lang/crates.io-index", - "hyper 1.7.0 registry+https://github.com/rust-lang/crates.io-index", + "hyper 1.8.0 registry+https://github.com/rust-lang/crates.io-index", "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "hyper-util 0.1.17 registry+https://github.com/rust-lang/crates.io-index", "iana-time-zone 0.1.64 registry+https://github.com/rust-lang/crates.io-index", @@ -556,7 +554,7 @@ "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", "indexmap 2.12.0 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", - "iri-string 0.7.8 registry+https://github.com/rust-lang/crates.io-index", + "iri-string 0.7.9 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index", "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", @@ -566,7 +564,7 @@ "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "libc 0.2.177 registry+https://github.com/rust-lang/crates.io-index", "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", - "libz-sys 1.1.22 registry+https://github.com/rust-lang/crates.io-index", + "libz-sys 1.1.23 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", "litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", @@ -575,6 +573,7 @@ "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "loop9 0.1.5 registry+https://github.com/rust-lang/crates.io-index", + "mac-addr 0.3.0 registry+https://github.com/rust-lang/crates.io-index", "mach2 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "matchers 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "maybe-rayon 0.1.1 registry+https://github.com/rust-lang/crates.io-index", @@ -588,7 +587,7 @@ "mio 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "nanoid 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", - "netdev 0.38.2 registry+https://github.com/rust-lang/crates.io-index", + "netdev 0.39.0 registry+https://github.com/rust-lang/crates.io-index", "new_debug_unreachable 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -658,7 +657,7 @@ "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", "quickxml_to_serde 0.6.1 git+https://github.com/LGUG2Z/quickxml_to_serde.git", - "quote 1.0.41 registry+https://github.com/rust-lang/crates.io-index", + "quote 1.0.42 registry+https://github.com/rust-lang/crates.io-index", "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", "rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index", "rand 0.9.2 registry+https://github.com/rust-lang/crates.io-index", @@ -722,7 +721,7 @@ "strum 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", - "syn 2.0.108 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.110 registry+https://github.com/rust-lang/crates.io-index", "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", "sysinfo 0.37.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", @@ -740,7 +739,7 @@ "time-core 0.1.6 registry+https://github.com/rust-lang/crates.io-index", "tokio 1.48.0 registry+https://github.com/rust-lang/crates.io-index", "tokio-native-tls 0.3.1 registry+https://github.com/rust-lang/crates.io-index", - "tokio-util 0.7.16 registry+https://github.com/rust-lang/crates.io-index", + "tokio-util 0.7.17 registry+https://github.com/rust-lang/crates.io-index", "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", "tower 0.5.2 registry+https://github.com/rust-lang/crates.io-index", "tower-http 0.6.6 registry+https://github.com/rust-lang/crates.io-index", @@ -759,7 +758,7 @@ "tz-rs 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.22 registry+https://github.com/rust-lang/crates.io-index", "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "unicode-xid 0.2.6 registry+https://github.com/rust-lang/crates.io-index", "uom 0.37.0 registry+https://github.com/rust-lang/crates.io-index", @@ -772,7 +771,7 @@ "want 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "webbrowser 1.0.6 registry+https://github.com/rust-lang/crates.io-index", - "weezl 0.1.10 registry+https://github.com/rust-lang/crates.io-index", + "weezl 0.1.12 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index", @@ -800,13 +799,13 @@ [ "OFL-1.1", [ - "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index" + "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "Ubuntu-font-1.0", [ - "epaint_default_fonts 0.32.3 registry+https://github.com/rust-lang/crates.io-index" + "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -822,7 +821,7 @@ "litemap 0.8.1 registry+https://github.com/rust-lang/crates.io-index", "potential_utf 0.1.4 registry+https://github.com/rust-lang/crates.io-index", "tinystr 0.8.2 registry+https://github.com/rust-lang/crates.io-index", - "unicode-ident 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "unicode-ident 1.0.22 registry+https://github.com/rust-lang/crates.io-index", "writeable 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "yoke 0.8.1 registry+https://github.com/rust-lang/crates.io-index", "yoke-derive 0.8.1 registry+https://github.com/rust-lang/crates.io-index", @@ -836,7 +835,7 @@ [ "Unlicense", [ - "aho-corasick 1.1.3 registry+https://github.com/rust-lang/crates.io-index", + "aho-corasick 1.1.4 registry+https://github.com/rust-lang/crates.io-index", "byteorder 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "byteorder-lite 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "memchr 2.7.6 registry+https://github.com/rust-lang/crates.io-index", diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 091672c0..7e663d54 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -17,13 +17,13 @@ crossbeam-channel = { workspace = true } dirs = { workspace = true } dunce = { workspace = true } eframe = { workspace = true } -egui-phosphor = "0.10" +egui-phosphor = { git = "https://github.com/amPerl/egui-phosphor", rev = "d13688738478ecd12b426e3e74c59d6577a85b59" } font-loader = "0.11" hotwatch = { workspace = true } icns = "0.3" image = "0.25" lazy_static = { workspace = true } -netdev = "0.38" +netdev = "0.39" num = "0.4" num-derive = "0.4" num-traits = "0.2" diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index ae779f00..c28ab834 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -9,7 +9,7 @@ komorebi-themes = { workspace = true } quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" } version = { path = "../version" } -base64 = "0.21" +base64 = "0.22" block2 = "0.6" clap = { workspace = true } chrono = { workspace = true } From 5304a32d91832a17ab4342c2ffaa23a612a8ffa3 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 12 Nov 2025 16:29:40 -0800 Subject: [PATCH 157/305] chore(deps): flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/50700219af884287ad7c85507e2f163b23a027a9' (2025-11-03) → 'github:ipetkov/crane/0cea393fffb39575c46b7a0318386467272182fe' (2025-11-07) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/ffcdcf99d65c61956d882df249a9be53e5902ea5' (2025-11-05) → 'github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369' (2025-11-08) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/9de55b59b6aaadbd9dbf223765a835239b767ee5' (2025-11-07) → 'github:oxalica/rust-overlay/aa1e85921cfa04de7b6914982a94621fbec5cc02' (2025-11-12) --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index a88daaff..4102f2fb 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1762189950, - "narHash": "sha256-aotggLUXjlDGqKWibGPQcMZJGgdr79S21ISrv1Wz6RI=", + "lastModified": 1762538466, + "narHash": "sha256-8zrIPl6J+wLm9MH5ksHcW7BUHo7jSNOu0/hA0ohOOaM=", "owner": "ipetkov", "repo": "crane", - "rev": "50700219af884287ad7c85507e2f163b23a027a9", + "rev": "0cea393fffb39575c46b7a0318386467272182fe", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1762361079, - "narHash": "sha256-lz718rr1BDpZBYk7+G8cE6wee3PiBUpn8aomG/vLLiY=", + "lastModified": 1762604901, + "narHash": "sha256-Pr2jpryIaQr9Yx8p6QssS03wqB6UifnnLr3HJw9veDw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ffcdcf99d65c61956d882df249a9be53e5902ea5", + "rev": "f6b44b2401525650256b977063dbcf830f762369", "type": "github" }, "original": { @@ -78,11 +78,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1762483116, - "narHash": "sha256-Z8EVsTH10BjCdFyPxbUu5jBV+HGL39rh9+beQcnNRm0=", + "lastModified": 1762915112, + "narHash": "sha256-d9j1g8nKmYDHy+/bIOPQTh9IwjRliqaTM0QLHMV92Ic=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "9de55b59b6aaadbd9dbf223765a835239b767ee5", + "rev": "aa1e85921cfa04de7b6914982a94621fbec5cc02", "type": "github" }, "original": { From 1a7d1a4cf229ada16cd8dbb40c44fc545d00cb26 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 22 Nov 2025 12:59:35 -0800 Subject: [PATCH 158/305] fix(wm): promoting a container shouldn't change resize dimensions This commit was originally contributed as 31c969f to LGUG2Z/komorebi by @alex-ds13 - When promoting a container it is using the `remove_focused_container()` and `insert_container_at_idx` functions which will remove the focused container size from `resize_dimensions` and then add the new container with size `None`. Then it was adding the previously stored size of the main container back to the first one. However this would result in at least 3 issues: 1. We were removing the size from index 0, however when inserting it back on the primary_idx we might not add it to index 0, specially now that there could be locked containers so if container 0 is locked we would be adding it to the next container, which would result in the main container having no size information which would result in a recalculation on the next update and it would revert back to default, so if a user had resized their containers that information would be lost. 2. We were removing the size from index 0. Then on `remove_focused_container` it would remove the size from the focused container index, but since we had already removed one size from the `resize_dimensions` that index would no longer match the actual focused container, so once again we would be losing information. 3. Since we were removing the size of the focused container idx from `resize_dimensions` (albeit the wrong one as stated above), this would mean that the container that moved to that position would have no resize information so it would show up as if the main container was taking up half width of the area, ignoring any user resize, until the next workspace update was triggered. - This commit completely ignores the `resize_dimensions` since promoting a container simply means moving one container from one position to the main one (usually index 0) and then shift all the rest to the "right". The existing `resize_dimensions` should be kept untouched. To do this we use the functions `remove_respecting_locks` and `insert_respecting_locks` on the containers themselves, which simply move the container and shifts the others which is precisely what we want. --- komorebi/src/workspace.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 09852097..37a8ecf3 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -821,18 +821,20 @@ impl Workspace { } pub fn promote_container(&mut self) -> eyre::Result<()> { - let resize = self.resize_dimensions.remove(0); + let focused_idx = self.focused_container_idx(); let container = self - .remove_focused_container() + .containers_mut() + .remove_respecting_locks(focused_idx) .ok_or_eyre("there is no container")?; - let primary_idx = match self.layout { + let primary_idx = match &self.layout { Layout::Default(_) => 0, }; - let insertion_idx = self.insert_container_at_idx(primary_idx, container); - self.resize_dimensions[insertion_idx] = resize; - self.focus_container(primary_idx); + let insertion_idx = self + .containers_mut() + .insert_respecting_locks(primary_idx, container); + self.focus_container(insertion_idx); Ok(()) } From 39e4aef485c781abb3fbc1ed950d11e46da2181b Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 22 Nov 2025 13:01:56 -0800 Subject: [PATCH 159/305] chore(deps): cargo update --- Cargo.lock | 363 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 182 insertions(+), 183 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db8075f7..89e63de0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,6 +157,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923" +dependencies = [ + "as-slice", +] + [[package]] name = "aligned-vec" version = "0.6.4" @@ -249,22 +258,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -295,7 +304,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf" dependencies = [ "clipboard-win", - "image 0.25.8", + "image 0.25.9", "log", "objc2 0.6.3", "objc2-app-kit 0.3.2", @@ -337,6 +346,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "ash" version = "0.38.0+1.3.281" @@ -539,6 +557,26 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "av-scenechange" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394" +dependencies = [ + "aligned", + "anyhow", + "arg_enum_proc_macro", + "arrayvec", + "log", + "num-rational 0.4.2", + "num-traits", + "pastey 0.1.1", + "rayon", + "thiserror 2.0.17", + "v_frame", + "y4m", +] + [[package]] name = "av1-grain" version = "0.2.5" @@ -653,9 +691,12 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "bitstream-io" -version = "2.6.0" +version = "4.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" +checksum = "60d4bd9d1db2c6bdf285e223a7fa369d5ce98ec767dec949c6ca62863ce61757" +dependencies = [ + "core2", +] [[package]] name = "block" @@ -726,9 +767,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" +checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" [[package]] name = "bumpalo" @@ -770,9 +811,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "calloop" @@ -854,9 +895,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.45" +version = "1.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe" +checksum = "cd405d82c84ff7f35739f175f67d8b9fb7687a0e84ccdc78bd3568839827cf07" dependencies = [ "find-msvc-tools", "jobserver", @@ -870,16 +911,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -[[package]] -name = "cfg-expr" -version = "0.15.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" -dependencies = [ - "smallvec", - "target-lexicon", -] - [[package]] name = "cfg-if" version = "1.0.4" @@ -927,9 +958,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.51" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" +checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" dependencies = [ "clap_builder", "clap_derive", @@ -937,9 +968,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.51" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" +checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" dependencies = [ "anstream", "anstyle", @@ -950,9 +981,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.60" +version = "4.5.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e602857739c5a4291dfa33b5a298aeac9006185229a700e5810a3ef7272d971" +checksum = "39615915e2ece2550c0149addac32fb5bd312c657f43845bb9088cb9c8a7c992" dependencies = [ "clap", ] @@ -1183,6 +1214,15 @@ dependencies = [ "libc", ] +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -1504,9 +1544,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adf31f99fad93fe83c1055b92b5c1b135f1ecfa464789817c372000e768d4bd1" +checksum = "084980ebede2fb1ad6c4f54285b3e489052ef2b6aa4016e4c19349417adc75c5" dependencies = [ "bytemuck", "emath", @@ -1538,9 +1578,9 @@ dependencies = [ [[package]] name = "eframe" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b829d302a09deb4acde242262a1840ba14fadd0371980ebf713060077a1987bc" +checksum = "4f60ee3c69cd01d5725b4ef476ed6a3a6009968c57843a2f1beb96f021e4a54b" dependencies = [ "ahash", "bytemuck", @@ -1552,7 +1592,7 @@ dependencies = [ "glow", "glutin", "glutin-winit", - "image 0.25.8", + "image 0.25.9", "js-sys", "log", "objc2 0.5.2", @@ -1573,9 +1613,9 @@ dependencies = [ [[package]] name = "egui" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9b5d3376c79439f53a78bf7da1e3c0b862ffa3e29f46ab0f3e107430f2e576" +checksum = "b75645894de4ca1695ab3ab7201c7953bb95c1725aafeefa6822dc901ad2a81b" dependencies = [ "accesskit", "ahash", @@ -1599,9 +1639,9 @@ dependencies = [ [[package]] name = "egui-wgpu" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef1fe83ba30b3d045814b2d811804f2a7e50a832034c975408f71c20df596e4" +checksum = "acdaac35a6e0ff458aaa5776b2bda578e38334a9d1258f7795042a70372745b7" dependencies = [ "ahash", "bytemuck", @@ -1619,9 +1659,9 @@ dependencies = [ [[package]] name = "egui-winit" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4ea8cb063c00d8f23ce11279c01eb63a195a72be0e21d429148246dab7983e" +checksum = "4772ed5f16fa8ec2ba295e58f62b58ee83fcf49e67ec13d2b7ddf4e9a2dea34e" dependencies = [ "accesskit_winit", "arboard", @@ -1641,9 +1681,9 @@ dependencies = [ [[package]] name = "egui_glow" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668c0d4f726cc33838f0915f6b8c00af0ca0910e975ab58cf34b3e39c614552c" +checksum = "17b94ff67a1d18933fff2519f5f57c388f932c093036c381fb9ae2853b3e1e09" dependencies = [ "bytemuck", "egui", @@ -1664,9 +1704,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "emath" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c615516cdceec867065f20d7db13d8eb8aedd65c9e32cc0c7c379380fa42e6e8" +checksum = "0e561352ae95c22ad179fb56c38d6e6eecd86cf4925cf5c70e738dd01df9b620" dependencies = [ "bytemuck", ] @@ -1709,9 +1749,9 @@ dependencies = [ [[package]] name = "epaint" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9926b9500ccb917adb070207ec722dd8ea78b8321f94a85ebec776f501f2930c" +checksum = "a909ce8cee63e8350fb0c251ad39277a5b24f19add60787e84a3b3ab3f2bd83a" dependencies = [ "ab_glyph", "ahash", @@ -1727,9 +1767,9 @@ dependencies = [ [[package]] name = "epaint_default_fonts" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66054d943c66715c6003a27a3dc152d87cadf714ef2597ccd79f550413009b97" +checksum = "ad9649446c23368ae138716910e3e28143995691b598fbb9de16b42b0722cbcc" [[package]] name = "equator" @@ -1893,9 +1933,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "fixedbitset" @@ -1932,7 +1972,7 @@ dependencies = [ "serde_yaml", "shell-words", "shellexpand", - "toml 0.5.11", + "toml", ] [[package]] @@ -2187,9 +2227,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.13.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae047235e33e2829703574b54fdec96bfbad892062d97fed2f76022287de61b" +checksum = "f954a9e9159ec994f73a30a12b96a702dde78f5547bcb561174597924f7d4162" dependencies = [ "color_quant", "weezl", @@ -2372,7 +2412,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.12.0", + "indexmap 2.12.1", "slab", "tokio", "tokio-util", @@ -2408,9 +2448,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "foldhash 0.2.0", ] @@ -2506,9 +2546,9 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "hyper" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1744436df46f0bde35af3eda22aeaba453aada65d8f1c171cd8a5f59030bd69f" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ "atomic-waker", "bytes", @@ -2560,9 +2600,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" dependencies = [ "base64", "bytes", @@ -2747,15 +2787,15 @@ dependencies = [ [[package]] name = "image" -version = "0.25.8" +version = "0.25.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "529feb3e6769d234375c4cf1ee2ce713682b8e76538cb13f9fc23e1400a591e7" +checksum = "e6506c6c10786659413faa717ceebcb8f70731c0a60cbae39795fdf114519c1a" dependencies = [ "bytemuck", "byteorder-lite", "color_quant", "exr", - "gif 0.13.3", + "gif 0.14.0", "image-webp", "moxcms", "num-traits", @@ -2765,8 +2805,8 @@ dependencies = [ "rayon", "rgb", "tiff 0.10.3", - "zune-core", - "zune-jpeg", + "zune-core 0.5.0", + "zune-jpeg 0.5.5", ] [[package]] @@ -2804,12 +2844,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "serde", "serde_core", ] @@ -2875,9 +2915,9 @@ checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" -version = "0.12.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] @@ -2985,7 +3025,7 @@ dependencies = [ "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", "parking_lot", - "pastey", + "pastey 0.2.0", "quickxml_to_serde", "regex", "reqwest", @@ -3020,7 +3060,7 @@ dependencies = [ "font-loader", "hotwatch", "icns", - "image 0.25.8", + "image 0.25.9", "komorebi-client", "komorebi-themes", "lazy_static", @@ -3079,7 +3119,7 @@ dependencies = [ "fs-tail", "komorebi-client", "lazy_static", - "pastey", + "pastey 0.2.0", "reqwest", "schemars 0.8.22", "serde_json_lenient", @@ -3458,9 +3498,9 @@ dependencies = [ "cfg_aliases", "codespan-reporting", "half", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "hexf-parse", - "indexmap 2.12.0", + "indexmap 2.12.1", "libm", "log", "num-traits", @@ -4424,6 +4464,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" +[[package]] +name = "pastey" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d6c094ee800037dff99e02cab0eaf3142826586742a270ab3d7a62656bd27a" + [[package]] name = "percent-encoding" version = "2.3.2" @@ -4437,7 +4483,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.12.0", + "indexmap 2.12.1", ] [[package]] @@ -4562,7 +4608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" dependencies = [ "base64", - "indexmap 2.12.0", + "indexmap 2.12.1", "quick-xml 0.38.4", "serde", "time", @@ -4658,7 +4704,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit 0.23.7", + "toml_edit", ] [[package]] @@ -4920,13 +4966,15 @@ checksum = "c3d6831663a5098ea164f89cff59c6284e95f4e3c76ce9848d4529f5ccca9bde" [[package]] name = "rav1e" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b" dependencies = [ + "aligned-vec", "arbitrary", "arg_enum_proc_macro", "arrayvec", + "av-scenechange", "av1-grain", "bitstream-io", "built", @@ -4941,23 +4989,21 @@ dependencies = [ "noop_proc_macro", "num-derive", "num-traits", - "once_cell", "paste", "profiling", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand 0.9.2", + "rand_chacha 0.9.0", "simd_helpers", - "system-deps", - "thiserror 1.0.69", + "thiserror 2.0.17", "v_frame", "wasm-bindgen", ] [[package]] name = "ravif" -version = "0.11.20" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5825c26fddd16ab9f515930d49028a630efec172e903483c94796cfe31893e6b" +checksum = "ef69c1990ceef18a116855938e74793a5f7496ee907562bd0857b6ac734ab285" dependencies = [ "avif-serialize", "imgref", @@ -5438,7 +5484,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e033097bf0d2b59a62b42c18ebbb797503839b26afdda2c4e1415cb6c813540" dependencies = [ - "indexmap 2.12.0", + "indexmap 2.12.1", "itoa", "memchr", "ryu", @@ -5456,15 +5502,6 @@ dependencies = [ "syn 2.0.110", ] -[[package]] -name = "serde_spanned" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -5488,15 +5525,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.15.1" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04" +checksum = "10574371d41b0d9b2cff89418eda27da52bcaff2cc8741db26382a77c29131f1" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.12.0", + "indexmap 2.12.1", "schemars 0.8.22", "schemars 0.9.0", "schemars 1.1.0", @@ -5508,9 +5545,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.15.1" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91a903660542fced4e99881aa481bdbaec1634568ee02e0b8bd57c64cb38955" +checksum = "08a72d8216842fdd57820dc78d840bef99248e35fb2554ff923319e60f2d686b" dependencies = [ "darling", "proc-macro2", @@ -5607,9 +5644,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" dependencies = [ "libc", ] @@ -5918,25 +5955,6 @@ dependencies = [ "libc", ] -[[package]] -name = "system-deps" -version = "6.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" -dependencies = [ - "cfg-expr", - "heck", - "pkg-config", - "toml 0.8.23", - "version-compare", -] - -[[package]] -name = "target-lexicon" -version = "0.12.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" - [[package]] name = "tempfile" version = "3.23.0" @@ -6040,7 +6058,7 @@ dependencies = [ "half", "quick-error", "weezl", - "zune-jpeg", + "zune-jpeg 0.4.21", ] [[package]] @@ -6167,27 +6185,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime 0.6.11", - "toml_edit 0.22.27", -] - -[[package]] -name = "toml_datetime" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" -dependencies = [ - "serde", -] - [[package]] name = "toml_datetime" version = "0.7.3" @@ -6197,27 +6194,14 @@ dependencies = [ "serde_core", ] -[[package]] -name = "toml_edit" -version = "0.22.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" -dependencies = [ - "indexmap 2.12.0", - "serde", - "serde_spanned", - "toml_datetime 0.6.11", - "winnow", -] - [[package]] name = "toml_edit" version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ - "indexmap 2.12.0", - "toml_datetime 0.7.3", + "indexmap 2.12.1", + "toml_datetime", "toml_parser", "winnow", ] @@ -6536,12 +6520,6 @@ dependencies = [ "shadow-rs", ] -[[package]] -name = "version-compare" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" - [[package]] name = "version_check" version = "0.9.5" @@ -6834,7 +6812,7 @@ dependencies = [ "cfg-if", "cfg_aliases", "document-features", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "js-sys", "log", "naga", @@ -6865,8 +6843,8 @@ dependencies = [ "bytemuck", "cfg_aliases", "document-features", - "hashbrown 0.16.0", - "indexmap 2.12.0", + "hashbrown 0.16.1", + "indexmap 2.12.1", "log", "naga", "once_cell", @@ -6932,7 +6910,7 @@ dependencies = [ "gpu-alloc", "gpu-allocator", "gpu-descriptor", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "js-sys", "khronos-egl", "libc", @@ -7155,13 +7133,13 @@ dependencies = [ [[package]] name = "windows-registry" -version = "0.5.3" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" dependencies = [ - "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings 0.4.2", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", ] [[package]] @@ -7661,6 +7639,12 @@ version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" +[[package]] +name = "y4m" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448" + [[package]] name = "yaml-rust" version = "0.4.5" @@ -7793,18 +7777,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26" dependencies = [ "proc-macro2", "quote", @@ -7877,6 +7861,12 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" +[[package]] +name = "zune-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111f7d9820f05fd715df3144e254d6fc02ee4088b0644c0ffd0efc9e6d9d2773" + [[package]] name = "zune-inflate" version = "0.2.54" @@ -7892,7 +7882,16 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29ce2c8a9384ad323cf564b67da86e21d3cfdff87908bc1223ed5c99bc792713" dependencies = [ - "zune-core", + "zune-core 0.4.12", +] + +[[package]] +name = "zune-jpeg" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6fb7703e32e9a07fb3f757360338b3a567a5054f21b5f52a666752e333d58e" +dependencies = [ + "zune-core 0.5.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a5db3503..a6584265 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = "0.33" hotwatch = "0.5" lazy_static = "1" parking_lot = "0.12" -pastey = "0.1" +pastey = "0.2" schemars = "0.8" serde = { version = "1", features = ["derive"] } serde_json = { package = "serde_json_lenient", version = "0.2" } From a03c466eed37060730f839683e694edb8aa55725 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 23 Nov 2025 11:31:22 -0800 Subject: [PATCH 160/305] fix(bar): update the network widget in a separate thread This commit was originally contributed as faed6ec by LGUG2Z/komorebi by @CtByte This commit changes the way how the default interface and network activity is loaded by spawning a new thread on each request. This way the main thread is not blocked by this process. There has been instances where getting the default interface blocked the egui ui thread, resulting in a frozen bar. --- komorebi-bar/src/widgets/network.rs | 159 +++++++++++++++++++--------- 1 file changed, 107 insertions(+), 52 deletions(-) diff --git a/komorebi-bar/src/widgets/network.rs b/komorebi-bar/src/widgets/network.rs index 4f8960a1..91f3e8d2 100644 --- a/komorebi-bar/src/widgets/network.rs +++ b/komorebi-bar/src/widgets/network.rs @@ -11,10 +11,15 @@ use eframe::egui::TextFormat; use eframe::egui::Ui; use eframe::egui::text::LayoutJob; use num_derive::FromPrimitive; +use parking_lot::Mutex; use serde::Deserialize; use serde::Serialize; use std::fmt; use std::process::Command; +use std::sync::Arc; +use std::sync::atomic::AtomicU64; +use std::sync::atomic::Ordering; +use std::thread; use std::time::Duration; use std::time::Instant; use sysinfo::Networks; @@ -66,21 +71,25 @@ impl From for Network { show_total_activity: value.show_total_activity, show_activity: value.show_activity, show_default_interface: value.show_default_interface.unwrap_or(true), - networks_network_activity: Networks::new_with_refreshed_list(), - default_interface: String::new(), + networks_network_activity: Arc::new(Mutex::new(Networks::new_with_refreshed_list())), + default_interface: Arc::new(Mutex::new(String::new())), + interface_generation: Arc::new(AtomicU64::new(0)), default_refresh_interval, data_refresh_interval, label_prefix: value.label_prefix.unwrap_or(LabelPrefix::Icon), auto_select: value.auto_select, activity_left_padding: value.activity_left_padding.unwrap_or_default(), - last_updated_default_interface: Instant::now() + last_update_request_default_interface: Instant::now() .checked_sub(Duration::from_secs(default_refresh_interval)) .unwrap(), - last_state_total_activity: vec![], - last_state_activity: vec![], - last_updated_network_activity: Instant::now() - .checked_sub(Duration::from_secs(data_refresh_interval)) - .unwrap(), + last_state_total_activity: Arc::new(Mutex::new(vec![])), + last_state_activity: Arc::new(Mutex::new(vec![])), + last_update_request_network_activity: Arc::new(Mutex::new( + Instant::now() + .checked_sub(Duration::from_secs(data_refresh_interval)) + .unwrap(), + )), + activity_generation: Arc::new(AtomicU64::new(0)), } } } @@ -90,64 +99,82 @@ pub struct Network { pub show_total_activity: bool, pub show_activity: bool, pub show_default_interface: bool, - networks_network_activity: Networks, + networks_network_activity: Arc>, default_refresh_interval: u64, data_refresh_interval: u64, label_prefix: LabelPrefix, auto_select: Option, - default_interface: String, - last_updated_default_interface: Instant, - last_state_total_activity: Vec, - last_state_activity: Vec, - last_updated_network_activity: Instant, + default_interface: Arc>, + interface_generation: Arc, + last_update_request_default_interface: Instant, + activity_generation: Arc, + last_state_activity: Arc>>, + last_state_total_activity: Arc>>, + last_update_request_network_activity: Arc>, activity_left_padding: usize, } impl Network { - fn default_interface(&mut self) { - let now = Instant::now(); + fn update_default_interface_async(&mut self) { + let gen_ = self.interface_generation.fetch_add(1, Ordering::SeqCst) + 1; + let gen_arc = Arc::clone(&self.interface_generation); + let iface_arc = Arc::clone(&self.default_interface); - if now.duration_since(self.last_updated_default_interface) - > Duration::from_secs(self.default_refresh_interval) - { + thread::spawn(move || { if let Ok(interface) = netdev::get_default_interface() && let Some(friendly_name) = &interface.friendly_name { - self.default_interface.clone_from(friendly_name); + // Only update if this is the latest request + if gen_ == gen_arc.load(Ordering::SeqCst) { + let mut iface = iface_arc.lock(); + *iface = friendly_name.clone(); + } } - - self.last_updated_default_interface = now; - } + }); } - fn network_activity(&mut self) -> (Vec, Vec) { - let mut activity = self.last_state_activity.clone(); - let mut total_activity = self.last_state_total_activity.clone(); + fn default_interface(&mut self) -> String { + let current = self.default_interface.lock().clone(); let now = Instant::now(); - if now.duration_since(self.last_updated_network_activity) - > Duration::from_secs(self.data_refresh_interval) + if now.duration_since(self.last_update_request_default_interface) + > Duration::from_secs(self.default_refresh_interval) { - activity.clear(); - total_activity.clear(); + self.last_update_request_default_interface = now; + self.update_default_interface_async(); + } + + current + } + + fn update_network_activity_async(&mut self) { + let gen_ = self.activity_generation.fetch_add(1, Ordering::SeqCst) + 1; + let gen_arc = Arc::clone(&self.activity_generation); + let activity_arc = Arc::clone(&self.last_state_activity); + let total_activity_arc = Arc::clone(&self.last_state_total_activity); + let data_refresh_interval = self.data_refresh_interval; + let show_activity = self.show_activity; + let show_total_activity = self.show_total_activity; + let networks_network_activity_arc = Arc::clone(&self.networks_network_activity); + + thread::spawn(move || { + let mut activity = Vec::new(); + let mut total_activity = Vec::new(); if let Ok(interface) = netdev::get_default_interface() - && let Some(friendly_name) = &interface.friendly_name + && let Some(_friendly_name) = &interface.friendly_name { + let mut networks = networks_network_activity_arc.lock(); let target_name = interface.name.clone(); - self.default_interface.clone_from(friendly_name); + networks.refresh(true); - self.networks_network_activity.refresh(true); - - for (interface_name, data) in &self.networks_network_activity { + for (interface_name, data) in &*networks { if interface_name.eq(&target_name) { - if self.show_activity { + if show_activity { let received = - Self::to_pretty_bytes(data.received(), self.data_refresh_interval); - let transmitted = Self::to_pretty_bytes( - data.transmitted(), - self.data_refresh_interval, - ); + Network::to_pretty_bytes(data.received(), data_refresh_interval); + let transmitted = + Network::to_pretty_bytes(data.transmitted(), data_refresh_interval); activity.push(NetworkReading::new( NetworkReadingFormat::Speed, @@ -156,26 +183,54 @@ impl Network { )); } - if self.show_total_activity { - let total_received = Self::to_pretty_bytes(data.total_received(), 1); + if show_total_activity { + let total_received = Network::to_pretty_bytes(data.total_received(), 1); let total_transmitted = - Self::to_pretty_bytes(data.total_transmitted(), 1); + Network::to_pretty_bytes(data.total_transmitted(), 1); total_activity.push(NetworkReading::new( NetworkReadingFormat::Total, ReadingValue::from(total_received), ReadingValue::from(total_transmitted), - )) + )); } } } } - self.last_state_activity.clone_from(&activity); - self.last_state_total_activity.clone_from(&total_activity); - self.last_updated_network_activity = now; + // Only update if this is the latest request + if gen_ == gen_arc.load(Ordering::SeqCst) { + let mut act = activity_arc.lock(); + *act = activity; + + let mut tot = total_activity_arc.lock(); + *tot = total_activity; + } + }); + } + + fn network_activity(&mut self) -> (Vec, Vec) { + let now = Instant::now(); + let should_update = { + let last_update_request = self.last_update_request_network_activity.lock(); + now.duration_since(*last_update_request) + > Duration::from_secs(self.data_refresh_interval) + }; + + if should_update { + { + let mut last_updated = self.last_update_request_network_activity.lock(); + *last_updated = now; + } + self.update_network_activity_async(); } + self.get_network_activity() + } + + fn get_network_activity(&self) -> (Vec, Vec) { + let activity = self.last_state_activity.lock().clone(); + let total_activity = self.last_state_total_activity.lock().clone(); (activity, total_activity) } @@ -448,9 +503,9 @@ impl BarWidget for Network { } if self.show_default_interface { - self.default_interface(); + let mut self_default_interface = self.default_interface(); - if !self.default_interface.is_empty() { + if !self_default_interface.is_empty() { let mut layout_job = LayoutJob::simple( match self.label_prefix { LabelPrefix::Icon | LabelPrefix::IconAndText => { @@ -464,11 +519,11 @@ impl BarWidget for Network { ); if let LabelPrefix::Text | LabelPrefix::IconAndText = self.label_prefix { - self.default_interface.insert_str(0, "NET: "); + self_default_interface.insert_str(0, "NET: "); } layout_job.append( - &self.default_interface, + &self_default_interface, 10.0, TextFormat { font_id: config.text_font_id.clone(), From f27cbc7121452de9b7c2a3412f046e42470451c0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 24 Nov 2025 11:12:11 -0800 Subject: [PATCH 161/305] fix(github): reduce artifact retention due to limits --- .github/workflows/nix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index 01fbb899..447325aa 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -34,7 +34,7 @@ jobs: name: komorebi-aarch64-apple-darwin-${{ github.sha }} path: | result/bin/komorebi* - retention-days: 90 + retention-days: 14 - if: ${{ github.ref == 'refs/heads/master' && github.repository == 'KomoCorp/komorebi-for-mac' }} uses: exuanbo/actions-deploy-gist@v1 with: From 23a2cccdf600cd99e574b11daf8a1782453219a1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 25 Nov 2025 20:18:33 -0800 Subject: [PATCH 162/305] docs(cli): improve quickstart output formatting --- komorebic/src/main.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 1770d847..04376a2b 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1362,7 +1362,8 @@ fn main() -> eyre::Result<()> { current_exe.pop(); let komorebi_exe = current_exe.join("komorebi"); - let term_program = std::env::var("TERM_PROGRAM").unwrap_or_default(); + let term_program = std::env::var("TERM_PROGRAM") + .unwrap_or_else(|_| String::from("this terminal emulator")); println!( "\nPlease grant Accessibility permissions to \"{}\" and \"{term_program}\"", @@ -1403,22 +1404,22 @@ fn main() -> eyre::Result<()> { { if let Some(server) = server { println!( - "\nIt looks like you are using a corporate device enrolled in mobile device management ({server})" + "It looks like you are using a corporate device enrolled in mobile device management ({server})\n" ); } else { println!( - "\nIt looks like you are using a corporate device enrolled in mobile device management" + "It looks like you are using a corporate device enrolled in mobile device management\n" ); } - println!("The Komorebi License does not permit any kind of commercial use"); + println!("The Komorebi License does not permit any kind of commercial use\n"); println!( - "A dedicated Individual Commercial Use License is available if you wish to use this software at work" + "A dedicated Individual Commercial Use License is available if you wish to use this software at work\n" ); println!( - "You are strongly encouraged to make your employer pay for your license, either directly or via reimbursement" + "You are strongly encouraged to make your employer pay for your license, either directly or via reimbursement\n" ); println!( - "If you already have a license, you can run \"komorebic license \" with the email address your license is associated with" + "If you already have a license, you can run \"komorebic license \" with the email address your license is associated with\n" ); } From 48a21eba61363264bb8a09f06488d6a609c2a59b Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 25 Nov 2025 20:02:00 -0800 Subject: [PATCH 163/305] fix(wm): explicitly init and process nsapplication events For reasons unknown, CFRunLoop::run_in_mode no longer processes NSApplication events on Tahoe. Display callbacks seem to now be more tightly coupled to the NSApplication event loop, so we initialize NSApplication with sharedApplication as early as possible to establish a window server connection, and then in our main loop we poll app.nextEvent every 0.1s for NSApplication events, which is where the DisplayReconfigurationListener callback will finally kick in again. --- komorebi/src/main.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 7cccd778..8a8558e2 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -21,12 +21,17 @@ use komorebi::theme_manager; use komorebi::window_manager::WindowManager; use komorebi::window_manager_event_listener; use komorebi::workspace_reconciliator; +use objc2::MainThreadMarker; use objc2::rc::autoreleasepool; +use objc2_app_kit::NSApplication; +use objc2_app_kit::NSEventMask; use objc2_application_services::AXIsProcessTrusted; use objc2_core_foundation::CFRunLoop; use objc2_core_foundation::kCFRunLoopDefaultMode; use objc2_core_graphics::CGPreflightScreenCaptureAccess; use objc2_core_graphics::CGRequestScreenCaptureAccess; +use objc2_foundation::NSDate; +use objc2_foundation::NSDefaultRunLoopMode; use parking_lot::Mutex; use serde::Deserialize; use std::net::Shutdown; @@ -211,6 +216,12 @@ fn main() -> eyre::Result<()> { std::fs::create_dir_all(&*DATA_DIR)?; } + let mtm = MainThreadMarker::new().ok_or_eyre("failed to create main thread marker")?; + // apparently this establishes the window server connection which is needed super early on tahoe + let app = NSApplication::sharedApplication(mtm); + // this lets us complete initialization without using a blocking method like run + app.finishLaunching(); + let _notification_center_listener = NotificationCenterListener::init(); let _display_reconfiguration_listener = DisplayReconfigurationListener::init(); @@ -297,8 +308,23 @@ fn main() -> eyre::Result<()> { break; } - // this gets our observer notification callbacks firing - autoreleasepool(|_| unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 0.1, false) }); + autoreleasepool(|_| { + // process NSApplication events explicitly - this is what makes display + // reconfiguration callbacks work on tahoe + if let Some(event) = unsafe { + app.nextEventMatchingMask_untilDate_inMode_dequeue( + NSEventMask::Any, + Some(&NSDate::dateWithTimeIntervalSinceNow(0.1)), + NSDefaultRunLoopMode, + true, + ) + } { + app.sendEvent(&event); + } + + // this gets our observer notification callbacks firing + unsafe { CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, 0.1, false) }; + }); } wm.lock().restore_all_windows(false)?; From 0b34b8bfb1caa3003bbefe12ac86cca79608c9ae Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 28 Nov 2025 12:49:35 -0800 Subject: [PATCH 164/305] build(nix): use flake-parts and treefmt --- flake.lock | 73 ++++++++---- flake.nix | 323 ++++++++++++++++++++++++++++------------------------- shell.nix | 44 ++++---- 3 files changed, 246 insertions(+), 194 deletions(-) diff --git a/flake.lock b/flake.lock index 4102f2fb..5f3eb4a7 100644 --- a/flake.lock +++ b/flake.lock @@ -15,21 +15,21 @@ "type": "github" } }, - "flake-utils": { + "flake-parts": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "lastModified": 1763759067, + "narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, @@ -49,6 +49,21 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1761765539, + "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1744536153, @@ -65,12 +80,29 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1761236834, + "narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "crane": "crane", - "flake-utils": "flake-utils", + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "rust-overlay": "rust-overlay", + "treefmt-nix": "treefmt-nix" } }, "rust-overlay": { @@ -91,18 +123,21 @@ "type": "github" } }, - "systems": { + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1762938485, + "narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "numtide", + "repo": "treefmt-nix", "type": "github" } } diff --git a/flake.nix b/flake.nix index 994950e3..adb11a75 100644 --- a/flake.nix +++ b/flake.nix @@ -3,183 +3,198 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; crane.url = "github:ipetkov/crane"; - flake-utils.url = "github:numtide/flake-utils"; rust-overlay.url = "github:oxalica/rust-overlay"; + treefmt-nix.url = "github:numtide/treefmt-nix"; }; - outputs = { - self, - nixpkgs, - crane, - flake-utils, - rust-overlay, - ... - }: let - komorebiBuild = system: let - overlays = [(import rust-overlay)]; - pkgs = import nixpkgs { - inherit system overlays; - }; + outputs = + inputs@{ + self, + nixpkgs, + flake-parts, + crane, + rust-overlay, + ... + }: + let + mkKomorebiPackages = + { pkgs }: + let + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + version = "0.1.0"; - inherit (pkgs) lib; - - toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; - craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; - version = "0.1.0"; - - src = lib.cleanSourceWith { - src = ./.; - filter = path: type: - (craneLib.filterCargoSources path type) - || (lib.hasInfix "/docs/" path) - || (builtins.match ".*/docs/.*" path != null); - }; - - commonArgs = { - inherit src version; - strictDeps = true; - - COMMIT_HASH = self.rev or (lib.removeSuffix "-dirty" self.dirtyRev); - - buildInputs = [ - pkgs.gcc - pkgs.libiconv - ]; - }; - - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - - individualCrateArgs = - commonArgs - // { - inherit cargoArtifacts; - doCheck = false; - doDoc = false; - }; - - packages = let - fullBuild = craneLib.buildPackage ( - individualCrateArgs - // { - pname = "komorebi-workspace"; - } - ); - - extractBinary = binaryName: - pkgs.runCommand "komorebi-${binaryName}" - { - meta = fullBuild.meta // {}; - } - '' - mkdir -p $out/bin - cp ${fullBuild}/bin/${binaryName} $out/bin/ - ''; - in { - komorebi-full = fullBuild; - komorebi = extractBinary "komorebi"; - komorebic = extractBinary "komorebic"; - komorebi-bar = extractBinary "komorebi-bar"; - }; - in - packages - // { - inherit - pkgs - craneLib - commonArgs - cargoArtifacts - individualCrateArgs - src - ; - }; - in - flake-utils.lib.eachSystem ["aarch64-darwin"] ( - system: let - buildResult = komorebiBuild system; - inherit - (buildResult) - individualCrateArgs - komorebi - komorebic - komorebi-bar - komorebi-full - pkgs - craneLib - src - ; - in { - checks = { - komorebi-workspace-clippy = craneLib.cargoClippy individualCrateArgs; - - komorebi-workspace-fmt = craneLib.cargoFmt { - inherit src; + src = pkgs.lib.cleanSourceWith { + src = ./.; + filter = + path: type: + (craneLib.filterCargoSources path type) + || (pkgs.lib.hasInfix "/docs/" path) + || (builtins.match ".*/docs/.*" path != null); }; - komorebi-workspace-toml-fmt = craneLib.taploFmt { - src = pkgs.lib.sources.sourceFilesBySuffices src [".toml"]; + commonArgs = { + inherit src version; + strictDeps = true; + COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" self.dirtyRev); + buildInputs = [ + pkgs.gcc + pkgs.libiconv + ]; }; - komorebi-workspace-deny = craneLib.cargoDeny { - inherit src; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + + individualCrateArgs = commonArgs // { + inherit cargoArtifacts; + doCheck = false; + doDoc = false; }; - komorebi-workspace-nextest = craneLib.cargoNextest individualCrateArgs; - }; + fullBuild = craneLib.buildPackage ( + individualCrateArgs + // { + pname = "komorebi-workspace"; + } + ); - packages = { + extractBinary = + binaryName: + pkgs.runCommand "komorebi-${binaryName}" + { + meta = fullBuild.meta // { }; + } + '' + mkdir -p $out/bin + cp ${fullBuild}/bin/${binaryName} $out/bin/ + ''; + in + { inherit - komorebi - komorebic - komorebi-bar - komorebi-full + craneLib + src + individualCrateArgs + fullBuild ; - default = komorebi-full; + komorebi = extractBinary "komorebi"; + komorebic = extractBinary "komorebic"; + komorebi-bar = extractBinary "komorebi-bar"; }; - apps = { - komorebi = flake-utils.lib.mkApp { - drv = komorebi; + mkPkgs = + system: + import nixpkgs { + inherit system; + overlays = [ (import rust-overlay) ]; + }; + in + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "aarch64-darwin" + "x86_64-darwin" + ]; + + imports = [ + inputs.treefmt-nix.flakeModule + ]; + + perSystem = + { + system, + ... + }: + let + pkgs = mkPkgs system; + build = mkKomorebiPackages { inherit pkgs; }; + in + { + treefmt = { + projectRootFile = "flake.nix"; + programs = { + deadnix.enable = true; + just.enable = true; + nixfmt.enable = true; + rustfmt.enable = true; + taplo.enable = true; + }; }; - komorebic = flake-utils.lib.mkApp { - drv = komorebic; + + checks = { + komorebi-workspace-clippy = build.craneLib.cargoClippy build.individualCrateArgs; + + komorebi-workspace-fmt = build.craneLib.cargoFmt { + inherit (build) src; + }; + + komorebi-workspace-toml-fmt = build.craneLib.taploFmt { + src = pkgs.lib.sources.sourceFilesBySuffices build.src [ ".toml" ]; + }; + + komorebi-workspace-deny = build.craneLib.cargoDeny { + inherit (build) src; + }; + + komorebi-workspace-nextest = build.craneLib.cargoNextest build.individualCrateArgs; }; - komorebi-bar = flake-utils.lib.mkApp { - drv = komorebi-bar; + + packages = { + inherit (build) komorebi komorebic komorebi-bar; + komorebi-full = build.fullBuild; + default = build.fullBuild; }; - default = flake-utils.lib.mkApp { - drv = komorebi-full; + + apps = { + komorebi = { + type = "app"; + program = "${build.komorebi}/bin/komorebi"; + }; + komorebic = { + type = "app"; + program = "${build.komorebic}/bin/komorebic"; + }; + komorebi-bar = { + type = "app"; + program = "${build.komorebi-bar}/bin/komorebi-bar"; + }; + default = { + type = "app"; + program = "${build.fullBuild}/bin/komorebi"; + }; + }; + + devShells.default = import ./shell.nix { + inherit pkgs; }; }; - devShells.default = import ./shell.nix { - inherit pkgs; - }; - } - ) - // { - overlays.default = final: _: let - buildResult = komorebiBuild final.system; - in { - inherit - (buildResult) - komorebi - komorebic - komorebi-bar - komorebi-full - ; - }; + flake = { + overlays.default = + final: _: + let + pkgs = mkPkgs final.system; + build = mkKomorebiPackages { + inherit pkgs; + }; + in + { + inherit (build) komorebi komorebic komorebi-bar; + komorebi-full = build.fullBuild; + }; - overlays.komorebi = final: _: let - buildResult = komorebiBuild final.system; - in { - inherit - (buildResult) - komorebi - komorebic - komorebi-bar - komorebi-full - ; + overlays.komorebi = + final: _: + let + pkgs = mkPkgs final.system; + build = mkKomorebiPackages { + inherit pkgs; + }; + in + { + inherit (build) komorebi komorebic komorebi-bar; + komorebi-full = build.fullBuild; + }; }; }; } diff --git a/shell.nix b/shell.nix index fb685225..96a37b90 100644 --- a/shell.nix +++ b/shell.nix @@ -1,25 +1,27 @@ -{pkgs ? import (fetchTarball "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz") {}}: +{ + pkgs ? import (fetchTarball "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz") { }, +}: with pkgs; - mkShell { - name = "komorebi"; +mkShell { + name = "komorebi"; - RUST_BACKTRACE = "full"; + RUST_BACKTRACE = "full"; - buildInputs = [ - alejandra - cargo-deny - cargo-nextest - cargo-udeps - gcc - jq - just - libiconv - prettier - taplo + buildInputs = [ + alejandra + cargo-deny + cargo-nextest + cargo-udeps + gcc + jq + just + libiconv + prettier + taplo - python311Packages.mkdocs-material - python311Packages.mkdocs-macros - python311Packages.setuptools - python311Packages.json-schema-for-humans - ]; - } + python311Packages.mkdocs-material + python311Packages.mkdocs-macros + python311Packages.setuptools + python311Packages.json-schema-for-humans + ]; +} From a5cbb4dc2a7bb309f7a55ec684a1e832de7b9a36 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 28 Nov 2025 12:50:12 -0800 Subject: [PATCH 165/305] chore(deps): flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/0cea393fffb39575c46b7a0318386467272182fe' (2025-11-07) → 'github:ipetkov/crane/d9e753122e51cee64eb8d2dddfe11148f339f5a2' (2025-11-23) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369' (2025-11-08) → 'github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e' (2025-11-27) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/aa1e85921cfa04de7b6914982a94621fbec5cc02' (2025-11-12) → 'github:oxalica/rust-overlay/9623580f8ce09ec444b9aca107566ec5db110e62' (2025-11-28) --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 5f3eb4a7..5959fae2 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1762538466, - "narHash": "sha256-8zrIPl6J+wLm9MH5ksHcW7BUHo7jSNOu0/hA0ohOOaM=", + "lastModified": 1763938834, + "narHash": "sha256-j8iB0Yr4zAvQLueCZ5abxfk6fnG/SJ5JnGUziETjwfg=", "owner": "ipetkov", "repo": "crane", - "rev": "0cea393fffb39575c46b7a0318386467272182fe", + "rev": "d9e753122e51cee64eb8d2dddfe11148f339f5a2", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1762604901, - "narHash": "sha256-Pr2jpryIaQr9Yx8p6QssS03wqB6UifnnLr3HJw9veDw=", + "lastModified": 1764230294, + "narHash": "sha256-Z63xl5Scj3Y/zRBPAWq1eT68n2wBWGCIEF4waZ0bQBE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f6b44b2401525650256b977063dbcf830f762369", + "rev": "0d59e0290eefe0f12512043842d7096c4070f30e", "type": "github" }, "original": { @@ -110,11 +110,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1762915112, - "narHash": "sha256-d9j1g8nKmYDHy+/bIOPQTh9IwjRliqaTM0QLHMV92Ic=", + "lastModified": 1764297505, + "narHash": "sha256-qrLpVu2/hA9Cu6IovMEsgh9YRyvmmWS+bSx7C1JGChA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "aa1e85921cfa04de7b6914982a94621fbec5cc02", + "rev": "9623580f8ce09ec444b9aca107566ec5db110e62", "type": "github" }, "original": { From 6b980a036078e61f6b33233947e380b5c6e1993d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 29 Nov 2025 14:09:24 -0800 Subject: [PATCH 166/305] fix(border): close nswindow on main thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit addresses a bug that was introduced/made visible in a5cbb4d. The nixpkgs flake input (tracking nixpkgs-unstable) was updated from github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369 to github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e and as a result the version of AppKit being linked against jumped from 2022.44.149 to 2487.50.124. Builds prior to a5cbb4d were building against macOS 13 (Ventura) era frameworks due to the use of compatability stubs in nixpkgs, whereas the nixpkgs-unstable update in a5cbb4d now links against the actual running system's framework versions (in this case, macOS 15). With github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369: ``` ❯ otool -L target/debug/komorebi | grep -E 'AppKit|Foundation|CoreFoundation|libSystem' /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1775.118.101) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.44.149) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1775.118.101) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5) ``` With github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e ``` ❯ otool -L target/debug/komorebi | grep -E 'AppKit|Foundation|CoreFoundation|libSystem' /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2420.0.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2487.50.124) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2420.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2) ``` Somewhere between macOS 13 and macOS 15 Apple added stricter thread-safety assertions in the AppKit framework, which resulted in the calls to `NSWindow::close()` in border.rs to crash on an assertion failure ("transaction must be valid") ``` * thread #9, stop reason = EXC_BREAKPOINT (code=1, subcode=0x19e543cc0) frame #0: 0x000000019e543cc0 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:] + 752 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:]: -> 0x19e543cc0 <+752>: brk #0x1 0x19e543cc4 <+756>: adrp x0, 827 0x19e543cc8 <+760>: add x0, x0, #0x4ba ; "assertion failure: transaction must be valid" 0x19e543ccc <+764>: bl 0x19e6eb58c ; symbol stub for: _os_crash Target 0: (komorebi) stopped. (lldb) bt * thread #9, stop reason = EXC_BREAKPOINT (code=1, subcode=0x19e543cc0) * frame #0: 0x000000019e543cc0 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:] + 752 frame #1: 0x000000019e372a00 AppKit`-[NSWindow(NSWMWindowManagement) window:didUpdateWithChangedProperties:] + 104 frame #2: 0x000000027a366720 WindowManagement`-[_WMWindow performUpdatesUsingBlock:] + 100 frame #3: 0x000000027a365714 WindowManagement`-[_WMWindow applyTags:mask:] + 712 frame #4: 0x000000027a365cf8 WindowManagement`-[_WMWindow setVisible:] + 84 frame #5: 0x000000019d91b064 AppKit`-[NSWindow _setVisible:] + 268 frame #6: 0x000000019da16df0 AppKit`-[NSWindow _doWindowWillBecomeHidden] + 88 frame #7: 0x000000019e3662e0 AppKit`-[NSWindow _reallyDoOrderWindowOutRelativeTo:] + 160 frame #8: 0x000000019e366794 AppKit`-[NSWindow _reallyDoOrderWindow:] + 80 frame #9: 0x000000019e3669e4 AppKit`-[NSWindow _doOrderWindow:] + 264 frame #10: 0x000000019e360c84 AppKit`-[NSWindow _finishClosingWindow] + 444 frame #11: 0x000000019daa6cc8 AppKit`-[NSWindow _close] + 380 frame #12: 0x0000000100c3380c komorebi`_$LT$$LP$$RP$$u20$as$u20$objc2..encode..EncodeArguments$GT$::__invoke::h1be54296556f108b(msg_send_fn=(libobjc.A.dylib`objc_msgSend), receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58e38, (null)=) at encode.rs:433:26 frame #13: 0x0000000100c30f84 komorebi`objc2::runtime::message_receiver::msg_send_primitive::send::h0de1c4d240a2223f(receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58e78, args=) at message_receiver.rs:172:18 frame #14: 0x0000000100c2e904 komorebi`objc2::runtime::message_receiver::MessageReceiver::send_message::h86c04ca17a2b6faf(self=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58ed0, args=) at message_receiver.rs:432:38 frame #15: 0x0000000100b9b1bc komorebi`_$LT$MethodFamily$u20$as$u20$objc2..__macro_helpers..msg_send_retained..MsgSend$LT$Receiver$C$Return$GT$$GT$::send_message::h6cb30a52e558d44c(receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58f48, args=) at msg_send_retained.rs:35:28 frame #16: 0x0000000100ba14b8 komorebi`objc2_app_kit::generated::__NSWindow::NSWindow::close::h34bc4ef6fc286b23(self=0x0000000132e09ea0) at extern_methods.rs:266:14 frame #17: 0x00000001002b22f0 komorebi`komorebi::border_manager::border::Border::destroy::_$u7b$$u7b$closure$u7d$$u7d$::h61d54fa62ea0b107((null)=AutoreleasePool @ 0x0000000170b58fb8) at border.rs:161:35 ``` To fix this, this commit ensures that the call to `NSWindow::close()` is made on the main thread using `DispatchQueue::main().exec_sync()`. --- flake.nix | 5 ++++- justfile | 3 +-- komorebi/src/border_manager/border.rs | 13 ++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index adb11a75..49545fc7 100644 --- a/flake.nix +++ b/flake.nix @@ -116,8 +116,11 @@ deadnix.enable = true; just.enable = true; nixfmt.enable = true; - rustfmt.enable = true; taplo.enable = true; + rustfmt = { + enable = true; + package = pkgs.rust-bin.nightly.latest.rustfmt; + }; }; }; diff --git a/justfile b/justfile index 46bc15af..eb7a2315 100644 --- a/justfile +++ b/justfile @@ -5,10 +5,9 @@ fmt: test -z "$(rg 'dbg!' --type rust)" || (echo "dbg! macro not allowed"; false) test -z "$(rg 'println!' --type rust ./komorebi)" || (echo "println! macro not allowed"; false) taplo fmt Cargo.toml */Cargo.toml - cargo +nightly fmt cargo +stable clippy - alejandra . prettier --write README.md + nix fmt fix: cargo clippy --fix --allow-dirty diff --git a/komorebi/src/border_manager/border.rs b/komorebi/src/border_manager/border.rs index 984696bf..5c779ec7 100644 --- a/komorebi/src/border_manager/border.rs +++ b/komorebi/src/border_manager/border.rs @@ -16,7 +16,9 @@ use crate::macos_api::MacosApi; use color_eyre::eyre; use dispatch2::DispatchQueue; use komorebi_themes::colour::Rgb; +use objc2::rc::Retained; use objc2::rc::autoreleasepool; +use objc2_app_kit::NSWindow; use objc2_application_services::AXObserver; use objc2_application_services::AXUIElement; use objc2_core_foundation::CFString; @@ -157,8 +159,13 @@ impl Border { } pub fn destroy(&self) { - autoreleasepool(|_| { - self.ns_window.window.close(); - }) + let window_ptr = Retained::as_ptr(&self.ns_window.window) as usize; + + DispatchQueue::main().exec_sync(|| { + autoreleasepool(|_| unsafe { + let window = window_ptr as *const NSWindow; + (*window).close(); + }); + }); } } From 2ff76f0881cccf6699d1da2ccc13e3f36d1c9d40 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 29 Nov 2025 14:41:23 -0800 Subject: [PATCH 167/305] fix(wm): disable monocle mode if window is closed This commit ensures that monocle mode will be automatically disabled if the last window in a monocle container is closed. --- justfile | 3 +++ komorebi/src/reaper.rs | 24 +++++++++++++++++++++--- komorebi/src/workspace.rs | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index eb7a2315..ab299ca1 100644 --- a/justfile +++ b/justfile @@ -27,6 +27,9 @@ build target: run target: cargo +stable run --bin {{ target }} --locked +error target $RUST_LOG="komorebi=error": + just run {{ target }} + warn target $RUST_LOG="komorebi=warn": just run {{ target }} diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs index 642f4fe9..d7fa74e3 100644 --- a/komorebi/src/reaper.rs +++ b/komorebi/src/reaper.rs @@ -80,6 +80,22 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> }); } + if let Some(container) = &mut workspace.monocle_container { + container.windows_mut().retain(|w| { + if w.id == window_id { + should_update = true; + tracing::info!("reaping window: {window_id}"); + } + + w.id != window_id + }); + + if container.windows().is_empty() { + workspace.monocle_container = None; + workspace.monocle_container_restore_idx = None; + } + } + workspace.floating_windows_mut().retain(|w| { if w.id == window_id { should_update = true; @@ -91,9 +107,11 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> } } - // If an invalid window was cleaned up, we update the workspace - wm.update_focused_workspace(false, false)?; - border_manager::send_notification(None, Some(window_id)); + if should_update { + // If an invalid window was cleaned up, we update the workspace + wm.update_focused_workspace(false, false)?; + border_manager::send_notification(None, Some(window_id)); + } } ReaperNotification::MouseUpKeyUp => { // this first one will do a "nothing" update to check if any windows failed diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 37a8ecf3..cfd4d59c 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -415,6 +415,22 @@ impl Workspace { } } + if let Some(container) = &self.monocle_container + && let Some(focused_window) = container.focused_window() + { + if focused_window.application.process_id == process_id + && !valid_window_ids.contains(&focused_window.id) + { + invalid_window_ids.push(focused_window.id); + } + + // if accessibility API calls fail on AXError::InvalidUIElement + // let's try and nuke these early + if !focused_window.is_valid() { + invalid_window_ids.push(focused_window.id); + } + } + for window in self.floating_windows() { if window.application.process_id == process_id { if !valid_window_ids.contains(&window.id) { From dcef667811baf8c1eced9c05af564319bc1e1c29 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 30 Nov 2025 11:53:41 -0800 Subject: [PATCH 168/305] fix(config): ensure pathext replaces ~ with $home --- komorebi/src/core/pathext.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/komorebi/src/core/pathext.rs b/komorebi/src/core/pathext.rs index 3713ac40..34be424e 100644 --- a/komorebi/src/core/pathext.rs +++ b/komorebi/src/core/pathext.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::env; use std::ffi::OsStr; use std::path::Component; use std::path::Path; @@ -34,6 +33,12 @@ impl> PathExt for P { c = OsStr::new("$Env:USERPROFILE"); } + #[cfg(target_os = "macos")] + // Special case for ~, replace with $HOME + if c == OsStr::new("~") { + c = OsStr::new("$HOME"); + } + let bytes = c.as_encoded_bytes(); // %LOCALAPPDATA% @@ -60,7 +65,7 @@ impl> PathExt for P { // if component is a variable, get the value from the environment if let Some(var) = var { let var = unsafe { OsStr::from_encoded_bytes_unchecked(var) }; - if let Some(value) = env::var_os(var) { + if let Some(value) = std::env::var_os(var) { out.push(value); continue; } @@ -206,6 +211,7 @@ mod tests { } // ~ and $HOME should be replaced with $Env:USERPROFILE + assert_eq!(resolve("~"), expected("/Users/user")); assert_eq!(resolve("$HOME"), expected("/Users/user")); } } From 82de4dd2305446ca73f12683d219f44f180e95e9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 30 Nov 2025 13:14:15 -0800 Subject: [PATCH 169/305] build(nix): clean runtime build inputs --- flake.nix | 20 +++++++++++++------- justfile | 1 - shell.nix | 4 ---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index 49545fc7..fbc4bd12 100644 --- a/flake.nix +++ b/flake.nix @@ -39,10 +39,19 @@ inherit src version; strictDeps = true; COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" self.dirtyRev); - buildInputs = [ - pkgs.gcc - pkgs.libiconv + nativeBuildInputs = [ + pkgs.darwin.cctools ]; + postFixup = '' + for bin in $out/bin/*; do + if [ -f "$bin" ] && [ -x "$bin" ]; then + # Get all linked libraries and fix libiconv references + otool -L "$bin" | grep -o '/nix/store/[^/]*/lib/libiconv[^ ]*' | while read -r lib; do + install_name_tool -change "$lib" /usr/lib/libiconv.dylib "$bin" + done + fi + done + ''; }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; @@ -101,10 +110,7 @@ ]; perSystem = - { - system, - ... - }: + { system, ... }: let pkgs = mkPkgs system; build = mkKomorebiPackages { inherit pkgs; }; diff --git a/justfile b/justfile index ab299ca1..ab316fef 100644 --- a/justfile +++ b/justfile @@ -4,7 +4,6 @@ fmt: test -z "$(rg 'eyre!' --type rust)" || (echo "eyre! macro not allowed"; false) test -z "$(rg 'dbg!' --type rust)" || (echo "dbg! macro not allowed"; false) test -z "$(rg 'println!' --type rust ./komorebi)" || (echo "println! macro not allowed"; false) - taplo fmt Cargo.toml */Cargo.toml cargo +stable clippy prettier --write README.md nix fmt diff --git a/shell.nix b/shell.nix index 96a37b90..6ea338e5 100644 --- a/shell.nix +++ b/shell.nix @@ -8,16 +8,12 @@ mkShell { RUST_BACKTRACE = "full"; buildInputs = [ - alejandra cargo-deny cargo-nextest cargo-udeps - gcc jq just - libiconv prettier - taplo python311Packages.mkdocs-material python311Packages.mkdocs-macros From e434526f0698f046716c7cdb6295aedc5cfdb4bc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 6 Dec 2025 12:34:36 -0800 Subject: [PATCH 170/305] chore(deps): flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/d9e753122e51cee64eb8d2dddfe11148f339f5a2' (2025-11-23) → 'github:ipetkov/crane/2b3a5a88d852575758e1eb6ac9ee677fcd633fc1' (2025-12-05) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e' (2025-11-27) → 'github:NixOS/nixpkgs/a672be65651c80d3f592a89b3945466584a22069' (2025-12-05) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/9623580f8ce09ec444b9aca107566ec5db110e62' (2025-11-28) → 'github:oxalica/rust-overlay/086fd19a68e80fcc8a298e9df4674982e4c498a6' (2025-12-06) --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 5959fae2..8a27428b 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1763938834, - "narHash": "sha256-j8iB0Yr4zAvQLueCZ5abxfk6fnG/SJ5JnGUziETjwfg=", + "lastModified": 1764903584, + "narHash": "sha256-RSkJtNtx0SEaQiYqsoFoRynwfZLo2OZ9z6rUq1DJR6g=", "owner": "ipetkov", "repo": "crane", - "rev": "d9e753122e51cee64eb8d2dddfe11148f339f5a2", + "rev": "2b3a5a88d852575758e1eb6ac9ee677fcd633fc1", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1764230294, - "narHash": "sha256-Z63xl5Scj3Y/zRBPAWq1eT68n2wBWGCIEF4waZ0bQBE=", + "lastModified": 1764947035, + "narHash": "sha256-EYHSjVM4Ox4lvCXUMiKKs2vETUSL5mx+J2FfutM7T9w=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0d59e0290eefe0f12512043842d7096c4070f30e", + "rev": "a672be65651c80d3f592a89b3945466584a22069", "type": "github" }, "original": { @@ -110,11 +110,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1764297505, - "narHash": "sha256-qrLpVu2/hA9Cu6IovMEsgh9YRyvmmWS+bSx7C1JGChA=", + "lastModified": 1764988672, + "narHash": "sha256-FIJtt3Zil89/hLy9i7f0R2xXcJDPc3CeqiiCLfsFV0Y=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "9623580f8ce09ec444b9aca107566ec5db110e62", + "rev": "086fd19a68e80fcc8a298e9df4674982e4c498a6", "type": "github" }, "original": { From bc6236abc09cdd3bdfe415fb981b031696d41829 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 7 Dec 2025 17:24:21 -0800 Subject: [PATCH 171/305] refactor(cli): use "args" var name uniformly --- komorebic/src/main.rs | 468 +++++++++++++++++++++--------------------- 1 file changed, 236 insertions(+), 232 deletions(-) diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 04376a2b..5ec666ce 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1254,16 +1254,16 @@ fn main() -> eyre::Result<()> { } } } - SubCommand::Splash(arg) => { - splash::show(arg.mdm_server)?; + SubCommand::Splash(args) => { + splash::show(args.mdm_server)?; } - SubCommand::Completions(arg) => { + SubCommand::Completions(args) => { let mut cli = Opts::command(); - clap_complete::generate(arg.shell, &mut cli, "komorebic", &mut std::io::stdout()); + clap_complete::generate(args.shell, &mut cli, "komorebic", &mut std::io::stdout()); } - SubCommand::License(arg) => { + SubCommand::License(args) => { let _ = std::fs::remove_file(DATA_DIR.join("icul.validation")); - std::fs::write(DATA_DIR.join("icul"), &arg.email)?; + std::fs::write(DATA_DIR.join("icul"), &args.email)?; match splash::should()? { ValidationFeedback::Successful(icul_validation) => { println!("Individual commercial use license validation successful"); @@ -1276,7 +1276,7 @@ fn main() -> eyre::Result<()> { ValidationFeedback::Unsuccessful(invalid_payload) => { println!( "No active individual commercial use license found for {}", - arg.email + args.email ); println!("\n{invalid_payload}"); println!( @@ -1287,7 +1287,7 @@ fn main() -> eyre::Result<()> { ValidationFeedback::NoConnectivity => { println!( "Could not make a connection to validate an individual commercial use license for {}", - arg.email + args.email ); } } @@ -1522,10 +1522,10 @@ fn main() -> eyre::Result<()> { std::fs::remove_file(&target)?; println!("Deleted {}", target.display()); } - SubCommand::Start(arg) => { + SubCommand::Start(args) => { let mut command = &mut Command::new("komorebi"); - if let Some(config) = &arg.config { + if let Some(config) = &args.config { command = command.args(["--config", &format!("'--config=\"{}\"'", config.display())]) }; @@ -1567,7 +1567,7 @@ fn main() -> eyre::Result<()> { if !running { println!("\nRunning komorebi directly for detailed error output\n"); - if let Some(config) = &arg.config { + if let Some(config) = &args.config { if let Ok(output) = Command::new("komorebi") .arg(format!("'--config=\"{}\"'", config.display())) .output() @@ -1581,7 +1581,7 @@ fn main() -> eyre::Result<()> { return Ok(()); } - if arg.bar { + if args.bar { let mut command = &mut Command::new("komorebi-bar"); command = command @@ -1630,14 +1630,14 @@ fn main() -> eyre::Result<()> { "* Read the docs https://lgug2z.github.io/komorebi - Quickly search through all komorebic commands" ); } - SubCommand::Stop(arg) => { - if arg.ignore_restore { + SubCommand::Stop(args) => { + if args.ignore_restore { send_message(&SocketMessage::StopIgnoreRestore)?; } else { send_message(&SocketMessage::Stop)?; } - if arg.bar { + if args.bar { Command::new("pkill").arg("komorebi-bar").spawn()?; } @@ -1674,38 +1674,38 @@ fn main() -> eyre::Result<()> { println!("{line}"); } } - SubCommand::Focus(arg) => { - send_message(&SocketMessage::FocusWindow(arg.operation_direction))?; + SubCommand::Focus(args) => { + send_message(&SocketMessage::FocusWindow(args.operation_direction))?; } - SubCommand::Move(arg) => { - send_message(&SocketMessage::MoveWindow(arg.operation_direction))?; + SubCommand::Move(args) => { + send_message(&SocketMessage::MoveWindow(args.operation_direction))?; } - SubCommand::PreselectDirection(arg) => { - send_message(&SocketMessage::PreselectDirection(arg.operation_direction))?; + SubCommand::PreselectDirection(args) => { + send_message(&SocketMessage::PreselectDirection(args.operation_direction))?; } SubCommand::CancelPreselect => { send_message(&SocketMessage::CancelPreselect)?; } - SubCommand::CycleFocus(arg) => { - send_message(&SocketMessage::CycleFocusWindow(arg.cycle_direction))?; + SubCommand::CycleFocus(args) => { + send_message(&SocketMessage::CycleFocusWindow(args.cycle_direction))?; } - SubCommand::CycleMove(arg) => { - send_message(&SocketMessage::CycleMoveWindow(arg.cycle_direction))?; + SubCommand::CycleMove(args) => { + send_message(&SocketMessage::CycleMoveWindow(args.cycle_direction))?; } SubCommand::TogglePause => { send_message(&SocketMessage::TogglePause)?; } - SubCommand::ChangeLayout(arg) => { - send_message(&SocketMessage::ChangeLayout(arg.default_layout))?; + SubCommand::ChangeLayout(args) => { + send_message(&SocketMessage::ChangeLayout(args.default_layout))?; } - SubCommand::CycleLayout(arg) => { - send_message(&SocketMessage::CycleLayout(arg.cycle_direction))?; + SubCommand::CycleLayout(args) => { + send_message(&SocketMessage::CycleLayout(args.cycle_direction))?; } - SubCommand::FlipLayout(arg) => { - send_message(&SocketMessage::FlipLayout(arg.axis))?; + SubCommand::FlipLayout(args) => { + send_message(&SocketMessage::FlipLayout(args.axis))?; } - SubCommand::Stack(arg) => { - send_message(&SocketMessage::StackWindow(arg.operation_direction))?; + SubCommand::Stack(args) => { + send_message(&SocketMessage::StackWindow(args.operation_direction))?; } SubCommand::StackAll => { send_message(&SocketMessage::StackAll)?; @@ -1716,17 +1716,17 @@ fn main() -> eyre::Result<()> { SubCommand::UnstackAll => { send_message(&SocketMessage::UnstackAll)?; } - SubCommand::FocusStackWindow(arg) => { - send_message(&SocketMessage::FocusStackWindow(arg.target))?; + SubCommand::FocusStackWindow(args) => { + send_message(&SocketMessage::FocusStackWindow(args.target))?; } - SubCommand::CycleStack(arg) => { - send_message(&SocketMessage::CycleStack(arg.cycle_direction))?; + SubCommand::CycleStack(args) => { + send_message(&SocketMessage::CycleStack(args.cycle_direction))?; } - SubCommand::CycleStackIndex(arg) => { - send_message(&SocketMessage::CycleStackIndex(arg.cycle_direction))?; + SubCommand::CycleStackIndex(args) => { + send_message(&SocketMessage::CycleStackIndex(args.cycle_direction))?; } - SubCommand::FocusWorkspace(arg) => { - send_message(&SocketMessage::FocusWorkspaceNumber(arg.target))?; + SubCommand::FocusWorkspace(args) => { + send_message(&SocketMessage::FocusWorkspaceNumber(args.target))?; } SubCommand::ToggleMonocle => { send_message(&SocketMessage::ToggleMonocle)?; @@ -1737,11 +1737,11 @@ fn main() -> eyre::Result<()> { SubCommand::ToggleWorkspaceLayer => { send_message(&SocketMessage::ToggleWorkspaceLayer)?; } - SubCommand::ResizeEdge(arg) => { - send_message(&SocketMessage::ResizeWindowEdge(arg.edge, arg.sizing))?; + SubCommand::ResizeEdge(args) => { + send_message(&SocketMessage::ResizeWindowEdge(args.edge, args.sizing))?; } - SubCommand::ResizeAxis(arg) => { - send_message(&SocketMessage::ResizeWindowAxis(arg.axis, arg.sizing))?; + SubCommand::ResizeAxis(args) => { + send_message(&SocketMessage::ResizeWindowAxis(args.axis, args.sizing))?; } SubCommand::Retile => { send_message(&SocketMessage::Retile)?; @@ -1767,8 +1767,8 @@ fn main() -> eyre::Result<()> { SubCommand::PromoteFocus => { send_message(&SocketMessage::PromoteFocus)?; } - SubCommand::PromoteWindow(arg) => { - send_message(&SocketMessage::PromoteWindow(arg.operation_direction))?; + SubCommand::PromoteWindow(args) => { + send_message(&SocketMessage::PromoteWindow(args.operation_direction))?; } SubCommand::ToggleWindowBasedWorkAreaOffset => { send_message(&SocketMessage::ToggleWindowBasedWorkAreaOffset)?; @@ -1794,8 +1794,8 @@ fn main() -> eyre::Result<()> { SubCommand::ToggleCrossMonitorMoveBehaviour => { send_message(&SocketMessage::ToggleCrossMonitorMoveBehaviour)?; } - SubCommand::FocusMonitor(arg) => { - send_message(&SocketMessage::FocusMonitorNumber(arg.target))?; + SubCommand::FocusMonitor(args) => { + send_message(&SocketMessage::FocusMonitorNumber(args.target))?; } SubCommand::FocusMonitorAtCursor => { send_message(&SocketMessage::FocusMonitorAtCursor)?; @@ -1803,88 +1803,92 @@ fn main() -> eyre::Result<()> { SubCommand::FocusLastWorkspace => { send_message(&SocketMessage::FocusLastWorkspace)?; } - SubCommand::FocusWorkspaces(arg) => { - send_message(&SocketMessage::FocusWorkspaceNumbers(arg.target))?; + SubCommand::FocusWorkspaces(args) => { + send_message(&SocketMessage::FocusWorkspaceNumbers(args.target))?; } - SubCommand::FocusMonitorWorkspace(arg) => { + SubCommand::FocusMonitorWorkspace(args) => { send_message(&SocketMessage::FocusMonitorWorkspaceNumber( - arg.target_monitor, - arg.target_workspace, + args.target_monitor, + args.target_workspace, ))?; } - SubCommand::FocusNamedWorkspace(arg) => { - send_message(&SocketMessage::FocusNamedWorkspace(arg.workspace))?; + SubCommand::FocusNamedWorkspace(args) => { + send_message(&SocketMessage::FocusNamedWorkspace(args.workspace))?; } SubCommand::CloseWorkspace => { send_message(&SocketMessage::CloseWorkspace)?; } - SubCommand::CycleMonitor(arg) => { - send_message(&SocketMessage::CycleFocusMonitor(arg.cycle_direction))?; + SubCommand::CycleMonitor(args) => { + send_message(&SocketMessage::CycleFocusMonitor(args.cycle_direction))?; } - SubCommand::CycleWorkspace(arg) => { - send_message(&SocketMessage::CycleFocusWorkspace(arg.cycle_direction))?; + SubCommand::CycleWorkspace(args) => { + send_message(&SocketMessage::CycleFocusWorkspace(args.cycle_direction))?; } - SubCommand::CycleEmptyWorkspace(arg) => { + SubCommand::CycleEmptyWorkspace(args) => { send_message(&SocketMessage::CycleFocusEmptyWorkspace( - arg.cycle_direction, + args.cycle_direction, ))?; } - SubCommand::MoveToMonitor(arg) => { - send_message(&SocketMessage::MoveContainerToMonitorNumber(arg.target))?; + SubCommand::MoveToMonitor(args) => { + send_message(&SocketMessage::MoveContainerToMonitorNumber(args.target))?; } - SubCommand::CycleMoveToMonitor(arg) => { + SubCommand::CycleMoveToMonitor(args) => { send_message(&SocketMessage::CycleMoveContainerToMonitor( - arg.cycle_direction, + args.cycle_direction, ))?; } - SubCommand::MoveToWorkspace(arg) => { - send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target))?; + SubCommand::MoveToWorkspace(args) => { + send_message(&SocketMessage::MoveContainerToWorkspaceNumber(args.target))?; } - SubCommand::MoveToNamedWorkspace(arg) => { - send_message(&SocketMessage::MoveContainerToNamedWorkspace(arg.workspace))?; + SubCommand::MoveToNamedWorkspace(args) => { + send_message(&SocketMessage::MoveContainerToNamedWorkspace( + args.workspace, + ))?; } - SubCommand::CycleMoveToWorkspace(arg) => { + SubCommand::CycleMoveToWorkspace(args) => { send_message(&SocketMessage::CycleMoveContainerToWorkspace( - arg.cycle_direction, + args.cycle_direction, ))?; } - SubCommand::SendToMonitor(arg) => { - send_message(&SocketMessage::SendContainerToMonitorNumber(arg.target))?; + SubCommand::SendToMonitor(args) => { + send_message(&SocketMessage::SendContainerToMonitorNumber(args.target))?; } - SubCommand::CycleSendToMonitor(arg) => { + SubCommand::CycleSendToMonitor(args) => { send_message(&SocketMessage::CycleSendContainerToMonitor( - arg.cycle_direction, + args.cycle_direction, ))?; } - SubCommand::SendToWorkspace(arg) => { - send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target))?; + SubCommand::SendToWorkspace(args) => { + send_message(&SocketMessage::SendContainerToWorkspaceNumber(args.target))?; } - SubCommand::SendToNamedWorkspace(arg) => { - send_message(&SocketMessage::SendContainerToNamedWorkspace(arg.workspace))?; + SubCommand::SendToNamedWorkspace(args) => { + send_message(&SocketMessage::SendContainerToNamedWorkspace( + args.workspace, + ))?; } - SubCommand::CycleSendToWorkspace(arg) => { + SubCommand::CycleSendToWorkspace(args) => { send_message(&SocketMessage::CycleSendContainerToWorkspace( - arg.cycle_direction, + args.cycle_direction, ))?; } - SubCommand::SendToMonitorWorkspace(arg) => { + SubCommand::SendToMonitorWorkspace(args) => { send_message(&SocketMessage::SendContainerToMonitorWorkspaceNumber( - arg.target_monitor, - arg.target_workspace, + args.target_monitor, + args.target_workspace, ))?; } - SubCommand::MoveToMonitorWorkspace(arg) => { + SubCommand::MoveToMonitorWorkspace(args) => { send_message(&SocketMessage::MoveContainerToMonitorWorkspaceNumber( - arg.target_monitor, - arg.target_workspace, + args.target_monitor, + args.target_workspace, ))?; } - SubCommand::MoveWorkspaceToMonitor(arg) => { - send_message(&SocketMessage::MoveWorkspaceToMonitorNumber(arg.target))?; + SubCommand::MoveWorkspaceToMonitor(args) => { + send_message(&SocketMessage::MoveWorkspaceToMonitorNumber(args.target))?; } - SubCommand::CycleMoveWorkspaceToMonitor(arg) => { + SubCommand::CycleMoveWorkspaceToMonitor(args) => { send_message(&SocketMessage::CycleMoveWorkspaceToMonitor( - arg.cycle_direction, + args.cycle_direction, ))?; } SubCommand::MoveToLastWorkspace => { @@ -1893,8 +1897,8 @@ fn main() -> eyre::Result<()> { SubCommand::SendToLastWorkspace => { send_message(&SocketMessage::SendContainerToLastWorkspace)?; } - SubCommand::SwapWorkspacesWithMonitor(arg) => { - send_message(&SocketMessage::SwapWorkspacesToMonitorNumber(arg.target))?; + SubCommand::SwapWorkspacesWithMonitor(args) => { + send_message(&SocketMessage::SwapWorkspacesToMonitorNumber(args.target))?; } SubCommand::State => { print_query(&SocketMessage::State); @@ -1902,8 +1906,8 @@ fn main() -> eyre::Result<()> { SubCommand::GlobalState => { print_query(&SocketMessage::GlobalState); } - SubCommand::Query(arg) => { - print_query(&SocketMessage::Query(arg.state_query)); + SubCommand::Query(args) => { + print_query(&SocketMessage::Query(args.state_query)); } SubCommand::VisibleWindows => { print_query(&SocketMessage::VisibleWindows); @@ -1942,50 +1946,50 @@ fn main() -> eyre::Result<()> { SubCommand::ClearSessionFloatRules => { send_message(&SocketMessage::ClearSessionFloatRules)?; } - SubCommand::IgnoreRule(arg) => { - send_message(&SocketMessage::IgnoreRule(arg.identifier, arg.id))?; + SubCommand::IgnoreRule(args) => { + send_message(&SocketMessage::IgnoreRule(args.identifier, args.id))?; } - SubCommand::ManageRule(arg) => { - send_message(&SocketMessage::ManageRule(arg.identifier, arg.id))?; + SubCommand::ManageRule(args) => { + send_message(&SocketMessage::ManageRule(args.identifier, args.id))?; } - SubCommand::InitialWorkspaceRule(arg) => { + SubCommand::InitialWorkspaceRule(args) => { send_message(&SocketMessage::InitialWorkspaceRule( - arg.identifier, - arg.id, - arg.monitor, - arg.workspace, + args.identifier, + args.id, + args.monitor, + args.workspace, ))?; } - SubCommand::InitialNamedWorkspaceRule(arg) => { + SubCommand::InitialNamedWorkspaceRule(args) => { send_message(&SocketMessage::InitialNamedWorkspaceRule( - arg.identifier, - arg.id, - arg.workspace, + args.identifier, + args.id, + args.workspace, ))?; } - SubCommand::WorkspaceRule(arg) => { + SubCommand::WorkspaceRule(args) => { send_message(&SocketMessage::WorkspaceRule( - arg.identifier, - arg.id, - arg.monitor, - arg.workspace, + args.identifier, + args.id, + args.monitor, + args.workspace, ))?; } - SubCommand::NamedWorkspaceRule(arg) => { + SubCommand::NamedWorkspaceRule(args) => { send_message(&SocketMessage::NamedWorkspaceRule( - arg.identifier, - arg.id, - arg.workspace, + args.identifier, + args.id, + args.workspace, ))?; } - SubCommand::ClearWorkspaceRules(arg) => { + SubCommand::ClearWorkspaceRules(args) => { send_message(&SocketMessage::ClearWorkspaceRules( - arg.monitor, - arg.workspace, + args.monitor, + args.workspace, ))?; } - SubCommand::ClearNamedWorkspaceRules(arg) => { - send_message(&SocketMessage::ClearNamedWorkspaceRules(arg.workspace))?; + SubCommand::ClearNamedWorkspaceRules(args) => { + send_message(&SocketMessage::ClearNamedWorkspaceRules(args.workspace))?; } SubCommand::ClearAllWorkspaceRules => { send_message(&SocketMessage::ClearAllWorkspaceRules)?; @@ -1993,8 +1997,8 @@ fn main() -> eyre::Result<()> { SubCommand::EnforceWorkspaceRules => { send_message(&SocketMessage::EnforceWorkspaceRules)?; } - SubCommand::EagerFocus(arg) => { - send_message(&SocketMessage::EagerFocus(arg.exe))?; + SubCommand::EagerFocus(args) => { + send_message(&SocketMessage::EagerFocus(args.exe))?; } SubCommand::NewWorkspace => { send_message(&SocketMessage::NewWorkspace)?; @@ -2006,124 +2010,124 @@ fn main() -> eyre::Result<()> { name.value, ))?; } - SubCommand::ResizeDelta(arg) => { - send_message(&SocketMessage::ResizeDelta(arg.pixels))?; + SubCommand::ResizeDelta(args) => { + send_message(&SocketMessage::ResizeDelta(args.pixels))?; } - SubCommand::MonitorWorkAreaOffset(arg) => { + SubCommand::MonitorWorkAreaOffset(args) => { send_message(&SocketMessage::MonitorWorkAreaOffset( - arg.monitor, + args.monitor, Rect { - left: arg.left, - top: arg.top, - right: arg.right, - bottom: arg.bottom, + left: args.left, + top: args.top, + right: args.right, + bottom: args.bottom, }, ))?; } - SubCommand::GlobalWorkAreaOffset(arg) => { + SubCommand::GlobalWorkAreaOffset(args) => { send_message(&SocketMessage::WorkAreaOffset(Rect { - left: arg.left, - top: arg.top, - right: arg.right, - bottom: arg.bottom, + left: args.left, + top: args.top, + right: args.right, + bottom: args.bottom, }))?; } - SubCommand::WorkspaceWorkAreaOffset(arg) => { + SubCommand::WorkspaceWorkAreaOffset(args) => { send_message(&SocketMessage::WorkspaceWorkAreaOffset( - arg.monitor, - arg.workspace, + args.monitor, + args.workspace, Rect { - left: arg.left, - top: arg.top, - right: arg.right, - bottom: arg.bottom, + left: args.left, + top: args.top, + right: args.right, + bottom: args.bottom, }, ))?; } - SubCommand::ContainerPadding(arg) => { + SubCommand::ContainerPadding(args) => { send_message(&SocketMessage::ContainerPadding( - arg.monitor, - arg.workspace, - arg.size, + args.monitor, + args.workspace, + args.size, ))?; } - SubCommand::NamedWorkspaceContainerPadding(arg) => { + SubCommand::NamedWorkspaceContainerPadding(args) => { send_message(&SocketMessage::NamedWorkspaceContainerPadding( - arg.workspace, - arg.size, + args.workspace, + args.size, ))?; } - SubCommand::WorkspacePadding(arg) => { + SubCommand::WorkspacePadding(args) => { send_message(&SocketMessage::WorkspacePadding( - arg.monitor, - arg.workspace, - arg.size, + args.monitor, + args.workspace, + args.size, ))?; } - SubCommand::NamedWorkspacePadding(arg) => { + SubCommand::NamedWorkspacePadding(args) => { send_message(&SocketMessage::NamedWorkspacePadding( - arg.workspace, - arg.size, + args.workspace, + args.size, ))?; } - SubCommand::FocusedWorkspacePadding(arg) => { - send_message(&SocketMessage::FocusedWorkspacePadding(arg.size))?; + SubCommand::FocusedWorkspacePadding(args) => { + send_message(&SocketMessage::FocusedWorkspacePadding(args.size))?; } - SubCommand::FocusedWorkspaceContainerPadding(arg) => { - send_message(&SocketMessage::FocusedWorkspaceContainerPadding(arg.size))?; + SubCommand::FocusedWorkspaceContainerPadding(args) => { + send_message(&SocketMessage::FocusedWorkspaceContainerPadding(args.size))?; } - SubCommand::AdjustWorkspacePadding(arg) => { + SubCommand::AdjustWorkspacePadding(args) => { send_message(&SocketMessage::AdjustWorkspacePadding( - arg.sizing, - arg.adjustment, + args.sizing, + args.adjustment, ))?; } - SubCommand::AdjustContainerPadding(arg) => { + SubCommand::AdjustContainerPadding(args) => { send_message(&SocketMessage::AdjustContainerPadding( - arg.sizing, - arg.adjustment, + args.sizing, + args.adjustment, ))?; } - SubCommand::WorkspaceLayout(arg) => { + SubCommand::WorkspaceLayout(args) => { send_message(&SocketMessage::WorkspaceLayout( - arg.monitor, - arg.workspace, - arg.value, + args.monitor, + args.workspace, + args.value, ))?; } - SubCommand::NamedWorkspaceLayout(arg) => { + SubCommand::NamedWorkspaceLayout(args) => { send_message(&SocketMessage::NamedWorkspaceLayout( - arg.workspace, - arg.value, + args.workspace, + args.value, ))?; } - SubCommand::WorkspaceTiling(arg) => { + SubCommand::WorkspaceTiling(args) => { send_message(&SocketMessage::WorkspaceTiling( - arg.monitor, - arg.workspace, - arg.value.into(), + args.monitor, + args.workspace, + args.value.into(), ))?; } - SubCommand::NamedWorkspaceTiling(arg) => { + SubCommand::NamedWorkspaceTiling(args) => { send_message(&SocketMessage::NamedWorkspaceTiling( - arg.workspace, - arg.value.into(), + args.workspace, + args.value.into(), ))?; } - SubCommand::ScrollingLayoutColumns(arg) => { - send_message(&SocketMessage::ScrollingLayoutColumns(arg.count))?; + SubCommand::ScrollingLayoutColumns(args) => { + send_message(&SocketMessage::ScrollingLayoutColumns(args.count))?; } - SubCommand::ClearWorkspaceLayoutRules(arg) => { + SubCommand::ClearWorkspaceLayoutRules(args) => { send_message(&SocketMessage::ClearWorkspaceLayoutRules( - arg.monitor, - arg.workspace, + args.monitor, + args.workspace, ))?; } - SubCommand::ClearNamedWorkspaceLayoutRules(arg) => { + SubCommand::ClearNamedWorkspaceLayoutRules(args) => { send_message(&SocketMessage::ClearNamedWorkspaceLayoutRules( - arg.workspace, + args.workspace, ))?; } SubCommand::EnsureWorkspaces(workspaces) => { @@ -2132,42 +2136,42 @@ fn main() -> eyre::Result<()> { workspaces.workspace_count, ))?; } - SubCommand::EnsureNamedWorkspaces(arg) => { + SubCommand::EnsureNamedWorkspaces(args) => { send_message(&SocketMessage::EnsureNamedWorkspaces( - arg.monitor, - arg.names, + args.monitor, + args.names, ))?; } - SubCommand::WorkspaceLayoutRule(arg) => { + SubCommand::WorkspaceLayoutRule(args) => { send_message(&SocketMessage::WorkspaceLayoutRule( - arg.monitor, - arg.workspace, - arg.at_container_count, - arg.layout, + args.monitor, + args.workspace, + args.at_container_count, + args.layout, ))?; } - SubCommand::NamedWorkspaceLayoutRule(arg) => { + SubCommand::NamedWorkspaceLayoutRule(args) => { send_message(&SocketMessage::NamedWorkspaceLayoutRule( - arg.workspace, - arg.at_container_count, - arg.layout, + args.workspace, + args.at_container_count, + args.layout, ))?; } - SubCommand::CrossMonitorMoveBehaviour(arg) => { + SubCommand::CrossMonitorMoveBehaviour(args) => { send_message(&SocketMessage::CrossMonitorMoveBehaviour( - arg.move_behaviour, + args.move_behaviour, ))?; } - SubCommand::UnmanagedWindowOperationBehaviour(arg) => { + SubCommand::UnmanagedWindowOperationBehaviour(args) => { send_message(&SocketMessage::UnmanagedWindowOperationBehaviour( - arg.operation_behaviour, + args.operation_behaviour, ))?; } SubCommand::ToggleMouseFollowsFocus => { send_message(&SocketMessage::ToggleMouseFollowsFocus)?; } - SubCommand::MouseFollowsFocus(arg) => { - send_message(&SocketMessage::MouseFollowsFocus(arg.boolean_state.into()))?; + SubCommand::MouseFollowsFocus(args) => { + send_message(&SocketMessage::MouseFollowsFocus(args.boolean_state.into()))?; } SubCommand::ApplicationSpecificConfigurationSchema => { #[cfg(feature = "schemars")] @@ -2209,11 +2213,11 @@ fn main() -> eyre::Result<()> { println!("{schema}"); } } - SubCommand::SubscribeSocket(arg) => { - send_message(&SocketMessage::AddSubscriberSocket(arg.socket))?; + SubCommand::SubscribeSocket(args) => { + send_message(&SocketMessage::AddSubscriberSocket(args.socket))?; } - SubCommand::UnsubscribeSocket(arg) => { - send_message(&SocketMessage::RemoveSubscriberSocket(arg.socket))?; + SubCommand::UnsubscribeSocket(args) => { + send_message(&SocketMessage::RemoveSubscriberSocket(args.socket))?; } SubCommand::GenerateStaticConfig => { print_query(&SocketMessage::GenerateStaticConfig); @@ -2224,37 +2228,37 @@ fn main() -> eyre::Result<()> { SubCommand::QuickLoadResize => { send_message(&SocketMessage::QuickLoad)?; } - SubCommand::SaveResize(arg) => { - send_message(&SocketMessage::Save(arg.path))?; + SubCommand::SaveResize(args) => { + send_message(&SocketMessage::Save(args.path))?; } - SubCommand::LoadResize(arg) => { - send_message(&SocketMessage::Load(arg.path))?; + SubCommand::LoadResize(args) => { + send_message(&SocketMessage::Load(args.path))?; } - SubCommand::DisplayIndexPreference(arg) => { + SubCommand::DisplayIndexPreference(args) => { send_message(&SocketMessage::DisplayIndexPreference( - arg.index_preference, - arg.display, + args.index_preference, + args.display, ))?; } - SubCommand::ReplaceConfiguration(arg) => { - send_message(&SocketMessage::ReplaceConfiguration(arg.path))?; + SubCommand::ReplaceConfiguration(args) => { + send_message(&SocketMessage::ReplaceConfiguration(args.path))?; } - SubCommand::Border(arg) => { - send_message(&SocketMessage::Border(arg.boolean_state.into()))?; + SubCommand::Border(args) => { + send_message(&SocketMessage::Border(args.boolean_state.into()))?; } - SubCommand::BorderColour(arg) => { + SubCommand::BorderColour(args) => { send_message(&SocketMessage::BorderColour( - arg.window_kind, - arg.r, - arg.g, - arg.b, + args.window_kind, + args.r, + args.g, + args.b, ))?; } - SubCommand::BorderWidth(arg) => { - send_message(&SocketMessage::BorderWidth(arg.width))?; + SubCommand::BorderWidth(args) => { + send_message(&SocketMessage::BorderWidth(args.width))?; } - SubCommand::BorderOffset(arg) => { - send_message(&SocketMessage::BorderOffset(arg.offset))?; + SubCommand::BorderOffset(args) => { + send_message(&SocketMessage::BorderOffset(args.offset))?; } } From 73705136f0f34d4893b8ea236004859d334a61da Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 7 Dec 2025 18:07:19 -0800 Subject: [PATCH 172/305] chore(deps): cargo update --- Cargo.lock | 251 ++++++++++++++++++++++++++--------------------------- 1 file changed, 125 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89e63de0..3bfe4e46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -325,7 +325,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -457,7 +457,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -492,7 +492,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -646,9 +646,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" +checksum = "0e050f626429857a27ddccb31e0aca21356bfa709c04041aefddac081a8f068a" [[package]] name = "beef" @@ -794,7 +794,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -895,9 +895,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.47" +version = "1.2.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd405d82c84ff7f35739f175f67d8b9fb7687a0e84ccdc78bd3568839827cf07" +checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215" dependencies = [ "find-msvc-tools", "jobserver", @@ -997,7 +997,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1332,7 +1332,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1356,7 +1356,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1367,7 +1367,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1486,7 +1486,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1722,9 +1722,9 @@ dependencies = [ [[package]] name = "endi" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" [[package]] name = "enumflags2" @@ -1744,7 +1744,7 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1788,7 +1788,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1892,7 +1892,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2033,7 +2033,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2129,7 +2129,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2227,9 +2227,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f954a9e9159ec994f73a30a12b96a702dde78f5547bcb561174597924f7d4162" +checksum = "f5df2ba84018d80c213569363bdcd0c64e6933c67fe4c1d60ecf822971a3c35e" dependencies = [ "color_quant", "weezl", @@ -2243,9 +2243,9 @@ checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" [[package]] name = "git2" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" +checksum = "3e2b37e2f62729cdada11f0e6b3b6fe383c69c29fc619e391223e12856af308c" dependencies = [ "bitflags 2.10.0", "libc", @@ -2506,12 +2506,11 @@ dependencies = [ [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] @@ -2600,9 +2599,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" dependencies = [ "base64", "bytes", @@ -2795,7 +2794,7 @@ dependencies = [ "byteorder-lite", "color_quant", "exr", - "gif 0.14.0", + "gif 0.14.1", "image-webp", "moxcms", "num-traits", @@ -2882,7 +2881,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2971,9 +2970,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -3168,9 +3167,9 @@ checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" [[package]] name = "libc" -version = "0.2.177" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "libfuzzer-sys" @@ -3184,9 +3183,9 @@ dependencies = [ [[package]] name = "libgit2-sys" -version = "0.18.2+1.9.1" +version = "0.18.3+1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222" +checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487" dependencies = [ "cc", "libc", @@ -3274,9 +3273,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "logos" @@ -3299,7 +3298,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3466,9 +3465,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" dependencies = [ "libc", "wasi 0.11.1+wasi-snapshot-preview1", @@ -3477,9 +3476,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbdd3d7436f8b5e892b8b7ea114271ff0fa00bc5acae845d53b07d498616ef6" +checksum = "80986bbbcf925ebd3be54c26613d861255284584501595cf418320c078945608" dependencies = [ "num-traits", "pxfm", @@ -3764,7 +3763,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3838,7 +3837,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4327,7 +4326,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4559,7 +4558,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4732,14 +4731,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] name = "pxfm" -version = "0.1.25" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cbdf373972bf78df4d3b518d07003938e2c7d1fb5891e55f9cb6df57009d84" +checksum = "7186d3822593aa4393561d186d1393b3923e9d6163d3fbfd6e825e3e6cf3e6a8" dependencies = [ "num-traits", ] @@ -5097,7 +5096,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5268,9 +5267,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" +checksum = "708c0f9d5f54ba0272468c1d306a52c495b31fa155e91bc25371e6df7996908c" dependencies = [ "zeroize", ] @@ -5361,7 +5360,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5451,7 +5450,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5462,7 +5461,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5499,7 +5498,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5525,9 +5524,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.16.0" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10574371d41b0d9b2cff89418eda27da52bcaff2cc8741db26382a77c29131f1" +checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" dependencies = [ "base64", "chrono", @@ -5545,14 +5544,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.16.0" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a72d8216842fdd57820dc78d840bef99248e35fb2554ff923319e60f2d686b" +checksum = "52a8e3ca0ca629121f70ab50f95249e5a6f925cc0f6ffe8256c45b728875706c" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5695,9 +5694,9 @@ checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "slotmap" -version = "1.0.7" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" dependencies = [ "version_check", ] @@ -5869,7 +5868,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5891,9 +5890,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.110" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -5917,7 +5916,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -6013,7 +6012,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -6024,7 +6023,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -6137,7 +6136,7 @@ checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ "bytes", "libc", - "mio 1.1.0", + "mio 1.1.1", "pin-project-lite", "socket2", "windows-sys 0.61.2", @@ -6196,9 +6195,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.23.7" +version = "0.23.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" +checksum = "5d7cbc3b4b49633d57a0509303158ca50de80ae32c265093b24c414705807832" dependencies = [ "indexmap 2.12.1", "toml_datetime", @@ -6232,9 +6231,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +checksum = "9cf146f99d442e8e68e585f5d798ccd3cad9a7835b917e09728880a862706456" dependencies = [ "bitflags 2.10.0", "bytes", @@ -6262,9 +6261,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "log", "pin-project-lite", @@ -6274,32 +6273,32 @@ dependencies = [ [[package]] name = "tracing-appender" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +checksum = "786d480bce6247ab75f005b14ae1624ad978d3029d9113f0a22fa1ac773faeaf" dependencies = [ "crossbeam-channel", - "thiserror 1.0.69", + "thiserror 2.0.17", "time", "tracing-subscriber", ] [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", "valuable", @@ -6328,9 +6327,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "matchers", "nu-ansi-term", @@ -6480,13 +6479,13 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.18.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ "getrandom 0.3.4", "js-sys", - "serde", + "serde_core", "wasm-bindgen", ] @@ -6568,9 +6567,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -6581,9 +6580,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.55" +version = "0.4.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" dependencies = [ "cfg-if", "js-sys", @@ -6594,9 +6593,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6604,22 +6603,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] @@ -6761,9 +6760,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" dependencies = [ "js-sys", "wasm-bindgen", @@ -7073,7 +7072,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -7084,7 +7083,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -7095,7 +7094,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -7106,7 +7105,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -7557,9 +7556,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" dependencies = [ "memchr", ] @@ -7673,7 +7672,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "synstructure", ] @@ -7713,9 +7712,9 @@ dependencies = [ [[package]] name = "zbus-lockstep" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e96e38ded30eeab90b6ba88cb888d70aef4e7489b6cd212c5e5b5ec38045b6" +checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863" dependencies = [ "zbus_xml", "zvariant", @@ -7723,13 +7722,13 @@ dependencies = [ [[package]] name = "zbus-lockstep-macros" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6821851fa840b708b4cbbaf6241868cabc85a2dc22f426361b0292bfc0b836" +checksum = "10da05367f3a7b7553c8cdf8fa91aee6b64afebe32b51c95177957efc47ca3a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "zbus-lockstep", "zbus_xml", "zvariant", @@ -7744,7 +7743,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "zbus_names", "zvariant", "zvariant_utils", @@ -7777,22 +7776,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.28" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.28" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -7812,7 +7811,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "synstructure", ] @@ -7852,7 +7851,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -7917,7 +7916,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "zvariant_utils", ] @@ -7930,6 +7929,6 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.110", + "syn 2.0.111", "winnow", ] From 8dfc70e6d23a6578f9aae52fb678f4793e976fb9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 15 Dec 2025 20:25:35 -0800 Subject: [PATCH 173/305] fix(wm): consume more appkit events and make border manager reconcile focus This commit ensures that NSWorkspaceDidActivateApplicationNotification and NSWorkspaceDidDeactivateApplicationNotification get emitted not just for the loginwindow but for all apps with a valid name. This helps us to catch events from windows which don't emit AXWindowCreated consistently like Mail, Calendar, etc. Additionally, if a window has been closed with cmd+w but the application is still active, the border manager will pick a window container to mark as the new focused window container, and call window.focus() on the selected window to align the focus with the focused border color. --- komorebi/src/border_manager/mod.rs | 48 +++++++++++++---- komorebi/src/monitor_reconciliator.rs | 2 +- komorebi/src/notification_center_listener.rs | 56 +++++++++++++++----- komorebi/src/process_command.rs | 2 +- komorebi/src/process_event.rs | 4 +- komorebi/src/reaper.rs | 3 +- 6 files changed, 85 insertions(+), 30 deletions(-) diff --git a/komorebi/src/border_manager/mod.rs b/komorebi/src/border_manager/mod.rs index dd913d54..34a0250b 100644 --- a/komorebi/src/border_manager/mod.rs +++ b/komorebi/src/border_manager/mod.rs @@ -54,7 +54,9 @@ lazy_static! { } pub enum Notification { - Update(Option, Option), + // NOTE: bool should only ever be set to true by the reaper + // TODO: eventually the bool should be a source enum so we can match on emitters + Update(Option, Option, bool), ForceUpdate, } @@ -86,9 +88,13 @@ pub fn window_border(window_id: u32) -> Option { }) } -pub fn send_notification(element: Option, window_id: Option) { +pub fn send_notification( + element: Option, + window_id: Option, + reaper: bool, +) { if event_tx() - .try_send(Notification::Update(element, window_id)) + .try_send(Notification::Update(element, window_id, reaper)) .is_err() { tracing::warn!("channel is full; dropping notification") @@ -200,7 +206,7 @@ fn handle_notifications( tracing::info!("listening"); let receiver = event_rx(); - event_tx().send(Notification::Update(None, None))?; + event_tx().send(Notification::Update(None, None, false))?; let mut previous_snapshot = Ring::default(); let mut previous_pending_move_op = None; @@ -232,7 +238,7 @@ fn handle_notifications( drop(state); let should_process_notification = match notification { - Notification::Update(_, notification_window_id) => { + Notification::Update(_, notification_window_id, reaper) => { let mut should_process_notification = true; if monitors == previous_snapshot @@ -285,7 +291,7 @@ fn handle_notifications( } if !should_process_notification - && let Some(Notification::Update(_, ref previous_window_id)) = + && let Some(Notification::Update(_, ref previous_window_id, false)) = previous_notification && previous_window_id.unwrap_or_default() != notification_window_id.unwrap_or_default() @@ -293,13 +299,17 @@ fn handle_notifications( should_process_notification = true; } + if reaper { + should_process_notification = true; + } + should_process_notification } Notification::ForceUpdate => true, }; if !should_process_notification { - // tracing::debug!("monitor state matches latest snapshot, skipping notification"); + tracing::debug!("monitor state matches latest snapshot, skipping notification"); continue 'receiver; } @@ -444,10 +454,18 @@ fn handle_notifications( } }; - let new_focus_state = if idx != ws.focused_container_idx() - || monitor_idx != focused_monitor_idx - || window.id != foreground_window - { + // this happens if we cmd+w a window, but the app is still active with no windows + let ignore_foreground_window = foreground_window == 0; + + let focus_state_condition = if ignore_foreground_window { + idx != ws.focused_container_idx() || monitor_idx != focused_monitor_idx + } else { + idx != ws.focused_container_idx() + || monitor_idx != focused_monitor_idx + || window.id != foreground_window + }; + + let new_focus_state = if focus_state_condition { if c.locked { WindowKind::UnfocusedLocked } else { @@ -459,6 +477,14 @@ fn handle_notifications( WindowKind::Single }; + // if we are in the cmd+w situation, we wanna make sure the window we're gonna + // set a focused border on actually has keyboard focus + if ignore_foreground_window + && matches!(new_focus_state, WindowKind::Single | WindowKind::Stack) + { + window.focus(false)?; + } + border.window_kind = new_focus_state; if border.tracking_window_id != window.id { diff --git a/komorebi/src/monitor_reconciliator.rs b/komorebi/src/monitor_reconciliator.rs index 847c5c4c..559346a5 100644 --- a/komorebi/src/monitor_reconciliator.rs +++ b/komorebi/src/monitor_reconciliator.rs @@ -569,7 +569,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result )?; } - border_manager::send_notification(None, None); + border_manager::send_notification(None, None, false); } Ok(()) diff --git a/komorebi/src/notification_center_listener.rs b/komorebi/src/notification_center_listener.rs index 317ee939..8df9be4a 100644 --- a/komorebi/src/notification_center_listener.rs +++ b/komorebi/src/notification_center_listener.rs @@ -78,23 +78,51 @@ define_class! { tracing::debug!("notification: {}, process: {process_id}", notif.name()); match AppKitWorkspaceNotification::from_str(¬if.name().to_string()) { Ok(AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification) => { - if application.is_some_and(|app| app.name().unwrap_or_default() == "loginwindow") { - window_manager_event_listener::send_notification( - WindowManagerEvent::ScreenLock( - SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification), - process_id - ) - ); + if let Some(app) = &application { + match app.name().unwrap_or_default().as_str() { + "loginwindow" => { + window_manager_event_listener::send_notification( + WindowManagerEvent::ScreenLock( + SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification), + process_id + ) + ); + } + app if !app.is_empty() => { + if let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidActivateApplicationNotification), + process_id, + window_id, + ) { + window_manager_event_listener::send_notification(event); + } + } + _ => {}, + } } } Ok(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification) => { - if application.is_some_and(|app| app.name().unwrap_or_default() == "loginwindow") { - window_manager_event_listener::send_notification( - WindowManagerEvent::ScreenUnlock( - SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification), - process_id - ) - ); + if let Some(app) = &application { + match app.name().unwrap_or_default().as_str() { + "loginwindow" => { + window_manager_event_listener::send_notification( + WindowManagerEvent::ScreenUnlock( + SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification), + process_id + ) + ); + } + app if !app.is_empty() => { + if let Some(event) = WindowManagerEvent::from_system_notification( + SystemNotification::AppKitWorkspace(AppKitWorkspaceNotification::NSWorkspaceDidDeactivateApplicationNotification), + process_id, + window_id, + ) { + window_manager_event_listener::send_notification(event); + } + } + _ => {}, + } } } Ok(notification) => { diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index d4f13b7a..c29bb256 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1757,7 +1757,7 @@ impl WindowManager { initial_state.has_been_modified(self.as_ref()), )?; - border_manager::send_notification(None, None); + border_manager::send_notification(None, None, false); if matches!(message, SocketMessage::Theme(_)) { tracing::trace!("processed command: {message}"); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index a4d2f6fc..9b9918ff 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -114,7 +114,7 @@ impl WindowManager { && let Some(current_space_id) = current_space_id() { if *space_id == current_space_id { - border_manager::send_notification(None, None); + border_manager::send_notification(None, None, false); } else { border_manager::destroy_all_borders()?; } @@ -976,7 +976,7 @@ impl WindowManager { initial_state.has_been_modified(self.as_ref()), )?; - border_manager::send_notification(window_element, window_id); + border_manager::send_notification(window_element, window_id, false); Ok(()) } diff --git a/komorebi/src/reaper.rs b/komorebi/src/reaper.rs index d7fa74e3..17771e06 100644 --- a/komorebi/src/reaper.rs +++ b/komorebi/src/reaper.rs @@ -107,10 +107,11 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> } } + // If an invalid window was cleaned up, we update the workspace if should_update { // If an invalid window was cleaned up, we update the workspace wm.update_focused_workspace(false, false)?; - border_manager::send_notification(None, Some(window_id)); + border_manager::send_notification(None, Some(window_id), true); } } ReaperNotification::MouseUpKeyUp => { From e15f3f0c22682f62b0082542370c821d5f7ad12a Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 16 Dec 2025 17:21:26 -0800 Subject: [PATCH 174/305] chore(deps): cargo update --- Cargo.lock | 113 +++++++++++++++++++++++++++++------------------------ 1 file changed, 61 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3bfe4e46..a22f857e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -159,9 +159,9 @@ dependencies = [ [[package]] name = "aligned" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923" +checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685" dependencies = [ "as-slice", ] @@ -773,9 +773,9 @@ checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" [[package]] name = "bumpalo" -version = "3.19.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" [[package]] name = "bytemuck" @@ -1017,9 +1017,9 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.54" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +checksum = "b042e5d8a74ae91bb0961acd039822472ec99f8ab0948cbf6d1369588f8be586" dependencies = [ "cc", ] @@ -1544,9 +1544,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084980ebede2fb1ad6c4f54285b3e489052ef2b6aa4016e4c19349417adc75c5" +checksum = "71ddb8ac7643d1dba1bb02110e804406dd459a838efcb14011ced10556711a8e" dependencies = [ "bytemuck", "emath", @@ -1578,9 +1578,9 @@ dependencies = [ [[package]] name = "eframe" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f60ee3c69cd01d5725b4ef476ed6a3a6009968c57843a2f1beb96f021e4a54b" +checksum = "457481173e6db5ca9fa2be93a58df8f4c7be639587aeb4853b526c6cf87db4e6" dependencies = [ "ahash", "bytemuck", @@ -1613,9 +1613,9 @@ dependencies = [ [[package]] name = "egui" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75645894de4ca1695ab3ab7201c7953bb95c1725aafeefa6822dc901ad2a81b" +checksum = "6a9b567d356674e9a5121ed3fedfb0a7c31e059fe71f6972b691bcd0bfc284e3" dependencies = [ "accesskit", "ahash", @@ -1639,9 +1639,9 @@ dependencies = [ [[package]] name = "egui-wgpu" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdaac35a6e0ff458aaa5776b2bda578e38334a9d1258f7795042a70372745b7" +checksum = "5e4d209971c84b2352a06174abdba701af1e552ce56b144d96f2bd50a3c91236" dependencies = [ "ahash", "bytemuck", @@ -1659,9 +1659,9 @@ dependencies = [ [[package]] name = "egui-winit" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4772ed5f16fa8ec2ba295e58f62b58ee83fcf49e67ec13d2b7ddf4e9a2dea34e" +checksum = "ec6687e5bb551702f4ad10ac428bab12acf9d53047ebb1082d4a0ed8c6251a29" dependencies = [ "accesskit_winit", "arboard", @@ -1681,9 +1681,9 @@ dependencies = [ [[package]] name = "egui_glow" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b94ff67a1d18933fff2519f5f57c388f932c093036c381fb9ae2853b3e1e09" +checksum = "6420863ea1d90e750f75075231a260030ad8a9f30a7cef82cdc966492dc4c4eb" dependencies = [ "bytemuck", "egui", @@ -1704,9 +1704,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "emath" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e561352ae95c22ad179fb56c38d6e6eecd86cf4925cf5c70e738dd01df9b620" +checksum = "491bdf728bf25ddd9ad60d4cf1c48588fa82c013a2440b91aa7fc43e34a07c32" dependencies = [ "bytemuck", ] @@ -1749,9 +1749,9 @@ dependencies = [ [[package]] name = "epaint" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a909ce8cee63e8350fb0c251ad39277a5b24f19add60787e84a3b3ab3f2bd83a" +checksum = "009d0dd3c2163823a0abdb899451ecbc78798dec545ee91b43aff1fa790bab62" dependencies = [ "ab_glyph", "ahash", @@ -1767,9 +1767,9 @@ dependencies = [ [[package]] name = "epaint_default_fonts" -version = "0.33.2" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad9649446c23368ae138716910e3e28143995691b598fbb9de16b42b0722cbcc" +checksum = "5c4fbe202b6578d3d56428fa185cdf114a05e49da05f477b3c7f0fbb221f1862" [[package]] name = "equator" @@ -2705,9 +2705,9 @@ checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] name = "icu_properties" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" dependencies = [ "icu_collections", "icu_locale_core", @@ -2719,9 +2719,9 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" [[package]] name = "icu_provider" @@ -2805,7 +2805,7 @@ dependencies = [ "rgb", "tiff 0.10.3", "zune-core 0.5.0", - "zune-jpeg 0.5.5", + "zune-jpeg 0.5.7", ] [[package]] @@ -3024,7 +3024,7 @@ dependencies = [ "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", "parking_lot", - "pastey 0.2.0", + "pastey 0.2.1", "quickxml_to_serde", "regex", "reqwest", @@ -3118,7 +3118,7 @@ dependencies = [ "fs-tail", "komorebi-client", "lazy_static", - "pastey 0.2.0", + "pastey 0.2.1", "reqwest", "schemars 0.8.22", "serde_json_lenient", @@ -3211,13 +3211,13 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" +checksum = "df15f6eac291ed1cf25865b1ee60399f57e7c227e7f51bdbd4c5270396a9ed50" dependencies = [ "bitflags 2.10.0", "libc", - "redox_syscall 0.5.18", + "redox_syscall 0.6.0", ] [[package]] @@ -3476,9 +3476,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80986bbbcf925ebd3be54c26613d861255284584501595cf418320c078945608" +checksum = "ac9557c559cd6fc9867e122e20d2cbefc9ca29d80d027a8e39310920ed2f0a97" dependencies = [ "num-traits", "pxfm", @@ -4465,9 +4465,9 @@ checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" [[package]] name = "pastey" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d6c094ee800037dff99e02cab0eaf3142826586742a270ab3d7a62656bd27a" +checksum = "b867cad97c0791bbd3aaa6472142568c6c9e8f71937e98379f584cfb0cf35bec" [[package]] name = "percent-encoding" @@ -5057,6 +5057,15 @@ dependencies = [ "bitflags 2.10.0", ] +[[package]] +name = "redox_syscall" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec96166dafa0886eb81fe1c0a388bece180fbef2135f97c1e2cf8302e74b43b5" +dependencies = [ + "bitflags 2.10.0", +] + [[package]] name = "redox_users" version = "0.4.6" @@ -5136,9 +5145,9 @@ checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "reqwest" -version = "0.12.24" +version = "0.12.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" +checksum = "3b4c14b2d9afca6a60277086b0cc6a6ae0b568f6f7916c943a8cdc79f8be240f" dependencies = [ "base64", "bytes", @@ -5622,9 +5631,9 @@ dependencies = [ [[package]] name = "shell-words" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77" [[package]] name = "shellexpand" @@ -5661,9 +5670,9 @@ dependencies = [ [[package]] name = "simd-adler32" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" [[package]] name = "simd_helpers" @@ -6231,9 +6240,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf146f99d442e8e68e585f5d798ccd3cad9a7835b917e09728880a862706456" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ "bitflags 2.10.0", "bytes", @@ -6378,9 +6387,9 @@ checksum = "14eff19b8dc1ace5bf7e4d920b2628ae3837f422ff42210cb1567cbf68b5accf" [[package]] name = "tzdb" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0be2ea5956f295449f47c0b825c5e109022ff1a6a53bb4f77682a87c2341fbf5" +checksum = "56d4e985b6dda743ae7fd4140c28105316ffd75bc58258ee6cc12934e3eb7a0c" dependencies = [ "iana-time-zone", "tz-rs", @@ -6389,9 +6398,9 @@ dependencies = [ [[package]] name = "tzdb_data" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c4c81d75033770e40fbd3643ce7472a1a9fd301f90b7139038228daf8af03ec" +checksum = "42302a846dea7ab786f42dc5f519387069045acff793e1178d9368414168fe95" dependencies = [ "tz-rs", ] @@ -7886,9 +7895,9 @@ dependencies = [ [[package]] name = "zune-jpeg" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6fb7703e32e9a07fb3f757360338b3a567a5054f21b5f52a666752e333d58e" +checksum = "51d915729b0e7d5fe35c2f294c5dc10b30207cc637920e5b59077bfa3da63f28" dependencies = [ "zune-core 0.5.0", ] From c6a13b04fded2da793069cb04e24c398a878b8e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:32:25 +0000 Subject: [PATCH 175/305] chore(deps): bump actions/upload-artifact from 5 to 6 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/nix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index 447325aa..0d5ed47e 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -29,7 +29,7 @@ jobs: fetch-depth: 0 - run: nix flake check - run: nix build - - uses: actions/upload-artifact@v5 + - uses: actions/upload-artifact@v6 with: name: komorebi-aarch64-apple-darwin-${{ github.sha }} path: | From 13635817c39e9d2cc748b44afe9aa1619627c828 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 20 Dec 2025 21:18:54 -0800 Subject: [PATCH 176/305] docs(schema): clarify that 'theme' takes priority over 'border_colours' --- komorebi/src/static_config.rs | 8 ++++---- schema.json | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 4a960b33..569d8ddc 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -417,22 +417,22 @@ pub struct StaticConfig { /// Path to applications.json from komorebi-application-specific-configurations (default: None) #[serde(skip_serializing_if = "Option::is_none")] pub app_specific_configuration_path: Option, - /// Width of the window border (default: 6) + /// Width of window borders (default: 6) #[serde(skip_serializing_if = "Option::is_none")] #[serde(alias = "active_window_border_width")] pub border_width: Option, - /// Offset of the window border (default: 5) + /// Offset of window borders (default: 5) #[serde(skip_serializing_if = "Option::is_none")] #[serde(alias = "active_window_border_offset")] pub border_offset: Option, - /// Radius of the window border (default: 10) + /// Radius of window borders (default: 10) #[serde(skip_serializing_if = "Option::is_none")] pub border_radius: Option, /// Display window borders (default: true) #[serde(skip_serializing_if = "Option::is_none")] #[serde(alias = "active_window_border")] pub border: Option, - /// Active window border colours for different container types + /// Window border colours for different container types (has no effect if a theme is defined) #[serde(skip_serializing_if = "Option::is_none")] #[serde(alias = "active_window_border_colours")] pub border_colours: Option, diff --git a/schema.json b/schema.json index 9b42c2a5..7db3b7ab 100644 --- a/schema.json +++ b/schema.json @@ -25,7 +25,7 @@ "type": "boolean" }, "border_colours": { - "description": "Active window border colours for different container types", + "description": "Window border colours for different container types (has no effect if a theme is defined)", "type": "object", "properties": { "floating": { @@ -265,7 +265,7 @@ } }, "border_offset": { - "description": "Offset of the window border (default: 5)", + "description": "Offset of window borders (default: 5)", "type": "integer", "format": "int32" }, @@ -353,12 +353,12 @@ } }, "border_radius": { - "description": "Radius of the window border (default: 10)", + "description": "Radius of window borders (default: 10)", "type": "integer", "format": "int32" }, "border_width": { - "description": "Width of the window border (default: 6)", + "description": "Width of window borders (default: 6)", "type": "integer", "format": "int32" }, From 1cb3327395648669bb241124effbad7ea4a24959 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 20 Dec 2025 22:18:02 -0800 Subject: [PATCH 177/305] chore(deps): bump schemars to 1.1 and netdev to 0.40 --- Cargo.lock | 114 +- Cargo.toml | 4 +- dependencies.json | 241 +- komorebi-bar/Cargo.toml | 2 +- komorebi-bar/src/main.rs | 11 +- komorebi/Cargo.toml | 2 +- komorebi/src/core/pathext.rs | 8 +- komorebi/src/process_command.rs | 12 +- komorebi/src/window.rs | 6 +- komorebic/src/main.rs | 10 +- schema.asc.json | 42 +- schema.json | 5600 ++++++++++--------------------- 12 files changed, 2085 insertions(+), 3967 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a22f857e..ba4111fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -618,10 +618,10 @@ dependencies = [ [[package]] name = "base16-egui-themes" version = "0.1.0" -source = "git+https://github.com/LGUG2Z/base16-egui-themes?rev=5472b1ab825c48af1a1726e324cfa13b7c385135#5472b1ab825c48af1a1726e324cfa13b7c385135" +source = "git+https://github.com/LGUG2Z/base16-egui-themes?rev=adfed118ab1408f134fd7d8a549ccfe47b99d752#adfed118ab1408f134fd7d8a549ccfe47b99d752" dependencies = [ "egui", - "schemars 0.8.22", + "schemars 1.1.0", "serde", "strum", "strum_macros", @@ -895,9 +895,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.49" +version = "1.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215" +checksum = "9f50d563227a1c37cc0a263f64eca3334388c01c5e4c4861a9def205c614383c" dependencies = [ "find-msvc-tools", "jobserver", @@ -981,9 +981,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.61" +version = "4.5.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39615915e2ece2550c0149addac32fb5bd312c657f43845bb9088cb9c8a7c992" +checksum = "004eef6b14ce34759aa7de4aea3217e368f463f46a3ed3764ca4b5a4404003b4" dependencies = [ "clap", ] @@ -1017,9 +1017,9 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b042e5d8a74ae91bb0961acd039822472ec99f8ab0948cbf6d1369588f8be586" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" dependencies = [ "cc", ] @@ -2923,9 +2923,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "7ee5b5339afb4c41626dde77b7a611bd4f2c202b897852b4bcf5d03eddc61010" [[package]] name = "jni" @@ -3028,7 +3028,7 @@ dependencies = [ "quickxml_to_serde", "regex", "reqwest", - "schemars 0.8.22", + "schemars 1.1.0", "serde", "serde_json_lenient", "serde_with", @@ -3072,7 +3072,7 @@ dependencies = [ "parking_lot", "random_word", "reqwest", - "schemars 0.8.22", + "schemars 1.1.0", "serde", "serde_json_lenient", "starship-battery", @@ -3092,15 +3092,15 @@ dependencies = [ [[package]] name = "komorebi-themes" -version = "0.1.39" -source = "git+https://github.com/LGUG2Z/komorebi?rev=c8c4c3507c3cb9cdd94e1a40d366320531455d75#c8c4c3507c3cb9cdd94e1a40d366320531455d75" +version = "0.1.40" +source = "git+https://github.com/LGUG2Z/komorebi?rev=7bf27717bc67a5c6e672acb4896b96a59ff78fc5#7bf27717bc67a5c6e672acb4896b96a59ff78fc5" dependencies = [ "base16-egui-themes", "catppuccin-egui", "eframe", "flavours", "hex_color", - "schemars 0.8.22", + "schemars 1.1.0", "serde", "serde_variant", "strum", @@ -3120,7 +3120,7 @@ dependencies = [ "lazy_static", "pastey 0.2.1", "reqwest", - "schemars 0.8.22", + "schemars 1.1.0", "serde_json_lenient", "shadow-rs", "sysinfo", @@ -3568,10 +3568,12 @@ dependencies = [ [[package]] name = "netdev" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35a703aa1a87cd885b9f674922445a42dbb0c0f4f1b28fef21b227ae32375d21" +checksum = "dc9815643a243856e7bd84524e1ff739e901e846cfb06ad9627cd2b6d59bd737" dependencies = [ + "block2 0.6.2", + "dispatch2", "dlopen2", "ipnet", "libc", @@ -3579,8 +3581,10 @@ dependencies = [ "netlink-packet-core", "netlink-packet-route", "netlink-sys", + "objc2-core-foundation", + "objc2-system-configuration", "once_cell", - "system-configuration", + "plist", "windows-sys 0.59.0", ] @@ -3700,9 +3704,9 @@ dependencies = [ [[package]] name = "ntapi" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +checksum = "c70f219e21142367c70c0b30c6a9e3a14d55b4d12a204d897fbec83a0363f081" dependencies = [ "winapi", ] @@ -4237,6 +4241,20 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-system-configuration" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396" +dependencies = [ + "bitflags 2.10.0", + "dispatch2", + "libc", + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-security", +] + [[package]] name = "objc2-ui-kit" version = "0.2.2" @@ -4654,9 +4672,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" +checksum = "f59e70c4aef1e55797c2e8fd94a4f2a973fc972cfde0e0b05f683667b0cd39dd" [[package]] name = "portable-atomic-util" @@ -5276,9 +5294,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "708c0f9d5f54ba0272468c1d306a52c495b31fa155e91bc25371e6df7996908c" +checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282" dependencies = [ "zeroize", ] @@ -5302,9 +5320,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "62049b2877bf12821e8f9ad256ee38fdc31db7387ec2d3b3f403024de2034aea" [[package]] name = "same-file" @@ -5324,18 +5342,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "schemars" -version = "0.8.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - [[package]] name = "schemars" version = "0.9.0" @@ -5356,15 +5362,16 @@ checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" dependencies = [ "dyn-clone", "ref-cast", + "schemars_derive", "serde", "serde_json", ] [[package]] name = "schemars_derive" -version = "0.8.22" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +checksum = "301858a4023d78debd2353c7426dc486001bddc91ae31a76fb1f55132f7e2633" dependencies = [ "proc-macro2", "quote", @@ -5542,7 +5549,6 @@ dependencies = [ "hex", "indexmap 1.9.3", "indexmap 2.12.1", - "schemars 0.8.22", "schemars 0.9.0", "schemars 1.1.0", "serde_core", @@ -5609,9 +5615,9 @@ dependencies = [ [[package]] name = "shadow-rs" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d18183cef626bce22836103349c7050d73db799be0171386b80947d157ae32" +checksum = "ff351910f271e7065781b6b4f0f43cb515d474d812f31176a0246d9058e47d5d" dependencies = [ "const_format", "git2", @@ -6195,18 +6201,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.3" +version = "0.7.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" dependencies = [ "serde_core", ] [[package]] name = "toml_edit" -version = "0.23.9" +version = "0.23.10+spec-1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d7cbc3b4b49633d57a0509303158ca50de80ae32c265093b24c414705807832" +checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" dependencies = [ "indexmap 2.12.1", "toml_datetime", @@ -6216,9 +6222,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.0.4" +version = "1.0.6+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" +checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" dependencies = [ "winnow", ] @@ -6270,9 +6276,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "log", "pin-project-lite", @@ -6305,9 +6311,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.35" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", "valuable", diff --git a/Cargo.toml b/Cargo.toml index a6584265..2e0e3d4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ version = "0.1.0" [workspace.dependencies] -komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "c8c4c3507c3cb9cdd94e1a40d366320531455d75" } +komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "7bf27717bc67a5c6e672acb4896b96a59ff78fc5" } chrono = "0.4" chrono-tz = "0.10" @@ -29,7 +29,7 @@ hotwatch = "0.5" lazy_static = "1" parking_lot = "0.12" pastey = "0.2" -schemars = "0.8" +schemars = "1.1" serde = { version = "1", features = ["derive"] } serde_json = { package = "serde_json_lenient", version = "0.2" } shadow-rs = "1" diff --git a/dependencies.json b/dependencies.json index 19f9c691..3cbd9c7b 100644 --- a/dependencies.json +++ b/dependencies.json @@ -20,14 +20,16 @@ "adler 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", + "aligned 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "anstream 0.6.21 registry+https://github.com/rust-lang/crates.io-index", "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", - "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "anstyle-query 1.1.5 registry+https://github.com/rust-lang/crates.io-index", "anyhow 1.0.100 registry+https://github.com/rust-lang/crates.io-index", "approx 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "arboard 3.6.1 registry+https://github.com/rust-lang/crates.io-index", "arrayvec 0.7.6 registry+https://github.com/rust-lang/crates.io-index", + "as-slice 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "atomic-waker 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", @@ -37,18 +39,18 @@ "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.10.0 registry+https://github.com/rust-lang/crates.io-index", - "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", + "bitstream-io 4.9.0 registry+https://github.com/rust-lang/crates.io-index", "block-buffer 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", - "cc 1.2.45 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.50 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.51 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.51 registry+https://github.com/rust-lang/crates.io-index", - "clap_complete 4.5.60 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.53 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.53 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.62 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.49 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -61,6 +63,7 @@ "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "core-text 19.2.0 registry+https://github.com/rust-lang/crates.io-index", + "core2 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "cpufeatures 0.2.17 registry+https://github.com/rust-lang/crates.io-index", "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", @@ -84,25 +87,25 @@ "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", - "ecolor 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "ed25519 2.2.3 registry+https://github.com/rust-lang/crates.io-index", - "eframe 0.33.0 registry+https://github.com/rust-lang/crates.io-index", - "egui 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.33.3 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "egui-phosphor 0.10.0 git+https://github.com/amPerl/egui-phosphor?rev=d13688738478ecd12b426e3e74c59d6577a85b59", - "egui-winit 0.33.0 registry+https://github.com/rust-lang/crates.io-index", - "egui_glow 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui-winit 0.33.3 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", - "emath 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "epaint 0.33.0 registry+https://github.com/rust-lang/crates.io-index", - "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.33.3 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index", "eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index", "fastrand 2.3.0 registry+https://github.com/rust-lang/crates.io-index", "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", - "find-msvc-tools 0.1.4 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.5 registry+https://github.com/rust-lang/crates.io-index", "flate2 1.1.5 registry+https://github.com/rust-lang/crates.io-index", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", "foreign-types 0.3.2 registry+https://github.com/rust-lang/crates.io-index", @@ -120,49 +123,49 @@ "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", - "gif 0.13.3 registry+https://github.com/rust-lang/crates.io-index", + "gif 0.14.1 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", + "git2 0.20.3 registry+https://github.com/rust-lang/crates.io-index", "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "glutin 0.32.3 registry+https://github.com/rust-lang/crates.io-index", "half 2.7.1 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", - "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.16.1 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "hex 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "hex_color 3.0.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", - "http 1.3.1 registry+https://github.com/rust-lang/crates.io-index", + "http 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "httparse 1.10.1 registry+https://github.com/rust-lang/crates.io-index", "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "iana-time-zone 0.1.64 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", - "image 0.25.8 registry+https://github.com/rust-lang/crates.io-index", + "image 0.25.9 registry+https://github.com/rust-lang/crates.io-index", "image-webp 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "imgref 1.12.0 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", - "indexmap 2.12.0 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 2.12.1 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.9 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index", - "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", - "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", + "itertools 0.14.0 registry+https://github.com/rust-lang/crates.io-index", + "itoa 1.0.16 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "libc 0.2.177 registry+https://github.com/rust-lang/crates.io-index", - "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.178 registry+https://github.com/rust-lang/crates.io-index", + "libgit2-sys 0.18.3+1.9.2 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.23 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", "litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", - "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", + "log 0.4.29 registry+https://github.com/rust-lang/crates.io-index", "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", @@ -171,7 +174,7 @@ "minimal-lexical 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.9 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.11 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "num 0.4.3 registry+https://github.com/rust-lang/crates.io-index", @@ -199,6 +202,7 @@ "objc2-metal 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-security 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-system-configuration 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "object 0.37.3 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", "owned_ttf_parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", @@ -208,6 +212,7 @@ "parking_lot_core 0.9.12 registry+https://github.com/rust-lang/crates.io-index", "paste 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", + "pastey 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", @@ -219,7 +224,7 @@ "proc-macro2 1.0.103 registry+https://github.com/rust-lang/crates.io-index", "profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index", "profiling-procmacros 1.0.17 registry+https://github.com/rust-lang/crates.io-index", - "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", + "pxfm 0.1.27 registry+https://github.com/rust-lang/crates.io-index", "qoi 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quote 1.0.42 registry+https://github.com/rust-lang/crates.io-index", @@ -236,15 +241,17 @@ "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", + "ref-cast 1.0.25 registry+https://github.com/rust-lang/crates.io-index", + "ref-cast-impl 1.0.25 registry+https://github.com/rust-lang/crates.io-index", "regex 1.12.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.8 registry+https://github.com/rust-lang/crates.io-index", - "reqwest 0.12.24 registry+https://github.com/rust-lang/crates.io-index", + "reqwest 0.12.26 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", "rustc_version 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", - "rustls-pki-types 1.13.0 registry+https://github.com/rust-lang/crates.io-index", - "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index", + "rustls-pki-types 1.13.2 registry+https://github.com/rust-lang/crates.io-index", + "ryu 1.0.21 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", "security-framework-sys 2.15.0 registry+https://github.com/rust-lang/crates.io-index", @@ -257,12 +264,12 @@ "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.15.1 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.15.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.16.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.16.1 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", "sha2 0.10.9 registry+https://github.com/rust-lang/crates.io-index", - "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", - "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "shadow-rs 1.5.0 registry+https://github.com/rust-lang/crates.io-index", + "shell-words 1.1.1 registry+https://github.com/rust-lang/crates.io-index", "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "signature 2.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -274,15 +281,13 @@ "stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", - "syn 2.0.110 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.111 registry+https://github.com/rust-lang/crates.io-index", "sync_wrapper 1.0.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "tempfile 3.23.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", - "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror 2.0.17 registry+https://github.com/rust-lang/crates.io-index", - "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 2.0.17 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", "time 0.3.44 registry+https://github.com/rust-lang/crates.io-index", @@ -291,8 +296,8 @@ "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "typenum 1.19.0 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.1 registry+https://github.com/rust-lang/crates.io-index", - "tzdb 0.7.2 registry+https://github.com/rust-lang/crates.io-index", - "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "tzdb 0.7.3 registry+https://github.com/rust-lang/crates.io-index", + "tzdb_data 0.2.3 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.22 registry+https://github.com/rust-lang/crates.io-index", "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", @@ -308,12 +313,14 @@ "weezl 0.1.12 registry+https://github.com/rust-lang/crates.io-index", "winit 0.30.12 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy 0.8.31 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy-derive 0.8.31 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-core 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", - "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" + "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index", + "zune-jpeg 0.5.7 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -334,10 +341,10 @@ [ "av1-grain 0.2.5 registry+https://github.com/rust-lang/crates.io-index", "mach2 0.5.0 registry+https://github.com/rust-lang/crates.io-index", - "rav1e 0.7.1 registry+https://github.com/rust-lang/crates.io-index", + "rav1e 0.8.1 registry+https://github.com/rust-lang/crates.io-index", "v_frame 0.3.9 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index" + "zerocopy 0.8.31 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy-derive 0.8.31 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -353,16 +360,16 @@ "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", "exr 1.74.0 registry+https://github.com/rust-lang/crates.io-index", "lebe 0.5.3 registry+https://github.com/rust-lang/crates.io-index", - "moxcms 0.7.9 registry+https://github.com/rust-lang/crates.io-index", - "pxfm 0.1.25 registry+https://github.com/rust-lang/crates.io-index", - "ravif 0.11.20 registry+https://github.com/rust-lang/crates.io-index", + "moxcms 0.7.11 registry+https://github.com/rust-lang/crates.io-index", + "pxfm 0.1.27 registry+https://github.com/rust-lang/crates.io-index", + "ravif 0.12.0 registry+https://github.com/rust-lang/crates.io-index", "subtle 2.6.1 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "BSL-1.0", [ - "ryu 1.0.20 registry+https://github.com/rust-lang/crates.io-index" + "ryu 1.0.21 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -393,17 +400,20 @@ "adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index", "aho-corasick 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "aligned 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "aligned-vec 0.6.4 registry+https://github.com/rust-lang/crates.io-index", "anstream 0.6.21 registry+https://github.com/rust-lang/crates.io-index", "anstyle 1.0.13 registry+https://github.com/rust-lang/crates.io-index", "anstyle-parse 0.2.7 registry+https://github.com/rust-lang/crates.io-index", - "anstyle-query 1.1.4 registry+https://github.com/rust-lang/crates.io-index", + "anstyle-query 1.1.5 registry+https://github.com/rust-lang/crates.io-index", "anyhow 1.0.100 registry+https://github.com/rust-lang/crates.io-index", "arboard 3.6.1 registry+https://github.com/rust-lang/crates.io-index", "arg_enum_proc_macro 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "arrayvec 0.7.6 registry+https://github.com/rust-lang/crates.io-index", + "as-slice 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "atomic-waker 1.1.2 registry+https://github.com/rust-lang/crates.io-index", "autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index", + "av-scenechange 0.14.1 registry+https://github.com/rust-lang/crates.io-index", "backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index", "base16_color_scheme 0.3.2 git+https://github.com/LGUG2Z/base16_color_scheme", "base64 0.22.1 registry+https://github.com/rust-lang/crates.io-index", @@ -411,30 +421,30 @@ "bit_field 0.10.3 registry+https://github.com/rust-lang/crates.io-index", "bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index", "bitflags 2.10.0 registry+https://github.com/rust-lang/crates.io-index", - "bitstream-io 2.6.0 registry+https://github.com/rust-lang/crates.io-index", + "bitstream-io 4.9.0 registry+https://github.com/rust-lang/crates.io-index", "block-buffer 0.10.4 registry+https://github.com/rust-lang/crates.io-index", "block2 0.5.1 registry+https://github.com/rust-lang/crates.io-index", "block2 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "brotli 8.0.2 registry+https://github.com/rust-lang/crates.io-index", "brotli-decompressor 5.0.0 registry+https://github.com/rust-lang/crates.io-index", - "built 0.7.7 registry+https://github.com/rust-lang/crates.io-index", + "built 0.8.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck 1.24.0 registry+https://github.com/rust-lang/crates.io-index", "bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index", "byteorder 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "byteorder-lite 0.1.0 registry+https://github.com/rust-lang/crates.io-index", - "bytes 1.10.1 registry+https://github.com/rust-lang/crates.io-index", + "bytes 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "calm_io 0.1.1 registry+https://github.com/rust-lang/crates.io-index", "calmio_filters 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "catppuccin-egui 5.6.0 git+https://github.com/LGUG2Z/catppuccin-egui?rev=b2f95cbf441d1dd99f3c955ef10dcb84ce23c20a", - "cc 1.2.45 registry+https://github.com/rust-lang/crates.io-index", + "cc 1.2.50 registry+https://github.com/rust-lang/crates.io-index", "cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index", "cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "chrono 0.4.42 registry+https://github.com/rust-lang/crates.io-index", "chrono-tz 0.10.4 registry+https://github.com/rust-lang/crates.io-index", - "clap 4.5.51 registry+https://github.com/rust-lang/crates.io-index", - "clap_builder 4.5.51 registry+https://github.com/rust-lang/crates.io-index", - "clap_complete 4.5.60 registry+https://github.com/rust-lang/crates.io-index", + "clap 4.5.53 registry+https://github.com/rust-lang/crates.io-index", + "clap_builder 4.5.53 registry+https://github.com/rust-lang/crates.io-index", + "clap_complete 4.5.62 registry+https://github.com/rust-lang/crates.io-index", "clap_derive 4.5.49 registry+https://github.com/rust-lang/crates.io-index", "clap_lex 0.7.6 registry+https://github.com/rust-lang/crates.io-index", "color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index", @@ -449,6 +459,7 @@ "core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index", "core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "core-text 19.2.0 registry+https://github.com/rust-lang/crates.io-index", + "core2 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "cpufeatures 0.2.17 registry+https://github.com/rust-lang/crates.io-index", "crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index", @@ -475,18 +486,18 @@ "document-features 0.2.12 registry+https://github.com/rust-lang/crates.io-index", "dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index", "dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index", - "ecolor 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "ecolor 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "ed25519 2.2.3 registry+https://github.com/rust-lang/crates.io-index", - "eframe 0.33.0 registry+https://github.com/rust-lang/crates.io-index", - "egui 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "eframe 0.33.3 registry+https://github.com/rust-lang/crates.io-index", + "egui 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "egui-phosphor 0.10.0 git+https://github.com/amPerl/egui-phosphor?rev=d13688738478ecd12b426e3e74c59d6577a85b59", - "egui-winit 0.33.0 registry+https://github.com/rust-lang/crates.io-index", - "egui_glow 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "egui-winit 0.33.3 registry+https://github.com/rust-lang/crates.io-index", + "egui_glow 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "either 1.15.0 registry+https://github.com/rust-lang/crates.io-index", - "emath 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "emath 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "encoding_rs 0.8.35 registry+https://github.com/rust-lang/crates.io-index", - "epaint 0.33.0 registry+https://github.com/rust-lang/crates.io-index", - "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index", + "epaint 0.33.3 registry+https://github.com/rust-lang/crates.io-index", + "epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index", "equator 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "equator-macro 0.4.2 registry+https://github.com/rust-lang/crates.io-index", "equivalent 1.0.2 registry+https://github.com/rust-lang/crates.io-index", @@ -497,7 +508,7 @@ "fax_derive 0.2.0 registry+https://github.com/rust-lang/crates.io-index", "fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "filetime 0.2.26 registry+https://github.com/rust-lang/crates.io-index", - "find-msvc-tools 0.1.4 registry+https://github.com/rust-lang/crates.io-index", + "find-msvc-tools 0.1.5 registry+https://github.com/rust-lang/crates.io-index", "flate2 1.1.5 registry+https://github.com/rust-lang/crates.io-index", "flavours 0.7.2 git+https://github.com/LGUG2Z/flavours", "fnv 1.0.7 registry+https://github.com/rust-lang/crates.io-index", @@ -520,9 +531,9 @@ "getrandom 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "getrandom 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "gif 0.11.4 registry+https://github.com/rust-lang/crates.io-index", - "gif 0.13.3 registry+https://github.com/rust-lang/crates.io-index", + "gif 0.14.1 registry+https://github.com/rust-lang/crates.io-index", "gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index", - "git2 0.20.2 registry+https://github.com/rust-lang/crates.io-index", + "git2 0.20.3 registry+https://github.com/rust-lang/crates.io-index", "glob 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index", "glutin-winit 0.5.0 registry+https://github.com/rust-lang/crates.io-index", @@ -530,45 +541,45 @@ "half 2.7.1 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.12.3 registry+https://github.com/rust-lang/crates.io-index", "hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index", - "hashbrown 0.16.0 registry+https://github.com/rust-lang/crates.io-index", + "hashbrown 0.16.1 registry+https://github.com/rust-lang/crates.io-index", "heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "hex 0.4.3 registry+https://github.com/rust-lang/crates.io-index", "hex_color 3.0.0 registry+https://github.com/rust-lang/crates.io-index", "hotwatch 0.5.0 registry+https://github.com/rust-lang/crates.io-index", - "http 1.3.1 registry+https://github.com/rust-lang/crates.io-index", + "http 1.4.0 registry+https://github.com/rust-lang/crates.io-index", "http-body 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "http-body-util 0.1.3 registry+https://github.com/rust-lang/crates.io-index", "httparse 1.10.1 registry+https://github.com/rust-lang/crates.io-index", - "hyper 1.8.0 registry+https://github.com/rust-lang/crates.io-index", + "hyper 1.8.1 registry+https://github.com/rust-lang/crates.io-index", "hyper-tls 0.6.0 registry+https://github.com/rust-lang/crates.io-index", - "hyper-util 0.1.17 registry+https://github.com/rust-lang/crates.io-index", + "hyper-util 0.1.19 registry+https://github.com/rust-lang/crates.io-index", "iana-time-zone 0.1.64 registry+https://github.com/rust-lang/crates.io-index", "icns 0.3.1 registry+https://github.com/rust-lang/crates.io-index", "ident_case 1.0.1 registry+https://github.com/rust-lang/crates.io-index", "idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "idna_adapter 1.2.1 registry+https://github.com/rust-lang/crates.io-index", "image 0.23.14 registry+https://github.com/rust-lang/crates.io-index", - "image 0.25.8 registry+https://github.com/rust-lang/crates.io-index", + "image 0.25.9 registry+https://github.com/rust-lang/crates.io-index", "image-webp 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index", "indexmap 1.9.3 registry+https://github.com/rust-lang/crates.io-index", - "indexmap 2.12.0 registry+https://github.com/rust-lang/crates.io-index", + "indexmap 2.12.1 registry+https://github.com/rust-lang/crates.io-index", "ipnet 2.11.0 registry+https://github.com/rust-lang/crates.io-index", "iri-string 0.7.9 registry+https://github.com/rust-lang/crates.io-index", "is_debug 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index", - "itertools 0.12.1 registry+https://github.com/rust-lang/crates.io-index", - "itoa 1.0.15 registry+https://github.com/rust-lang/crates.io-index", + "itertools 0.14.0 registry+https://github.com/rust-lang/crates.io-index", + "itoa 1.0.16 registry+https://github.com/rust-lang/crates.io-index", "jobserver 0.1.34 registry+https://github.com/rust-lang/crates.io-index", "jpeg-decoder 0.1.22 registry+https://github.com/rust-lang/crates.io-index", "lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index", - "libc 0.2.177 registry+https://github.com/rust-lang/crates.io-index", - "libgit2-sys 0.18.2+1.9.1 registry+https://github.com/rust-lang/crates.io-index", + "libc 0.2.178 registry+https://github.com/rust-lang/crates.io-index", + "libgit2-sys 0.18.3+1.9.2 registry+https://github.com/rust-lang/crates.io-index", "libz-sys 1.1.23 registry+https://github.com/rust-lang/crates.io-index", "linked-hash-map 0.5.6 registry+https://github.com/rust-lang/crates.io-index", "litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index", "lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index", - "log 0.4.28 registry+https://github.com/rust-lang/crates.io-index", + "log 0.4.29 registry+https://github.com/rust-lang/crates.io-index", "logos 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-codegen 0.14.4 registry+https://github.com/rust-lang/crates.io-index", "logos-derive 0.14.4 registry+https://github.com/rust-lang/crates.io-index", @@ -584,10 +595,10 @@ "miniz_oxide 0.3.7 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.4.4 registry+https://github.com/rust-lang/crates.io-index", "miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index", - "mio 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "mio 1.1.1 registry+https://github.com/rust-lang/crates.io-index", "nanoid 0.4.0 registry+https://github.com/rust-lang/crates.io-index", "native-tls 0.2.14 registry+https://github.com/rust-lang/crates.io-index", - "netdev 0.39.0 registry+https://github.com/rust-lang/crates.io-index", + "netdev 0.40.0 registry+https://github.com/rust-lang/crates.io-index", "new_debug_unreachable 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "nix 0.30.1 registry+https://github.com/rust-lang/crates.io-index", "nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -627,6 +638,7 @@ "objc2-metal 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-security 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-system-configuration 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "object 0.37.3 registry+https://github.com/rust-lang/crates.io-index", "once_cell 1.21.3 registry+https://github.com/rust-lang/crates.io-index", "owo-colors 4.2.3 registry+https://github.com/rust-lang/crates.io-index", @@ -636,6 +648,7 @@ "parking_lot_core 0.9.12 registry+https://github.com/rust-lang/crates.io-index", "paste 1.0.15 registry+https://github.com/rust-lang/crates.io-index", "pastey 0.1.1 registry+https://github.com/rust-lang/crates.io-index", + "pastey 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index", "phf 0.12.1 registry+https://github.com/rust-lang/crates.io-index", "phf 0.8.0 registry+https://github.com/rust-lang/crates.io-index", @@ -646,6 +659,7 @@ "pin-project-lite 0.2.16 registry+https://github.com/rust-lang/crates.io-index", "pin-utils 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "pkg-config 0.3.32 registry+https://github.com/rust-lang/crates.io-index", + "plist 1.8.0 registry+https://github.com/rust-lang/crates.io-index", "png 0.16.8 registry+https://github.com/rust-lang/crates.io-index", "png 0.18.0 registry+https://github.com/rust-lang/crates.io-index", "powerfmt 0.2.0 registry+https://github.com/rust-lang/crates.io-index", @@ -656,6 +670,7 @@ "qoi 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index", "quick-xml 0.17.2 registry+https://github.com/rust-lang/crates.io-index", + "quick-xml 0.38.4 registry+https://github.com/rust-lang/crates.io-index", "quickxml_to_serde 0.6.1 git+https://github.com/LGUG2Z/quickxml_to_serde.git", "quote 1.0.42 registry+https://github.com/rust-lang/crates.io-index", "rand 0.7.3 registry+https://github.com/rust-lang/crates.io-index", @@ -672,18 +687,20 @@ "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "rayon 1.11.0 registry+https://github.com/rust-lang/crates.io-index", "rayon-core 1.13.0 registry+https://github.com/rust-lang/crates.io-index", + "ref-cast 1.0.25 registry+https://github.com/rust-lang/crates.io-index", + "ref-cast-impl 1.0.25 registry+https://github.com/rust-lang/crates.io-index", "regex 1.12.2 registry+https://github.com/rust-lang/crates.io-index", "regex-automata 0.4.13 registry+https://github.com/rust-lang/crates.io-index", "regex-syntax 0.8.8 registry+https://github.com/rust-lang/crates.io-index", - "reqwest 0.12.24 registry+https://github.com/rust-lang/crates.io-index", + "reqwest 0.12.26 registry+https://github.com/rust-lang/crates.io-index", "rgb 0.8.52 registry+https://github.com/rust-lang/crates.io-index", "rustc-demangle 0.1.26 registry+https://github.com/rust-lang/crates.io-index", "rustc_version 0.4.1 registry+https://github.com/rust-lang/crates.io-index", "rustix 1.1.2 registry+https://github.com/rust-lang/crates.io-index", - "rustls-pki-types 1.13.0 registry+https://github.com/rust-lang/crates.io-index", + "rustls-pki-types 1.13.2 registry+https://github.com/rust-lang/crates.io-index", "same-file 1.0.6 registry+https://github.com/rust-lang/crates.io-index", - "schemars 0.8.22 registry+https://github.com/rust-lang/crates.io-index", - "schemars_derive 0.8.22 registry+https://github.com/rust-lang/crates.io-index", + "schemars 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "schemars_derive 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "scoped_threadpool 0.1.9 registry+https://github.com/rust-lang/crates.io-index", "scopeguard 1.2.0 registry+https://github.com/rust-lang/crates.io-index", "security-framework 2.11.1 registry+https://github.com/rust-lang/crates.io-index", @@ -697,17 +714,17 @@ "serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index", "serde_urlencoded 0.7.1 registry+https://github.com/rust-lang/crates.io-index", "serde_variant 0.1.3 registry+https://github.com/rust-lang/crates.io-index", - "serde_with 3.15.1 registry+https://github.com/rust-lang/crates.io-index", - "serde_with_macros 3.15.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with 3.16.1 registry+https://github.com/rust-lang/crates.io-index", + "serde_with_macros 3.16.1 registry+https://github.com/rust-lang/crates.io-index", "serde_yaml 0.8.26 registry+https://github.com/rust-lang/crates.io-index", "sha2 0.10.9 registry+https://github.com/rust-lang/crates.io-index", - "shadow-rs 1.4.0 registry+https://github.com/rust-lang/crates.io-index", + "shadow-rs 1.5.0 registry+https://github.com/rust-lang/crates.io-index", "sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index", - "shell-words 1.1.0 registry+https://github.com/rust-lang/crates.io-index", + "shell-words 1.1.1 registry+https://github.com/rust-lang/crates.io-index", "shellexpand 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "shlex 1.3.0 registry+https://github.com/rust-lang/crates.io-index", "signature 2.2.0 registry+https://github.com/rust-lang/crates.io-index", - "simd-adler32 0.3.7 registry+https://github.com/rust-lang/crates.io-index", + "simd-adler32 0.3.8 registry+https://github.com/rust-lang/crates.io-index", "simd_helpers 0.1.0 registry+https://github.com/rust-lang/crates.io-index", "siphasher 0.3.11 registry+https://github.com/rust-lang/crates.io-index", "siphasher 1.0.1 registry+https://github.com/rust-lang/crates.io-index", @@ -721,16 +738,14 @@ "strum 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "strum_macros 0.27.2 registry+https://github.com/rust-lang/crates.io-index", "syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index", - "syn 2.0.110 registry+https://github.com/rust-lang/crates.io-index", + "syn 2.0.111 registry+https://github.com/rust-lang/crates.io-index", "synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index", "sysinfo 0.37.2 registry+https://github.com/rust-lang/crates.io-index", "system-configuration 0.6.1 registry+https://github.com/rust-lang/crates.io-index", "system-configuration-sys 0.6.0 registry+https://github.com/rust-lang/crates.io-index", "tempfile 3.23.0 registry+https://github.com/rust-lang/crates.io-index", "terminal_size 0.4.3 registry+https://github.com/rust-lang/crates.io-index", - "thiserror 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror 2.0.17 registry+https://github.com/rust-lang/crates.io-index", - "thiserror-impl 1.0.69 registry+https://github.com/rust-lang/crates.io-index", "thiserror-impl 2.0.17 registry+https://github.com/rust-lang/crates.io-index", "thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index", "tiff 0.10.3 registry+https://github.com/rust-lang/crates.io-index", @@ -742,21 +757,21 @@ "tokio-util 0.7.17 registry+https://github.com/rust-lang/crates.io-index", "toml 0.5.11 registry+https://github.com/rust-lang/crates.io-index", "tower 0.5.2 registry+https://github.com/rust-lang/crates.io-index", - "tower-http 0.6.6 registry+https://github.com/rust-lang/crates.io-index", + "tower-http 0.6.8 registry+https://github.com/rust-lang/crates.io-index", "tower-layer 0.3.3 registry+https://github.com/rust-lang/crates.io-index", "tower-service 0.3.3 registry+https://github.com/rust-lang/crates.io-index", - "tracing 0.1.41 registry+https://github.com/rust-lang/crates.io-index", - "tracing-appender 0.2.3 registry+https://github.com/rust-lang/crates.io-index", - "tracing-attributes 0.1.30 registry+https://github.com/rust-lang/crates.io-index", - "tracing-core 0.1.34 registry+https://github.com/rust-lang/crates.io-index", + "tracing 0.1.44 registry+https://github.com/rust-lang/crates.io-index", + "tracing-appender 0.2.4 registry+https://github.com/rust-lang/crates.io-index", + "tracing-attributes 0.1.31 registry+https://github.com/rust-lang/crates.io-index", + "tracing-core 0.1.36 registry+https://github.com/rust-lang/crates.io-index", "tracing-error 0.2.1 registry+https://github.com/rust-lang/crates.io-index", "tracing-log 0.2.0 registry+https://github.com/rust-lang/crates.io-index", - "tracing-subscriber 0.3.20 registry+https://github.com/rust-lang/crates.io-index", + "tracing-subscriber 0.3.22 registry+https://github.com/rust-lang/crates.io-index", "try-lock 0.2.5 registry+https://github.com/rust-lang/crates.io-index", "ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index", "typenum 1.19.0 registry+https://github.com/rust-lang/crates.io-index", "tz-rs 0.7.1 registry+https://github.com/rust-lang/crates.io-index", - "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index", + "tzdb_data 0.2.3 registry+https://github.com/rust-lang/crates.io-index", "unicase 2.8.1 registry+https://github.com/rust-lang/crates.io-index", "unicode-ident 1.0.22 registry+https://github.com/rust-lang/crates.io-index", "unicode-segmentation 1.12.0 registry+https://github.com/rust-lang/crates.io-index", @@ -772,20 +787,23 @@ "web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index", "webbrowser 1.0.6 registry+https://github.com/rust-lang/crates.io-index", "weezl 0.1.12 registry+https://github.com/rust-lang/crates.io-index", + "y4m 0.8.0 registry+https://github.com/rust-lang/crates.io-index", "yaml-rust 0.4.5 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy 0.8.27 registry+https://github.com/rust-lang/crates.io-index", - "zerocopy-derive 0.8.27 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy 0.8.31 registry+https://github.com/rust-lang/crates.io-index", + "zerocopy-derive 0.8.31 registry+https://github.com/rust-lang/crates.io-index", "zeroize 1.8.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-core 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", - "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" + "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index", + "zune-jpeg 0.5.7 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "MIT-0", [ "dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index", - "tzdb_data 0.2.2 registry+https://github.com/rust-lang/crates.io-index" + "tzdb_data 0.2.3 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -799,13 +817,13 @@ [ "OFL-1.1", [ - "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index" + "epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index" ] ], [ "Ubuntu-font-1.0", [ - "epaint_default_fonts 0.33.0 registry+https://github.com/rust-lang/crates.io-index" + "epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index" ] ], [ @@ -815,8 +833,8 @@ "icu_locale_core 2.1.1 registry+https://github.com/rust-lang/crates.io-index", "icu_normalizer 2.1.1 registry+https://github.com/rust-lang/crates.io-index", "icu_normalizer_data 2.1.1 registry+https://github.com/rust-lang/crates.io-index", - "icu_properties 2.1.1 registry+https://github.com/rust-lang/crates.io-index", - "icu_properties_data 2.1.1 registry+https://github.com/rust-lang/crates.io-index", + "icu_properties 2.1.2 registry+https://github.com/rust-lang/crates.io-index", + "icu_properties_data 2.1.2 registry+https://github.com/rust-lang/crates.io-index", "icu_provider 2.1.1 registry+https://github.com/rust-lang/crates.io-index", "litemap 0.8.1 registry+https://github.com/rust-lang/crates.io-index", "potential_utf 0.1.4 registry+https://github.com/rust-lang/crates.io-index", @@ -871,10 +889,13 @@ "objc2-metal 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-quartz-core 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "objc2-security 0.3.2 registry+https://github.com/rust-lang/crates.io-index", + "objc2-system-configuration 0.3.2 registry+https://github.com/rust-lang/crates.io-index", "raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index", "zune-core 0.4.12 registry+https://github.com/rust-lang/crates.io-index", + "zune-core 0.5.0 registry+https://github.com/rust-lang/crates.io-index", "zune-inflate 0.2.54 registry+https://github.com/rust-lang/crates.io-index", - "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index" + "zune-jpeg 0.4.21 registry+https://github.com/rust-lang/crates.io-index", + "zune-jpeg 0.5.7 registry+https://github.com/rust-lang/crates.io-index" ] ] ] diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 7e663d54..251d6ce9 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -23,7 +23,7 @@ hotwatch = { workspace = true } icns = "0.3" image = "0.25" lazy_static = { workspace = true } -netdev = "0.39" +netdev = "0.40" num = "0.4" num-derive = "0.4" num-traits = "0.2" diff --git a/komorebi-bar/src/main.rs b/komorebi-bar/src/main.rs index c0b83ce7..aa8a852e 100644 --- a/komorebi-bar/src/main.rs +++ b/komorebi-bar/src/main.rs @@ -76,15 +76,8 @@ fn main() -> eyre::Result<()> { #[cfg(feature = "schemars")] if opts.schema { - let settings = schemars::r#gen::SchemaSettings::default().with(|s| { - s.option_nullable = false; - s.option_add_null_type = false; - s.inline_subschemas = true; - }); - - let generator = settings.into_generator(); - let socket_message = generator.into_root_schema_for::(); - let schema = serde_json::to_string_pretty(&socket_message)?; + let bar_config = schemars::schema_for!(KomobarConfig); + let schema = serde_json::to_string_pretty(&bar_config)?; println!("{schema}"); std::process::exit(0); diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index c28ab834..3fc1fee0 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -42,7 +42,7 @@ reqwest = { version = "0.12", features = ["blocking"] } schemars = { workspace = true, optional = true } serde = { workspace = true } serde_json = { workspace = true, features = ["preserve_order"] } -serde_with = { version = "3", features = ["schemars_0_8"] } +serde_with = { version = "3", features = ["schemars_1"] } shadow-rs = { workspace = true } strum = { version = "0.27", features = ["derive"] } sysinfo = { workspace = true } diff --git a/komorebi/src/core/pathext.rs b/komorebi/src/core/pathext.rs index 34be424e..c0953e38 100644 --- a/komorebi/src/core/pathext.rs +++ b/komorebi/src/core/pathext.rs @@ -129,12 +129,12 @@ impl<'de> serde_with::DeserializeAs<'de, PathBuf> for ResolvedPathBuf { } #[cfg(feature = "schemars")] -impl serde_with::schemars_0_8::JsonSchemaAs for ResolvedPathBuf { - fn schema_name() -> String { - "PathBuf".to_string() +impl serde_with::schemars_1::JsonSchemaAs for ResolvedPathBuf { + fn schema_name() -> std::borrow::Cow<'static, str> { + std::borrow::Cow::Borrowed("PathBuf") } - fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::schema::Schema { + fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema { ::json_schema(generator) } } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index c29bb256..8115acb6 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1557,16 +1557,8 @@ impl WindowManager { SocketMessage::StaticConfigSchema => { #[cfg(feature = "schemars")] { - let settings = schemars::r#gen::SchemaSettings::default().with(|s| { - s.option_nullable = false; - s.option_add_null_type = false; - s.inline_subschemas = true; - }); - - let generator = settings.into_generator(); - let socket_message = - generator.into_root_schema_for::(); - let schema = serde_json::to_string_pretty(&socket_message)?; + let static_config = schemars::schema_for!(StaticConfig); + let schema = serde_json::to_string_pretty(&static_config)?; reply.write_all(schema.as_bytes())?; } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 4765845c..97b26542 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -307,11 +307,11 @@ struct SerializedWindow { #[cfg(feature = "schemars")] impl schemars::JsonSchema for Window { - fn schema_name() -> String { - "Window".to_string() + fn schema_name() -> std::borrow::Cow<'static, str> { + std::borrow::Cow::Borrowed("Window") } - fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::schema::Schema { + fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema { ::json_schema(generator) } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 5ec666ce..893ce77c 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -2200,15 +2200,7 @@ fn main() -> eyre::Result<()> { SubCommand::StaticConfigSchema => { #[cfg(feature = "schemars")] { - let settings = schemars::r#gen::SchemaSettings::default().with(|s| { - s.option_nullable = false; - s.option_add_null_type = false; - s.inline_subschemas = true; - }); - - let generator = settings.into_generator(); - let socket_message = - generator.into_root_schema_for::(); + let socket_message = schemars::schema_for!(komorebi_client::StaticConfig); let schema = serde_json::to_string_pretty(&socket_message)?; println!("{schema}"); } diff --git a/schema.asc.json b/schema.asc.json index d39fec39..24b49e77 100644 --- a/schema.asc.json +++ b/schema.asc.json @@ -1,11 +1,11 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "ApplicationSpecificConfiguration", "type": "object", "additionalProperties": { - "$ref": "#/definitions/AscApplicationRulesOrSchema" + "$ref": "#/$defs/AscApplicationRulesOrSchema" }, - "definitions": { + "$defs": { "ApplicationIdentifier": { "type": "string", "enum": [ @@ -26,7 +26,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } }, "ignore": { @@ -36,7 +36,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } }, "layered": { @@ -46,7 +46,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } }, "manage": { @@ -56,7 +56,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } }, "object_name_change": { @@ -66,7 +66,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } }, "slow_application": { @@ -76,7 +76,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } }, "transparency_ignore": { @@ -86,7 +86,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } }, "tray_and_multi_window": { @@ -96,7 +96,7 @@ "null" ], "items": { - "$ref": "#/definitions/MatchingRule" + "$ref": "#/$defs/MatchingRule" } } } @@ -104,7 +104,7 @@ "AscApplicationRulesOrSchema": { "anyOf": [ { - "$ref": "#/definitions/AscApplicationRules" + "$ref": "#/$defs/AscApplicationRules" }, { "type": "string" @@ -113,38 +113,38 @@ }, "IdWithIdentifier": { "type": "object", - "required": [ - "id", - "kind" - ], "properties": { "id": { "type": "string" }, "kind": { - "$ref": "#/definitions/ApplicationIdentifier" + "$ref": "#/$defs/ApplicationIdentifier" }, "matching_strategy": { "anyOf": [ { - "$ref": "#/definitions/MatchingStrategy" + "$ref": "#/$defs/MatchingStrategy" }, { "type": "null" } ] } - } + }, + "required": [ + "kind", + "id" + ] }, "MatchingRule": { "anyOf": [ { - "$ref": "#/definitions/IdWithIdentifier" + "$ref": "#/$defs/IdWithIdentifier" }, { "type": "array", "items": { - "$ref": "#/definitions/IdWithIdentifier" + "$ref": "#/$defs/IdWithIdentifier" } } ] diff --git a/schema.json b/schema.json index 7db3b7ab..c8cba531 100644 --- a/schema.json +++ b/schema.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "StaticConfig", "description": "The `komorebi.json` static configuration file reference for `v0.1.39`", "type": "object", @@ -8,62 +8,763 @@ "description": "Path to applications.json from komorebi-application-specific-configurations (default: None)", "anyOf": [ { - "description": "A single applications.json file", - "type": "string" + "$ref": "#/$defs/AppSpecificConfigurationPath" }, { - "description": "Multiple applications.json files", - "type": "array", - "items": { - "type": "string" - } + "type": "null" } ] }, "border": { "description": "Display window borders (default: true)", - "type": "boolean" + "type": [ + "boolean", + "null" + ] }, "border_colours": { "description": "Window border colours for different container types (has no effect if a theme is defined)", + "anyOf": [ + { + "$ref": "#/$defs/BorderColours" + }, + { + "type": "null" + } + ] + }, + "border_offset": { + "description": "Offset of window borders (default: 5)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "border_overflow_applications": { + "description": "Identify border overflow applications", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "border_radius": { + "description": "Radius of window borders (default: 10)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "border_width": { + "description": "Width of window borders (default: 6)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "cross_boundary_behaviour": { + "description": "Determine what happens when an action is called on a window at a monitor boundary (default: Monitor)", + "anyOf": [ + { + "$ref": "#/$defs/CrossBoundaryBehaviour" + }, + { + "type": "null" + } + ] + }, + "cross_monitor_move_behaviour": { + "description": "Determine what happens when a window is moved across a monitor boundary (default: Swap)", + "anyOf": [ + { + "$ref": "#/$defs/MoveBehaviour" + }, + { + "type": "null" + } + ] + }, + "default_container_padding": { + "description": "Global default container padding (default: 10)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "default_workspace_padding": { + "description": "Add transparency to unfocused windows (default: false)\nGlobal default workspace padding (default: 10)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "display_index_preferences": { + "description": "Set display index preferences", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "type": "string" + } + } + }, + "float_override": { + "description": "Enable or disable float override, which makes it so every new window opens in floating mode\n(default: false)", + "type": [ + "boolean", + "null" + ] + }, + "float_override_placement": { + "description": "Determines the `Placement` to be used when spawning a window with float override active\n(default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "float_rule_placement": { + "description": "Determines the `Placement` to be used when spawning a window that matches a\n'floating_applications' rule (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "floating_applications": { + "description": "Identify applications which should be managed as floating windows", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "floating_layer_behaviour": { + "description": "Determines what happens on a new window when on the `FloatingLayer`\n(default: Tile)", + "anyOf": [ + { + "$ref": "#/$defs/FloatingLayerBehaviour" + }, + { + "type": "null" + } + ] + }, + "floating_layer_placement": { + "description": "Determines the `Placement` to be used when spawning a window on the floating layer with the\n`FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float` (default: Center)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "floating_window_aspect_ratio": { + "description": "Identify applications which are slow to send initial event notifications\nAspect ratio to resize with when toggling floating mode for a window", + "anyOf": [ + { + "$ref": "#/$defs/AspectRatio" + }, + { + "type": "null" + } + ] + }, + "global_work_area_offset": { + "description": "Global work area (space used for tiling) offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "ignore_rules": { + "description": "Individual window floating rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "layered_applications": { + "description": "Identify applications that have the WS_EX_LAYERED extended window style", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "manage_rules": { + "description": "Individual window force-manage rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "monitors": { + "description": "Monitor and workspace configurations", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MonitorConfig" + } + }, + "mouse_follows_focus": { + "description": "Enable or disable mouse follows focus (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "object_name_change_applications": { + "description": "Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare)", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "object_name_change_title_ignore_list": { + "description": "Do not process EVENT_OBJECT_NAMECHANGE events as Show events for identified applications matching these title regexes", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "resize_delta": { + "description": "Delta to resize windows by (default 50)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "theme": { + "description": "Theme configuration options", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiTheme" + }, + { + "type": "null" + } + ] + }, + "toggle_float_placement": { + "description": "Determines the placement of a new window when toggling to float (default: CenterAndResize)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "tray_and_multi_window_applications": { + "description": "Identify tray and multi-window applications", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "unmanaged_window_operation_behaviour": { + "description": "Determine what happens when commands are sent while an unmanaged window is in the foreground (default: Op)", + "anyOf": [ + { + "$ref": "#/$defs/OperationBehaviour" + }, + { + "type": "null" + } + ] + }, + "window_container_behaviour": { + "description": "Determine what happens when a new window is opened (default: Create)", + "anyOf": [ + { + "$ref": "#/$defs/WindowContainerBehaviour" + }, + { + "type": "null" + } + ] + } + }, + "$defs": { + "AppSpecificConfigurationPath": { + "anyOf": [ + { + "description": "A single applications.json file", + "$ref": "#/$defs/PathBuf" + }, + { + "description": "Multiple applications.json files", + "type": "array", + "items": { + "$ref": "#/$defs/PathBuf" + } + } + ] + }, + "ApplicationIdentifier": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "AspectRatio": { + "anyOf": [ + { + "description": "A predefined aspect ratio", + "$ref": "#/$defs/PredefinedAspectRatio" + }, + { + "description": "A custom W:H aspect ratio", + "type": "array", + "maxItems": 2, + "minItems": 2, + "prefixItems": [ + { + "type": "integer", + "format": "int32" + }, + { + "type": "integer", + "format": "int32" + } + ] + } + ] + }, + "Axis": { + "type": "string", + "enum": [ + "Horizontal", + "Vertical", + "HorizontalAndVertical" + ] + }, + "Base16": { + "type": "string", + "enum": [ + "3024", + "Apathy", + "Apprentice", + "Ashes", + "AtelierCaveLight", + "AtelierCave", + "AtelierDuneLight", + "AtelierDune", + "AtelierEstuaryLight", + "AtelierEstuary", + "AtelierForestLight", + "AtelierForest", + "AtelierHeathLight", + "AtelierHeath", + "AtelierLakesideLight", + "AtelierLakeside", + "AtelierPlateauLight", + "AtelierPlateau", + "AtelierSavannaLight", + "AtelierSavanna", + "AtelierSeasideLight", + "AtelierSeaside", + "AtelierSulphurpoolLight", + "AtelierSulphurpool", + "Atlas", + "AyuDark", + "AyuLight", + "AyuMirage", + "Aztec", + "Bespin", + "BlackMetalBathory", + "BlackMetalBurzum", + "BlackMetalDarkFuneral", + "BlackMetalGorgoroth", + "BlackMetalImmortal", + "BlackMetalKhold", + "BlackMetalMarduk", + "BlackMetalMayhem", + "BlackMetalNile", + "BlackMetalVenom", + "BlackMetal", + "Blueforest", + "Blueish", + "Brewer", + "Bright", + "Brogrammer", + "BrushtreesDark", + "Brushtrees", + "Caroline", + "CatppuccinFrappe", + "CatppuccinLatte", + "CatppuccinMacchiato", + "CatppuccinMocha", + "Chalk", + "Circus", + "ClassicDark", + "ClassicLight", + "Codeschool", + "Colors", + "Cupcake", + "Cupertino", + "DaOneBlack", + "DaOneGray", + "DaOneOcean", + "DaOnePaper", + "DaOneSea", + "DaOneWhite", + "DanqingLight", + "Danqing", + "Darcula", + "Darkmoss", + "Darktooth", + "Darkviolet", + "Decaf", + "DefaultDark", + "DefaultLight", + "Dirtysea", + "Dracula", + "EdgeDark", + "EdgeLight", + "Eighties", + "EmbersLight", + "Embers", + "Emil", + "EquilibriumDark", + "EquilibriumGrayDark", + "EquilibriumGrayLight", + "EquilibriumLight", + "Eris", + "Espresso", + "EvaDim", + "Eva", + "EvenokDark", + "EverforestDarkHard", + "Everforest", + "Flat", + "Framer", + "FruitSoda", + "Gigavolt", + "Github", + "GoogleDark", + "GoogleLight", + "Gotham", + "GrayscaleDark", + "GrayscaleLight", + "Greenscreen", + "Gruber", + "GruvboxDarkHard", + "GruvboxDarkMedium", + "GruvboxDarkPale", + "GruvboxDarkSoft", + "GruvboxLightHard", + "GruvboxLightMedium", + "GruvboxLightSoft", + "GruvboxMaterialDarkHard", + "GruvboxMaterialDarkMedium", + "GruvboxMaterialDarkSoft", + "GruvboxMaterialLightHard", + "GruvboxMaterialLightMedium", + "GruvboxMaterialLightSoft", + "Hardcore", + "Harmonic16Dark", + "Harmonic16Light", + "HeetchLight", + "Heetch", + "Helios", + "Hopscotch", + "HorizonDark", + "HorizonLight", + "HorizonTerminalDark", + "HorizonTerminalLight", + "HumanoidDark", + "HumanoidLight", + "IaDark", + "IaLight", + "Icy", + "Irblack", + "Isotope", + "Jabuti", + "Kanagawa", + "Katy", + "Kimber", + "Lime", + "Macintosh", + "Marrakesh", + "Materia", + "MaterialDarker", + "MaterialLighter", + "MaterialPalenight", + "MaterialVivid", + "Material", + "MeasuredDark", + "MeasuredLight", + "MellowPurple", + "MexicoLight", + "Mocha", + "Monokai", + "Moonlight", + "Mountain", + "Nebula", + "NordLight", + "Nord", + "Nova", + "Ocean", + "Oceanicnext", + "OneLight", + "OnedarkDark", + "Onedark", + "OutrunDark", + "OxocarbonDark", + "OxocarbonLight", + "Pandora", + "PapercolorDark", + "PapercolorLight", + "Paraiso", + "Pasque", + "Phd", + "Pico", + "Pinky", + "Pop", + "Porple", + "PreciousDarkEleven", + "PreciousDarkFifteen", + "PreciousLightWarm", + "PreciousLightWhite", + "PrimerDarkDimmed", + "PrimerDark", + "PrimerLight", + "Purpledream", + "Qualia", + "Railscasts", + "Rebecca", + "RosePineDawn", + "RosePineMoon", + "RosePine", + "Saga", + "Sagelight", + "Sakura", + "Sandcastle", + "SelenizedBlack", + "SelenizedDark", + "SelenizedLight", + "SelenizedWhite", + "Seti", + "ShadesOfPurple", + "ShadesmearDark", + "ShadesmearLight", + "Shapeshifter", + "SilkDark", + "SilkLight", + "Snazzy", + "SolarflareLight", + "Solarflare", + "SolarizedDark", + "SolarizedLight", + "Spaceduck", + "Spacemacs", + "Sparky", + "StandardizedDark", + "StandardizedLight", + "Stella", + "StillAlive", + "Summercamp", + "SummerfruitDark", + "SummerfruitLight", + "SynthMidnightDark", + "SynthMidnightLight", + "Tango", + "Tarot", + "Tender", + "TerracottaDark", + "Terracotta", + "TokyoCityDark", + "TokyoCityLight", + "TokyoCityTerminalDark", + "TokyoCityTerminalLight", + "TokyoNightDark", + "TokyoNightLight", + "TokyoNightMoon", + "TokyoNightStorm", + "TokyoNightTerminalDark", + "TokyoNightTerminalLight", + "TokyoNightTerminalStorm", + "TokyodarkTerminal", + "Tokyodark", + "TomorrowNightEighties", + "TomorrowNight", + "Tomorrow", + "Tube", + "Twilight", + "UnikittyDark", + "UnikittyLight", + "UnikittyReversible", + "Uwunicorn", + "Vesper", + "Vice", + "Vulcan", + "Windows10Light", + "Windows10", + "Windows95Light", + "Windows95", + "WindowsHighcontrastLight", + "WindowsHighcontrast", + "WindowsNtLight", + "WindowsNt", + "Woodland", + "XcodeDusk", + "Zenbones", + "Zenburn" + ] + }, + "Base16ColourPalette": { + "type": "object", + "properties": { + "base_00": { + "$ref": "#/$defs/Colour" + }, + "base_01": { + "$ref": "#/$defs/Colour" + }, + "base_02": { + "$ref": "#/$defs/Colour" + }, + "base_03": { + "$ref": "#/$defs/Colour" + }, + "base_04": { + "$ref": "#/$defs/Colour" + }, + "base_05": { + "$ref": "#/$defs/Colour" + }, + "base_06": { + "$ref": "#/$defs/Colour" + }, + "base_07": { + "$ref": "#/$defs/Colour" + }, + "base_08": { + "$ref": "#/$defs/Colour" + }, + "base_09": { + "$ref": "#/$defs/Colour" + }, + "base_0a": { + "$ref": "#/$defs/Colour" + }, + "base_0b": { + "$ref": "#/$defs/Colour" + }, + "base_0c": { + "$ref": "#/$defs/Colour" + }, + "base_0d": { + "$ref": "#/$defs/Colour" + }, + "base_0e": { + "$ref": "#/$defs/Colour" + }, + "base_0f": { + "$ref": "#/$defs/Colour" + } + }, + "required": [ + "base_00", + "base_01", + "base_02", + "base_03", + "base_04", + "base_05", + "base_06", + "base_07", + "base_08", + "base_09", + "base_0a", + "base_0b", + "base_0c", + "base_0d", + "base_0e", + "base_0f" + ] + }, + "Base16Value": { + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "BorderColours": { "type": "object", "properties": { "floating": { "description": "Border colour when the container is in floating mode", "anyOf": [ { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } + "$ref": "#/$defs/Colour" }, { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" + "type": "null" } ] }, @@ -71,38 +772,10 @@ "description": "Border colour when the container is in monocle mode", "anyOf": [ { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } + "$ref": "#/$defs/Colour" }, { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" + "type": "null" } ] }, @@ -110,38 +783,10 @@ "description": "Border colour when the container contains a single window", "anyOf": [ { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } + "$ref": "#/$defs/Colour" }, { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" + "type": "null" } ] }, @@ -149,38 +794,10 @@ "description": "Border colour when the container contains multiple windows", "anyOf": [ { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } + "$ref": "#/$defs/Colour" }, { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" + "type": "null" } ] }, @@ -188,38 +805,10 @@ "description": "Border colour when the container is unfocused", "anyOf": [ { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } + "$ref": "#/$defs/Colour" }, { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" + "type": "null" } ] }, @@ -227,443 +816,765 @@ "description": "Border colour when the container is unfocused and locked", "anyOf": [ { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } + "$ref": "#/$defs/Colour" }, { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" + "type": "null" } ] } } }, - "border_offset": { - "description": "Offset of window borders (default: 5)", - "type": "integer", - "format": "int32" + "Catppuccin": { + "type": "string", + "enum": [ + "Frappe", + "Latte", + "Macchiato", + "Mocha" + ] }, - "border_overflow_applications": { - "description": "Identify border overflow applications", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } + "CatppuccinValue": { + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] }, - "border_radius": { - "description": "Radius of window borders (default: 10)", - "type": "integer", - "format": "int32" + "Colour": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "$ref": "#/$defs/Rgb" + }, + { + "description": "Colour represented as Hex", + "$ref": "#/$defs/Hex" + } + ] }, - "border_width": { - "description": "Width of window borders (default: 6)", - "type": "integer", - "format": "int32" - }, - "cross_boundary_behaviour": { - "description": "Determine what happens when an action is called on a window at a monitor boundary (default: Monitor)", + "CrossBoundaryBehaviour": { "oneOf": [ { "description": "Attempt to perform actions across a workspace boundary", "type": "string", - "enum": [ - "Workspace" - ] + "const": "Workspace" }, { "description": "Attempt to perform actions across a monitor boundary", "type": "string", - "enum": [ - "Monitor" - ] + "const": "Monitor" } ] }, - "cross_monitor_move_behaviour": { - "description": "Determine what happens when a window is moved across a monitor boundary (default: Swap)", - "oneOf": [ - { - "description": "Swap the window container with the window container at the edge of the adjacent monitor", - "type": "string", - "enum": [ - "Swap" - ] - }, - { - "description": "Insert the window container into the focused workspace on the adjacent monitor", - "type": "string", - "enum": [ - "Insert" - ] - }, - { - "description": "Do nothing if trying to move a window container in the direction of an adjacent monitor", - "type": "string", - "enum": [ - "NoOp" - ] - } + "DefaultLayout": { + "type": "string", + "enum": [ + "BSP", + "Columns", + "Rows", + "VerticalStack", + "HorizontalStack", + "UltrawideVerticalStack", + "Grid", + "RightMainVerticalStack", + "Scrolling" ] }, - "default_container_padding": { - "description": "Global default container padding (default: 10)", - "type": "integer", - "format": "int32" - }, - "default_workspace_padding": { - "description": "Add transparency to unfocused windows (default: false) Global default workspace padding (default: 10)", - "type": "integer", - "format": "int32" - }, - "display_index_preferences": { - "description": "Set display index preferences", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "float_override": { - "description": "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)", - "type": "boolean" - }, - "float_override_placement": { - "description": "Determines the `Placement` to be used when spawning a window with float override active (default: None)", - "oneOf": [ - { - "description": "Does not change the size or position of the window", - "type": "string", - "enum": [ - "None" - ] - }, - { - "description": "Center the window without changing the size", - "type": "string", - "enum": [ - "Center" - ] - }, - { - "description": "Center the window and resize it according to the `AspectRatio`", - "type": "string", - "enum": [ - "CenterAndResize" - ] - } - ] - }, - "float_rule_placement": { - "description": "Determines the `Placement` to be used when spawning a window that matches a 'floating_applications' rule (default: None)", - "oneOf": [ - { - "description": "Does not change the size or position of the window", - "type": "string", - "enum": [ - "None" - ] - }, - { - "description": "Center the window without changing the size", - "type": "string", - "enum": [ - "Center" - ] - }, - { - "description": "Center the window and resize it according to the `AspectRatio`", - "type": "string", - "enum": [ - "CenterAndResize" - ] - } - ] - }, - "floating_applications": { - "description": "Identify applications which should be managed as floating windows", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } - }, - "floating_layer_behaviour": { - "description": "Determines what happens on a new window when on the `FloatingLayer` (default: Tile)", + "FloatingLayerBehaviour": { "oneOf": [ { "description": "Tile new windows (unless they match a float rule or float override is active)", "type": "string", - "enum": [ - "Tile" - ] + "const": "Tile" }, { "description": "Float new windows", "type": "string", - "enum": [ - "Float" + "const": "Float" + } + ] + }, + "GridLayoutOptions": { + "type": "object", + "properties": { + "rows": { + "description": "Maximum number of rows per grid column", + "type": "integer", + "format": "uint", + "minimum": 0 + } + }, + "required": [ + "rows" + ] + }, + "Hex": { + "type": "string", + "format": "color-hex" + }, + "IdWithIdentifier": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "kind": { + "$ref": "#/$defs/ApplicationIdentifier" + }, + "matching_strategy": { + "anyOf": [ + { + "$ref": "#/$defs/MatchingStrategy" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "kind", + "id" + ] + }, + "KomorebiTheme": { + "oneOf": [ + { + "description": "A theme from catppuccin-egui", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Blue)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Yellow)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Pink)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "name": { + "description": "Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)", + "$ref": "#/$defs/Catppuccin" + }, + "palette": { + "type": "string", + "const": "Catppuccin" + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Blue)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Green)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Green)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Text)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Red)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "palette", + "name" + ] + }, + { + "description": "A theme from base16-egui-themes", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "name": { + "description": "Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)", + "$ref": "#/$defs/Base16" + }, + "palette": { + "type": "string", + "const": "Base16" + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "palette", + "name" + ] + }, + { + "description": "A custom Base16 theme", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "colours": { + "description": "Colours of the custom Base16 theme palette", + "$ref": "#/$defs/Base16ColourPalette" + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "palette": { + "type": "string", + "const": "Custom" + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "palette", + "colours" ] } ] }, - "floating_layer_placement": { - "description": "Determines the `Placement` to be used when spawning a window on the floating layer with the `FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float` (default: Center)", + "LayoutOptions": { + "type": "object", + "properties": { + "grid": { + "description": "Options related to the Grid layout", + "anyOf": [ + { + "$ref": "#/$defs/GridLayoutOptions" + }, + { + "type": "null" + } + ] + }, + "scrolling": { + "description": "Options related to the Scrolling layout", + "anyOf": [ + { + "$ref": "#/$defs/ScrollingLayoutOptions" + }, + { + "type": "null" + } + ] + } + } + }, + "MatchingRule": { + "anyOf": [ + { + "$ref": "#/$defs/IdWithIdentifier" + }, + { + "type": "array", + "items": { + "$ref": "#/$defs/IdWithIdentifier" + } + } + ] + }, + "MatchingStrategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + }, + "MonitorConfig": { + "type": "object", + "properties": { + "container_padding": { + "description": "Container padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "floating_layer_behaviour": { + "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", + "anyOf": [ + { + "$ref": "#/$defs/FloatingLayerBehaviour" + }, + { + "type": "null" + } + ] + }, + "wallpaper": { + "description": "Specify a wallpaper for this monitor", + "anyOf": [ + { + "$ref": "#/$defs/Wallpaper" + }, + { + "type": "null" + } + ] + }, + "window_based_work_area_offset": { + "description": "Window based work area offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "window_based_work_area_offset_limit": { + "description": "Open window limit after which the window based work area offset will no longer be applied (default: 1)", + "type": [ + "integer", + "null" + ], + "format": "int" + }, + "window_hiding_position": { + "description": "Determine which position windows should be hidden at on this monitor", + "anyOf": [ + { + "$ref": "#/$defs/WindowHidingPosition" + }, + { + "type": "null" + } + ] + }, + "work_area_offset": { + "description": "Monitor-specific work area offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "workspace_padding": { + "description": "Workspace padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "workspaces": { + "description": "Workspace configurations", + "type": "array", + "items": { + "$ref": "#/$defs/WorkspaceConfig" + } + } + }, + "required": [ + "workspaces" + ] + }, + "MoveBehaviour": { + "oneOf": [ + { + "description": "Swap the window container with the window container at the edge of the adjacent monitor", + "type": "string", + "const": "Swap" + }, + { + "description": "Insert the window container into the focused workspace on the adjacent monitor", + "type": "string", + "const": "Insert" + }, + { + "description": "Do nothing if trying to move a window container in the direction of an adjacent monitor", + "type": "string", + "const": "NoOp" + } + ] + }, + "OperationBehaviour": { + "oneOf": [ + { + "description": "Process komorebic commands on temporarily unmanaged/floated windows", + "type": "string", + "const": "Op" + }, + { + "description": "Ignore komorebic commands on temporarily unmanaged/floated windows", + "type": "string", + "const": "NoOp" + } + ] + }, + "PathBuf": { + "type": "string" + }, + "Placement": { "oneOf": [ { "description": "Does not change the size or position of the window", "type": "string", - "enum": [ - "None" - ] + "const": "None" }, { "description": "Center the window without changing the size", "type": "string", - "enum": [ - "Center" - ] + "const": "Center" }, { "description": "Center the window and resize it according to the `AspectRatio`", "type": "string", - "enum": [ - "CenterAndResize" - ] + "const": "CenterAndResize" } ] }, - "floating_window_aspect_ratio": { - "description": "Identify applications which are slow to send initial event notifications Aspect ratio to resize with when toggling floating mode for a window", - "anyOf": [ + "PredefinedAspectRatio": { + "oneOf": [ { - "description": "A predefined aspect ratio", - "oneOf": [ - { - "description": "21:9", - "type": "string", - "enum": [ - "Ultrawide" - ] - }, - { - "description": "16:9", - "type": "string", - "enum": [ - "Widescreen" - ] - }, - { - "description": "4:3", - "type": "string", - "enum": [ - "Standard" - ] - } - ] + "description": "21:9", + "type": "string", + "const": "Ultrawide" }, { - "description": "A custom W:H aspect ratio", - "type": "array", - "items": [ - { - "type": "integer", - "format": "int32" - }, - { - "type": "integer", - "format": "int32" - } - ], - "maxItems": 2, - "minItems": 2 + "description": "16:9", + "type": "string", + "const": "Widescreen" + }, + { + "description": "4:3", + "type": "string", + "const": "Standard" } ] }, - "global_work_area_offset": { - "description": "Global work area (space used for tiling) offset (default: None)", + "Rect": { "type": "object", - "required": [ - "bottom", - "left", - "right", - "top" - ], "properties": { "bottom": { "type": "integer", @@ -681,3233 +1592,436 @@ "type": "integer", "format": "int32" } - } - }, - "ignore_rules": { - "description": "Individual window floating rules", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } - }, - "layered_applications": { - "description": "Identify applications that have the WS_EX_LAYERED extended window style", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } - }, - "manage_rules": { - "description": "Individual window force-manage rules", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } - }, - "monitors": { - "description": "Monitor and workspace configurations", - "type": "array", - "items": { - "type": "object", - "required": [ - "workspaces" - ], - "properties": { - "container_padding": { - "description": "Container padding (default: global)", - "type": "integer", - "format": "int32" - }, - "floating_layer_behaviour": { - "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", - "oneOf": [ - { - "description": "Tile new windows (unless they match a float rule or float override is active)", - "type": "string", - "enum": [ - "Tile" - ] - }, - { - "description": "Float new windows", - "type": "string", - "enum": [ - "Float" - ] - } - ] - }, - "wallpaper": { - "description": "Specify a wallpaper for this monitor", - "type": "object", - "required": [ - "path" - ], - "properties": { - "generate_theme": { - "description": "Generate and apply Base16 theme for this wallpaper (default: true)", - "type": "boolean" - }, - "path": { - "description": "Path to the wallpaper image file", - "type": "string" - }, - "theme_options": { - "description": "Specify Light or Dark variant for theme generation (default: Dark)", - "type": "object", - "properties": { - "bar_accent": { - "description": "Komorebi status bar accent (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "floating_border": { - "description": "Border colour when the window is floating (default: Base09)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "monocle_border": { - "description": "Border colour when the container is in monocle mode (default: Base0F)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "single_border": { - "description": "Border colour when the container contains a single window (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stack_border": { - "description": "Border colour when the container contains multiple windows (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_background": { - "description": "Stackbar tab background colour (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_focused_text": { - "description": "Stackbar focused tab text colour (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_unfocused_text": { - "description": "Stackbar unfocused tab text colour (default: Base05)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "theme_variant": { - "description": "Specify Light or Dark variant for theme generation (default: Dark)", - "type": "string", - "enum": [ - "Dark", - "Light" - ] - }, - "unfocused_border": { - "description": "Border colour when the container is unfocused (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "unfocused_locked_border": { - "description": "Border colour when the container is unfocused and locked (default: Base08)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - } - } - } - } - }, - "window_based_work_area_offset": { - "description": "Window based work area offset (default: None)", - "type": "object", - "required": [ - "bottom", - "left", - "right", - "top" - ], - "properties": { - "bottom": { - "type": "integer", - "format": "int32" - }, - "left": { - "type": "integer", - "format": "int32" - }, - "right": { - "type": "integer", - "format": "int32" - }, - "top": { - "type": "integer", - "format": "int32" - } - } - }, - "window_based_work_area_offset_limit": { - "description": "Open window limit after which the window based work area offset will no longer be applied (default: 1)", - "type": "integer", - "format": "int" - }, - "window_hiding_position": { - "description": "Determine which position windows should be hidden at on this monitor", - "oneOf": [ - { - "description": "Hide windows in the bottom left corner of the screen", - "type": "string", - "enum": [ - "BottomLeft" - ] - }, - { - "description": "Hide windows in the bottom right corner of the screen", - "type": "string", - "enum": [ - "BottomRight" - ] - } - ] - }, - "work_area_offset": { - "description": "Monitor-specific work area offset (default: None)", - "type": "object", - "required": [ - "bottom", - "left", - "right", - "top" - ], - "properties": { - "bottom": { - "type": "integer", - "format": "int32" - }, - "left": { - "type": "integer", - "format": "int32" - }, - "right": { - "type": "integer", - "format": "int32" - }, - "top": { - "type": "integer", - "format": "int32" - } - } - }, - "workspace_padding": { - "description": "Workspace padding (default: global)", - "type": "integer", - "format": "int32" - }, - "workspaces": { - "description": "Workspace configurations", - "type": "array", - "items": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "apply_window_based_work_area_offset": { - "description": "Apply this monitor's window-based work area offset (default: true)", - "type": "boolean" - }, - "container_padding": { - "description": "Container padding (default: global)", - "type": "integer", - "format": "int32" - }, - "custom_layout": { - "description": "END OF LIFE FEATURE: Custom Layout (default: None)", - "type": "string" - }, - "float_override": { - "description": "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)", - "type": "boolean" - }, - "floating_layer_behaviour": { - "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", - "oneOf": [ - { - "description": "Tile new windows (unless they match a float rule or float override is active)", - "type": "string", - "enum": [ - "Tile" - ] - }, - { - "description": "Float new windows", - "type": "string", - "enum": [ - "Float" - ] - } - ] - }, - "initial_workspace_rules": { - "description": "Initial workspace application rules", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } - }, - "layout": { - "description": "Layout (default: BSP)", - "type": "string", - "enum": [ - "BSP", - "Columns", - "Rows", - "VerticalStack", - "HorizontalStack", - "UltrawideVerticalStack", - "Grid", - "RightMainVerticalStack", - "Scrolling" - ] - }, - "layout_flip": { - "description": "Specify an axis on which to flip the selected layout (default: None)", - "type": "string", - "enum": [ - "Horizontal", - "Vertical", - "HorizontalAndVertical" - ] - }, - "layout_options": { - "description": "Layout-specific options (default: None)", - "type": "object", - "properties": { - "grid": { - "description": "Options related to the Grid layout", - "type": "object", - "required": [ - "rows" - ], - "properties": { - "rows": { - "description": "Maximum number of rows per grid column", - "type": "integer", - "format": "uint", - "minimum": 0.0 - } - } - }, - "scrolling": { - "description": "Options related to the Scrolling layout", - "type": "object", - "required": [ - "columns" - ], - "properties": { - "center_focused_column": { - "description": "With an odd number of visible columns, keep the focused window column centered", - "type": "boolean" - }, - "columns": { - "description": "Desired number of visible columns (default: 3)", - "type": "integer", - "format": "uint", - "minimum": 0.0 - } - } - } - } - }, - "layout_rules": { - "description": "Layout rules in the format of threshold => layout (default: None)", - "type": "object", - "additionalProperties": { - "type": "string", - "enum": [ - "BSP", - "Columns", - "Rows", - "VerticalStack", - "HorizontalStack", - "UltrawideVerticalStack", - "Grid", - "RightMainVerticalStack", - "Scrolling" - ] - } - }, - "name": { - "description": "Name", - "type": "string" - }, - "tile": { - "description": "Enable or disable tiling for the workspace (default: true)", - "type": "boolean" - }, - "wallpaper": { - "description": "Specify a wallpaper for this workspace", - "type": "object", - "required": [ - "path" - ], - "properties": { - "generate_theme": { - "description": "Generate and apply Base16 theme for this wallpaper (default: true)", - "type": "boolean" - }, - "path": { - "description": "Path to the wallpaper image file", - "type": "string" - }, - "theme_options": { - "description": "Specify Light or Dark variant for theme generation (default: Dark)", - "type": "object", - "properties": { - "bar_accent": { - "description": "Komorebi status bar accent (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "floating_border": { - "description": "Border colour when the window is floating (default: Base09)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "monocle_border": { - "description": "Border colour when the container is in monocle mode (default: Base0F)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "single_border": { - "description": "Border colour when the container contains a single window (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stack_border": { - "description": "Border colour when the container contains multiple windows (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_background": { - "description": "Stackbar tab background colour (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_focused_text": { - "description": "Stackbar focused tab text colour (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_unfocused_text": { - "description": "Stackbar unfocused tab text colour (default: Base05)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "theme_variant": { - "description": "Specify Light or Dark variant for theme generation (default: Dark)", - "type": "string", - "enum": [ - "Dark", - "Light" - ] - }, - "unfocused_border": { - "description": "Border colour when the container is unfocused (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "unfocused_locked_border": { - "description": "Border colour when the container is unfocused and locked (default: Base08)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - } - } - } - } - }, - "window_container_behaviour": { - "description": "Determine what happens when a new window is opened (default: Create)", - "oneOf": [ - { - "description": "Create a new container for each new window", - "type": "string", - "enum": [ - "Create" - ] - }, - { - "description": "Append new windows to the focused window container", - "type": "string", - "enum": [ - "Append" - ] - } - ] - }, - "window_container_behaviour_rules": { - "description": "Window container behaviour rules in the format of threshold => behaviour (default: None)", - "type": "object", - "additionalProperties": { - "oneOf": [ - { - "description": "Create a new container for each new window", - "type": "string", - "enum": [ - "Create" - ] - }, - { - "description": "Append new windows to the focused window container", - "type": "string", - "enum": [ - "Append" - ] - } - ] - } - }, - "work_area_offset": { - "description": "Workspace specific work area offset (default: None)", - "type": "object", - "required": [ - "bottom", - "left", - "right", - "top" - ], - "properties": { - "bottom": { - "type": "integer", - "format": "int32" - }, - "left": { - "type": "integer", - "format": "int32" - }, - "right": { - "type": "integer", - "format": "int32" - }, - "top": { - "type": "integer", - "format": "int32" - } - } - }, - "workspace_padding": { - "description": "Workspace padding (default: global)", - "type": "integer", - "format": "int32" - }, - "workspace_rules": { - "description": "Permanent workspace application rules", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } - } - } - } - } - } - } - }, - "mouse_follows_focus": { - "description": "Enable or disable mouse follows focus (default: true)", - "type": "boolean" - }, - "object_name_change_applications": { - "description": "Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare)", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } - } - } - ] - } - }, - "object_name_change_title_ignore_list": { - "description": "Do not process EVENT_OBJECT_NAMECHANGE events as Show events for identified applications matching these title regexes", - "type": "array", - "items": { - "type": "string" - } - }, - "resize_delta": { - "description": "Delta to resize windows by (default 50)", - "type": "integer", - "format": "int32" - }, - "theme": { - "description": "Theme configuration options", - "oneOf": [ - { - "description": "A theme from catppuccin-egui", - "type": "object", - "required": [ - "name", - "palette" - ], - "properties": { - "bar_accent": { - "description": "Komorebi status bar accent (default: Blue)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "floating_border": { - "description": "Border colour when the window is floating (default: Yellow)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "monocle_border": { - "description": "Border colour when the container is in monocle mode (default: Pink)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "name": { - "description": "Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)", - "type": "string", - "enum": [ - "Frappe", - "Latte", - "Macchiato", - "Mocha" - ] - }, - "palette": { - "type": "string", - "enum": [ - "Catppuccin" - ] - }, - "single_border": { - "description": "Border colour when the container contains a single window (default: Blue)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "stack_border": { - "description": "Border colour when the container contains multiple windows (default: Green)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "stackbar_background": { - "description": "Stackbar tab background colour (default: Base)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "stackbar_focused_text": { - "description": "Stackbar focused tab text colour (default: Green)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "stackbar_unfocused_text": { - "description": "Stackbar unfocused tab text colour (default: Text)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "unfocused_border": { - "description": "Border colour when the container is unfocused (default: Base)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - }, - "unfocused_locked_border": { - "description": "Border colour when the container is unfocused and locked (default: Red)", - "type": "string", - "enum": [ - "Rosewater", - "Flamingo", - "Pink", - "Mauve", - "Red", - "Maroon", - "Peach", - "Yellow", - "Green", - "Teal", - "Sky", - "Sapphire", - "Blue", - "Lavender", - "Text", - "Subtext1", - "Subtext0", - "Overlay2", - "Overlay1", - "Overlay0", - "Surface2", - "Surface1", - "Surface0", - "Base", - "Mantle", - "Crust" - ] - } - } - }, - { - "description": "A theme from base16-egui-themes", - "type": "object", - "required": [ - "name", - "palette" - ], - "properties": { - "bar_accent": { - "description": "Komorebi status bar accent (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "floating_border": { - "description": "Border colour when the window is floating (default: Base09)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "monocle_border": { - "description": "Border colour when the container is in monocle mode (default: Base0F)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "name": { - "description": "Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)", - "type": "string", - "enum": [ - "3024", - "Apathy", - "Apprentice", - "Ashes", - "AtelierCaveLight", - "AtelierCave", - "AtelierDuneLight", - "AtelierDune", - "AtelierEstuaryLight", - "AtelierEstuary", - "AtelierForestLight", - "AtelierForest", - "AtelierHeathLight", - "AtelierHeath", - "AtelierLakesideLight", - "AtelierLakeside", - "AtelierPlateauLight", - "AtelierPlateau", - "AtelierSavannaLight", - "AtelierSavanna", - "AtelierSeasideLight", - "AtelierSeaside", - "AtelierSulphurpoolLight", - "AtelierSulphurpool", - "Atlas", - "AyuDark", - "AyuLight", - "AyuMirage", - "Aztec", - "Bespin", - "BlackMetalBathory", - "BlackMetalBurzum", - "BlackMetalDarkFuneral", - "BlackMetalGorgoroth", - "BlackMetalImmortal", - "BlackMetalKhold", - "BlackMetalMarduk", - "BlackMetalMayhem", - "BlackMetalNile", - "BlackMetalVenom", - "BlackMetal", - "Blueforest", - "Blueish", - "Brewer", - "Bright", - "Brogrammer", - "BrushtreesDark", - "Brushtrees", - "Caroline", - "CatppuccinFrappe", - "CatppuccinLatte", - "CatppuccinMacchiato", - "CatppuccinMocha", - "Chalk", - "Circus", - "ClassicDark", - "ClassicLight", - "Codeschool", - "Colors", - "Cupcake", - "Cupertino", - "DaOneBlack", - "DaOneGray", - "DaOneOcean", - "DaOnePaper", - "DaOneSea", - "DaOneWhite", - "DanqingLight", - "Danqing", - "Darcula", - "Darkmoss", - "Darktooth", - "Darkviolet", - "Decaf", - "DefaultDark", - "DefaultLight", - "Dirtysea", - "Dracula", - "EdgeDark", - "EdgeLight", - "Eighties", - "EmbersLight", - "Embers", - "Emil", - "EquilibriumDark", - "EquilibriumGrayDark", - "EquilibriumGrayLight", - "EquilibriumLight", - "Eris", - "Espresso", - "EvaDim", - "Eva", - "EvenokDark", - "EverforestDarkHard", - "Everforest", - "Flat", - "Framer", - "FruitSoda", - "Gigavolt", - "Github", - "GoogleDark", - "GoogleLight", - "Gotham", - "GrayscaleDark", - "GrayscaleLight", - "Greenscreen", - "Gruber", - "GruvboxDarkHard", - "GruvboxDarkMedium", - "GruvboxDarkPale", - "GruvboxDarkSoft", - "GruvboxLightHard", - "GruvboxLightMedium", - "GruvboxLightSoft", - "GruvboxMaterialDarkHard", - "GruvboxMaterialDarkMedium", - "GruvboxMaterialDarkSoft", - "GruvboxMaterialLightHard", - "GruvboxMaterialLightMedium", - "GruvboxMaterialLightSoft", - "Hardcore", - "Harmonic16Dark", - "Harmonic16Light", - "HeetchLight", - "Heetch", - "Helios", - "Hopscotch", - "HorizonDark", - "HorizonLight", - "HorizonTerminalDark", - "HorizonTerminalLight", - "HumanoidDark", - "HumanoidLight", - "IaDark", - "IaLight", - "Icy", - "Irblack", - "Isotope", - "Jabuti", - "Kanagawa", - "Katy", - "Kimber", - "Lime", - "Macintosh", - "Marrakesh", - "Materia", - "MaterialDarker", - "MaterialLighter", - "MaterialPalenight", - "MaterialVivid", - "Material", - "MeasuredDark", - "MeasuredLight", - "MellowPurple", - "MexicoLight", - "Mocha", - "Monokai", - "Moonlight", - "Mountain", - "Nebula", - "NordLight", - "Nord", - "Nova", - "Ocean", - "Oceanicnext", - "OneLight", - "OnedarkDark", - "Onedark", - "OutrunDark", - "OxocarbonDark", - "OxocarbonLight", - "Pandora", - "PapercolorDark", - "PapercolorLight", - "Paraiso", - "Pasque", - "Phd", - "Pico", - "Pinky", - "Pop", - "Porple", - "PreciousDarkEleven", - "PreciousDarkFifteen", - "PreciousLightWarm", - "PreciousLightWhite", - "PrimerDarkDimmed", - "PrimerDark", - "PrimerLight", - "Purpledream", - "Qualia", - "Railscasts", - "Rebecca", - "RosePineDawn", - "RosePineMoon", - "RosePine", - "Saga", - "Sagelight", - "Sakura", - "Sandcastle", - "SelenizedBlack", - "SelenizedDark", - "SelenizedLight", - "SelenizedWhite", - "Seti", - "ShadesOfPurple", - "ShadesmearDark", - "ShadesmearLight", - "Shapeshifter", - "SilkDark", - "SilkLight", - "Snazzy", - "SolarflareLight", - "Solarflare", - "SolarizedDark", - "SolarizedLight", - "Spaceduck", - "Spacemacs", - "Sparky", - "StandardizedDark", - "StandardizedLight", - "Stella", - "StillAlive", - "Summercamp", - "SummerfruitDark", - "SummerfruitLight", - "SynthMidnightDark", - "SynthMidnightLight", - "Tango", - "Tarot", - "Tender", - "TerracottaDark", - "Terracotta", - "TokyoCityDark", - "TokyoCityLight", - "TokyoCityTerminalDark", - "TokyoCityTerminalLight", - "TokyoNightDark", - "TokyoNightLight", - "TokyoNightMoon", - "TokyoNightStorm", - "TokyoNightTerminalDark", - "TokyoNightTerminalLight", - "TokyoNightTerminalStorm", - "TokyodarkTerminal", - "Tokyodark", - "TomorrowNightEighties", - "TomorrowNight", - "Tomorrow", - "Tube", - "Twilight", - "UnikittyDark", - "UnikittyLight", - "UnikittyReversible", - "Uwunicorn", - "Vesper", - "Vice", - "Vulcan", - "Windows10Light", - "Windows10", - "Windows95Light", - "Windows95", - "WindowsHighcontrastLight", - "WindowsHighcontrast", - "WindowsNtLight", - "WindowsNt", - "Woodland", - "XcodeDusk", - "Zenbones", - "Zenburn" - ] - }, - "palette": { - "type": "string", - "enum": [ - "Base16" - ] - }, - "single_border": { - "description": "Border colour when the container contains a single window (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stack_border": { - "description": "Border colour when the container contains multiple windows (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_background": { - "description": "Stackbar tab background colour (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_focused_text": { - "description": "Stackbar focused tab text colour (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_unfocused_text": { - "description": "Stackbar unfocused tab text colour (default: Base05)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "unfocused_border": { - "description": "Border colour when the container is unfocused (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "unfocused_locked_border": { - "description": "Border colour when the container is unfocused and locked (default: Base08)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - } - } - }, - { - "description": "A custom Base16 theme", - "type": "object", - "required": [ - "colours", - "palette" - ], - "properties": { - "bar_accent": { - "description": "Komorebi status bar accent (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "colours": { - "description": "Colours of the custom Base16 theme palette", - "type": "object", - "required": [ - "base_00", - "base_01", - "base_02", - "base_03", - "base_04", - "base_05", - "base_06", - "base_07", - "base_08", - "base_09", - "base_0a", - "base_0b", - "base_0c", - "base_0d", - "base_0e", - "base_0f" - ], - "properties": { - "base_00": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_01": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_02": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_03": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_04": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_05": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_06": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_07": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_08": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_09": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_0a": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_0b": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_0c": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_0d": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_0e": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - }, - "base_0f": { - "anyOf": [ - { - "description": "Colour represented as RGB", - "type": "object", - "required": [ - "b", - "g", - "r" - ], - "properties": { - "b": { - "description": "Blue", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "g": { - "description": "Green", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "r": { - "description": "Red", - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - { - "description": "Colour represented as Hex", - "type": "string", - "format": "color-hex" - } - ] - } - } - }, - "floating_border": { - "description": "Border colour when the window is floating (default: Base09)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "monocle_border": { - "description": "Border colour when the container is in monocle mode (default: Base0F)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "palette": { - "type": "string", - "enum": [ - "Custom" - ] - }, - "single_border": { - "description": "Border colour when the container contains a single window (default: Base0D)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stack_border": { - "description": "Border colour when the container contains multiple windows (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_background": { - "description": "Stackbar tab background colour (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_focused_text": { - "description": "Stackbar focused tab text colour (default: Base0B)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "stackbar_unfocused_text": { - "description": "Stackbar unfocused tab text colour (default: Base05)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "unfocused_border": { - "description": "Border colour when the container is unfocused (default: Base01)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - }, - "unfocused_locked_border": { - "description": "Border colour when the container is unfocused and locked (default: Base08)", - "type": "string", - "enum": [ - "Base00", - "Base01", - "Base02", - "Base03", - "Base04", - "Base05", - "Base06", - "Base07", - "Base08", - "Base09", - "Base0A", - "Base0B", - "Base0C", - "Base0D", - "Base0E", - "Base0F" - ] - } - } - } + }, + "required": [ + "left", + "top", + "right", + "bottom" ] }, - "toggle_float_placement": { - "description": "Determines the placement of a new window when toggling to float (default: CenterAndResize)", - "oneOf": [ - { - "description": "Does not change the size or position of the window", - "type": "string", - "enum": [ - "None" - ] + "Rgb": { + "type": "object", + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0 }, - { - "description": "Center the window without changing the size", - "type": "string", - "enum": [ - "Center" - ] + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0 }, - { - "description": "Center the window and resize it according to the `AspectRatio`", - "type": "string", - "enum": [ - "CenterAndResize" - ] + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0 } + }, + "required": [ + "r", + "g", + "b" ] }, - "tray_and_multi_window_applications": { - "description": "Identify tray and multi-window applications", - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } + "ScrollingLayoutOptions": { + "type": "object", + "properties": { + "center_focused_column": { + "description": "With an odd number of visible columns, keep the focused window column centered", + "type": [ + "boolean", + "null" + ] + }, + "columns": { + "description": "Desired number of visible columns (default: 3)", + "type": "integer", + "format": "uint", + "minimum": 0 + } + }, + "required": [ + "columns" + ] + }, + "ThemeOptions": { + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" } - }, - { - "type": "array", - "items": { - "type": "object", - "required": [ - "id", - "kind" - ], - "properties": { - "id": { - "type": "string" - }, - "kind": { - "type": "string", - "enum": [ - "Exe", - "Class", - "Title", - "Path" - ] - }, - "matching_strategy": { - "type": "string", - "enum": [ - "Legacy", - "Equals", - "StartsWith", - "EndsWith", - "Contains", - "Regex", - "DoesNotEndWith", - "DoesNotStartWith", - "DoesNotEqual", - "DoesNotContain" - ] - } - } + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" } - } - ] + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "theme_variant": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "anyOf": [ + { + "$ref": "#/$defs/ThemeVariant" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + } } }, - "unmanaged_window_operation_behaviour": { - "description": "Determine what happens when commands are sent while an unmanaged window is in the foreground (default: Op)", - "oneOf": [ - { - "description": "Process komorebic commands on temporarily unmanaged/floated windows", - "type": "string", - "enum": [ - "Op" - ] - }, - { - "description": "Ignore komorebic commands on temporarily unmanaged/floated windows", - "type": "string", - "enum": [ - "NoOp" - ] - } + "ThemeVariant": { + "type": "string", + "enum": [ + "Dark", + "Light" ] }, - "window_container_behaviour": { - "description": "Determine what happens when a new window is opened (default: Create)", + "Wallpaper": { + "type": "object", + "properties": { + "generate_theme": { + "description": "Generate and apply Base16 theme for this wallpaper (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "path": { + "description": "Path to the wallpaper image file", + "$ref": "#/$defs/PathBuf" + }, + "theme_options": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "anyOf": [ + { + "$ref": "#/$defs/ThemeOptions" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "path" + ] + }, + "WindowContainerBehaviour": { "oneOf": [ { "description": "Create a new container for each new window", "type": "string", - "enum": [ - "Create" - ] + "const": "Create" }, { "description": "Append new windows to the focused window container", "type": "string", - "enum": [ - "Append" - ] + "const": "Append" } ] + }, + "WindowHidingPosition": { + "oneOf": [ + { + "description": "Hide windows in the bottom left corner of the screen", + "type": "string", + "const": "BottomLeft" + }, + { + "description": "Hide windows in the bottom right corner of the screen", + "type": "string", + "const": "BottomRight" + } + ] + }, + "WorkspaceConfig": { + "type": "object", + "properties": { + "apply_window_based_work_area_offset": { + "description": "Apply this monitor's window-based work area offset (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "container_padding": { + "description": "Container padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "custom_layout": { + "description": "END OF LIFE FEATURE: Custom Layout (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/PathBuf" + }, + { + "type": "null" + } + ] + }, + "float_override": { + "description": "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)", + "type": [ + "boolean", + "null" + ] + }, + "floating_layer_behaviour": { + "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", + "anyOf": [ + { + "$ref": "#/$defs/FloatingLayerBehaviour" + }, + { + "type": "null" + } + ] + }, + "initial_workspace_rules": { + "description": "Initial workspace application rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "layout": { + "description": "Layout (default: BSP)", + "anyOf": [ + { + "$ref": "#/$defs/DefaultLayout" + }, + { + "type": "null" + } + ] + }, + "layout_flip": { + "description": "Specify an axis on which to flip the selected layout (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Axis" + }, + { + "type": "null" + } + ] + }, + "layout_options": { + "description": "Layout-specific options (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/LayoutOptions" + }, + { + "type": "null" + } + ] + }, + "layout_rules": { + "description": "Layout rules in the format of threshold => layout (default: None)", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "$ref": "#/$defs/DefaultLayout" + } + } + }, + "name": { + "description": "Name", + "type": "string" + }, + "tile": { + "description": "Enable or disable tiling for the workspace (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "wallpaper": { + "description": "Specify a wallpaper for this workspace", + "anyOf": [ + { + "$ref": "#/$defs/Wallpaper" + }, + { + "type": "null" + } + ] + }, + "window_container_behaviour": { + "description": "Determine what happens when a new window is opened (default: Create)", + "anyOf": [ + { + "$ref": "#/$defs/WindowContainerBehaviour" + }, + { + "type": "null" + } + ] + }, + "window_container_behaviour_rules": { + "description": "Window container behaviour rules in the format of threshold => behaviour (default: None)", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "$ref": "#/$defs/WindowContainerBehaviour" + } + } + }, + "work_area_offset": { + "description": "Workspace specific work area offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "workspace_padding": { + "description": "Workspace padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "workspace_rules": { + "description": "Permanent workspace application rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + } + }, + "required": [ + "name" + ] } } } From 1e71cb7d923551fffb4e4be2e5b73ec395c7265d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Dec 2025 12:00:13 -0800 Subject: [PATCH 178/305] docs(schema): publish versioned schema docs to lgug2z.com --- .gitignore | 2 + Cargo.lock | 2 +- justfile | 13 + komorebi-bar/Cargo.toml | 2 +- komorebi-bar/src/config.rs | 4 +- komorebi/src/static_config.rs | 4 +- schema.bar.json | 2257 +++++++++++++++++++++++++++++++++ schema.json | 2 +- shell.nix | 1 + 9 files changed, 2282 insertions(+), 5 deletions(-) create mode 100644 schema.bar.json diff --git a/.gitignore b/.gitignore index afe4db65..7a2a220f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /.idea /.direnv /komorebic/applications.json +/komorebi-schema +/bar-schema diff --git a/Cargo.lock b/Cargo.lock index ba4111fa..36227a49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3045,7 +3045,7 @@ dependencies = [ [[package]] name = "komorebi-bar" -version = "0.1.39" +version = "0.1.0" dependencies = [ "chrono", "chrono-tz", diff --git a/justfile b/justfile index ab316fef..41279c84 100644 --- a/justfile +++ b/justfile @@ -51,6 +51,19 @@ docgen: jsonschema: cargo run --package komorebic -- static-config-schema > schema.json cargo run --package komorebic -- application-specific-configuration-schema > schema.asc.json + cargo run --package komorebi-bar -- --schema > schema.bar.json + +version := `cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "komorebi") | .version'` + +schemagen: + mkdir -p komorebi-schema + schemars-docgen schema.json -o komorebi-schema/komorebi.html + schemars-docgen schema.bar.json -o komorebi-schema/bar.html + cp schema.json komorebi-schema/komorebi.{{ version }}.schema.json + cp schema.bar.json komorebi-schema/komorebi.bar.{{ version }}.schema.json + +schemapub: + wrangler pages deploy --project-name komorebi-for-mac --branch main ./komorebi-schema depgen: cargo deny check diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 251d6ce9..fb6bc50f 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "komorebi-bar" -version = "0.1.39" +version = "0.1.0" edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/komorebi-bar/src/config.rs b/komorebi-bar/src/config.rs index 33ae0103..1bf84591 100644 --- a/komorebi-bar/src/config.rs +++ b/komorebi-bar/src/config.rs @@ -15,7 +15,9 @@ use std::path::PathBuf; #[derive(Clone, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// The `komorebi.bar.json` configuration file reference for `v0.1.39` +/// The `komorebi.bar.json` static configuration file reference for komorebi for Mac `v0.1.0` +/// +/// `"$schema": "https://komorebi-for-mac.lgug2z.com/komorebi.bar.0.1.0.schema.json"` pub struct KomobarConfig { /// Bar height (default: 50) pub height: Option, diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 569d8ddc..2543534d 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -365,7 +365,9 @@ pub enum AppSpecificConfigurationPath { #[serde_with::serde_as] #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// The `komorebi.json` static configuration file reference for `v0.1.39` +/// The `komorebi.json` static configuration file reference for komorebi for Mac `v0.1.0` +/// +/// `"$schema": "https://komorebi-for-mac.lgug2z.com/komorebi.0.1.0.schema.json"` pub struct StaticConfig { // /// DISCOURAGED: Minimum width for a window to be eligible for tiling // #[serde(skip_serializing_if = "Option::is_none")] diff --git a/schema.bar.json b/schema.bar.json new file mode 100644 index 00000000..f702adbe --- /dev/null +++ b/schema.bar.json @@ -0,0 +1,2257 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "KomobarConfig", + "description": "The `komorebi.bar.json` static configuration file reference for komorebi for Mac `v0.1.0`\n\n`\"$schema\": \"https://komorebi-for-mac.lgug2z.com/komorebi.bar.0.1.0.schema.json\"`", + "type": "object", + "properties": { + "center_widgets": { + "description": "Center widgets (ordered left-to-right)", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/WidgetConfig" + } + }, + "font_family": { + "description": "Font family", + "type": [ + "string", + "null" + ] + }, + "font_size": { + "description": "Font size (default: 12.5)", + "type": [ + "number", + "null" + ], + "format": "float" + }, + "frame": { + "description": "Frame options (see: https://docs.rs/egui/latest/egui/containers/frame/struct.Frame.html)", + "anyOf": [ + { + "$ref": "#/$defs/FrameConfig" + }, + { + "type": "null" + } + ] + }, + "grouping": { + "description": "Visual grouping for widgets", + "anyOf": [ + { + "$ref": "#/$defs/Grouping" + }, + { + "type": "null" + } + ] + }, + "height": { + "description": "Bar height (default: 50)", + "type": [ + "number", + "null" + ], + "format": "float" + }, + "icon_scale": { + "description": "Scale of the icons relative to the font_size [[1.0-2.0]]. (default: 1.4)", + "type": [ + "number", + "null" + ], + "format": "float" + }, + "left_widgets": { + "description": "Options for mouse interaction on the bar\nLeft side widgets (ordered left-to-right)", + "type": "array", + "items": { + "$ref": "#/$defs/WidgetConfig" + } + }, + "margin": { + "description": "Bar margin. Use one value for all sides or use a grouped margin for horizontal and/or\nvertical definition which can each take a single value for a symmetric margin or two\nvalues for each side, i.e.:\n```json\n\"margin\": {\n \"horizontal\": 10\n}\n```\nor:\n```json\n\"margin\": {\n \"vertical\": [top, bottom]\n}\n```\nYou can also set individual margin on each side like this:\n```json\n\"margin\": {\n \"top\": 10,\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n}\n```\nBy default, margin is set to 0 on all sides.", + "anyOf": [ + { + "$ref": "#/$defs/SpacingKind" + }, + { + "type": "null" + } + ] + }, + "max_label_width": { + "description": "Max label width before text truncation (default: 400.0)", + "type": [ + "number", + "null" + ], + "format": "float" + }, + "monitor": { + "description": "The monitor index or the full monitor options", + "$ref": "#/$defs/MonitorConfigOrIndex" + }, + "padding": { + "description": "Bar padding. Use one value for all sides or use a grouped padding for horizontal and/or\nvertical definition which can each take a single value for a symmetric padding or two\nvalues for each side, i.e.:\n```json\n\"padding\": {\n \"horizontal\": 10\n}\n```\nor:\n```json\n\"padding\": {\n \"horizontal\": [left, right]\n}\n```\nYou can also set individual padding on each side like this:\n```json\n\"padding\": {\n \"top\": 10,\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n}\n```\nBy default, padding is set to 10 on all sides.", + "anyOf": [ + { + "$ref": "#/$defs/SpacingKind" + }, + { + "type": "null" + } + ] + }, + "position": { + "description": "Bar positioning options", + "anyOf": [ + { + "$ref": "#/$defs/PositionConfig" + }, + { + "type": "null" + } + ] + }, + "right_widgets": { + "description": "Right side widgets (ordered left-to-right)", + "type": "array", + "items": { + "$ref": "#/$defs/WidgetConfig" + } + }, + "theme": { + "description": "Theme", + "anyOf": [ + { + "$ref": "#/$defs/KomobarTheme" + }, + { + "type": "null" + } + ] + }, + "transparency_alpha": { + "description": "Alpha value for the color transparency [[0-255]] (default: 200)", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + }, + "widget_spacing": { + "description": "Spacing between widgets (default: 10.0)", + "type": [ + "number", + "null" + ], + "format": "float" + } + }, + "required": [ + "monitor", + "left_widgets", + "right_widgets" + ], + "$defs": { + "AppConfig": { + "type": "object", + "properties": { + "command": { + "description": "Command to execute (e.g. path to the application or shell command).", + "type": "string" + }, + "display": { + "description": "Display format for this application button (optional). Overrides global format if set.", + "anyOf": [ + { + "$ref": "#/$defs/DisplayFormat" + }, + { + "type": "null" + } + ] + }, + "enable": { + "description": "Whether to enable this application button (optional).\nInherits from the global `Applications` setting if omitted.", + "type": [ + "boolean", + "null" + ] + }, + "icon": { + "description": "Optional icon: a path to an image or a text-based glyph (e.g., from Nerd Fonts).\nIf not set, and if the `command` is a path to an executable, an icon might be extracted from it.\nNote: glyphs require a compatible `font_family`.", + "type": [ + "string", + "null" + ] + }, + "name": { + "description": "Display name of the application.", + "type": "string" + }, + "show_command_on_hover": { + "description": "Whether to show the launch command on hover (optional).\nInherits from the global `Applications` setting if omitted.", + "type": [ + "boolean", + "null" + ] + } + }, + "required": [ + "name", + "command" + ] + }, + "ApplicationsConfig": { + "type": "object", + "properties": { + "display": { + "description": "Default display format for all applications (optional).\nCould be overridden per application. Defaults to `Icon`.", + "anyOf": [ + { + "$ref": "#/$defs/DisplayFormat" + }, + { + "type": "null" + } + ] + }, + "enable": { + "description": "Enables or disables the applications widget.", + "type": "boolean" + }, + "items": { + "description": "List of configured applications to display.", + "type": "array", + "items": { + "$ref": "#/$defs/AppConfig" + } + }, + "show_command_on_hover": { + "description": "Whether to show the launch command on hover (optional).\nCould be overridden per application. Defaults to `false` if not set.", + "type": [ + "boolean", + "null" + ] + }, + "spacing": { + "description": "Horizontal spacing between application buttons.", + "type": [ + "number", + "null" + ], + "format": "float" + } + }, + "required": [ + "enable", + "items" + ] + }, + "Base16": { + "type": "string", + "enum": [ + "3024", + "Apathy", + "Apprentice", + "Ashes", + "AtelierCaveLight", + "AtelierCave", + "AtelierDuneLight", + "AtelierDune", + "AtelierEstuaryLight", + "AtelierEstuary", + "AtelierForestLight", + "AtelierForest", + "AtelierHeathLight", + "AtelierHeath", + "AtelierLakesideLight", + "AtelierLakeside", + "AtelierPlateauLight", + "AtelierPlateau", + "AtelierSavannaLight", + "AtelierSavanna", + "AtelierSeasideLight", + "AtelierSeaside", + "AtelierSulphurpoolLight", + "AtelierSulphurpool", + "Atlas", + "AyuDark", + "AyuLight", + "AyuMirage", + "Aztec", + "Bespin", + "BlackMetalBathory", + "BlackMetalBurzum", + "BlackMetalDarkFuneral", + "BlackMetalGorgoroth", + "BlackMetalImmortal", + "BlackMetalKhold", + "BlackMetalMarduk", + "BlackMetalMayhem", + "BlackMetalNile", + "BlackMetalVenom", + "BlackMetal", + "Blueforest", + "Blueish", + "Brewer", + "Bright", + "Brogrammer", + "BrushtreesDark", + "Brushtrees", + "Caroline", + "CatppuccinFrappe", + "CatppuccinLatte", + "CatppuccinMacchiato", + "CatppuccinMocha", + "Chalk", + "Circus", + "ClassicDark", + "ClassicLight", + "Codeschool", + "Colors", + "Cupcake", + "Cupertino", + "DaOneBlack", + "DaOneGray", + "DaOneOcean", + "DaOnePaper", + "DaOneSea", + "DaOneWhite", + "DanqingLight", + "Danqing", + "Darcula", + "Darkmoss", + "Darktooth", + "Darkviolet", + "Decaf", + "DefaultDark", + "DefaultLight", + "Dirtysea", + "Dracula", + "EdgeDark", + "EdgeLight", + "Eighties", + "EmbersLight", + "Embers", + "Emil", + "EquilibriumDark", + "EquilibriumGrayDark", + "EquilibriumGrayLight", + "EquilibriumLight", + "Eris", + "Espresso", + "EvaDim", + "Eva", + "EvenokDark", + "EverforestDarkHard", + "Everforest", + "Flat", + "Framer", + "FruitSoda", + "Gigavolt", + "Github", + "GoogleDark", + "GoogleLight", + "Gotham", + "GrayscaleDark", + "GrayscaleLight", + "Greenscreen", + "Gruber", + "GruvboxDarkHard", + "GruvboxDarkMedium", + "GruvboxDarkPale", + "GruvboxDarkSoft", + "GruvboxLightHard", + "GruvboxLightMedium", + "GruvboxLightSoft", + "GruvboxMaterialDarkHard", + "GruvboxMaterialDarkMedium", + "GruvboxMaterialDarkSoft", + "GruvboxMaterialLightHard", + "GruvboxMaterialLightMedium", + "GruvboxMaterialLightSoft", + "Hardcore", + "Harmonic16Dark", + "Harmonic16Light", + "HeetchLight", + "Heetch", + "Helios", + "Hopscotch", + "HorizonDark", + "HorizonLight", + "HorizonTerminalDark", + "HorizonTerminalLight", + "HumanoidDark", + "HumanoidLight", + "IaDark", + "IaLight", + "Icy", + "Irblack", + "Isotope", + "Jabuti", + "Kanagawa", + "Katy", + "Kimber", + "Lime", + "Macintosh", + "Marrakesh", + "Materia", + "MaterialDarker", + "MaterialLighter", + "MaterialPalenight", + "MaterialVivid", + "Material", + "MeasuredDark", + "MeasuredLight", + "MellowPurple", + "MexicoLight", + "Mocha", + "Monokai", + "Moonlight", + "Mountain", + "Nebula", + "NordLight", + "Nord", + "Nova", + "Ocean", + "Oceanicnext", + "OneLight", + "OnedarkDark", + "Onedark", + "OutrunDark", + "OxocarbonDark", + "OxocarbonLight", + "Pandora", + "PapercolorDark", + "PapercolorLight", + "Paraiso", + "Pasque", + "Phd", + "Pico", + "Pinky", + "Pop", + "Porple", + "PreciousDarkEleven", + "PreciousDarkFifteen", + "PreciousLightWarm", + "PreciousLightWhite", + "PrimerDarkDimmed", + "PrimerDark", + "PrimerLight", + "Purpledream", + "Qualia", + "Railscasts", + "Rebecca", + "RosePineDawn", + "RosePineMoon", + "RosePine", + "Saga", + "Sagelight", + "Sakura", + "Sandcastle", + "SelenizedBlack", + "SelenizedDark", + "SelenizedLight", + "SelenizedWhite", + "Seti", + "ShadesOfPurple", + "ShadesmearDark", + "ShadesmearLight", + "Shapeshifter", + "SilkDark", + "SilkLight", + "Snazzy", + "SolarflareLight", + "Solarflare", + "SolarizedDark", + "SolarizedLight", + "Spaceduck", + "Spacemacs", + "Sparky", + "StandardizedDark", + "StandardizedLight", + "Stella", + "StillAlive", + "Summercamp", + "SummerfruitDark", + "SummerfruitLight", + "SynthMidnightDark", + "SynthMidnightLight", + "Tango", + "Tarot", + "Tender", + "TerracottaDark", + "Terracotta", + "TokyoCityDark", + "TokyoCityLight", + "TokyoCityTerminalDark", + "TokyoCityTerminalLight", + "TokyoNightDark", + "TokyoNightLight", + "TokyoNightMoon", + "TokyoNightStorm", + "TokyoNightTerminalDark", + "TokyoNightTerminalLight", + "TokyoNightTerminalStorm", + "TokyodarkTerminal", + "Tokyodark", + "TomorrowNightEighties", + "TomorrowNight", + "Tomorrow", + "Tube", + "Twilight", + "UnikittyDark", + "UnikittyLight", + "UnikittyReversible", + "Uwunicorn", + "Vesper", + "Vice", + "Vulcan", + "Windows10Light", + "Windows10", + "Windows95Light", + "Windows95", + "WindowsHighcontrastLight", + "WindowsHighcontrast", + "WindowsNtLight", + "WindowsNt", + "Woodland", + "XcodeDusk", + "Zenbones", + "Zenburn" + ] + }, + "Base16ColourPalette": { + "type": "object", + "properties": { + "base_00": { + "$ref": "#/$defs/Colour" + }, + "base_01": { + "$ref": "#/$defs/Colour" + }, + "base_02": { + "$ref": "#/$defs/Colour" + }, + "base_03": { + "$ref": "#/$defs/Colour" + }, + "base_04": { + "$ref": "#/$defs/Colour" + }, + "base_05": { + "$ref": "#/$defs/Colour" + }, + "base_06": { + "$ref": "#/$defs/Colour" + }, + "base_07": { + "$ref": "#/$defs/Colour" + }, + "base_08": { + "$ref": "#/$defs/Colour" + }, + "base_09": { + "$ref": "#/$defs/Colour" + }, + "base_0a": { + "$ref": "#/$defs/Colour" + }, + "base_0b": { + "$ref": "#/$defs/Colour" + }, + "base_0c": { + "$ref": "#/$defs/Colour" + }, + "base_0d": { + "$ref": "#/$defs/Colour" + }, + "base_0e": { + "$ref": "#/$defs/Colour" + }, + "base_0f": { + "$ref": "#/$defs/Colour" + } + }, + "required": [ + "base_00", + "base_01", + "base_02", + "base_03", + "base_04", + "base_05", + "base_06", + "base_07", + "base_08", + "base_09", + "base_0a", + "base_0b", + "base_0c", + "base_0d", + "base_0e", + "base_0f" + ] + }, + "Base16Value": { + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "BatteryConfig": { + "type": "object", + "properties": { + "auto_select_under": { + "description": "Select when the current percentage is under this value [[1-100]]", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + }, + "data_refresh_interval": { + "description": "Data refresh interval (default: 10 seconds)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "enable": { + "description": "Enable the Battery widget", + "type": "boolean" + }, + "hide_on_full_charge": { + "description": "Hide the widget if the battery is at full charge", + "type": [ + "boolean", + "null" + ] + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "enable" + ] + }, + "Catppuccin": { + "type": "string", + "enum": [ + "Frappe", + "Latte", + "Macchiato", + "Mocha" + ] + }, + "CatppuccinValue": { + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "Colour": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "$ref": "#/$defs/Rgb" + }, + { + "description": "Colour represented as Hex", + "$ref": "#/$defs/Hex" + } + ] + }, + "CpuConfig": { + "type": "object", + "properties": { + "auto_select_over": { + "description": "Select when the current percentage is over this value [[1-100]]", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + }, + "data_refresh_interval": { + "description": "Data refresh interval (default: 10 seconds)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "enable": { + "description": "Enable the Cpu widget", + "type": "boolean" + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "enable" + ] + }, + "CustomModifiers": { + "description": "Custom format with additive modifiers for integer format specifiers", + "type": "object", + "properties": { + "format": { + "description": "Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html)", + "type": "string" + }, + "modifiers": { + "description": "Additive modifiers for integer format specifiers (e.g. { \"%U\": 1 } to increment the zero-indexed week number by 1)", + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int32" + } + } + }, + "required": [ + "format", + "modifiers" + ] + }, + "DateConfig": { + "type": "object", + "properties": { + "enable": { + "description": "Enable the Date widget", + "type": "boolean" + }, + "format": { + "description": "Set the Date format", + "$ref": "#/$defs/DateFormat" + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + }, + "timezone": { + "description": "TimeZone (https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html)\n\nUse a custom format to display additional information, i.e.:\n```json\n{\n \"Date\": {\n \"enable\": true,\n \"format\": { \"Custom\": \"%D %Z (Tokyo)\" },\n \"timezone\": \"Asia/Tokyo\"\n }\n}\n```", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "enable", + "format" + ] + }, + "DateFormat": { + "oneOf": [ + { + "description": "Month/Date/Year format (09/08/24)", + "type": "string", + "const": "MonthDateYear" + }, + { + "description": "Year-Month-Date format (2024-09-08)", + "type": "string", + "const": "YearMonthDate" + }, + { + "description": "Date-Month-Year format (8-Sep-2024)", + "type": "string", + "const": "DateMonthYear" + }, + { + "description": "Day Date Month Year format (8 September 2024)", + "type": "string", + "const": "DayDateMonthYear" + }, + { + "description": "Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html)", + "type": "object", + "properties": { + "Custom": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "Custom" + ] + }, + { + "description": "Custom format with modifiers", + "type": "object", + "properties": { + "CustomModifiers": { + "$ref": "#/$defs/CustomModifiers" + } + }, + "additionalProperties": false, + "required": [ + "CustomModifiers" + ] + } + ] + }, + "DefaultLayout": { + "type": "string", + "enum": [ + "BSP", + "Columns", + "Rows", + "VerticalStack", + "HorizontalStack", + "UltrawideVerticalStack", + "Grid", + "RightMainVerticalStack", + "Scrolling" + ] + }, + "DisplayFormat": { + "oneOf": [ + { + "description": "Show only the application icon.", + "type": "string", + "const": "Icon" + }, + { + "description": "Show only the application name as text.", + "type": "string", + "const": "Text" + }, + { + "description": "Show both the application icon and name.", + "type": "string", + "const": "IconAndText" + } + ] + }, + "DisplayFormat2": { + "oneOf": [ + { + "description": "Show only icon", + "type": "string", + "const": "Icon" + }, + { + "description": "Show only text", + "type": "string", + "const": "Text" + }, + { + "description": "Show an icon and text for the selected element, and text on the rest", + "type": "string", + "const": "TextAndIconOnSelected" + }, + { + "description": "Show both icon and text", + "type": "string", + "const": "IconAndText" + }, + { + "description": "Show an icon and text for the selected element, and icons on the rest", + "type": "string", + "const": "IconAndTextOnSelected" + } + ] + }, + "FrameConfig": { + "type": "object", + "properties": { + "inner_margin": { + "description": "Margin inside the painted frame", + "$ref": "#/$defs/Position" + } + }, + "required": [ + "inner_margin" + ] + }, + "GroupedSpacingConfig": { + "type": "object", + "properties": { + "horizontal": { + "anyOf": [ + { + "$ref": "#/$defs/GroupedSpacingOptions" + }, + { + "type": "null" + } + ] + }, + "vertical": { + "anyOf": [ + { + "$ref": "#/$defs/GroupedSpacingOptions" + }, + { + "type": "null" + } + ] + } + } + }, + "GroupedSpacingOptions": { + "anyOf": [ + { + "type": "number", + "format": "float" + }, + { + "type": "array", + "maxItems": 2, + "minItems": 2, + "prefixItems": [ + { + "type": "number", + "format": "float" + }, + { + "type": "number", + "format": "float" + } + ] + } + ] + }, + "Grouping": { + "oneOf": [ + { + "description": "No grouping is applied", + "type": "object", + "properties": { + "kind": { + "type": "string", + "const": "None" + } + }, + "required": [ + "kind" + ] + }, + { + "description": "Widgets are grouped as a whole", + "type": "object", + "properties": { + "kind": { + "type": "string", + "const": "Bar" + } + }, + "$ref": "#/$defs/GroupingConfig", + "required": [ + "kind" + ] + }, + { + "description": "Widgets are grouped by alignment", + "type": "object", + "properties": { + "kind": { + "type": "string", + "const": "Alignment" + } + }, + "$ref": "#/$defs/GroupingConfig", + "required": [ + "kind" + ] + }, + { + "description": "Widgets are grouped individually", + "type": "object", + "properties": { + "kind": { + "type": "string", + "const": "Widget" + } + }, + "$ref": "#/$defs/GroupingConfig", + "required": [ + "kind" + ] + } + ] + }, + "GroupingConfig": { + "type": "object", + "properties": { + "rounding": { + "description": "Rounding values for the 4 corners. Can be a single or 4 values.", + "anyOf": [ + { + "$ref": "#/$defs/RoundingConfig" + }, + { + "type": "null" + } + ] + }, + "style": { + "description": "Styles for the grouping", + "anyOf": [ + { + "$ref": "#/$defs/GroupingStyle" + }, + { + "type": "null" + } + ] + }, + "transparency_alpha": { + "description": "Alpha value for the color transparency [[0-255]] (default: 200)", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + } + } + }, + "GroupingStyle": { + "oneOf": [ + { + "type": "string", + "enum": [ + "Default" + ] + }, + { + "description": "A shadow is added under the default group. (blur: 4, offset: x-1 y-1, spread: 3)", + "type": "string", + "const": "DefaultWithShadowB4O1S3" + }, + { + "description": "A shadow is added under the default group. (blur: 4, offset: x-0 y-0, spread: 3)", + "type": "string", + "const": "DefaultWithShadowB4O0S3" + }, + { + "description": "A shadow is added under the default group. (blur: 0, offset: x-1 y-1, spread: 3)", + "type": "string", + "const": "DefaultWithShadowB0O1S3" + }, + { + "description": "A glow is added under the default group. (blur: 3, offset: x-1 y-1, spread: 2)", + "type": "string", + "const": "DefaultWithGlowB3O1S2" + }, + { + "description": "A glow is added under the default group. (blur: 3, offset: x-0 y-0, spread: 2)", + "type": "string", + "const": "DefaultWithGlowB3O0S2" + }, + { + "description": "A glow is added under the default group. (blur: 0, offset: x-1 y-1, spread: 2)", + "type": "string", + "const": "DefaultWithGlowB0O1S2" + } + ] + }, + "Hex": { + "type": "string", + "format": "color-hex" + }, + "IndividualSpacingConfig": { + "type": "object", + "properties": { + "bottom": { + "type": "number", + "format": "float" + }, + "left": { + "type": "number", + "format": "float" + }, + "right": { + "type": "number", + "format": "float" + }, + "top": { + "type": "number", + "format": "float" + } + }, + "required": [ + "top", + "bottom", + "left", + "right" + ] + }, + "KomobarTheme": { + "oneOf": [ + { + "description": "A theme from catppuccin-egui", + "type": "object", + "properties": { + "accent": { + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "auto_select_fill": { + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "auto_select_text": { + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "name": { + "description": "Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)", + "$ref": "#/$defs/Catppuccin" + }, + "palette": { + "type": "string", + "const": "Catppuccin" + } + }, + "required": [ + "palette", + "name" + ] + }, + { + "description": "A theme from base16-egui-themes", + "type": "object", + "properties": { + "accent": { + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "auto_select_fill": { + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "auto_select_text": { + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "name": { + "description": "Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)", + "$ref": "#/$defs/Base16" + }, + "palette": { + "type": "string", + "const": "Base16" + } + }, + "required": [ + "palette", + "name" + ] + }, + { + "description": "A custom Base16 theme", + "type": "object", + "properties": { + "accent": { + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "auto_select_fill": { + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "auto_select_text": { + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "colours": { + "description": "Colours of the custom Base16 theme palette", + "$ref": "#/$defs/Base16ColourPalette" + }, + "palette": { + "type": "string", + "const": "Custom" + } + }, + "required": [ + "palette", + "colours" + ] + } + ] + }, + "KomorebiConfig": { + "type": "object", + "properties": { + "configuration_switcher": { + "description": "Configure the Configuration Switcher widget", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiConfigurationSwitcherConfig" + }, + { + "type": "null" + } + ] + }, + "focused_container": { + "description": "Configure the Focused Container widget", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiFocusedContainerConfig" + }, + { + "type": "null" + } + ] + }, + "layout": { + "description": "Configure the Layout widget", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiLayoutConfig" + }, + { + "type": "null" + } + ] + }, + "locked_container": { + "description": "Configure the Locked Container widget", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiLockedContainerConfig" + }, + { + "type": "null" + } + ] + }, + "workspace_layer": { + "description": "Configure the Workspace Layer widget", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiWorkspaceLayerConfig" + }, + { + "type": "null" + } + ] + }, + "workspaces": { + "description": "Configure the Workspaces widget", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiWorkspacesConfig" + }, + { + "type": "null" + } + ] + } + } + }, + "KomorebiConfigurationSwitcherConfig": { + "type": "object", + "properties": { + "configurations": { + "description": "A map of display friendly name => path to configuration.json", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "enable": { + "description": "Enable the Komorebi Configurations widget", + "type": "boolean" + } + }, + "required": [ + "enable", + "configurations" + ] + }, + "KomorebiFocusedContainerConfig": { + "type": "object", + "properties": { + "display": { + "description": "Display format of the currently focused container", + "anyOf": [ + { + "$ref": "#/$defs/DisplayFormat2" + }, + { + "type": "null" + } + ] + }, + "enable": { + "description": "Enable the Komorebi Focused Container widget", + "type": "boolean" + }, + "show_icon": { + "description": "DEPRECATED: use 'display' instead (Show the icon of the currently focused container)", + "type": [ + "boolean", + "null" + ] + } + }, + "required": [ + "enable" + ] + }, + "KomorebiLayout": { + "anyOf": [ + { + "$ref": "#/$defs/DefaultLayout" + }, + { + "type": "null" + }, + { + "type": "null" + }, + { + "type": "null" + }, + { + "type": "null" + } + ] + }, + "KomorebiLayoutConfig": { + "type": "object", + "properties": { + "display": { + "description": "Display format of the current layout", + "anyOf": [ + { + "$ref": "#/$defs/DisplayFormat2" + }, + { + "type": "null" + } + ] + }, + "enable": { + "description": "Enable the Komorebi Layout widget", + "type": "boolean" + }, + "options": { + "description": "List of layout options", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/KomorebiLayout" + } + } + }, + "required": [ + "enable" + ] + }, + "KomorebiLockedContainerConfig": { + "type": "object", + "properties": { + "display": { + "description": "Display format of the current locked state", + "anyOf": [ + { + "$ref": "#/$defs/DisplayFormat2" + }, + { + "type": "null" + } + ] + }, + "enable": { + "description": "Enable the Komorebi Locked Container widget", + "type": "boolean" + }, + "show_when_unlocked": { + "description": "Show the widget event if the layer is unlocked", + "type": [ + "boolean", + "null" + ] + } + }, + "required": [ + "enable" + ] + }, + "KomorebiWorkspaceLayerConfig": { + "type": "object", + "properties": { + "display": { + "description": "Display format of the current layer", + "anyOf": [ + { + "$ref": "#/$defs/DisplayFormat2" + }, + { + "type": "null" + } + ] + }, + "enable": { + "description": "Enable the Komorebi Workspace Layer widget", + "type": "boolean" + }, + "show_when_tiling": { + "description": "Show the widget event if the layer is Tiling", + "type": [ + "boolean", + "null" + ] + } + }, + "required": [ + "enable" + ] + }, + "KomorebiWorkspacesConfig": { + "type": "object", + "properties": { + "display": { + "description": "Display format of the workspace", + "anyOf": [ + { + "$ref": "#/$defs/WorkspacesDisplayFormat" + }, + { + "type": "null" + } + ] + }, + "enable": { + "description": "Enable the Komorebi Workspaces widget", + "type": "boolean" + }, + "hide_empty_workspaces": { + "description": "Hide workspaces without any windows", + "type": "boolean" + } + }, + "required": [ + "enable", + "hide_empty_workspaces" + ] + }, + "LabelPrefix": { + "oneOf": [ + { + "description": "Show no prefix", + "type": "string", + "const": "None" + }, + { + "description": "Show an icon", + "type": "string", + "const": "Icon" + }, + { + "description": "Show text", + "type": "string", + "const": "Text" + }, + { + "description": "Show an icon and text", + "type": "string", + "const": "IconAndText" + } + ] + }, + "MemoryConfig": { + "type": "object", + "properties": { + "auto_select_over": { + "description": "Select when the current percentage is over this value [[1-100]]", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + }, + "data_refresh_interval": { + "description": "Data refresh interval (default: 10 seconds)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "enable": { + "description": "Enable the Memory widget", + "type": "boolean" + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "enable" + ] + }, + "MonitorConfig": { + "type": "object", + "properties": { + "index": { + "description": "Komorebi monitor index of the monitor on which to render the bar", + "type": "integer", + "format": "uint", + "minimum": 0 + }, + "work_area_offset": { + "description": "Automatically apply a work area offset for this monitor to accommodate the bar", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "index" + ] + }, + "MonitorConfigOrIndex": { + "anyOf": [ + { + "description": "The monitor index where you want the bar to show", + "type": "integer", + "format": "uint", + "minimum": 0 + }, + { + "description": "The full monitor options with the index and an optional work_area_offset", + "$ref": "#/$defs/MonitorConfig" + } + ] + }, + "NetworkConfig": { + "type": "object", + "properties": { + "activity_left_padding": { + "description": "Characters to reserve for received and transmitted activity", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 0 + }, + "auto_select": { + "description": "Select when the value is over a limit (1MiB is 1048576 bytes (1024*1024))", + "anyOf": [ + { + "$ref": "#/$defs/NetworkSelectConfig" + }, + { + "type": "null" + } + ] + }, + "data_refresh_interval": { + "description": "Data refresh interval (default: 10 seconds)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "enable": { + "description": "Enable the Network widget", + "type": "boolean" + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + }, + "show_activity": { + "description": "Show received and transmitted activity", + "type": "boolean" + }, + "show_default_interface": { + "description": "Show default interface", + "type": [ + "boolean", + "null" + ] + }, + "show_total_activity": { + "description": "Show total received and transmitted activity", + "type": "boolean" + } + }, + "required": [ + "enable", + "show_total_activity", + "show_activity" + ] + }, + "NetworkSelectConfig": { + "type": "object", + "properties": { + "received_over": { + "description": "Select the received data when it's over this value", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "total_received_over": { + "description": "Select the total received data when it's over this value", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "total_transmitted_over": { + "description": "Select the total transmitted data when it's over this value", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "transmitted_over": { + "description": "Select the transmitted data when it's over this value", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + } + } + }, + "Position": { + "type": "object", + "properties": { + "x": { + "description": "X coordinate", + "type": "number", + "format": "float" + }, + "y": { + "description": "Y coordinate", + "type": "number", + "format": "float" + } + }, + "required": [ + "x", + "y" + ] + }, + "PositionConfig": { + "type": "object", + "properties": { + "end": { + "description": "The desired size of the bar from the starting position (usually monitor width x desired height)", + "anyOf": [ + { + "$ref": "#/$defs/Position" + }, + { + "type": "null" + } + ] + }, + "start": { + "description": "The desired starting position of the bar (0,0 = top left of the screen)", + "anyOf": [ + { + "$ref": "#/$defs/Position" + }, + { + "type": "null" + } + ] + } + } + }, + "Rect": { + "type": "object", + "properties": { + "bottom": { + "type": "integer", + "format": "int32" + }, + "left": { + "type": "integer", + "format": "int32" + }, + "right": { + "type": "integer", + "format": "int32" + }, + "top": { + "type": "integer", + "format": "int32" + } + }, + "required": [ + "left", + "top", + "right", + "bottom" + ] + }, + "Rgb": { + "type": "object", + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0 + } + }, + "required": [ + "r", + "g", + "b" + ] + }, + "RoundingConfig": { + "anyOf": [ + { + "description": "All 4 corners are the same", + "type": "number", + "format": "float" + }, + { + "description": "All 4 corners are custom. Order: NW, NE, SW, SE", + "type": "array", + "items": { + "type": "number", + "format": "float" + }, + "maxItems": 4, + "minItems": 4 + } + ] + }, + "SpacingKind": { + "anyOf": [ + { + "type": "number", + "format": "float" + }, + { + "$ref": "#/$defs/IndividualSpacingConfig" + }, + { + "$ref": "#/$defs/GroupedSpacingConfig" + } + ] + }, + "StorageConfig": { + "type": "object", + "properties": { + "auto_hide_under": { + "description": "Hide when the current percentage is under this value [[1-100]]", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + }, + "auto_select_over": { + "description": "Select when the current percentage is over this value [[1-100]]", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + }, + "data_refresh_interval": { + "description": "Data refresh interval (default: 10 seconds)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "enable": { + "description": "Enable the Storage widget", + "type": "boolean" + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + }, + "show_read_only_disks": { + "description": "Show disks that are read only. (default: false)", + "type": [ + "boolean", + "null" + ] + }, + "show_removable_disks": { + "description": "Show removable disks. (default: true)", + "type": [ + "boolean", + "null" + ] + } + }, + "required": [ + "enable" + ] + }, + "TimeConfig": { + "type": "object", + "properties": { + "changing_icon": { + "description": "Change the icon depending on the time. The default icon is used between 8:30 and 12:00. (default: false)", + "type": [ + "boolean", + "null" + ] + }, + "enable": { + "description": "Enable the Time widget", + "type": "boolean" + }, + "format": { + "description": "Set the Time format", + "$ref": "#/$defs/TimeFormat" + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + }, + "timezone": { + "description": "TimeZone (https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html)\n\nUse a custom format to display additional information, i.e.:\n```json\n{\n \"Time\": {\n \"enable\": true,\n \"format\": { \"Custom\": \"%T %Z (Tokyo)\" },\n \"timezone\": \"Asia/Tokyo\"\n }\n}\n```", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "enable", + "format" + ] + }, + "TimeFormat": { + "oneOf": [ + { + "description": "Twelve-hour format (with seconds)", + "type": "string", + "const": "TwelveHour" + }, + { + "description": "Twelve-hour format (without seconds)", + "type": "string", + "const": "TwelveHourWithoutSeconds" + }, + { + "description": "Twenty-four-hour format (with seconds)", + "type": "string", + "const": "TwentyFourHour" + }, + { + "description": "Twenty-four-hour format (without seconds)", + "type": "string", + "const": "TwentyFourHourWithoutSeconds" + }, + { + "description": "Twenty-four-hour format displayed as a binary clock with circles (with seconds) (https://en.wikipedia.org/wiki/Binary_clock)", + "type": "string", + "const": "BinaryCircle" + }, + { + "description": "Twenty-four-hour format displayed as a binary clock with rectangles (with seconds) (https://en.wikipedia.org/wiki/Binary_clock)", + "type": "string", + "const": "BinaryRectangle" + }, + { + "description": "Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html)", + "type": "object", + "properties": { + "Custom": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "Custom" + ] + } + ] + }, + "UpdateConfig": { + "type": "object", + "properties": { + "data_refresh_interval": { + "description": "Data refresh interval (default: 12 hours)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "enable": { + "description": "Enable the Update widget", + "type": "boolean" + }, + "label_prefix": { + "description": "Display label prefix", + "anyOf": [ + { + "$ref": "#/$defs/LabelPrefix" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "enable" + ] + }, + "WidgetConfig": { + "oneOf": [ + { + "type": "object", + "properties": { + "Applications": { + "$ref": "#/$defs/ApplicationsConfig" + } + }, + "additionalProperties": false, + "required": [ + "Applications" + ] + }, + { + "type": "object", + "properties": { + "Battery": { + "$ref": "#/$defs/BatteryConfig" + } + }, + "additionalProperties": false, + "required": [ + "Battery" + ] + }, + { + "type": "object", + "properties": { + "Cpu": { + "$ref": "#/$defs/CpuConfig" + } + }, + "additionalProperties": false, + "required": [ + "Cpu" + ] + }, + { + "type": "object", + "properties": { + "Date": { + "$ref": "#/$defs/DateConfig" + } + }, + "additionalProperties": false, + "required": [ + "Date" + ] + }, + { + "type": "object", + "properties": { + "Komorebi": { + "$ref": "#/$defs/KomorebiConfig" + } + }, + "additionalProperties": false, + "required": [ + "Komorebi" + ] + }, + { + "type": "object", + "properties": { + "Memory": { + "$ref": "#/$defs/MemoryConfig" + } + }, + "additionalProperties": false, + "required": [ + "Memory" + ] + }, + { + "type": "object", + "properties": { + "Network": { + "$ref": "#/$defs/NetworkConfig" + } + }, + "additionalProperties": false, + "required": [ + "Network" + ] + }, + { + "type": "object", + "properties": { + "Storage": { + "$ref": "#/$defs/StorageConfig" + } + }, + "additionalProperties": false, + "required": [ + "Storage" + ] + }, + { + "type": "object", + "properties": { + "Time": { + "$ref": "#/$defs/TimeConfig" + } + }, + "additionalProperties": false, + "required": [ + "Time" + ] + }, + { + "type": "object", + "properties": { + "Update": { + "$ref": "#/$defs/UpdateConfig" + } + }, + "additionalProperties": false, + "required": [ + "Update" + ] + } + ] + }, + "WorkspacesDisplayFormat": { + "anyOf": [ + { + "description": "Show all icons only", + "type": "string", + "const": "AllIcons" + }, + { + "description": "Show both all icons and text", + "type": "string", + "const": "AllIconsAndText" + }, + { + "description": "Show all icons and text for the selected element, and all icons on the rest", + "type": "string", + "const": "AllIconsAndTextOnSelected" + }, + { + "$ref": "#/$defs/DisplayFormat2" + } + ] + } + } +} diff --git a/schema.json b/schema.json index c8cba531..ffec640c 100644 --- a/schema.json +++ b/schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "StaticConfig", - "description": "The `komorebi.json` static configuration file reference for `v0.1.39`", + "description": "The `komorebi.json` static configuration file reference for komorebi for Mac `v0.1.0`\n\n`\"$schema\": \"https://komorebi-for-mac.lgug2z.com/komorebi.0.1.0.schema.json\"`", "type": "object", "properties": { "app_specific_configuration_path": { diff --git a/shell.nix b/shell.nix index 6ea338e5..94032484 100644 --- a/shell.nix +++ b/shell.nix @@ -14,6 +14,7 @@ mkShell { jq just prettier + wrangler python311Packages.mkdocs-material python311Packages.mkdocs-macros From f6bfae31034095b80ffce8a22c2be2179fe42d2f Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Dec 2025 17:07:56 -0800 Subject: [PATCH 179/305] docs(schema): avoid duplicating display format enums in bar This commit also addresses some clippy warnings. --- komorebi-bar/src/widgets/applications.rs | 14 +++---- komorebi/src/workspace.rs | 14 +++---- schema.bar.json | 52 ++++++++++++------------ 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/komorebi-bar/src/widgets/applications.rs b/komorebi-bar/src/widgets/applications.rs index 2bdbae1e..4a01fe48 100644 --- a/komorebi-bar/src/widgets/applications.rs +++ b/komorebi-bar/src/widgets/applications.rs @@ -41,7 +41,7 @@ pub struct ApplicationsConfig { pub spacing: Option, /// Default display format for all applications (optional). /// Could be overridden per application. Defaults to `Icon`. - pub display: Option, + pub display: Option, /// List of configured applications to display. pub items: Vec, } @@ -64,12 +64,12 @@ pub struct AppConfig { /// Command to execute (e.g. path to the application or shell command). pub command: String, /// Display format for this application button (optional). Overrides global format if set. - pub display: Option, + pub display: Option, } #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Default)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -pub enum DisplayFormat { +pub enum ApplicationsDisplayFormat { /// Show only the application icon. #[default] Icon, @@ -165,7 +165,7 @@ pub struct App { /// Command to execute when the application is launched. pub command: UserCommand, /// Display format (icon, text, or both). - pub display: DisplayFormat, + pub display: ApplicationsDisplayFormat, /// Whether to show the launch command on hover. pub show_command_on_hover: bool, } @@ -180,9 +180,9 @@ impl App { ui.spacing_mut().item_spacing = Vec2::splat(4.0); match self.display { - DisplayFormat::Icon => self.draw_icon(ctx, ui, icon_config), - DisplayFormat::Text => self.draw_name(ui), - DisplayFormat::IconAndText => { + ApplicationsDisplayFormat::Icon => self.draw_icon(ctx, ui, icon_config), + ApplicationsDisplayFormat::Text => self.draw_name(ui), + ApplicationsDisplayFormat::IconAndText => { self.draw_icon(ctx, ui, icon_config); self.draw_name(ui); } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index cfd4d59c..246e4481 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1497,7 +1497,7 @@ impl Workspace { 0 | 1 => self.enforce_no_resize(), _ => { // Zero is actually on the left - if let Some(mut left) = resize_dimensions[0] { + if let Some(left) = resize_dimensions[0].as_mut() { left.top = 0; left.bottom = 0; left.left = 0; @@ -1530,7 +1530,7 @@ impl Workspace { 0 | 1 => self.enforce_no_resize(), _ => { // Zero is actually on the right - if let Some(mut left) = resize_dimensions[1] { + if let Some(left) = resize_dimensions[1].as_mut() { left.top = 0; left.bottom = 0; left.right = 0; @@ -1561,7 +1561,7 @@ impl Workspace { match resize_dimensions.len() { 0 | 1 => self.enforce_no_resize(), _ => { - if let Some(mut left) = resize_dimensions[0] { + if let Some(left) = resize_dimensions[0].as_mut() { left.top = 0; left.left = 0; left.right = 0; @@ -1592,14 +1592,14 @@ impl Workspace { // Two windows can only be resized in the middle 2 => { // Zero is actually on the right - if let Some(mut right) = resize_dimensions[0] { + if let Some(right) = resize_dimensions[0].as_mut() { right.top = 0; right.bottom = 0; right.right = 0; } // One is on the left - if let Some(mut left) = resize_dimensions[1] { + if let Some(left) = resize_dimensions[1].as_mut() { left.top = 0; left.bottom = 0; left.left = 0; @@ -1609,13 +1609,13 @@ impl Workspace { // stack on the right _ => { // Central can be resized left or right - if let Some(mut right) = resize_dimensions[0] { + if let Some(right) = resize_dimensions[0].as_mut() { right.top = 0; right.bottom = 0; } // Left one can only be resized to the right - if let Some(mut left) = resize_dimensions[1] { + if let Some(left) = resize_dimensions[1].as_mut() { left.top = 0; left.bottom = 0; left.left = 0; diff --git a/schema.bar.json b/schema.bar.json index f702adbe..7f066088 100644 --- a/schema.bar.json +++ b/schema.bar.json @@ -173,7 +173,7 @@ "description": "Display format for this application button (optional). Overrides global format if set.", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat" + "$ref": "#/$defs/ApplicationsDisplayFormat" }, { "type": "null" @@ -218,7 +218,7 @@ "description": "Default display format for all applications (optional).\nCould be overridden per application. Defaults to `Icon`.", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat" + "$ref": "#/$defs/ApplicationsDisplayFormat" }, { "type": "null" @@ -257,6 +257,25 @@ "items" ] }, + "ApplicationsDisplayFormat": { + "oneOf": [ + { + "description": "Show only the application icon.", + "type": "string", + "const": "Icon" + }, + { + "description": "Show only the application name as text.", + "type": "string", + "const": "Text" + }, + { + "description": "Show both the application icon and name.", + "type": "string", + "const": "IconAndText" + } + ] + }, "Base16": { "type": "string", "enum": [ @@ -888,25 +907,6 @@ ] }, "DisplayFormat": { - "oneOf": [ - { - "description": "Show only the application icon.", - "type": "string", - "const": "Icon" - }, - { - "description": "Show only the application name as text.", - "type": "string", - "const": "Text" - }, - { - "description": "Show both the application icon and name.", - "type": "string", - "const": "IconAndText" - } - ] - }, - "DisplayFormat2": { "oneOf": [ { "description": "Show only icon", @@ -1408,7 +1408,7 @@ "description": "Display format of the currently focused container", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -1457,7 +1457,7 @@ "description": "Display format of the current layout", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -1490,7 +1490,7 @@ "description": "Display format of the current locked state", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -1520,7 +1520,7 @@ "description": "Display format of the current layer", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -2249,7 +2249,7 @@ "const": "AllIconsAndTextOnSelected" }, { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" } ] } From f42457e2e884df833823037df5bb1123b2c03079 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Dec 2025 18:55:50 -0800 Subject: [PATCH 180/305] feat(animation): add window movement animations This commit adds window movement animations to komorebi for macOS, maintaining configuration API compatibility with komorebi for Windows. The animation system is adapted from the Windows implementation but uses macOS-specific APIs for screen update batching and accessibility control, and borrows heavily from the implementation details of animations in rift. In order to have decent performance, there are some calls to private APIS. For this reason, the animation feature will be marked as "UNSAFE". UNSAFE features should be expected to break between major operating system updates, and depending on which way I want to go, may only support one major macOS version at a time (i.e. they will not have a backwards compatibility guarantee with previous versions of macOS). This currently look awful when used with the Scrolling layout, but looks relatively good with other layouts. As with Windows, the animations when two windows of very different sizes change position aren't great. Some high level notes on the implementation: * Uses the private SkyLight framework for screen update batching via SLSDisableUpdate/SLSReenableUpdate - these APIs prevent visual flicker by compositing all window position changes at once rather than updating each window individually during layout operations * AnimationEngine runs animations in background threads with frame-based timing, supporting cancellation when new animations are triggered for the same window * MovementRenderDispatcher implements the RenderDispatcher trait to interpolate window positions using configurable easing functions * All 30+ easing styles from the Windows implementation are supported, including standard CSS-style functions and CubicBezier for custom curves * Enhanced User Interface (AXEnhancedUserInterface) is temporarily disabled during window positioning operations for better performance * The Transparency animation prefix is not supported on macOS as there is no equivalent to the Win32 transparency feature This feature is off-by-default and can be enabled in the static config or via komorebic commands (animation, animation-duration, animation-fps, animation-style). --- docs/cli/animation-duration.md | 21 + docs/cli/animation-fps.md | 16 + docs/cli/animation-style.md | 24 + docs/cli/animation.md | 21 + komorebi-client/src/lib.rs | 2 + komorebi/build.rs | 7 + komorebi/src/accessibility/mod.rs | 48 ++ komorebi/src/accessibility/private.rs | 54 +++ komorebi/src/animation/animation_manager.rs | 115 +++++ komorebi/src/animation/engine.rs | 121 +++++ komorebi/src/animation/lerp.rs | 77 +++ komorebi/src/animation/mod.rs | 59 +++ komorebi/src/animation/prefix.rs | 21 + komorebi/src/animation/render_dispatcher.rs | 8 + komorebi/src/animation/style.rs | 507 ++++++++++++++++++++ komorebi/src/core/animation.rs | 120 +++++ komorebi/src/core/mod.rs | 11 +- komorebi/src/lib.rs | 1 + komorebi/src/process_command.rs | 42 ++ komorebi/src/skylight.rs | 13 +- komorebi/src/static_config.rs | 126 ++--- komorebi/src/window.rs | 173 +++++++ komorebi/src/workspace.rs | 120 +++-- komorebic/src/main.rs | 79 ++- mkdocs.yml | 6 +- 25 files changed, 1664 insertions(+), 128 deletions(-) create mode 100644 docs/cli/animation-duration.md create mode 100644 docs/cli/animation-fps.md create mode 100644 docs/cli/animation-style.md create mode 100644 docs/cli/animation.md create mode 100644 komorebi/build.rs create mode 100644 komorebi/src/animation/animation_manager.rs create mode 100644 komorebi/src/animation/engine.rs create mode 100644 komorebi/src/animation/lerp.rs create mode 100644 komorebi/src/animation/mod.rs create mode 100644 komorebi/src/animation/prefix.rs create mode 100644 komorebi/src/animation/render_dispatcher.rs create mode 100644 komorebi/src/animation/style.rs create mode 100644 komorebi/src/core/animation.rs diff --git a/docs/cli/animation-duration.md b/docs/cli/animation-duration.md new file mode 100644 index 00000000..dbbcb2b1 --- /dev/null +++ b/docs/cli/animation-duration.md @@ -0,0 +1,21 @@ +# animation-duration + +``` +Set the duration for movement animations in ms + +Usage: komorebic animation-duration [OPTIONS] + +Arguments: + + Desired animation durations in ms + +Options: + -a, --animation-type + Animation type to apply the duration to. If not specified, sets global duration + + [possible values: movement] + + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/animation-fps.md b/docs/cli/animation-fps.md new file mode 100644 index 00000000..c2a34d07 --- /dev/null +++ b/docs/cli/animation-fps.md @@ -0,0 +1,16 @@ +# animation-fps + +``` +Set the frames per second for movement animations + +Usage: komorebic animation-fps + +Arguments: + + Desired animation frames per second + +Options: + -h, --help + Print help + +``` \ No newline at end of file diff --git a/docs/cli/animation-style.md b/docs/cli/animation-style.md new file mode 100644 index 00000000..a8b47396 --- /dev/null +++ b/docs/cli/animation-style.md @@ -0,0 +1,24 @@ +# animation-style + +``` +Set the ease function for movement animations + +Usage: komorebic animation-style [OPTIONS] + +Options: + -s, --style