From 756b45a95c5465542b64f3990108660c71f67377 Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Mon, 19 Feb 2024 00:09:38 +0200 Subject: [PATCH] move to rustbus --- Cargo.lock | 1391 ++++++-------------------------------------- Cargo.toml | 18 +- src/dbus_client.rs | 188 ++++-- src/dbus_server.rs | 324 +++++++---- src/main.rs | 85 ++- src/wayland.rs | 84 +-- 6 files changed, 651 insertions(+), 1439 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4296fb4..ab191ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,35 +2,11 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" -dependencies = [ - "memchr", -] - [[package]] name = "anstream" -version = "0.6.1" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6cd65a4b849ace0b7f6daeebcc1a1d111282227ca745458c61dbf670e52a597" +checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" dependencies = [ "anstyle", "anstyle-parse", @@ -42,1162 +18,322 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" - -[[package]] -name = "anstyle-parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0238ca56c96dfa37bdf7c373c8886dd591322500aceeeccdb2216fe06dc2f796" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "async-broadcast" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" -dependencies = [ - "event-listener 2.5.3", - "futures-core", -] - -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener 2.5.3", - "futures-core", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix 0.37.23", - "slab", - "socket2 0.4.9", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener 2.5.3", -] - -[[package]] -name = "async-process" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf012553ce51eb7aa6dc2143804cc8252bd1cb681a1c5cb7fa94ca88682dee1d" -dependencies = [ - "async-io", - "async-lock", - "async-signal", - "blocking", - "cfg-if", - "event-listener 3.0.0", - "futures-lite", - "rustix 0.38.14", - "windows-sys", -] - -[[package]] -name = "async-recursion" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", -] - -[[package]] -name = "async-signal" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c99f3cb3f9ff89f7d718fbb942c9eb91bedff12e396adf09a622dfe7ffec2bc2" -dependencies = [ - "async-io", - "async-lock", - "atomic-waker", - "cfg-if", - "concurrent-queue", - "futures-core", - "futures-io", - "libc", - "signal-hook-registry", - "slab", - "windows-sys", -] - -[[package]] -name = "async-task" -version = "4.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9441c6b2fe128a7c2bf680a44c34d0df31ce09e5b7e401fcca3faa483dbc921" - -[[package]] -name = "async-trait" -version = "0.1.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", -] - -[[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.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - -[[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 = "blocking" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c4ef1f913d78636d78d538eec1f18de81e481f44b1be0a81060090530846e1" -dependencies = [ - "async-channel", - "async-lock", - "async-task", - "fastrand 2.0.1", - "futures-io", - "futures-lite", - "piper", - "tracing", -] - -[[package]] -name = "bytemuck" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - -[[package]] -name = "cc" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clap" -version = "4.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.37", -] - -[[package]] -name = "clap_lex" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "concurrent-queue" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "cpufeatures" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" -dependencies = [ - "libc", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - -[[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 = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[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 = "enumflags2" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" -dependencies = [ - "enumflags2_derive", - "serde", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "event-listener" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e56284f00d94c1bc7fd3c77027b4623c88c1f53d8d2394c6199f2921dea325" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "futures" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures-core", - "futures-sink", - "futures-task", - "pin-project-lite", - "pin-utils", - "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 = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" - -[[package]] -name = "hashbrown" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hermit-abi" -version = "0.3.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "indexmap" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad227c3af19d4914570ad36d30409928b75967c298feb9ea1969db3a610bb14e" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - -[[package]] -name = "libc" -version = "0.2.148" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memchr" -version = "2.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" - -[[package]] -name = "memmap2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" -dependencies = [ - "libc", - "wasi", - "windows-sys", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.7.1", -] - -[[package]] -name = "nix" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" -dependencies = [ - "bitflags 2.4.0", - "cfg-if", - "libc", - "memoffset 0.9.0", -] - -[[package]] -name = "object" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[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 = "parking" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e52c774a4c39359c1d1c52e43f73dd91a75a614652c825408eec30c95a9b2067" - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" +name = "anstyle-parse" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] [[package]] -name = "piper" -version = "0.2.1" +name = "anstyle-query" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "atomic-waker", - "fastrand 2.0.1", - "futures-io", + "windows-sys", ] [[package]] -name = "polling" -version = "2.8.0" +name = "anstyle-wincon" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", + "anstyle", "windows-sys", ] [[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "anyhow" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] -name = "proc-macro-crate" -version = "1.3.1" +name = "autocfg" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "proc-macro2" -version = "1.0.67" +name = "bitflags" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" -dependencies = [ - "unicode-ident", -] +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] -name = "quick-xml" -version = "0.30.0" +name = "bytemuck" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" -dependencies = [ - "memchr", -] +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] -name = "quote" -version = "1.0.33" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "rand" -version = "0.8.5" +name = "clap" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ - "libc", - "rand_chacha", - "rand_core", + "clap_builder", + "clap_derive", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "clap_builder" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ - "ppv-lite86", - "rand_core", + "anstream", + "anstyle", + "clap_lex", + "strsim", ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "clap_derive" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ - "getrandom", + "heck", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "redox_syscall" -version = "0.3.5" +name = "clap_lex" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] -name = "regex" -version = "1.9.5" +name = "colorchoice" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] -name = "regex-automata" -version = "0.3.8" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "regex-syntax" -version = "0.7.5" +name = "hashbrown" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] -name = "rustc-demangle" -version = "0.1.23" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "rustix" -version = "0.37.23" +name = "indexmap" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys", + "equivalent", + "hashbrown", ] [[package]] -name = "rustix" -version = "0.38.14" +name = "libc" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" -dependencies = [ - "bitflags 2.4.0", - "errno", - "libc", - "linux-raw-sys 0.4.7", - "windows-sys", -] +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] -name = "serde" -version = "1.0.188" +name = "memchr" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" -dependencies = [ - "serde_derive", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] -name = "serde_derive" -version = "1.0.188" +name = "memmap2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", + "libc", ] [[package]] -name = "serde_repr" -version = "0.1.16" +name = "memoffset" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", + "autocfg", ] [[package]] -name = "sha1" -version = "0.10.6" +name = "nix" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ + "bitflags", "cfg-if", - "cpufeatures", - "digest", + "libc", + "memoffset", ] [[package]] -name = "shmemfdrs" -version = "0.1.4" +name = "proc-macro-crate" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a07caaa5573b8fa1142d19783d30ba2999c6a221169784f3bb7e2b9b308bcbdb" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "libc", + "toml_edit", ] [[package]] -name = "signal-hook-registry" -version = "1.4.1" +name = "proc-macro2" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ - "libc", + "unicode-ident", ] [[package]] -name = "slab" -version = "0.4.9" +name = "quick-xml" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ - "autocfg", + "memchr", ] [[package]] -name = "socket2" -version = "0.4.9" +name = "quote" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ - "libc", - "winapi", + "proc-macro2", ] [[package]] -name = "socket2" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +name = "rustbus" +version = "0.19.3" +source = "git+https://github.com/KillingSpark/rustbus?rev=59f0926#59f09261ae03d91964a6975070a9522ad9f7301c" dependencies = [ - "libc", - "windows-sys", + "nix", + "rustbus_derive", + "thiserror", ] [[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +name = "rustbus-service" +version = "0.1.0" +source = "git+https://github.com/MaxVerevkin/rustbus-service?rev=a674dbb#a674dbb3315dc388f15272c1b73094bd1c179d42" +dependencies = [ + "rustbus", + "rustbus-service-macros", +] [[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +name = "rustbus-service-macros" +version = "0.1.0" +source = "git+https://github.com/MaxVerevkin/rustbus-service?rev=a674dbb#a674dbb3315dc388f15272c1b73094bd1c179d42" dependencies = [ - "proc-macro2", + "proc-macro-crate", "quote", - "unicode-ident", + "syn", ] [[package]] -name = "syn" -version = "2.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +name = "rustbus_derive" +version = "0.5.0" +source = "git+https://github.com/KillingSpark/rustbus?rev=59f0926#59f09261ae03d91964a6975070a9522ad9f7301c" dependencies = [ "proc-macro2", "quote", - "unicode-ident", + "syn", ] [[package]] -name = "tempfile" -version = "3.8.0" +name = "shmemfdrs" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "a07caaa5573b8fa1142d19783d30ba2999c6a221169784f3bb7e2b9b308bcbdb" dependencies = [ - "cfg-if", - "fastrand 2.0.1", - "redox_syscall", - "rustix 0.38.14", - "windows-sys", + "libc", ] [[package]] -name = "thiserror" -version = "1.0.49" +name = "strsim" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" -dependencies = [ - "thiserror-impl", -] +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] -name = "thiserror-impl" -version = "1.0.49" +name = "syn" +version = "2.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "unicode-ident", ] [[package]] -name = "tokio" -version = "1.32.0" +name = "thiserror" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "pin-project-lite", - "signal-hook-registry", - "socket2 0.5.4", - "tokio-macros", - "tracing", - "windows-sys", + "thiserror-impl", ] [[package]] -name = "tokio-macros" -version = "2.1.0" +name = "thiserror-impl" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", "winnow", ] -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", -] - -[[package]] -name = "tracing-core" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "uds_windows" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" -dependencies = [ - "tempfile", - "winapi", -] - [[package]] name = "unicode-ident" version = "1.0.12" @@ -1211,93 +347,62 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "waker-fn" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "wayrs-client" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "47dafedf9cea6c2a27479d015848a7874cd7eed0d71461b9ace072f2cf4a21a2" +dependencies = [ + "nix", + "thiserror", + "wayrs-scanner", +] [[package]] -name = "wayrs-client" -version = "0.12.2" +name = "wayrs-proto-parser" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1c2f175a4be77a0cc50cdb27fcd28d47c5a6b14fc8c011657a89af2b6a1c4d" +checksum = "1406ebeb6ba4a201745a92c221eca3dcec5b404fcbe948acf8a166b323582fa9" dependencies = [ - "nix 0.27.1", + "quick-xml", "thiserror", - "tokio", - "wayrs-scanner", ] [[package]] name = "wayrs-protocols" -version = "0.12.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f6a462aa49952d3b0210042f792fcbe83f4894a84da5dda6aed77fa58f8b718" +checksum = "537e83a10ea2eca491a6f7af040b5c1eabdb66e80ee560da62ce4ddaca73f854" dependencies = [ "wayrs-client", ] [[package]] name = "wayrs-scanner" -version = "0.12.2" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e6f4157da3cde8f7906d0838331d0133233184bee126273f8cdaf177e0a9a7" +checksum = "e387d47549e37bd2a6f03973a77578bb003f661559a096c9274b5b9bcd78bf1f" dependencies = [ "proc-macro-crate", "proc-macro2", - "quick-xml", "quote", - "syn 2.0.37", -] - -[[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", + "syn", + "wayrs-proto-parser", ] -[[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-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1310,51 +415,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -1366,120 +471,10 @@ dependencies = [ "anyhow", "bytemuck", "clap", - "futures", + "libc", "memmap2", + "rustbus-service", "shmemfdrs", - "tokio", "wayrs-client", "wayrs-protocols", - "zbus", -] - -[[package]] -name = "xdg-home" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" -dependencies = [ - "nix 0.26.4", - "winapi", -] - -[[package]] -name = "zbus" -version = "3.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" -dependencies = [ - "async-broadcast", - "async-process", - "async-recursion", - "async-trait", - "byteorder", - "derivative", - "enumflags2", - "event-listener 2.5.3", - "futures-core", - "futures-sink", - "futures-util", - "hex", - "nix 0.26.4", - "once_cell", - "ordered-stream", - "rand", - "serde", - "serde_repr", - "sha1", - "static_assertions", - "tokio", - "tracing", - "uds_windows", - "winapi", - "xdg-home", - "zbus_macros", - "zbus_names", - "zvariant", -] - -[[package]] -name = "zbus_macros" -version = "3.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "regex", - "syn 1.0.109", - "zvariant_utils", -] - -[[package]] -name = "zbus_names" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" -dependencies = [ - "serde", - "static_assertions", - "zvariant", -] - -[[package]] -name = "zvariant" -version = "3.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" -dependencies = [ - "byteorder", - "enumflags2", - "libc", - "serde", - "static_assertions", - "zvariant_derive", -] - -[[package]] -name = "zvariant_derive" -version = "3.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", - "zvariant_utils", -] - -[[package]] -name = "zvariant_utils" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", ] diff --git a/Cargo.toml b/Cargo.toml index 60700e1..f800273 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,18 +10,14 @@ keywords = ["redshift", "gammastep", "wayland", "night-mode"] [dependencies] anyhow = "1.0" -memmap2 = "0.8" -shmemfdrs = { version = "0.1", features = ["memfd"] } -futures = { version = "0.3", default-features = false } -zbus = { version = "3.5", default-features = false, features = ["tokio"] } +bytemuck = "1.13" clap = { version = "4.0", features = ["derive"] } -wayrs-client = { version = "0.12", features = ["tokio"] } -wayrs-protocols = { version = "0.12", features = ["wlr-gamma-control-unstable-v1"] } -bytemuck = "1.13.0" - -[dependencies.tokio] -version = "1.21" -features = ["macros", "net", "rt", "sync"] +libc = "0.2" +memmap2 = "0.9" +rustbus-service = { git = "https://github.com/MaxVerevkin/rustbus-service", rev = "a674dbb" } +shmemfdrs = { version = "0.1", features = ["memfd"] } +wayrs-client = "1.0" +wayrs-protocols = { version = "0.13", features = ["wlr-gamma-control-unstable-v1"] } [profile.release] lto = "fat" diff --git a/src/dbus_client.rs b/src/dbus_client.rs index c2fe87d..d57d10e 100644 --- a/src/dbus_client.rs +++ b/src/dbus_client.rs @@ -1,73 +1,139 @@ +use std::{ + collections::HashMap, + os::fd::{AsRawFd, RawFd}, +}; + use anyhow::Result; -use futures::stream::StreamExt; -use zbus::dbus_proxy; +use rustbus_service::rustbus::{ + self, connection::Timeout, get_session_bus_path, standard_messages, + wire::unmarshal::traits::Variant as UnVariant, DuplexConn, MessageBuilder, MessageType, +}; -pub async fn watch_dbus(format: &str) -> Result<()> { - let conn = zbus::ConnectionBuilder::session()?.build().await?; - let proxy = BusInterfaceProxy::new(&conn).await?; - let mut temperature = proxy.temperature().await?; - let mut gamma = proxy.gamma().await?; - let mut brightness = proxy.brightness().await?; - let mut t_stream = proxy.receive_temperature_changed().await; - let mut g_stream = proxy.receive_gamma_changed().await; - let mut b_stream = proxy.receive_brightness_changed().await; - loop { - print_formatted(format, temperature, gamma, brightness); - tokio::select! { - Some(t) = t_stream.next() => { - temperature = t.get().await?; - } - Some(g) = g_stream.next() => { - gamma = g.get().await?; - } - Some(b) = b_stream.next() => { - brightness = b.get().await?; +pub struct DbusClient { + format: String, + conn: DuplexConn, + temperature: u16, + gamma: f64, + brightness: f64, +} + +impl DbusClient { + pub fn new(format: String, server_running: bool) -> Result { + let mut conn = DuplexConn::connect_to_bus(get_session_bus_path()?, true)?; + conn.send_hello(Timeout::Infinite)?; + + conn.send + .send_message_write_all(&standard_messages::add_match( + "type='signal',sender='rs.wl-gammarelay',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'", + ))?; + + let mut temperature = 6500; + let mut gamma = 1.0; + let mut brightness = 1.0; + + if server_running { + let mut t_done = false; + let mut g_done = false; + let mut b_done = false; + let mut msg = MessageBuilder::new() + .call("Get") + .on("/") + .with_interface("org.freedesktop.DBus.Properties") + .at("rs.wl-gammarelay") + .build(); + + msg.body.reset(); + msg.body.push_param("rs.wl.gammarelay")?; + msg.body.push_param("Temperature")?; + let t_serial = conn.send.send_message_write_all(&msg)?; + msg.body.reset(); + msg.body.push_param("rs.wl.gammarelay")?; + msg.body.push_param("Gamma")?; + let g_serial = conn.send.send_message_write_all(&msg)?; + msg.body.reset(); + msg.body.push_param("rs.wl.gammarelay")?; + msg.body.push_param("Brightness")?; + let b_serial = conn.send.send_message_write_all(&msg)?; + + while !(t_done && g_done && b_done) { + let msg = conn.recv.get_next_message(Timeout::Infinite)?; + let mut parser = msg.body.parser(); + if msg.dynheader.response_serial == Some(t_serial) { + temperature = parser.get::()?.get::()?; + t_done = true; + } else if msg.dynheader.response_serial == Some(g_serial) { + gamma = parser.get::()?.get::()?; + g_done = true; + } else if msg.dynheader.response_serial == Some(b_serial) { + brightness = parser.get::()?.get::()?; + b_done = true; + } } } - } -} -fn print_formatted(format: &str, temperature: u16, gamma: f64, brightness: f64) { - println!( - "{}", - format - .replace("{t}", &temperature.to_string()) - .replace("{g}", &format!("{gamma:.2}")) - .replace("{b}", &format!("{brightness:.2}")) - .replace("{bp}", &format!("{:.0}", brightness * 100.)) - ); -} + let this = Self { + format, + conn, + temperature, + gamma, + brightness, + }; -#[dbus_proxy( - interface = "rs.wl.gammarelay", - default_service = "rs.wl-gammarelay", - default_path = "/" -)] -trait BusInterface { - /// UpdateBrightness method - fn update_brightness(&self, delta_brightness: f64) -> zbus::Result<()>; + this.print(); - /// UpdateGamma method - fn update_gamma(&self, delta_gamma: f64) -> zbus::Result<()>; + Ok(this) + } - /// UpdateTemperature method - fn update_temperature(&self, delta_temp: i16) -> zbus::Result<()>; + pub fn poll_fd(&self) -> RawFd { + self.conn.as_raw_fd() + } - /// Brightness property - #[dbus_proxy(property)] - fn brightness(&self) -> zbus::Result; - #[dbus_proxy(property)] - fn set_brightness(&self, value: f64) -> zbus::Result<()>; + pub fn run(&mut self, blocking: bool) -> Result<()> { + let timeout = if blocking { + Timeout::Infinite + } else { + Timeout::Nonblock + }; + loop { + let msg = match self.conn.recv.get_next_message(timeout) { + Ok(msg) => msg, + Err(rustbus::connection::Error::TimedOut) => return Ok(()), + Err(e) => return Err(e.into()), + }; - /// Gamma property - #[dbus_proxy(property)] - fn gamma(&self) -> zbus::Result; - #[dbus_proxy(property)] - fn set_gamma(&self, value: f64) -> zbus::Result<()>; + if msg.typ == MessageType::Signal + && msg.dynheader.interface.as_deref() == Some("org.freedesktop.DBus.Properties") + && msg.dynheader.member.as_deref() == Some("PropertiesChanged") + { + let mut parser = msg.body.parser(); + let iface = parser.get::<&str>()?; + if iface == "rs.wl.gammarelay" { + let changed = parser.get::>()?; + let invalidated = parser.get::>()?; + assert!(invalidated.is_empty()); + if let Some(v) = changed.get("Temperature") { + self.temperature = v.get::()?; + } + if let Some(v) = changed.get("Gamma") { + self.gamma = v.get::()?; + } + if let Some(v) = changed.get("Brightness") { + self.brightness = v.get::()?; + } + self.print(); + } + } + } + } - /// Temperature property - #[dbus_proxy(property)] - fn temperature(&self) -> zbus::Result; - #[dbus_proxy(property)] - fn set_temperature(&self, value: u16) -> zbus::Result<()>; + fn print(&self) { + println!( + "{}", + self.format + .replace("{t}", &self.temperature.to_string()) + .replace("{g}", &format!("{:.2}", self.gamma)) + .replace("{b}", &format!("{:.2}", self.brightness)) + .replace("{bp}", &format!("{:.0}", self.brightness * 100.)) + ); + } } diff --git a/src/dbus_server.rs b/src/dbus_server.rs index 05aed9a..00f7476 100644 --- a/src/dbus_server.rs +++ b/src/dbus_server.rs @@ -1,150 +1,228 @@ -use crate::color::Color; -use crate::wayland::Request; +use std::collections::HashMap; +use std::os::fd::{AsRawFd, RawFd}; + +use crate::State; use anyhow::Result; -use tokio::sync::mpsc; -use zbus::dbus_interface; - -#[derive(Debug)] -struct Server { - tx: mpsc::Sender, - color: Color, -} - -pub async fn run(tx: mpsc::Sender) -> Result { - match zbus::ConnectionBuilder::session()? - .serve_at( - "/", - Server { - tx, - color: Default::default(), - }, - )? - .name("rs.wl-gammarelay")? - .build() - .await - { - Err(zbus::Error::NameTaken) => Ok(false), - Err(e) => Err(e.into()), - Ok(server) => { - std::mem::forget(server); - Ok(true) - } - } -} +use rustbus::{ + connection::Timeout, + get_session_bus_path, + message_builder::MarshalledMessage, + params::{Param, Variant}, + wire::unmarshal::traits::Variant as UnVariant, + DuplexConn, MessageBuilder, +}; +use rustbus_service::rustbus; +use rustbus_service::{Access, InterfaceImp, MethodContext, PropContext, Service}; -impl Server { - async fn send_color(&self) { - let _ = self.tx.send(Request::SetColor(self.color)).await; - } +pub struct DbusServer { + conn: DuplexConn, + service: Service, } -#[dbus_interface(name = "rs.wl.gammarelay")] -impl Server { - #[dbus_interface(property)] - async fn temperature(&self) -> u16 { - self.color.temp - } +impl DbusServer { + pub fn new() -> Result> { + let mut conn = rustbus::DuplexConn::connect_to_bus(get_session_bus_path()?, true)?; + conn.send_hello(Timeout::Infinite)?; + + let mut service = Service::new(); - #[dbus_interface(property)] - async fn set_temperature(&mut self, temp: u16) -> Result<(), zbus::fdo::Error> { - if (1000..=10000).contains(&temp) { - self.color.temp = temp; - self.send_color().await; - Ok(()) - } else { - Err(zbus::fdo::Error::InvalidArgs( - "temperature must be in range [1000,10000]".into(), - )) + let req_name_serial = + conn.send + .send_message_write_all(&rustbus::standard_messages::request_name( + "rs.wl-gammarelay", + 0, + ))?; + let req_name_resp = service.get_reply(&mut conn, req_name_serial, Timeout::Infinite)?; + if req_name_resp.body.parser().get::()? + != rustbus::standard_messages::DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER + { + return Ok(None); } - } - async fn update_temperature( - &mut self, - #[zbus(signal_context)] cx: zbus::SignalContext<'_>, - delta_temp: i16, - ) -> Result<(), zbus::fdo::Error> { - self.color.temp = (self.color.temp as i16 + delta_temp).clamp(1_000, 10_000) as _; - self.send_color().await; - self.temperature_changed(&cx).await?; - Ok(()) - } + let gammarelay_iface = InterfaceImp::new("rs.wl.gammarelay") + .with_method::<(), ()>("ToggleInverted", toggle_inverted_cb) + .with_method::("UpdateTemperature", update_temperature_cb) + .with_method::("UpdateGamma", update_gamma_cb) + .with_method::("UpdateBrightness", update_brightness_cb) + .with_prop( + "Inverted", + Access::ReadWrite(get_inverted_cb, set_inverted_cb), + ) + .with_prop( + "Temperature", + Access::ReadWrite(get_temperature_cb, set_temperature_cb), + ) + .with_prop("Gamma", Access::ReadWrite(get_gamma_cb, set_gamma_cb)) + .with_prop( + "Brightness", + Access::ReadWrite(get_brightness_cb, set_brightness_cb), + ); + + service.root_mut().add_interface(gammarelay_iface); - #[dbus_interface(property)] - async fn gamma(&self) -> f64 { - self.color.gamma + Ok(Some(Self { conn, service })) } - #[dbus_interface(property)] - async fn set_gamma(&mut self, gamma: f64) -> Result<(), zbus::fdo::Error> { - if gamma > 0.0 { - self.color.gamma = gamma; - self.send_color().await; - Ok(()) - } else { - Err(zbus::fdo::Error::InvalidArgs( - "gamma must be greater than zero".into(), - )) - } + pub fn poll_fd(&self) -> RawFd { + self.conn.as_raw_fd() } - async fn update_gamma( - &mut self, - #[zbus(signal_context)] cx: zbus::SignalContext<'_>, - delta_gamma: f64, - ) -> Result<(), zbus::fdo::Error> { - self.color.gamma = (self.color.gamma + delta_gamma).max(0.0); - self.send_color().await; - self.gamma_changed(&cx).await?; + pub fn poll(&mut self, state: &mut State) -> Result<()> { + self.service.run(&mut self.conn, state, Timeout::Nonblock)?; Ok(()) } +} + +fn toggle_inverted_cb(ctx: &mut MethodContext, _args: ()) { + ctx.state.color.inverted = !ctx.state.color.inverted; + ctx.state.dirty = true; - #[dbus_interface(property)] - async fn brightness(&self) -> f64 { - self.color.brightness + let sig = prop_changed_message( + ctx.object_path, + "rs.wl.gammarelay", + "Inverted", + ctx.state.color.inverted.into(), + ); + ctx.conn.send.send_message_write_all(&sig).unwrap(); +} + +fn get_inverted_cb(ctx: PropContext) -> bool { + ctx.state.color.inverted +} + +fn set_inverted_cb(ctx: PropContext, val: UnVariant) { + let val = val.get::().unwrap(); + if ctx.state.color.inverted != val { + ctx.state.color.inverted = val; + ctx.state.dirty = true; + + let sig = prop_changed_message(ctx.object_path, "rs.wl.gammarelay", ctx.name, val.into()); + ctx.conn.send.send_message_write_all(&sig).unwrap(); } +} - #[dbus_interface(property)] - async fn set_brightness(&mut self, brightness: f64) -> Result<(), zbus::fdo::Error> { - if (0.0..=1.0).contains(&brightness) { - self.color.brightness = brightness; - self.send_color().await; - Ok(()) - } else { - Err(zbus::fdo::Error::InvalidArgs( - "brightness must be in range [0,1]".into(), - )) - } +#[derive(rustbus_service::Args)] +struct UpdateBrightnessArgs { + delta: f64, +} + +fn update_brightness_cb(ctx: &mut MethodContext, args: UpdateBrightnessArgs) { + let val = (ctx.state.color.brightness + args.delta).clamp(0.0, 1.0); + + if ctx.state.color.brightness != val { + ctx.state.color.brightness = val; + ctx.state.dirty = true; + + let sig = prop_changed_message( + ctx.object_path, + "rs.wl.gammarelay", + "Brightness", + val.into(), + ); + ctx.conn.send.send_message_write_all(&sig).unwrap(); } +} - async fn update_brightness( - &mut self, - #[zbus(signal_context)] cx: zbus::SignalContext<'_>, - delta_brightness: f64, - ) -> Result<(), zbus::fdo::Error> { - self.color.brightness = (self.color.brightness + delta_brightness).clamp(0.0, 1.0); - self.send_color().await; - self.brightness_changed(&cx).await?; - Ok(()) +fn get_brightness_cb(ctx: PropContext) -> f64 { + ctx.state.color.brightness +} + +fn set_brightness_cb(ctx: PropContext, val: UnVariant) { + let val = val.get::().unwrap().clamp(0.0, 1.0); + + if ctx.state.color.brightness != val { + ctx.state.color.brightness = val; + ctx.state.dirty = true; + + let sig = prop_changed_message(ctx.object_path, "rs.wl.gammarelay", ctx.name, val.into()); + ctx.conn.send.send_message_write_all(&sig).unwrap(); } +} + +#[derive(rustbus_service::Args)] +struct UpdateTemperatureArgs { + delta: i16, +} + +fn update_temperature_cb(ctx: &mut MethodContext, args: UpdateTemperatureArgs) { + let val = (ctx.state.color.temp as i16 + args.delta).clamp(1_000, 10_000) as u16; - #[dbus_interface(property)] - async fn inverted(&self) -> bool { - self.color.inverted + if ctx.state.color.temp != val { + ctx.state.color.temp = val; + ctx.state.dirty = true; + + let sig = prop_changed_message( + ctx.object_path, + "rs.wl.gammarelay", + "Temperature", + val.into(), + ); + ctx.conn.send.send_message_write_all(&sig).unwrap(); } +} + +fn get_temperature_cb(ctx: PropContext) -> u16 { + ctx.state.color.temp +} - #[dbus_interface(property)] - async fn set_inverted(&mut self, value: bool) { - self.color.inverted = value; - self.send_color().await; +fn set_temperature_cb(ctx: PropContext, val: UnVariant) { + let val = val.get::().unwrap().clamp(1_000, 10_000); + if ctx.state.color.temp != val { + ctx.state.color.temp = val; + ctx.state.dirty = true; + + let sig = prop_changed_message(ctx.object_path, "rs.wl.gammarelay", ctx.name, val.into()); + ctx.conn.send.send_message_write_all(&sig).unwrap(); } +} - async fn toggle_inverted( - &mut self, - #[zbus(signal_context)] cx: zbus::SignalContext<'_>, - ) -> Result<(), zbus::fdo::Error> { - self.color.inverted = !self.color.inverted; - self.send_color().await; - self.brightness_changed(&cx).await?; - Ok(()) +#[derive(rustbus_service::Args)] +struct UpdateGammaArgs { + delta: f64, +} + +fn update_gamma_cb(ctx: &mut MethodContext, args: UpdateGammaArgs) { + let val = (ctx.state.color.gamma + args.delta).max(0.1); + + if ctx.state.color.gamma != val { + ctx.state.color.gamma = val; + ctx.state.dirty = true; + + let sig = prop_changed_message(ctx.object_path, "rs.wl.gammarelay", "Gamma", val.into()); + ctx.conn.send.send_message_write_all(&sig).unwrap(); } } + +fn get_gamma_cb(ctx: PropContext) -> f64 { + ctx.state.color.gamma +} + +fn set_gamma_cb(ctx: PropContext, val: UnVariant) { + let val = val.get::().unwrap().max(0.1); + if ctx.state.color.gamma != val { + ctx.state.color.gamma = val; + ctx.state.dirty = true; + + let sig = prop_changed_message(ctx.object_path, "rs.wl.gammarelay", ctx.name, val.into()); + ctx.conn.send.send_message_write_all(&sig).unwrap(); + } +} + +fn prop_changed_message(path: &str, iface: &str, prop: &str, value: Param) -> MarshalledMessage { + let mut map = HashMap::new(); + map.insert( + prop, + Variant { + sig: value.sig(), + value, + }, + ); + + let mut sig = MessageBuilder::new() + .signal("org.freedesktop.DBus.Properties", "PropertiesChanged", path) + .build(); + sig.body.push_param(iface).unwrap(); + sig.body.push_param(map).unwrap(); + sig.body.push_param::<&[&str]>(&[]).unwrap(); + sig +} diff --git a/src/main.rs b/src/main.rs index c53621f..462f6af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,11 @@ mod dbus_client; mod dbus_server; mod wayland; +use std::{io, os::fd::RawFd}; + use clap::{Parser, Subcommand}; -use tokio::sync::mpsc; + +use color::Color; #[derive(Debug, Parser)] #[clap(author, version, about)] @@ -21,27 +24,87 @@ enum Command { Watch { format: String }, } -#[tokio::main(flavor = "current_thread")] -async fn main() -> Result<(), Box> { - let commnad = Cli::parse().command.unwrap_or(Command::Run); +struct State { + color: Color, + dirty: bool, +} - let (tx, rx) = mpsc::channel(16); - let new_instance = dbus_server::run(tx).await?; +fn main() -> anyhow::Result<()> { + let commnad = Cli::parse().command.unwrap_or(Command::Run); + let dbus_server = dbus_server::DbusServer::new()?; match commnad { Command::Run => { - if new_instance { - wayland::run(rx).await?; + if let Some(mut dbus_server) = dbus_server { + let mut wayland = wayland::Wayland::new()?; + + let mut state = State { + color: Color::default(), + dirty: true, + }; + + loop { + let res = poll([dbus_server.poll_fd(), wayland.poll_fd()])?; + if res[0] { + dbus_server.poll(&mut state)?; + } + if res[1] || state.dirty { + wayland.poll(&mut state)?; + } + } + } else { + eprintln!("wl-gammarelay-rs is already running"); } } Command::Watch { format } => { - if new_instance { - tokio::try_join!(wayland::run(rx), dbus_client::watch_dbus(&format))?; + let mut dbus_client = dbus_client::DbusClient::new(format, dbus_server.is_none())?; + if let Some(mut dbus_server) = dbus_server { + let mut wayland = wayland::Wayland::new()?; + + let mut state = State { + color: Color::default(), + dirty: true, + }; + + loop { + let res = poll([ + dbus_server.poll_fd(), + wayland.poll_fd(), + dbus_client.poll_fd(), + ])?; + if res[0] { + dbus_server.poll(&mut state)?; + } + if res[1] || state.dirty { + wayland.poll(&mut state)?; + } + if res[2] { + dbus_client.run(false)?; + } + } } else { - dbus_client::watch_dbus(&format).await?; + dbus_client.run(true)?; } } } Ok(()) } + +fn poll(fds: [RawFd; N]) -> io::Result<[bool; N]> { + let mut pollfds = fds.map(|fd| libc::pollfd { + fd, + events: libc::POLLIN, + revents: 0, + }); + loop { + if unsafe { libc::poll(pollfds.as_mut_ptr(), N as _, -1) } == -1 { + let err = io::Error::last_os_error(); + if err.kind() == io::ErrorKind::Interrupted { + continue; + } + return Err(err); + } + return Ok(pollfds.map(|fd| fd.revents != 0)); + } +} diff --git a/src/wayland.rs b/src/wayland.rs index ab2896b..1e18f8b 100644 --- a/src/wayland.rs +++ b/src/wayland.rs @@ -1,5 +1,5 @@ use wayrs_client::protocol::*; -use wayrs_client::EventCtx; +use wayrs_client::{EventCtx, IoMode}; use wayrs_protocols::wlr_gamma_control_unstable_v1::*; use anyhow::Result; @@ -10,49 +10,63 @@ use wayrs_client::proxy::Proxy; use wayrs_client::Connection; use std::fs::File; +use std::io::ErrorKind; +use std::os::fd::AsRawFd; +use std::os::fd::RawFd; use std::os::unix::io::FromRawFd; -use tokio::sync::mpsc; - use crate::color::{colorramp_fill, Color}; -#[derive(Debug)] -pub enum Request { - SetColor(Color), +pub struct Wayland { + conn: Connection, + state: State, } -pub async fn run(mut rx: mpsc::Receiver) -> Result<()> { - let (mut conn, globals) = Connection::async_connect_and_collect_globals().await?; - conn.add_registry_cb(wl_registry_cb); +impl Wayland { + pub fn new() -> Result { + let (mut conn, globals) = Connection::connect_and_collect_globals()?; + conn.add_registry_cb(wl_registry_cb); - let gamma_manager = globals.bind(&mut conn, 1)?; + let gamma_manager = globals.bind(&mut conn, 1)?; - let outputs = globals - .iter() - .filter(|g| g.is::()) - .map(|output| Output::bind(&mut conn, output, gamma_manager)) - .collect(); - - let mut state = State { - color: Default::default(), - outputs, - gamma_manager, - }; - - loop { - conn.async_flush().await?; - - tokio::select! { - recv_events = conn.async_recv_events() => { - recv_events?; - conn.dispatch_events(&mut state); - } - Some(request) = rx.recv() => { - let Request::SetColor(color) = request; - state.color = color; - state.outputs.iter_mut().try_for_each(|o| o.set_color(&mut conn, color))?; - } + let outputs = globals + .iter() + .filter(|g| g.is::()) + .map(|output| Output::bind(&mut conn, output, gamma_manager)) + .collect(); + + let state = State { + color: Default::default(), + outputs, + gamma_manager, + }; + + conn.flush(IoMode::Blocking)?; + + Ok(Self { conn, state }) + } + + pub fn poll_fd(&self) -> RawFd { + self.conn.as_raw_fd() + } + + pub fn poll(&mut self, state: &mut super::State) -> Result<()> { + match self.conn.recv_events(IoMode::NonBlocking) { + Ok(()) => self.conn.dispatch_events(&mut self.state), + Err(e) if e.kind() == ErrorKind::WouldBlock => (), + Err(e) => return Err(e.into()), } + + if state.dirty { + self.state.color = state.color; + self.state + .outputs + .iter_mut() + .try_for_each(|o| o.set_color(&mut self.conn, self.state.color))?; + } + + self.conn.flush(IoMode::Blocking)?; + Ok(()) } }