diff --git a/Cargo.lock b/Cargo.lock index 82e28f7..dd76b0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "async-trait" version = "0.1.66" @@ -34,24 +49,57 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bumpalo" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" + [[package]] name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +[[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 = "chrono" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "windows-targets 0.52.0", +] + [[package]] name = "convert_case" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "derive_more" version = "0.99.17" @@ -71,6 +119,21 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "flexi_logger" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f248c29a6d4bc5d065c9e9068d858761a0dcd796759f7801cc14db35db23abd8" +dependencies = [ + "chrono", + "glob", + "is-terminal", + "log", + "nu-ansi-term", + "regex", + "thiserror", +] + [[package]] name = "futures" version = "0.3.27" @@ -160,6 +223,12 @@ dependencies = [ "slab", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "heck" version = "0.4.1" @@ -175,6 +244,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" + [[package]] name = "hex" version = "0.4.3" @@ -183,9 +258,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hyprland" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d42b8c26f4d39e0c489b7495ba8d91bde7de45bf02e1d8ddc7b759befd4a5c8" +checksum = "f87a8f1cc065d451894dd3916c0bc3fcf9b67b276126c05f27b1db912688dde8" dependencies = [ "async-trait", "derive_more", @@ -216,19 +291,64 @@ dependencies = [ [[package]] name = "hyprland-workspaces" -version = "1.2.5" +version = "2.0.0" dependencies = [ + "flexi_logger", "hyprland", + "log", "serde", "serde_json", ] +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi 0.3.6", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "itoa" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +[[package]] +name = "js-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -253,18 +373,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mio" @@ -275,7 +392,16 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "nu-ansi-term" +version = "0.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68" +dependencies = [ + "windows-sys 0.48.0", ] [[package]] @@ -293,10 +419,16 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + [[package]] name = "parking_lot" version = "0.12.1" @@ -317,7 +449,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -367,9 +499,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -379,9 +511,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -390,9 +522,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustc_version" @@ -429,29 +561,29 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.156" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.156" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.12", ] [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" dependencies = [ "itoa", "ryu", @@ -505,18 +637,18 @@ dependencies = [ [[package]] name = "strum" -version = "0.25.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.25.1" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6069ca09d878a33f883cc06aaa9718ede171841d3832450354410b718b097232" +checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" dependencies = [ "heck", "proc-macro2", @@ -547,6 +679,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + [[package]] name = "tokio" version = "1.26.0" @@ -564,7 +716,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -590,6 +742,60 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.12", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" + [[package]] name = "winapi" version = "0.3.9" @@ -612,13 +818,40 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -627,13 +860,43 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -642,38 +905,122 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/Cargo.toml b/Cargo.toml index 4da9baa..a93e7cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,13 @@ [package] name = "hyprland-workspaces" -version = "1.2.5" +version = "2.0.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -hyprland = "0.3.11" +hyprland = "0.3.13" serde_json = "1.0" serde = "1.0" +flexi_logger = "0.28" +log = "0.4" \ No newline at end of file diff --git a/README.md b/README.md index 1fa2408..a7a2cb5 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,14 @@ cargo build --release ``` ## Usage +### Basic Usage Pass the name of the monitor to follow as the only argument. ``` ./hyprland-workspaces eDP-1 ``` -If you wish to get all workspaces across all monitors, pass the special argument "_". +If you wish to get all workspaces across all monitors, pass the special argument "ALL". ``` -./hyprland-workspaces _ +./hyprland-workspaces ALL ``` It will then follow that monitor(s) and output the workspaces details in JSON to stdout. ```json @@ -67,7 +68,62 @@ It can be used as a workspaces widget in Eww with config similar to below. (workspaces1) (other_widget))) ``` +### Advanced Usage +Passing the special argument '_' will output all workspaces, wrapped in an array of monitors. This allows only running a single instance of hyprland-workspaces and simplified eww configuration. +``` +./hyprland-workspaces _ +``` +Each monitor will have a sub array, workspaces, which will be the same information output as `hyprland-workspaces MONITORNAME`. +```json +[ + { + "name": "eDP-1", + "workspaces": [ + {"active": false,"class": "workspace-button w6","id": 6,"name": "6 []"} + ] + }, + { + "name": "DP-3", + "workspaces": [ + {"active": false,"class": "workspace-button w1","id": 1,"name": "1 "}, + {"active": true,"class": "workspace-button w3 workspace-active wa3","id": 3,"name": "3 "} + ] + }, + { + "name": "DP-4", + "workspaces": [ + {"active": false,"class": "workspace-button w2","id": 2,"name": "2 "}, + {"active": false,"class": "workspace-button w5","id": 5,"name": "5 "} + ] + } +] +``` +This helps avoid repetition within your eww configuration, by using something similar to below. +```yuck +(deflisten workspaces "hyprland-workspaces _") + +(defwidget workspaceWidget [monitor] + (eventbox :onscroll "hyprctl dispatch workspace `echo {} | sed 's/up/+/\' | sed 's/down/-/'`1" + (box :class "workspaces" + (for i in {workspaces[monitor].workspaces} + (button + :onclick "hyprctl dispatch workspace ${i.id}" + :class "${i.class}" + "${i.name}"))))) +(defwidget bar0 [] + (box + (workspaceWidget :monitor 0) + ) +) + +(defwidget bar1 [] + (box + (workspaceWidget :monitor 1) + ) +) +``` +### Classes The following classes are output, to provide multiple options for theming your workspaces widget. * `workspace-button`: all workspaces will have this class * `workspace-active`: only the active workspace will have this class. Will not be present if workspace is active, but focus is on another monitor. diff --git a/src/main.rs b/src/main.rs index 6ed7490..b197d35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,16 @@ +use flexi_logger::{FileSpec, Logger}; use hyprland::data::{Monitors, Workspace, Workspaces}; use hyprland::event_listener::EventListenerMutable as EventListener; -use hyprland::shared::HyprData; -use hyprland::shared::HyprDataActive; +use hyprland::shared::{HyprData, HyprDataActive, HyprError}; use hyprland::Result; -use std::env; +use log; use serde::Serialize; use serde_json::json; +use std::env; +use std::sync::Arc; const HELP: &str = "\ -hyprland-workspaces: a multi monitor aware hyprland workspaces json widget generator for eww/waybar. +hyprland-workspaces: a multi monitor aware hyprland workspaces json widget generator for eww. USAGE: hyprland-workspaces MONITOR @@ -17,7 +19,8 @@ FLAGS: -h, --help Prints help information ARGS: - Monitor to track windows/workspaces on or _ to track all monitors + Monitor to track windows/workspaces on + Use the special keywords ALL to track all monitors or _ to track all monitors and output monitor name information as well "; #[derive(Serialize)] @@ -28,51 +31,100 @@ struct WorkspaceCustom { pub class: String, } -fn output(monitor: &str) { +#[derive(Serialize)] +struct MonitorCustom { + pub name: String, + pub workspaces: Vec, +} + +fn get_workspace_windows(monitor: &str) -> Result> { // get all workspaces - let mut workspaces: Vec<_> = Workspaces::get().expect("unable to get workspaces").into_iter().collect(); + let mut workspaces: Vec<_> = Workspaces::get()?.into_iter().collect(); workspaces.sort_by_key(|w| w.id); //get active workspace let active_workspace_id: i32; - if monitor == "_" { - active_workspace_id = Workspace::get_active().expect("unable to get active workspace").id; + if monitor == "ALL" { + active_workspace_id = Workspace::get_active()?.id; } else { - active_workspace_id = Monitors::get() - .expect("unable to get monitors") + active_workspace_id = Monitors::get()? .find(|m| m.name == monitor) - .unwrap() + .ok_or_else(|| { + log::error!("No monitor found with name: {}", monitor); + HyprError::NotOkDispatch("No monitor found".to_string()) + })? .active_workspace .id; } //active monitor name - let active_monitor_name = Monitors::get() - .expect("unable to get monitors") + let active_monitor_name = Monitors::get()? .find(|m| m.focused == true) - .unwrap() + .ok_or_else(|| { + log::error!("No active monitor found."); + HyprError::NotOkDispatch("No active monitor found".to_string()) + })? .name; - let mut out_workspaces: Vec = Vec::new(); - for workspace in workspaces.iter().filter(|m| m.monitor == monitor || monitor == "_") { - let mut active = false; - let mut class = format!("workspace-button w{}",workspace.id); - if active_workspace_id == workspace.id && (active_monitor_name == monitor || monitor == "_") { - class = format!("{} workspace-active wa{}", class, workspace.id); - active = true; - } + for workspace in workspaces + .iter() + .filter(|m| m.monitor == monitor || monitor == "ALL" || monitor == "_") + { + let mut active = false; + let mut class = format!("workspace-button w{}", workspace.id); + if active_workspace_id == workspace.id + && (active_monitor_name == monitor || monitor == "ALL") + { + class = format!("{} workspace-active wa{}", class, workspace.id); + active = true; + } - let ws: WorkspaceCustom = WorkspaceCustom { - name: workspace.name.clone(), - id: workspace.id, - active, - class, - }; - out_workspaces.push(ws); + let ws: WorkspaceCustom = WorkspaceCustom { + name: workspace.name.clone(), + id: workspace.id, + active, + class, + }; + out_workspaces.push(ws); + } + return Ok(out_workspaces); +} + +fn get_all_advanced() -> Result> { + let monitors = Monitors::get()?; + let mut out_monitors: Vec = Vec::new(); + for m in monitors { + let workspaces = get_workspace_windows(&m.name)?; + let mc: MonitorCustom = MonitorCustom { + name: m.name, + workspaces: workspaces, + }; + out_monitors.push(mc); } - println!("{}", json!(out_workspaces).to_string()); + Ok(out_monitors) } +fn output(monitor: &str) { + if monitor == "_" { + println!( + "{}", + json!(get_all_advanced().unwrap_or_else(|err| { + log::error!("Advanced get failed: {}", err); + Vec::new() + })) + .to_string() + ); + } else { + println!( + "{}", + json!(get_workspace_windows(monitor).unwrap_or_else(|err| { + log::error!("Basic get failed: {}", err); + Vec::new() + })) + .to_string() + ); + } +} fn main() -> Result<()> { let args: Vec = env::args().collect(); @@ -81,74 +133,112 @@ fn main() -> Result<()> { println!("{HELP}"); std::process::exit(0); } - let mon = env::args().nth(1).unwrap(); + let _logger = match Logger::try_with_str("info") { + Ok(logger) => { + match logger + .log_to_file( + FileSpec::default() + .directory("/tmp") + .basename("hyprland-workspaces"), + ) + .start() + { + Ok(logger) => logger, + Err(e) => { + println!("Unable to start logger: {}", e); + std::process::exit(1) + } + }; + } + Err(e) => { + println!("Unable to initialise logger: {}", e); + std::process::exit(1) + } + }; + let mon = Arc::new(String::from(args[1].to_string())); if let None = Monitors::get() - .expect("unable to get monitors") - .find(|m| m.name == mon || mon == "_") { - println!("Unable to find monitor {mon}"); - std::process::exit(0); + .unwrap_or_else(|err| { + log::error!("Unable to get monitors: {}", err); + std::process::exit(1) + }) + .find(|m| m.name == mon.to_string() || mon.to_string() == "ALL" || mon.to_string() == "_") + { + log::error!("Unable to find monitor {mon}"); + std::process::exit(0); } - macro_rules! output { - () => { - output(&env::args().nth(1).unwrap()); - }; - } - output!(); + log::info!("Started with arg {}", mon); + output(&mon); // Create a event listener let mut event_listener = EventListener::new(); - event_listener.add_workspace_change_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_workspace_change_handler(move |_, _| { + output(&mon_clone); + }); + let mon_clone = Arc::clone(&mon); + event_listener.add_workspace_added_handler(move |_, _| { + output(&mon_clone); + }); + let mon_clone = Arc::clone(&mon); + event_listener.add_workspace_destroy_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_workspace_added_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_workspace_moved_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_workspace_destroy_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_monitor_added_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_workspace_moved_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_monitor_removed_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_monitor_added_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_window_close_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_monitor_removed_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_window_open_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_window_close_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_active_monitor_change_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_window_open_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_active_window_change_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_active_monitor_change_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_window_close_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_active_window_change_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_fullscreen_state_change_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_window_close_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_window_moved_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_fullscreen_state_change_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_layer_open_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_window_moved_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_layer_closed_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_layer_open_handler(|_, _| { - output!(); - }); - event_listener.add_layer_closed_handler(|_, _| { - output!(); - }); - event_listener.add_urgent_state_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_urgent_state_handler(move |_, _| { + output(&mon_clone); }); - event_listener.add_window_title_change_handler(|_, _| { - output!(); + let mon_clone = Arc::clone(&mon); + event_listener.add_window_title_change_handler(move |_, _| { + output(&mon_clone); }); event_listener.start_listener() - }