diff --git a/Cargo.lock b/Cargo.lock index 678ab4d..92d225b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "autocfg" @@ -104,7 +104,7 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "bakery" -version = "0.2.3" +version = "0.3.0" dependencies = [ "anyhow", "chrono", @@ -134,9 +134,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.13.0" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" [[package]] name = "block-buffer" @@ -149,7 +149,7 @@ dependencies = [ [[package]] name = "bread-onnx" -version = "0.2.3" +version = "0.3.0" dependencies = [ "anyhow", "bread-utils", @@ -162,9 +162,20 @@ dependencies = [ "ureq", ] +[[package]] +name = "bread-shared" +version = "0.7.0" +source = "git+https://git.breadway.dev/Breadway/bread?tag=v0.7.0#22e34e2cf2202305d7960759dfccb54dc79f948b" +dependencies = [ + "dirs", + "serde", + "serde_json", + "toml 0.8.23", +] + [[package]] name = "bread-theme" -version = "0.2.3" +version = "0.3.0" dependencies = [ "dirs", "gtk4", @@ -174,8 +185,9 @@ dependencies = [ [[package]] name = "bread-utils" -version = "0.2.3" +version = "0.3.0" dependencies = [ + "bread-shared", "dirs", "gtk4", "gtk4-layer-shell", @@ -225,9 +237,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.63" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f" +checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8" dependencies = [ "find-msvc-tools", "shlex", @@ -264,9 +276,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.6.1" +version = "4.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +checksum = "dd059f9da4f5c36b3787f65d38ccaab1cc315f07b01f89abc8359ee6a8205011" dependencies = [ "clap_builder", "clap_derive", @@ -274,9 +286,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.6.0" +version = "4.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +checksum = "f09628afdcc538b57f3c6341e9c8e9970f18e4a481690a64974d7023bd33548b" dependencies = [ "anstream", "anstyle", @@ -592,12 +604,6 @@ 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 = "form_urlencoded" version = "1.2.2" @@ -609,24 +615,24 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" [[package]] name = "futures-executor" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +checksum = "6754879cc9f2c66f88c6e5c35344bb0bdb0708b0352b1201815667c7eabc7458" dependencies = [ "futures-core", "futures-task", @@ -635,15 +641,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" +checksum = "4577ecaa3c4f96589d473f679a71b596316f6641bc350038b962a5daf0085d7a" [[package]] name = "futures-macro" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +checksum = "2d6d3cde68c518367be28956066ddfef33813991b77a55005a69dae04bf3b10b" dependencies = [ "proc-macro2", "quote", @@ -652,15 +658,15 @@ dependencies = [ [[package]] name = "futures-task" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" +checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" [[package]] name = "futures-util" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" dependencies = [ "futures-core", "futures-macro", @@ -696,9 +702,9 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.11.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd42fdbbf48612c6e8f47c65fb92d2e8f39c25aecd6af047e83897c1a22d2a4e" +checksum = "d81e2a6c6ecba2aab60633a98df1868b03fa0bfdce8105edc27c1bccf71f0e39" dependencies = [ "cairo-rs", "gdk-pixbuf", @@ -712,9 +718,9 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.11.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d974ac4f15e67472c3a9728daf612590b4a5762a4b33f0edd298df0b80d043c" +checksum = "3d8f608d8d7d229975c4d0d026f5d3071598c4ddab3c5262b0a31840fec78d13" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -762,22 +768,20 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", - "wasip2", - "wasip3", ] [[package]] name = "gio" -version = "0.22.6" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3848bcba3a35cc0a71df8ba8ecfd799d6bfb862342a53a4a915fb62213aa4e6" +checksum = "8b3e1f669909c326b9413bde5a742097b8c90a7d78f45326db13668984769ded" dependencies = [ "futures-channel", "futures-core", @@ -792,9 +796,9 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.22.0" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64729ba2772c080448f9f966dba8f4456beeb100d8c28a865ef8a0f2ef4987e1" +checksum = "353fdc7da7cd16da916104b1e0e4e7de380ec9c8aaa20d4d742d66310ab4b0d5" dependencies = [ "glib-sys", "gobject-sys", @@ -825,9 +829,9 @@ dependencies = [ [[package]] name = "glib" -version = "0.22.7" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c207e04e51605dcf7b2924c41591b3a10e1438eaac5bcf448fb91f325381104a" +checksum = "ddbcf514bd1881fc1b960e4e52b4e82873f4da3bceddbd58d42827b508888100" dependencies = [ "bitflags", "futures-channel", @@ -858,9 +862,9 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.22.6" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7fbac234ed5bc2a28359b7bde8e1b9cdf1441cc2d7f068e4824672d7db9445" +checksum = "030967459f9f676851872c6304adea7825c6d462ec9b72554c733cf0c5952233" dependencies = [ "libc", "system-deps", @@ -879,32 +883,30 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.22.0" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d1b7881f96869f49808b6adfe906a93a57a34204952253444d68c3208d71f1" +checksum = "eb856b9c558971c3f13ab692358926da710b046932a4e087aedcc35b040d7dff" dependencies = [ "glib", "graphene-sys", - "libc", ] [[package]] name = "graphene-sys" -version = "0.22.0" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "517f062f3fd6b7fd3e57a3f038a74b3c23ca32f51199ff028aa704609943f79c" +checksum = "5c7ffdfde88f3570d3705e0d8a2433e036d387a1f2930bbf47eafcb5f569fd04" dependencies = [ "glib-sys", "libc", - "pkg-config", "system-deps", ] [[package]] name = "gsk4" -version = "0.11.1" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53c912dfcbd28acace5fc99c40bb9f25e1dcb73efb1f2608327f66a99acdcb62" +checksum = "b867be1c5f14dcb8f552c0eff6e9a9b1da5f8b43943e8efc3a63c889d84952ff" dependencies = [ "cairo-rs", "gdk4", @@ -917,9 +919,9 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.11.1" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d54bbc7a9d8b6ffe4f0c95eede15ccfb365c8bf521275abe6bcfb57b18fb8a" +checksum = "5b7c7eb2e681ee896646cfb8872b431f24d09f53ba9283289d9b10caa6707088" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -933,9 +935,9 @@ dependencies = [ [[package]] name = "gtk4" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7181b837f04cbe93f79441475f7a00560a92cba7a72e38cc1a68b6f8b78eaae2" +checksum = "98a0a0466484f64b07b5b8184d43fa46be78eb0b8e04ae4e179af31d770b76d9" dependencies = [ "cairo-rs", "field-offset", @@ -982,9 +984,9 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.11.0" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3581b242ba62fdff122ebb626ea641582ec326031622bd19d60f85029c804a87" +checksum = "5ac7179400a36a04de039c24206bb841c5596992b907b43b23ee8d5bdc40d00e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -994,9 +996,9 @@ dependencies = [ [[package]] name = "gtk4-sys" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ba8e695e2640455561274e65e45f0a151619e450746007667f4b23ceae4e1b" +checksum = "82b8f954786af0b1984425c4446b77f5ff6594346181316be3f850caab1c6f01" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -1011,15 +1013,6 @@ dependencies = [ "system-deps", ] -[[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.17.1" @@ -1144,12 +1137,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "id-arena" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" - [[package]] name = "ident_case" version = "1.0.1" @@ -1184,9 +1171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.17.1", - "serde", - "serde_core", + "hashbrown", ] [[package]] @@ -1225,13 +1210,12 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" -version = "0.3.99" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bc4740e452c1e57ade0cbc129f139c9093e354346f0872ef985f4f5cf5f11" +checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" dependencies = [ "cfg-if", "futures-util", - "once_cell", "wasm-bindgen", ] @@ -1241,12 +1225,6 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" -[[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - [[package]] name = "libc" version = "0.2.186" @@ -1255,9 +1233,9 @@ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libredox" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" +checksum = "c943259e342f1e06ff2da7a83eabdfe7f92ce10262688dbf1895ff0b3e6e4652" dependencies = [ "libc", ] @@ -1276,9 +1254,9 @@ checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" [[package]] name = "log" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "macro_rules_attribute" @@ -1308,9 +1286,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "memoffset" @@ -1477,13 +1455,12 @@ checksum = "d7b497d21a8b6fbb4b5a544f8fadb77e801a09ae0add9e411d31c6f89e3c1e90" [[package]] name = "pango" -version = "0.22.6" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "251bdc6e6487b811be0e406a21e301e07e45c0aa8fa39e00c0c8e12a91752438" +checksum = "5d800d8d0de2ad5d0fb046f5344dbaba14a003cf3dd27cc21d85893d35ea316c" dependencies = [ "gio", "glib", - "libc", "pango-sys", ] @@ -1525,9 +1502,9 @@ checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" [[package]] name = "portable-atomic" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" +checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3" [[package]] name = "portable-atomic-util" @@ -1556,23 +1533,13 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn", -] - [[package]] name = "proc-macro-crate" version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ - "toml_edit 0.25.12+spec-1.1.0", + "toml_edit 0.25.13+spec-1.1.0", ] [[package]] @@ -1586,9 +1553,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" dependencies = [ "proc-macro2", ] @@ -1749,9 +1716,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.40" +version = "0.23.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +checksum = "3c54fcab019b409d04215d3a17cb438fd7fbf192ee61461f20f4fe18704bc138" dependencies = [ "log", "once_cell", @@ -1764,9 +1731,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.14.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046" dependencies = [ "zeroize", ] @@ -1784,9 +1751,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] name = "ryu" @@ -1880,9 +1847,9 @@ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "simd-adler32" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" [[package]] name = "slab" @@ -1892,9 +1859,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "spm_precompiled" @@ -1934,9 +1901,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.117" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" dependencies = [ "proc-macro2", "quote", @@ -1963,7 +1930,7 @@ dependencies = [ "cfg-expr", "heck", "pkg-config", - "toml 1.1.2+spec-1.1.0", + "toml 1.1.3+spec-1.1.0", "version-compare", ] @@ -1980,7 +1947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.2", + "getrandom 0.4.3", "once_cell", "rustix", "windows-sys 0.61.2", @@ -2084,9 +2051,9 @@ dependencies = [ [[package]] name = "toml" -version = "1.1.2+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee" +checksum = "53c96ecdfa941c8fc4fcaed14f99ada8ebed502eef533015095a07e3301d4c3c" dependencies = [ "indexmap", "serde_core", @@ -2094,7 +2061,7 @@ dependencies = [ "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", - "winnow 1.0.3", + "winnow 1.0.4", ] [[package]] @@ -2131,14 +2098,14 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.25.12+spec-1.1.0" +version = "0.25.13+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2153edc6955a6c354fad8f5efd38b6a8769bdccf9fe50f8e1329f81b0baa5d7" +checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" dependencies = [ "indexmap", "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", - "winnow 1.0.3", + "winnow 1.0.4", ] [[package]] @@ -2147,7 +2114,7 @@ version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" dependencies = [ - "winnow 1.0.3", + "winnow 1.0.4", ] [[package]] @@ -2158,9 +2125,9 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "toml_writer" -version = "1.1.1+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "tracing" @@ -2226,12 +2193,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "unicode_categories" version = "0.1.1" @@ -2312,27 +2273,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.3+wasi-0.2.9" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ - "wit-bindgen 0.57.1", -] - -[[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" -dependencies = [ - "wit-bindgen 0.51.0", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409" +checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" dependencies = [ "cfg-if", "once_cell", @@ -2343,9 +2295,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6" +checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2353,9 +2305,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e" +checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" dependencies = [ "bumpalo", "proc-macro2", @@ -2366,47 +2318,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437" +checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" dependencies = [ "unicode-ident", ] -[[package]] -name = "wasm-encoder" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasmparser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" -dependencies = [ - "bitflags", - "hashbrown 0.15.5", - "indexmap", - "semver", -] - [[package]] name = "web-time" version = "1.1.0" @@ -2423,14 +2341,14 @@ version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" dependencies = [ - "webpki-roots 1.0.7", + "webpki-roots 1.0.9", ] [[package]] name = "webpki-roots" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" dependencies = [ "rustls-pki-types", ] @@ -2653,107 +2571,19 @@ dependencies = [ [[package]] name = "winnow" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" dependencies = [ "memchr", ] -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - [[package]] name = "wit-bindgen" version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck", - "indexmap", - "prettyplease", - "syn", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - [[package]] name = "writeable" version = "0.6.3" @@ -2832,9 +2662,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" [[package]] name = "zerotrie" @@ -2871,6 +2701,6 @@ dependencies = [ [[package]] name = "zmij" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml index b51552a..6675555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,10 +3,10 @@ members = ["bakery", "bread-theme", "bread-utils", "bread-onnx"] resolver = "2" [workspace.package] -version = "0.2.3" +version = "0.3.0" edition = "2021" license = "MIT" -authors = ["Breadway "] +authors = ["Breadway "] [workspace.dependencies] anyhow = "1" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..373e4ee --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Breadway + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index c01995a..fff6340 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ bakery install breadbar | `breadbox` | GTK4 fuzzy app launcher for Hyprland with context-aware sorting; ships an icon-sync daemon (`breadbox-sync`) | | `breadcrumbs` | Profile-aware Wi-Fi state machine with Tailscale exit-node management and a self-healing watch daemon | | `breadpad` | Quick-capture scratchpad popup with AI-powered note classification, reminders, recurrence, and a full note viewer (`breadman`) | +| `breadpaper` | Wallpaper manager for the bread desktop | ## Recommended keybinds @@ -35,19 +36,31 @@ to keys. ## Theming -All GUIs share one look via `bread-theme`. The `bread-theme` CLI renders the -component stylesheet from your pywal palette, layered on a fixed BOS dark -base (background/surface/overlay never come from pywal — only the accent -colors do, so a light wallpaper can't wash out the UI), to -`$XDG_RUNTIME_DIR/bread/theme.css`; every app loads that file and **live-reloads** -it, so changing your wallpaper recolours the whole ecosystem with no rebuilds: +All GUI products (breadbar, breadbox, breadpad) share one stylesheet via +`bread-theme`. Background, surface, overlay, and foreground are always BOS's +fixed dark values; only the accent colors are read from the pywal palette in +`~/.cache/wal/colors.json`. When that file is absent, the accents fall back +to BOS's curated bread-toned defaults (not Catppuccin Mocha). The stylesheet +is written to `$XDG_RUNTIME_DIR/bread/theme.css`; running apps watch that +file and recolour live when it changes. Per-app CSS overrides live at +`~/.config//style.css`. ```sh wal -i ~/Pictures/wall.png # regenerate pywal palette bread-theme generate # render the shared stylesheet (run from a wal hook) ``` -See [`BREAD_DESIGN_SYSTEM.md`](BREAD_DESIGN_SYSTEM.md) for the tokens (fonts, +`bread-theme` subcommands: + +| Subcommand | Description | +|------------|-------------| +| `generate` | Render the current palette and write the shared stylesheet (default) | +| `reload` | Same as `generate`; use after a palette change to trigger live recolour in running apps | +| `path` | Print the stylesheet path | +| `print` | Render the stylesheet to stdout without writing | + +The shared theming logic lives in the `bread-theme` crate in this repo. See +[`BREAD_DESIGN_SYSTEM.md`](BREAD_DESIGN_SYSTEM.md) for the design tokens (fonts, spacing, radii, colour roles) the stylesheet is built from. ## Installing bakery @@ -94,18 +107,6 @@ bakery remove # remove a package (data files are never deleted) Install all required deps with `sudo pacman -S `. Use `pacman -Q ` to check whether any are already present. -## Theming - -All GUI products (breadbar, breadbox, breadpad) read pywal colors from -`~/.cache/wal/colors.json` for accents only; background, surface, overlay, -and foreground are always BOS's fixed dark values (see -[`BREAD_DESIGN_SYSTEM.md`](BREAD_DESIGN_SYSTEM.md#color-system)) regardless -of what pywal extracted from the wallpaper. When `colors.json` is absent, -accents fall back to BOS's curated bread-toned defaults. Per-app CSS -overrides live at `~/.config//style.css`. - -The shared theming logic lives in the `bread-theme` crate in this repo. - ## Workspace This repo is a Cargo workspace: diff --git a/bakery/Cargo.toml b/bakery/Cargo.toml index 3664980..a344e87 100644 --- a/bakery/Cargo.toml +++ b/bakery/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true license.workspace = true authors.workspace = true description = "Package manager for the bread ecosystem" -repository = "https://github.com/Breadway/bread-ecosystem" +repository = "https://git.breadway.dev/Breadway/bread-ecosystem" [dependencies] anyhow = { workspace = true } diff --git a/bread-onnx/Cargo.toml b/bread-onnx/Cargo.toml index d8cb08a..170bdfc 100644 --- a/bread-onnx/Cargo.toml +++ b/bread-onnx/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true license.workspace = true authors.workspace = true description = "Shared ONNX Runtime plumbing for the bread ecosystem: session building, execution-provider fallback with loud diagnostics, embedding-pipeline tensor math, and verified model downloads" -repository = "https://github.com/Breadway/bread-ecosystem" +repository = "https://git.breadway.dev/Breadway/bread-ecosystem" keywords = ["onnx", "onnxruntime", "ml", "embeddings"] [dependencies] diff --git a/bread-theme/Cargo.toml b/bread-theme/Cargo.toml index 8547e24..43c3952 100644 --- a/bread-theme/Cargo.toml +++ b/bread-theme/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true license.workspace = true authors.workspace = true description = "Shared pywal-accented, fixed-dark-base theming crate for the bread ecosystem" -repository = "https://github.com/Breadway/bread-ecosystem" +repository = "https://git.breadway.dev/Breadway/bread-ecosystem" keywords = ["theming", "pywal", "gtk4", "wayland"] [dependencies] diff --git a/bread-utils/Cargo.toml b/bread-utils/Cargo.toml index 851c3e2..69e2172 100644 --- a/bread-utils/Cargo.toml +++ b/bread-utils/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true license.workspace = true authors.workspace = true description = "Shared plumbing for the bread ecosystem: Hyprland IPC, single-instance toggling, timeout-guarded subprocess execution, atomic file writes, XDG paths, and a GTK4 layer-shell popup scaffold" -repository = "https://github.com/Breadway/bread-ecosystem" +repository = "https://git.breadway.dev/Breadway/bread-ecosystem" keywords = ["hyprland", "wayland", "xdg", "gtk4"] [dependencies] @@ -15,6 +15,7 @@ dirs = { workspace = true } gtk4 = { version = "0.11", features = ["v4_12"], optional = true } gtk4-layer-shell = { version = "0.8", optional = true } toml_edit = { version = "0.22", optional = true } +bread-shared = { git = "https://git.breadway.dev/Breadway/bread", tag = "v0.7.0", optional = true } [features] # Enable the layer-shell popup scaffold (breadbox, breadclip). Kept optional @@ -25,6 +26,11 @@ gtk = ["dep:gtk4", "dep:gtk4-layer-shell"] # breadhelp). Optional so consumers that don't edit TOML configs (breadbox, # breadclip, breadmon, ...) don't pull in toml_edit. toml = ["dep:toml_edit"] +# Enable BreadClient, a persistent-connection client for breadd's IPC +# socket (emit + subscribe), for sibling bread* app daemons that want to +# integrate with the bread automation fabric. Optional so consumers that +# don't talk to breadd at all aren't forced to pull in bread-shared. +bread-client = ["dep:bread-shared"] [dev-dependencies] tempfile = "3" diff --git a/bread-utils/src/bread_client.rs b/bread-utils/src/bread_client.rs new file mode 100644 index 0000000..3f4adcf --- /dev/null +++ b/bread-utils/src/bread_client.rs @@ -0,0 +1,302 @@ +//! A persistent-connection client for breadd's IPC socket, for sibling +//! `bread*` app daemons that run continuously. +//! +//! This is deliberately a *second* client alongside `bread-emit` (the +//! fire-and-forget CLI binary in the `bread` repo), not a replacement for +//! it: `bread-emit` skips holding a connection open at all, which is right +//! for occasional/hook-style callers (a git hook, a shell prompt) but wrong +//! for a long-running daemon like breadclipd that wants to publish an +//! event on every clipboard change and subscribe to a command stream — +//! reconnecting from scratch for every single emit would be wasteful, and +//! subscribing needs a held-open connection by nature. +//! +//! # Graceful degradation +//! +//! A sibling app must never crash or block because breadd is down, +//! restarting, or was never installed. Concretely: +//! - [`BreadClient::emit`] is a best-effort, fire-and-forget single-shot +//! connection (mirroring `bread-emit`'s own stance) — if breadd is +//! unreachable, the event is silently dropped, not an error the caller +//! has to handle. +//! - [`BreadClient::subscribe`] runs its read loop on a background thread +//! that reconnects with exponential backoff on any disconnect. The +//! caller's callback simply stops being invoked while disconnected; it +//! resumes automatically once breadd comes back. +//! +//! # Namespace enforcement +//! +//! `emit` refuses locally (no network round trip) to publish an event +//! outside the app's own `bread..*` segment, so a misconfigured +//! caller fails fast instead of discovering the mistake from the daemon's +//! rejection. The daemon enforces the same rule server-side regardless. + +use std::io::{BufRead, BufReader, Write}; +use std::net::Shutdown; +use std::os::unix::net::UnixStream; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::Duration; + +use bread_shared::apps::validate_app_namespace; +use serde_json::{json, Value}; + +/// A normalized event as delivered by breadd's `events.subscribe` stream. +#[derive(Debug, Clone)] +pub struct BreadEvent { + /// Dotted event name, e.g. `bread.command.clip.clear`. + pub event: String, + /// Unix epoch milliseconds when the daemon observed the originating signal. + pub timestamp: u64, + /// Structured event data; shape depends on the event family. + pub data: Value, +} + +/// A client bound to one sibling app's identity, used to `emit` within that +/// app's namespace and `subscribe` to events (typically its own +/// `bread.command..**` verb namespace). +/// +/// Cheap to clone (just an `Arc`-free `String`); safe to share across +/// threads by cloning, or to construct fresh per call site. +#[derive(Clone)] +pub struct BreadClient { + app_id: String, +} + +impl BreadClient { + /// Bind a client to `app_id` (e.g. `"clip"`). Does not connect yet — + /// there is no persistent connection to "fail" at construction time; + /// `emit` and `subscribe` each connect (or reconnect) as needed. This + /// is itself part of the graceful-degradation story: constructing a + /// `BreadClient` can never fail just because breadd isn't running yet. + pub fn connect(app_id: impl Into) -> Self { + Self { + app_id: app_id.into(), + } + } + + /// The app id this client is bound to. + pub fn app_id(&self) -> &str { + &self.app_id + } + + /// Publish `event` (must be within `bread..*`) with `data`. + /// Fire-and-forget: a single short-lived connection is opened, the + /// request is written, and the reply is never read (mirroring + /// `bread-emit`). If breadd is unreachable or slow, this silently does + /// nothing — it never blocks or errors the caller. + pub fn emit(&self, event: &str, data: Value) { + if !validate_app_namespace(&self.app_id, event) { + eprintln!( + "bread-client: refusing to emit '{event}' outside the '{}' namespace", + self.app_id + ); + return; + } + + let request = json!({ + "id": "0", + "method": "emit", + "params": { + "event": event, + "source": self.app_id, + "kind": event, + "data": data, + } + }); + let Ok(line) = serde_json::to_string(&request) else { + return; + }; + + let Ok(mut stream) = UnixStream::connect(bread_shared::resolve_socket_path()) else { + return; + }; + let _ = stream.set_write_timeout(Some(Duration::from_millis(200))); + let _ = writeln!(stream, "{line}"); + } + + /// Subscribe to events matching `pattern` (glob: `*`/`**`/`?`), invoking + /// `on_event` for each one on a dedicated background thread. Typically + /// called with `"bread.command..**"` to receive commands + /// addressed to this app. + /// + /// Returns a [`Subscription`] handle; drop or call [`Subscription::stop`] + /// to end it. The background thread reconnects with exponential backoff + /// (500ms, capped at ~32s) whenever the connection drops, so a restart + /// of breadd is transparent to the caller — `on_event` simply pauses + /// and resumes. + pub fn subscribe(&self, pattern: impl Into, on_event: F) -> Subscription + where + F: Fn(BreadEvent) + Send + 'static, + { + let pattern = pattern.into(); + let stop = Arc::new(AtomicBool::new(false)); + let current_stream: Arc>> = Arc::new(Mutex::new(None)); + + let stop_for_thread = stop.clone(); + let stream_for_thread = current_stream.clone(); + let handle = thread::spawn(move || { + let mut attempt: u32 = 0; + while !stop_for_thread.load(Ordering::Relaxed) { + match run_subscription_once(&pattern, &on_event, &stream_for_thread) { + Ok(()) => attempt = 0, // clean end (stop() closed the socket) + Err(_) => attempt = attempt.saturating_add(1), + } + + *stream_for_thread.lock().unwrap_or_else(|p| p.into_inner()) = None; + + if stop_for_thread.load(Ordering::Relaxed) { + break; + } + let backoff_ms = 500u64.saturating_mul(2u64.saturating_pow(attempt.min(6))); + thread::sleep(Duration::from_millis(backoff_ms)); + } + }); + + Subscription { + stop, + current_stream, + handle: Some(handle), + } + } +} + +/// Connects once, sends `events.subscribe`, and invokes `on_event` for every +/// matching line until the connection ends (cleanly or with an error). +/// Stores the live stream in `current_stream` so [`Subscription::stop`] can +/// shut it down from another thread to interrupt the blocking read promptly. +fn run_subscription_once( + pattern: &str, + on_event: &impl Fn(BreadEvent), + current_stream: &Mutex>, +) -> std::io::Result<()> { + let stream = UnixStream::connect(bread_shared::resolve_socket_path())?; + let read_stream = stream.try_clone()?; + *current_stream.lock().unwrap_or_else(|p| p.into_inner()) = Some(stream); + + // Re-borrow to write the subscribe request through the stored copy so + // there is exactly one owner performing I/O per direction. + { + let guard = current_stream.lock().unwrap_or_else(|p| p.into_inner()); + if let Some(stream) = guard.as_ref() { + let mut writer = stream; + let request = json!({ + "id": "sub", + "method": "events.subscribe", + "params": { "filter": pattern } + }); + let line = serde_json::to_string(&request).unwrap_or_default(); + writeln!(writer, "{line}")?; + } + } + + for line in BufReader::new(read_stream).lines() { + let line = line?; + if line.trim().is_empty() { + continue; + } + let Ok(value) = serde_json::from_str::(&line) else { + continue; + }; + // The first line is the subscribe ack ({"result": {"subscribed": true}}); + // only lines with an "event" field are actual BreadEvents. + if let Some(event_name) = value.get("event").and_then(Value::as_str) { + let timestamp = value.get("timestamp").and_then(Value::as_u64).unwrap_or(0); + let data = value.get("data").cloned().unwrap_or(Value::Null); + on_event(BreadEvent { + event: event_name.to_string(), + timestamp, + data, + }); + } + } + Ok(()) +} + +/// Handle to a running [`BreadClient::subscribe`] background thread. +pub struct Subscription { + stop: Arc, + current_stream: Arc>>, + handle: Option>, +} + +impl Subscription { + /// Stop the subscription and block until its background thread exits. + /// Shuts down the live socket (if connected) so a thread blocked in a + /// read wakes up immediately, rather than waiting for the next event or + /// a future reconnect attempt to notice the stop flag. + pub fn stop(mut self) { + self.stop.store(true, Ordering::Relaxed); + if let Some(stream) = self + .current_stream + .lock() + .unwrap_or_else(|p| p.into_inner()) + .as_ref() + { + let _ = stream.shutdown(Shutdown::Both); + } + if let Some(h) = self.handle.take() { + let _ = h.join(); + } + } +} + +impl Drop for Subscription { + fn drop(&mut self) { + self.stop.store(true, Ordering::Relaxed); + if let Some(stream) = self + .current_stream + .lock() + .unwrap_or_else(|p| p.into_inner()) + .as_ref() + { + let _ = stream.shutdown(Shutdown::Both); + } + // Best-effort on drop: don't block a caller who simply let the + // handle go out of scope. Explicit `stop()` is what actually waits. + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn connect_never_fails_even_with_no_daemon_present() { + // Constructing a client must not depend on breadd actually running — + // that's the whole point of the graceful-degradation design. + let _client = BreadClient::connect("clip"); + } + + #[test] + fn emit_is_a_silent_no_op_when_daemon_is_unreachable() { + // Point at a socket path that can't possibly exist by using an + // app id that still passes namespace validation; the daemon being + // absent must not panic or block this call. + let client = BreadClient::connect("clip"); + client.emit("bread.clip.copied", json!({ "len": 1 })); + } + + #[test] + fn emit_refuses_event_outside_own_namespace_without_connecting() { + // "pad" events are not this client's to publish — this must be + // caught locally (and cheaply) rather than round-tripped to a + // daemon that isn't even running in this test. + let client = BreadClient::connect("clip"); + client.emit("bread.pad.reminder.due", json!({})); + // No assertion beyond "did not panic" — there is no daemon to + // observe the (correctly suppressed) call against in a unit test; + // the cross-process behavior is covered by breadd's own + // integration tests for the IPC-side of namespace validation. + } + + #[test] + fn subscription_stop_joins_the_background_thread() { + let client = BreadClient::connect("clip"); + let sub = client.subscribe("bread.command.clip.**", |_event| {}); + // Even with no daemon present (so the thread is spinning on + // connect-refused + backoff), stop() must return promptly rather + // than hanging. + sub.stop(); + } +} diff --git a/bread-utils/src/lib.rs b/bread-utils/src/lib.rs index 12f6bf5..0817ad3 100644 --- a/bread-utils/src/lib.rs +++ b/bread-utils/src/lib.rs @@ -18,6 +18,9 @@ //! load/save discipline built on [`atomic`]. //! - [`gtk_popup`] (feature `gtk`) — shared layer-shell popup window setup, //! list navigation, and click-outside-to-close. +//! - [`bread_client`] (feature `bread-client`) — a persistent-connection +//! client for breadd's IPC socket (emit + subscribe), for sibling +//! `bread*` app daemons integrating with the bread automation fabric. pub mod atomic; pub mod hypr; @@ -42,3 +45,6 @@ pub mod tomlcfg; #[cfg(feature = "gtk")] pub mod gtk_popup; + +#[cfg(feature = "bread-client")] +pub mod bread_client; diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD index 793c187..6a3f8bf 100644 --- a/packaging/arch/PKGBUILD +++ b/packaging/arch/PKGBUILD @@ -1,11 +1,11 @@ -# Maintainer: Breadway +# Maintainer: Breadway pkgname=bakery pkgver=0.2.3 pkgrel=1 pkgdesc="Package manager for the bread ecosystem" arch=('x86_64') -url="https://github.com/Breadway/bread-ecosystem" +url="https://git.breadway.dev/Breadway/bread-ecosystem" license=('MIT') # Some Rust deps (ring/mlua) build vendored C/asm into static archives; makepkg's # default -flto=auto emits GCC LTO bitcode the Rust (lld) link cannot read,