wayland-pipewire-idle-inhibit-0.7.1/.cargo_vcs_info.json0000644000000001361046102023000167030ustar { "git": { "sha1": "948aa87003f6c94080650804a6974182e5948ca1" }, "path_in_vcs": "" }wayland-pipewire-idle-inhibit-0.7.1/.envrc000064400000000000000000000000671046102023000165720ustar 00000000000000watch_file default.nix watch_file shell.nix use flake wayland-pipewire-idle-inhibit-0.7.1/.gitignore000064400000000000000000000000501046102023000174340ustar 00000000000000/target /result /config.toml /.direnv/ wayland-pipewire-idle-inhibit-0.7.1/Cargo.lock0000644000001503331046102023000146630ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "aho-corasick" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] [[package]] name = "android_system_properties" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ "libc", ] [[package]] name = "annotate-snippets" version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4" dependencies = [ "anstyle", "unicode-width", ] [[package]] name = "anstream" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anstyle-parse" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", "windows-sys", ] [[package]] name = "anyhow" version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "async-broadcast" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" dependencies = [ "event-listener", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-channel" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" dependencies = [ "concurrent-queue", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c96bf972d85afc50bf5ab8fe2d54d1586b4e0b46c97c50a0c9e71e2f7bcd812a" dependencies = [ "async-task", "concurrent-queue", "fastrand", "futures-lite", "pin-project-lite", "slab", ] [[package]] name = "async-io" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" dependencies = [ "autocfg", "cfg-if", "concurrent-queue", "futures-io", "futures-lite", "parking", "polling", "rustix", "slab", "windows-sys", ] [[package]] name = "async-lock" version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" dependencies = [ "event-listener", "event-listener-strategy", "pin-project-lite", ] [[package]] name = "async-process" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" dependencies = [ "async-channel", "async-io", "async-lock", "async-signal", "async-task", "blocking", "cfg-if", "event-listener", "futures-lite", "rustix", ] [[package]] name = "async-recursion" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "async-signal" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43c070bbf59cd3570b6b2dd54cd772527c7c3620fce8be898406dd3ed6adc64c" dependencies = [ "async-io", "async-lock", "atomic-waker", "cfg-if", "futures-core", "futures-io", "rustix", "signal-hook-registry", "slab", "windows-sys", ] [[package]] name = "async-task" version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" version = "0.1.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "atomic" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" dependencies = [ "bytemuck", ] [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bindgen" version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ "annotate-snippets", "bitflags", "cexpr", "clang-sys", "itertools", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", "syn", ] [[package]] name = "bitflags" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "blocking" version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" dependencies = [ "async-channel", "async-task", "futures-io", "futures-lite", "piper", ] [[package]] name = "bumpalo" version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "bytemuck" version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" [[package]] name = "cc" version = "1.2.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" dependencies = [ "find-msvc-tools", "shlex", ] [[package]] name = "cexpr" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ "nom 7.1.3", ] [[package]] name = "cfg-expr" version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c6b04e07d8080154ed4ac03546d9a2b303cc2fe1901ba0b35b301516e289368" dependencies = [ "smallvec", "target-lexicon", ] [[package]] name = "cfg-if" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" dependencies = [ "iana-time-zone", "js-sys", "num-traits", "serde", "wasm-bindgen", "windows-link", ] [[package]] name = "clang-sys" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", "libloading", ] [[package]] name = "clap" version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" dependencies = [ "clap_builder", "clap_derive", ] [[package]] name = "clap_builder" version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", ] [[package]] name = "clap_derive" version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" dependencies = [ "heck", "proc-macro2", "quote", "syn", ] [[package]] name = "clap_lex" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "colorchoice" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] name = "concurrent-queue" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] [[package]] name = "convert_case" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baaaa0ecca5b51987b9423ccdc971514dd8b0bb7b4060b983d3664dad3f1f89f" dependencies = [ "unicode-segmentation", ] [[package]] name = "cookie-factory" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" [[package]] name = "core-foundation-sys" version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crossbeam-utils" version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "darling" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ "darling_core", "darling_macro", ] [[package]] name = "darling_core" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" dependencies = [ "ident_case", "proc-macro2", "quote", "strsim", "syn", ] [[package]] name = "darling_macro" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core", "quote", "syn", ] [[package]] name = "deranged" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ "powerfmt", "serde_core", ] [[package]] name = "downcast-rs" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dyn-clone" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "endi" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" [[package]] name = "enumflags2" version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" dependencies = [ "enumflags2_derive", "serde", ] [[package]] name = "enumflags2_derive" version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", "windows-sys", ] [[package]] name = "event-listener" version = "5.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" dependencies = [ "concurrent-queue", "parking", "pin-project-lite", ] [[package]] name = "event-listener-strategy" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ "event-listener", "pin-project-lite", ] [[package]] name = "fastrand" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "figment" version = "0.10.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3" dependencies = [ "atomic", "serde", "toml 0.8.23", "uncased", "version_check", ] [[package]] name = "find-msvc-tools" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "foldhash" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "futures-core" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" [[package]] name = "futures-io" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" [[package]] name = "futures-lite" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" dependencies = [ "fastrand", "futures-core", "futures-io", "parking", "pin-project-lite", ] [[package]] name = "getrandom" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", "r-efi", "wasip2", "wasip3", ] [[package]] name = "glob" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "foldhash", ] [[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "iana-time-zone" version = "0.1.65" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "log", "wasm-bindgen", "windows-core", ] [[package]] name = "iana-time-zone-haiku" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ "cc", ] [[package]] name = "id-arena" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" [[package]] name = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", "serde", ] [[package]] name = "indexmap" version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", "hashbrown 0.16.1", "serde", "serde_core", ] [[package]] name = "is_terminal_polyfill" version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] [[package]] name = "itoa" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "js-sys" version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", ] [[package]] name = "leb128fmt" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "libloading" version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" dependencies = [ "cfg-if", "windows-link", ] [[package]] name = "libspa" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b8cfa2a7656627b4c92c6b9ef929433acd673d5ab3708cda1b18478ac00df4" dependencies = [ "bitflags", "cc", "convert_case", "cookie-factory", "libc", "libspa-sys", "nix", "nom 8.0.0", "system-deps", ] [[package]] name = "libspa-sys" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "901049455d2eb6decf9058235d745237952f4804bc584c5fcb41412e6adcc6e0" dependencies = [ "bindgen", "cc", "system-deps", ] [[package]] name = "linux-raw-sys" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "log" version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" dependencies = [ "serde_core", ] [[package]] name = "memchr" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "memoffset" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] [[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nix" version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ "bitflags", "cfg-if", "cfg_aliases", "libc", ] [[package]] name = "nom" version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", ] [[package]] name = "nom" version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" dependencies = [ "memchr", ] [[package]] name = "num-conv" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "num_threads" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ "libc", ] [[package]] name = "once_cell" version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "once_cell_polyfill" version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[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.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "pin-project-lite" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "piper" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" dependencies = [ "atomic-waker", "fastrand", "futures-io", ] [[package]] name = "pipewire" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9688b89abf11d756499f7c6190711d6dbe5a3acdb30c8fbf001d6596d06a8d44" dependencies = [ "anyhow", "bitflags", "libc", "libspa", "libspa-sys", "nix", "once_cell", "pipewire-sys", "thiserror", ] [[package]] name = "pipewire-sys" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb028afee0d6ca17020b090e3b8fa2d7de23305aef975c7e5192a5050246ea36" dependencies = [ "bindgen", "libspa-sys", "system-deps", ] [[package]] name = "pkg-config" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "polling" version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi", "pin-project-lite", "rustix", "windows-sys", ] [[package]] name = "powerfmt" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "prettyplease" version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", "syn", ] [[package]] name = "proc-macro-crate" version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ "toml_edit 0.25.5+spec-1.1.0", ] [[package]] name = "proc-macro2" version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quick-xml" version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "958f21e8e7ceb5a1aa7fa87fab28e7c75976e0bfe7e23ff069e0a260f894067d" dependencies = [ "memchr", ] [[package]] name = "quote" version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "ref-cast" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "regex" version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "rustc-hash" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", "windows-sys", ] [[package]] name = "rustversion" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "schemars" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" dependencies = [ "dyn-clone", "ref-cast", "serde", "serde_json", ] [[package]] name = "schemars" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" dependencies = [ "dyn-clone", "ref-cast", "serde", "serde_json", ] [[package]] name = "semver" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "serde" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", ] [[package]] name = "serde_core" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", "serde", "serde_core", "zmij", ] [[package]] name = "serde_regex" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8136f1a4ea815d7eac4101cfd0b16dc0cb5e1fe1b8609dfd728058656b7badf" dependencies = [ "regex", "serde", ] [[package]] name = "serde_repr" version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_spanned" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" dependencies = [ "serde", ] [[package]] name = "serde_spanned" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" dependencies = [ "serde_core", ] [[package]] name = "serde_with" version = "3.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd5414fad8e6907dbdd5bc441a50ae8d6e26151a03b1de04d89a5576de61d01f" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", "indexmap 2.13.0", "schemars 0.9.0", "schemars 1.2.1", "serde_core", "serde_json", "serde_with_macros", "time", ] [[package]] name = "serde_with_macros" version = "3.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3db8978e608f1fe7357e211969fd9abdcae80bac1ba7a3369bb7eb6b404eb65" dependencies = [ "darling", "proc-macro2", "quote", "syn", ] [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b57709da74f9ff9f4a27dce9526eec25ca8407c45a7887243b031a58935fb8e" dependencies = [ "libc", "signal-hook-registry", ] [[package]] name = "signal-hook-registry" version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ "errno", "libc", ] [[package]] name = "simplelog" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16257adbfaef1ee58b1363bdc0664c9b8e1e30aed86049635fb5f147d065a9c0" dependencies = [ "log", "termcolor", "time", ] [[package]] name = "slab" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "system-deps" version = "7.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c8f33736f986f16d69b6cb8b03f55ddcad5c41acc4ccc39dd88e84aa805e7f" dependencies = [ "cfg-expr", "heck", "pkg-config", "toml 0.9.12+spec-1.1.0", "version-compare", ] [[package]] name = "target-lexicon" version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c" [[package]] name = "tempfile" version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", "getrandom", "once_cell", "rustix", "windows-sys", ] [[package]] name = "termcolor" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "time" version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" dependencies = [ "deranged", "itoa", "libc", "num-conv", "num_threads", "powerfmt", "serde_core", "time-core", "time-macros", ] [[package]] name = "time-core" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" dependencies = [ "num-conv", "time-core", ] [[package]] name = "timer" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31d42176308937165701f50638db1c31586f183f1aab416268216577aec7306b" dependencies = [ "chrono", ] [[package]] name = "toml" version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned 0.6.9", "toml_datetime 0.6.11", "toml_edit 0.22.27", ] [[package]] name = "toml" version = "0.9.12+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" dependencies = [ "indexmap 2.13.0", "serde_core", "serde_spanned 1.0.4", "toml_datetime 0.7.5+spec-1.1.0", "toml_parser", "toml_writer", "winnow 0.7.15", ] [[package]] name = "toml_datetime" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] [[package]] name = "toml_datetime" version = "0.7.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" dependencies = [ "serde_core", ] [[package]] name = "toml_datetime" version = "1.0.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b320e741db58cac564e26c607d3cc1fdc4a88fd36c879568c07856ed83ff3e9" dependencies = [ "serde_core", ] [[package]] name = "toml_edit" version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap 2.13.0", "serde", "serde_spanned 0.6.9", "toml_datetime 0.6.11", "toml_write", "winnow 0.7.15", ] [[package]] name = "toml_edit" version = "0.25.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ca1a40644a28bce036923f6a431df0b34236949d111cc07cb6dca830c9ef2e1" dependencies = [ "indexmap 2.13.0", "toml_datetime 1.0.1+spec-1.1.0", "toml_parser", "winnow 1.0.0", ] [[package]] name = "toml_parser" version = "1.0.10+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7df25b4befd31c4816df190124375d5a20c6b6921e2cad937316de3fccd63420" dependencies = [ "winnow 1.0.0", ] [[package]] name = "toml_write" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "toml_writer" version = "1.0.7+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17aaa1c6e3dc22b1da4b6bba97d066e354c7945cac2f7852d4e4e7ca7a6b56d" [[package]] name = "tracing" version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing-core" version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", ] [[package]] name = "uds_windows" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" dependencies = [ "memoffset", "tempfile", "windows-sys", ] [[package]] name = "uncased" version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" dependencies = [ "version_check", ] [[package]] name = "unicode-ident" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "unicode-xid" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" dependencies = [ "js-sys", "serde_core", "wasm-bindgen", ] [[package]] name = "version-compare" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasip2" version = "1.0.2+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" dependencies = [ "wit-bindgen", ] [[package]] name = "wasip3" version = "0.4.0+wasi-0.3.0-rc-2026-01-06" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ "wit-bindgen", ] [[package]] name = "wasm-bindgen" version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ "bumpalo", "proc-macro2", "quote", "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-encoder" version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" dependencies = [ "leb128fmt", "wasmparser", ] [[package]] name = "wasm-metadata" version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" dependencies = [ "anyhow", "indexmap 2.13.0", "wasm-encoder", "wasmparser", ] [[package]] name = "wasmparser" version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ "bitflags", "hashbrown 0.15.5", "indexmap 2.13.0", "semver", ] [[package]] name = "wayland-backend" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa75f400b7f719bcd68b3f47cd939ba654cedeef690f486db71331eec4c6a406" dependencies = [ "cc", "downcast-rs", "rustix", "smallvec", "wayland-sys", ] [[package]] name = "wayland-client" version = "0.31.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab51d9f7c071abeee76007e2b742499e535148035bb835f97aaed1338cf516c3" dependencies = [ "bitflags", "rustix", "wayland-backend", "wayland-scanner", ] [[package]] name = "wayland-pipewire-idle-inhibit" version = "0.7.1" dependencies = [ "chrono", "clap", "fastrand", "figment", "log", "nix", "pipewire", "regex", "serde", "serde_regex", "serde_with", "signal-hook", "simplelog", "timer", "wayland-client", "wayland-protocols", "wayland-protocols-wlr", "xdg", "zbus", ] [[package]] name = "wayland-protocols" version = "0.32.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23b5df31ceff1328f06ac607591d5ba360cf58f90c8fad4ac8d3a55a3c4aec7" dependencies = [ "bitflags", "wayland-backend", "wayland-client", "wayland-scanner", ] [[package]] name = "wayland-protocols-wlr" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78248e4cc0eff8163370ba5c158630dcae1f3497a586b826eca2ef5f348d6235" dependencies = [ "bitflags", "wayland-backend", "wayland-client", "wayland-protocols", "wayland-scanner", ] [[package]] name = "wayland-scanner" version = "0.31.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86287151a309799b821ca709b7345a048a2956af05957c89cb824ab919fa4e3" dependencies = [ "proc-macro2", "quick-xml", "quote", ] [[package]] name = "wayland-sys" version = "0.31.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "374f6b70e8e0d6bf9461a32988fd553b59ff630964924dad6e4a4eb6bd538d17" dependencies = [ "pkg-config", ] [[package]] name = "winapi-util" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ "windows-sys", ] [[package]] name = "windows-core" version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", "windows-link", "windows-result", "windows-strings", ] [[package]] name = "windows-implement" version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "windows-interface" version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-result" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ "windows-link", ] [[package]] name = "windows-sys" version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ "windows-link", ] [[package]] name = "winnow" version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" dependencies = [ "memchr", ] [[package]] name = "winnow" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a90e88e4667264a994d34e6d1ab2d26d398dcdca8b7f52bec8668957517fc7d8" dependencies = [ "memchr", ] [[package]] name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" dependencies = [ "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" dependencies = [ "anyhow", "heck", "wit-parser", ] [[package]] name = "wit-bindgen-rust" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" dependencies = [ "anyhow", "heck", "indexmap 2.13.0", "prettyplease", "syn", "wasm-metadata", "wit-bindgen-core", "wit-component", ] [[package]] name = "wit-bindgen-rust-macro" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" dependencies = [ "anyhow", "prettyplease", "proc-macro2", "quote", "syn", "wit-bindgen-core", "wit-bindgen-rust", ] [[package]] name = "wit-component" version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", "bitflags", "indexmap 2.13.0", "log", "serde", "serde_derive", "serde_json", "wasm-encoder", "wasm-metadata", "wasmparser", "wit-parser", ] [[package]] name = "wit-parser" version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" dependencies = [ "anyhow", "id-arena", "indexmap 2.13.0", "log", "semver", "serde", "serde_derive", "serde_json", "unicode-xid", "wasmparser", ] [[package]] name = "xdg" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fb433233f2df9344722454bc7e96465c9d03bff9d77c248f9e7523fe79585b5" [[package]] name = "zbus" version = "5.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca82f95dbd3943a40a53cfded6c2d0a2ca26192011846a1810c4256ef92c60bc" dependencies = [ "async-broadcast", "async-executor", "async-io", "async-lock", "async-process", "async-recursion", "async-task", "async-trait", "blocking", "enumflags2", "event-listener", "futures-core", "futures-lite", "hex", "libc", "ordered-stream", "rustix", "serde", "serde_repr", "tracing", "uds_windows", "uuid", "windows-sys", "winnow 0.7.15", "zbus_macros", "zbus_names", "zvariant", ] [[package]] name = "zbus_macros" version = "5.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897e79616e84aac4b2c46e9132a4f63b93105d54fe8c0e8f6bffc21fa8d49222" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn", "zbus_names", "zvariant", "zvariant_utils", ] [[package]] name = "zbus_names" version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffd8af6d5b78619bab301ff3c560a5bd22426150253db278f164d6cf3b72c50f" dependencies = [ "serde", "winnow 0.7.15", "zvariant", ] [[package]] name = "zmij" version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" [[package]] name = "zvariant" version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5708299b21903bbe348e94729f22c49c55d04720a004aa350f1f9c122fd2540b" dependencies = [ "endi", "enumflags2", "serde", "winnow 0.7.15", "zvariant_derive", "zvariant_utils", ] [[package]] name = "zvariant_derive" version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b59b012ebe9c46656f9cc08d8da8b4c726510aef12559da3e5f1bf72780752c" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn", "zvariant_utils", ] [[package]] name = "zvariant_utils" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f75c23a64ef8f40f13a6989991e643554d9bef1d682a281160cf0c1bc389c5e9" dependencies = [ "proc-macro2", "quote", "serde", "syn", "winnow 0.7.15", ] wayland-pipewire-idle-inhibit-0.7.1/Cargo.toml0000644000000040741046102023000147060ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "wayland-pipewire-idle-inhibit" version = "0.7.1" authors = ["Rafael Carvalho "] build = false autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "Inhibit wayland idle when computer is playing sound" readme = "README.md" keywords = [ "pipewire", "wayland", "utility", "idle", "inhibit", ] categories = ["multimedia"] license = "GPL-3.0-only" repository = "https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit" [[bin]] name = "wayland-pipewire-idle-inhibit" path = "src/main.rs" [dependencies.chrono] version = "0.4" [dependencies.clap] version = "4.5" features = [ "derive", "cargo", "string", ] [dependencies.fastrand] version = "2.3" [dependencies.figment] version = "0.10" features = ["toml"] [dependencies.log] version = "0.4" features = ["serde"] [dependencies.nix] version = "0.30" features = [ "event", "mman", "fs", ] [dependencies.pipewire] version = "0.9" [dependencies.regex] version = "1.12" [dependencies.serde] version = "1.0" features = ["derive"] [dependencies.serde_regex] version = "1.1" [dependencies.serde_with] version = "3.16" [dependencies.signal-hook] version = "0.4" [dependencies.simplelog] version = "0.12" [dependencies.timer] version = "0.2" [dependencies.wayland-client] version = "0.31" [dependencies.wayland-protocols] version = "0.32" features = [ "unstable", "client", ] [dependencies.wayland-protocols-wlr] version = "0.3" features = ["client"] [dependencies.xdg] version = "3.0" [dependencies.zbus] version = "5.13" wayland-pipewire-idle-inhibit-0.7.1/Cargo.toml.orig000064400000000000000000000022151046102023000203400ustar 00000000000000[package] name = "wayland-pipewire-idle-inhibit" version = "0.7.1" authors = ["Rafael Carvalho "] edition = "2021" license = "GPL-3.0-only" repository = "https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit" readme = "README.md" description = "Inhibit wayland idle when computer is playing sound" keywords = ["pipewire", "wayland", "utility", "idle", "inhibit"] categories = ["multimedia"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] chrono = "0.4" clap = { version = "4.5", features = ["derive", "cargo", "string"] } fastrand = "2.3" figment = { version = "0.10", features = ["toml"] } log = { version = "0.4", features = ["serde"] } nix = { version = "0.30", features = ["event", "mman", "fs"] } pipewire = "0.9" regex = "1.12" serde_regex = "1.1" serde = { version = "1.0", features = ["derive"] } serde_with = "3.16" signal-hook = "0.4" simplelog = "0.12" timer = "0.2" wayland-client = "0.31" wayland-protocols = { version = "0.32", features = ["unstable", "client"] } wayland-protocols-wlr = { version = "0.3", features = ["client"] } xdg = "3.0" zbus = "5.13" wayland-pipewire-idle-inhibit-0.7.1/LICENCE000064400000000000000000001045161046102023000164450ustar 00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . wayland-pipewire-idle-inhibit-0.7.1/README.md000064400000000000000000000162641046102023000167410ustar 00000000000000# Wayland PipeWire Idle Inhibit ## Description Suspends automatic idling when media is being played through Pipewire. For detecting media being played, it depends on [PipeWire](https://www.pipewire.org/). For inhibiting idle, it depends, either on: - Wayland compositors implementing the experimental protocols [idle-inhibit-unstable-v1](https://wayland.app/protocols/idle-inhibit-unstable-v1) and [wlr-layer-shell-unstable-v1](https://wayland.app/protocols/wlr-layer-shell-unstable-v1) - Daemons implementing the D-Bus [org.freedesktop.ScreenSaver](https://specifications.freedesktop.org/idle-inhibit-spec/latest/re01.html) service Supported by pretty much all Wayland Compositors. They only exception being Gnome, on which it works only using the Dbus method, because it does not implement the [wlr-layer-shell-unstable-v1](https://wayland.app/protocols/wlr-layer-shell-unstable-v1) protocol. ### Main features - Inhibit idle when any app plays audio through PipeWire - Customisable minimum media duration to inhibit idle (Useful for keeping notifications from inhibiting idle) - Customisable list of client filters (Useful for ignoring certain programs, such as background music) - Support for idle inhibiting through Wayland compositors and dbus services Feedback and contributions are welcome! ## Availability - [AUR](#aur) - [Cargo](#cargo-1) - [Nix Flake](#nix-flake-recommended) - [Nixpkgs](#nixpkgs) ## Usage ``` Usage: wayland-pipewire-idle-inhibit [OPTIONS] Options: -d, --media-minimum-duration Minimum media duration to inhibit idle [default: 5] -v, --verbosity Log verbosity [default: WARN] [possible values: OFF, ERROR, WARN, INFO, DEBUG, TRACE] -q, --quiet Disables logging completely -i, --idle-inhibitor Sets what idle inhibitor backend to use [default: wayland] [possible values: d-bus, dry-run, wayland] -b, --d-bus Enable DBus (org.freedesktop.ScreenSaver) idle inhibitor -w, --wayland Enable Wayland idle inhibitor -n, --dry-run Only logs (at INFO level) about idle inhibitor state changes -c, --config Path to config file -h, --help Print help -V, --version Print version ``` ## Building ### Cargo ```sh git clone https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit cd wayland-pipewire-idle-inhibit cargo build ``` ### Nix ```sh git clone https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit cd wayland-pipewire-idle-inhibit nix build ``` ```sh nix build github:rafaelrc7/wayland-pipewire-idle-inhibit ``` ## Installing ### Cargo ```sh cargo install wayland-pipewire-idle-inhibit ``` See [Running](#running) for instructions on how to run the program. ### AUR This package is available in the Arch User Repository: [wayland-pipewire-idle-inhibit](https://aur.archlinux.org/packages/wayland-pipewire-idle-inhibit) Install it using your AUR helper of choice. The package includes the binary and the default systemd service unit file, that may be enabled and ran with: ```sh systemctl --user enable wayland-pipewire-idle-inhibit.service --now ``` See [Running](#running) for further instructions on how to run the program. ### Nixpkgs This package is available in the nixpkgs repo as `wayland-pipewire-idle-inhibit`. ### Nix Flake (recommended) Add the following snippet to your flake inputs: ```nix wayland-pipewire-idle-inhibit.url = "github:rafaelrc7/wayland-pipewire-idle-inhibit"; ``` From this point you have many options: #### Using the module (recommended) Add the following to your imports: ```nix inputs.wayland-pipewire-idle-inhibit.nixosModules.default ``` Or alternatively, to your home-manager imports: ```nix inputs.wayland-pipewire-idle-inhibit.homeModules.default ``` And then you may use the options to set it up, for example: ```nix services.wayland-pipewire-idle-inhibit = { enable = true; systemdTarget = "sway-session.target"; settings = { verbosity = "INFO"; media_minimum_duration = 10; idle_inhibitor = "wayland"; sink_whitelist = [ { name = "Starship/Matisse HD Audio Controller Analog Stereo"; } ]; node_blacklist = [ { name = "spotify"; } { app_name = "Music Player Daemon"; } ]; }; }; ``` This method will install the program and setup a user systemd service. #### Using the overlay ```nix inputs.wayland-pipewire-idle-inhibit.overlays.default ``` By adding the overlay, you may then install the `wayland-pipewire-idle-inhibit` package. See [Running](#running) for instructions on how to run the program. #### Using the package ```nix inputs.wayland-pipewire-idle-inhibit.packages.default ``` See [Running](#running) for instructions on how to run the program. ## Running ### Compositor Then you may run it in your Sway config, or equivalent for your Wayland compositor: ``` exec wayland-pipewire-idle-inhibit ``` ### systemd Another option is to setup a systemd user service. See [wayland-pipewire-idle-inhibit.service](wayland-pipewire-idle-inhibit.service) for a model. You may customise it by, for example, adding CLI args to `ExecStart` or changing the `WantedBy` target to, for instance, `sway-session.target`. - Copy the example service file to `~/.config/systemd/user/` and edit it to your liking - Run `systemctl --user daemon-reload` - Run `systemctl --user enable wayland-pipewire-idle-inhibit.service --now` ## Config Most settings may be defined either via CLI arguments (run the program with the `--help` for more information) or config file. CLI arguments have priority over the config file. The default config file path is `~/.config/wayland-pipewire-idle-inhibit/config.toml`, but other path may be set using `--config `. `~/.config/wayland-pipewire-idle-inhibit/config.toml` with the default options ```toml verbosity = "WARN" media_minimum_duration = 5 idle_inhibitor = "wayland" sink_whitelist = [ ] node_blacklist = [ ] ``` ### Sink Whitelist You may set a list of Sink filters to be considered by the program. If the Sink matches any of the filters, it will be used. #### Supported fields - `name`: Regex #### Example ```toml [[sink_whitelist]] name = "Sink 1 name" [[sink_whitelist]] name = "Another Sink" ``` ### Node (Client) Blacklist You may set a list of Node filters to be ignored and not inhibit idle even when playing media. If the node matches any of the filters, it will be ignored. #### Supported fields - `name`: Regex. This name is the same used by Helvum for the node. - `app_name`: Regex - `media_class`: Regex - `media_role`: Regex - `media_software`: Regex #### Example ```toml [[node_blacklist]] name = "[Ff]irefox" ``` ## Thanks - [Misterio77](https://github.com/Misterio77/) For help with the creation of the home-manager module. This project was inspired by - [SwayAudioIdleInhibit](https://github.com/ErikReider/SwayAudioIdleInhibit) - [Helvum](https://gitlab.freedesktop.org/pipewire/helvum) ## Licence and Credits This project is licensed under the terms of the GPL3 licence. See [LICENCE](LICENCE) for more information. Parts of the code of the PipeWire connection were greatly inspired by [Helvum](https://gitlab.freedesktop.org/pipewire/helvum), which is also licensed under the terms of the GPL3 licence. wayland-pipewire-idle-inhibit-0.7.1/default.nix000064400000000000000000000012071046102023000176150ustar 00000000000000{ lib, pipewire, pkg-config, rustPlatform, }: let cargoToml = fromTOML (builtins.readFile ./Cargo.toml); in rustPlatform.buildRustPackage { inherit (cargoToml.package) version; pname = cargoToml.package.name; cargoLock.lockFile = ./Cargo.lock; src = lib.cleanSource ./.; strictDeps = true; nativeBuildInputs = [ pkg-config rustPlatform.bindgenHook ]; buildInputs = [ pipewire ]; meta = { inherit (cargoToml.package) description; homepage = cargoToml.package.repository; mainProgram = cargoToml.package.name; license = lib.licenses.gpl3Only; platforms = lib.platforms.linux; }; } wayland-pipewire-idle-inhibit-0.7.1/flake.lock000064400000000000000000000040751046102023000174130ustar 00000000000000{ "nodes": { "flake-parts": { "inputs": { "nixpkgs-lib": [ "nixpkgs" ] }, "locked": { "lastModified": 1772408722, "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", "owner": "hercules-ci", "repo": "flake-parts", "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", "type": "github" }, "original": { "owner": "hercules-ci", "repo": "flake-parts", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1773821835, "narHash": "sha256-TJ3lSQtW0E2JrznGVm8hOQGVpXjJyXY2guAxku2O9A4=", "owner": "nixos", "repo": "nixpkgs", "rev": "b40629efe5d6ec48dd1efba650c797ddbd39ace0", "type": "github" }, "original": { "owner": "nixos", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", "systems": "systems", "treefmt-nix": "treefmt-nix" } }, "systems": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", "repo": "default-linux", "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default-linux", "type": "github" } }, "treefmt-nix": { "inputs": { "nixpkgs": [ "nixpkgs" ] }, "locked": { "lastModified": 1773297127, "narHash": "sha256-6E/yhXP7Oy/NbXtf1ktzmU8SdVqJQ09HC/48ebEGBpk=", "owner": "numtide", "repo": "treefmt-nix", "rev": "71b125cd05fbfd78cab3e070b73544abe24c5016", "type": "github" }, "original": { "owner": "numtide", "repo": "treefmt-nix", "type": "github" } } }, "root": "root", "version": 7 } wayland-pipewire-idle-inhibit-0.7.1/flake.nix000064400000000000000000000050421046102023000172540ustar 00000000000000{ description = "Inhibit Wayland idling when audio is played through PipeWire"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; systems.url = "github:nix-systems/default-linux"; flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } ( { self, withSystem, ... }: { imports = [ inputs.flake-parts.flakeModules.easyOverlay inputs.treefmt-nix.flakeModule ]; flake.nixosModules.default = self.nixosModules.wayland-pipewire-idle-inhibit; flake.nixosModules.wayland-pipewire-idle-inhibit = { lib, pkgs, ... }: { imports = [ ./nix/modules/nixos.nix ]; services.wayland-pipewire-idle-inhibit.package = lib.mkDefault ( withSystem pkgs.stdenv.hostPlatform.system ( { self', ... }: self'.packages.wayland-pipewire-idle-inhibit ) ); }; flake.homeModules.default = self.homeModules.wayland-pipewire-idle-inhibit; flake.homeModules.wayland-pipewire-idle-inhibit = { lib, pkgs, ... }: { imports = [ ./nix/modules/home-manager.nix ]; services.wayland-pipewire-idle-inhibit.package = lib.mkDefault ( withSystem pkgs.stdenv.hostPlatform.system ( { self', ... }: self'.packages.wayland-pipewire-idle-inhibit ) ); }; systems = import inputs.systems; perSystem = { self', pkgs, ... }: { packages = { default = self'.packages.wayland-pipewire-idle-inhibit; wayland-pipewire-idle-inhibit = pkgs.callPackage ./default.nix { }; }; overlayAttrs = { inherit (self'.packages) wayland-pipewire-idle-inhibit; }; devShells.default = import ./shell.nix { inherit pkgs; inputsFrom = [ self'.packages.wayland-pipewire-idle-inhibit ]; }; treefmt.config = { projectRootFile = "flake.nix"; programs = { nixfmt.enable = true; prettier.enable = true; rustfmt.enable = true; taplo.enable = true; }; }; }; } ); } wayland-pipewire-idle-inhibit-0.7.1/nix/modules/common.nix000064400000000000000000000020061046102023000217250ustar 00000000000000{ lib, pkgs, ... }: let inherit (lib) literalExpression mkEnableOption mkOption types ; tomlFormat = pkgs.formats.toml { }; in { options.services.wayland-pipewire-idle-inhibit = { enable = mkEnableOption "wayland-pipewire-idle-inhibit"; package = mkOption { type = types.package; default = pkgs.callPackage ../../default.nix { }; description = "The wayland-pipewire-idle-inhibit package to use."; }; systemdTarget = mkOption { type = types.str; default = "graphical-session.target"; example = "sway-session.target"; description = "systemd target to bind to."; }; settings = mkOption { type = tomlFormat.type; default = { }; example = literalExpression '' { verbosity = "WARN"; media_minimum_duration = 5; node_blacklist = [ { name = "spotify"; } ]; } ''; description = "Configuration for wayland-pipewire-idle-inhibit."; }; }; } wayland-pipewire-idle-inhibit-0.7.1/nix/modules/home-manager.nix000064400000000000000000000016101046102023000227750ustar 00000000000000{ config, lib, pkgs, ... }: let inherit (lib) mkIf; cfg = config.services.wayland-pipewire-idle-inhibit; tomlFormat = pkgs.formats.toml { }; configFile = tomlFormat.generate "wayland-pipewire-idle-inhibit.toml" cfg.settings; in { imports = [ ./common.nix ]; config = mkIf cfg.enable { systemd.user.services.wayland-pipewire-idle-inhibit = { Unit = { Description = "Inhibit Wayland idling when media is played through pipewire"; Documentation = "https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit"; After = [ "pipewire.service" cfg.systemdTarget ]; Wants = [ "pipewire.service" ]; }; Install.WantedBy = [ cfg.systemdTarget ]; Service = { ExecStart = "${lib.getExe cfg.package} --config ${configFile}"; Restart = "always"; RestartSec = 10; }; }; }; } wayland-pipewire-idle-inhibit-0.7.1/nix/modules/nixos.nix000064400000000000000000000016141046102023000216010ustar 00000000000000{ config, lib, pkgs, ... }: let inherit (lib) mkIf; cfg = config.services.wayland-pipewire-idle-inhibit; tomlFormat = pkgs.formats.toml { }; configFile = tomlFormat.generate "wayland-pipewire-idle-inhibit.toml" cfg.settings; in { imports = [ ./common.nix ]; config = mkIf cfg.enable { systemd.user.services.wayland-pipewire-idle-inhibit = { unitConfig = { Description = "Inhibit Wayland idling when media is played through pipewire"; Documentation = "https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit"; After = [ "pipewire.service" cfg.systemdTarget ]; Wants = [ "pipewire.service" ]; }; wantedBy = [ cfg.systemdTarget ]; serviceConfig = { ExecStart = "${lib.getExe cfg.package} --config ${configFile}"; Restart = "always"; RestartSec = 10; }; }; }; } wayland-pipewire-idle-inhibit-0.7.1/shell.nix000064400000000000000000000005571046102023000173070ustar 00000000000000{ pkgs ? import { }, devTools ? true, inputsFrom ? [ (pkgs.callPackage ./default.nix { }) ], ... }: pkgs.mkShell { inherit inputsFrom; strictDeps = true; nativeBuildInputs = with pkgs; [ cargo rustc ] ++ pkgs.lib.optionals devTools [ clippy gdb rust-analyzer rustfmt valgrind ]; } wayland-pipewire-idle-inhibit-0.7.1/src/idle_inhibitor/dbus/mod.rs000064400000000000000000000055451046102023000233170ustar 00000000000000// Copyright (C) 2024-2026 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // SPDX-License-Identifier: GPL-3.0-only use std::error::Error; use log::{debug, error, info}; use zbus::{blocking::Connection, proxy}; use super::IdleInhibitor; #[proxy( interface = "org.freedesktop.ScreenSaver", default_service = "org.freedesktop.ScreenSaver", default_path = "/ScreenSaver" )] trait ScreenSaver { fn Inhibit(&self, application_name: &str, reason_for_inhibit: &str) -> zbus::Result; fn UnInhibit(&self, cookie: u32) -> zbus::Result<()>; } pub struct DbusIdleInhibitor<'a> { _dbus_connection: Connection, dbus_proxy: ScreenSaverProxyBlocking<'a>, cookie: Option, } impl<'a> DbusIdleInhibitor<'a> { pub fn new() -> Result, Box> { let dbus_connection = Connection::session()?; let dbus_proxy = ScreenSaverProxyBlocking::new(&dbus_connection)?; let mut dbus_idle_inhibitor = DbusIdleInhibitor { _dbus_connection: dbus_connection, dbus_proxy, cookie: None, }; dbus_idle_inhibitor.inhibit()?; dbus_idle_inhibitor.uninhibit()?; debug!(target: "DbusIdleInhibitor::new", "DBus Idle Inhibitor created"); Ok(dbus_idle_inhibitor) } } impl Drop for DbusIdleInhibitor<'_> { fn drop(&mut self) { if let Some(cookie) = self.cookie { if let Err(error) = self.dbus_proxy.UnInhibit(cookie) { error!(target: "DbusIdleInhibitor::drop", "{error}"); } self.cookie = None; } } } impl IdleInhibitor for DbusIdleInhibitor<'_> { fn inhibit(&mut self) -> Result<(), Box> { if self.cookie.is_none() { self.cookie = Some( self.dbus_proxy .Inhibit(env!("CARGO_PKG_NAME"), "Media is being played")?, ); info!(target: "DbusIdleInhibitor::inhibit", "Idle Inhibitor was ENABLED"); } Ok(()) } fn uninhibit(&mut self) -> Result<(), Box> { if let Some(cookie) = self.cookie { self.dbus_proxy.UnInhibit(cookie)?; self.cookie = None; info!(target: "DbusIdleInhibitor::uninhibit", "Idle Inhibitor was DISABLED"); } Ok(()) } } wayland-pipewire-idle-inhibit-0.7.1/src/idle_inhibitor/dry/mod.rs000064400000000000000000000025761046102023000231610ustar 00000000000000// Copyright (C) 2024 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // SPDX-License-Identifier: GPL-3.0-only use std::error::Error; use log::info; use super::IdleInhibitor; #[derive(Default)] pub struct DryRunIdleInhibitor { is_idle_inhibited: bool, } impl IdleInhibitor for DryRunIdleInhibitor { fn inhibit(&mut self) -> Result<(), Box> { if !self.is_idle_inhibited { self.is_idle_inhibited = true; info!(target: "DryRunIdleInhibitor::inhibit", "Idle Inhibitor was ENABLED"); } Ok(()) } fn uninhibit(&mut self) -> Result<(), Box> { if self.is_idle_inhibited { self.is_idle_inhibited = false; info!(target: "DryRunIdleInhibitor::inhibit", "Idle Inhibitor was DISABLED"); } Ok(()) } } wayland-pipewire-idle-inhibit-0.7.1/src/idle_inhibitor/mod.rs000064400000000000000000000023361046102023000223550ustar 00000000000000// Copyright (C) 2024-2025 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // SPDX-License-Identifier: GPL-3.0-only use std::error::Error; pub mod dbus; pub mod dry; pub mod wayland; pub trait IdleInhibitor { /// Inhibit Idle, does nothing if idle is already inhibited fn inhibit(&mut self) -> Result<(), Box>; /// Uninhibit Idle, does nothing if idle is not inhibited fn uninhibit(&mut self) -> Result<(), Box>; fn set_inhibit_idle(&mut self, should_inhibit_idle: bool) -> Result<(), Box> { if should_inhibit_idle { self.inhibit() } else { self.uninhibit() } } } wayland-pipewire-idle-inhibit-0.7.1/src/idle_inhibitor/wayland/mod.rs000064400000000000000000000416161046102023000240200ustar 00000000000000// Copyright (C) 2023-2025 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // SPDX-License-Identifier: GPL-3.0-only //! Connection to the Wayland compositor and manages the Wayland Idle Inhibitor. use std::collections::HashMap; use std::error::Error; use std::iter::repeat_with; use std::os::fd::{AsFd, OwnedFd}; use nix::errno::Errno; use nix::fcntl::OFlag; use nix::libc::off_t; use nix::sys::mman::{shm_open, shm_unlink}; use nix::sys::stat::Mode; use nix::unistd::ftruncate; use wayland_client::backend::ObjectId; use wayland_client::protocol::wl_buffer; use wayland_client::protocol::wl_output::WlOutput; use wayland_client::{ Connection, Dispatch, EventQueue, Proxy, QueueHandle, delegate_noop, globals::{GlobalListContents, registry_queue_init}, protocol::{ wl_buffer::WlBuffer, wl_compositor::WlCompositor, wl_registry::{self, WlRegistry}, wl_shm::{Format, WlShm}, wl_shm_pool::WlShmPool, wl_surface::WlSurface, }, }; use wayland_protocols::wp::idle_inhibit::zv1::client::{ zwp_idle_inhibit_manager_v1::ZwpIdleInhibitManagerV1, zwp_idle_inhibitor_v1::ZwpIdleInhibitorV1, }; use wayland_protocols_wlr::layer_shell::v1::client::{ zwlr_layer_shell_v1::{self, ZwlrLayerShellV1}, zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1}, }; use super::IdleInhibitor; // Structs pub type WaylandEventQueue = EventQueue; /// Wayland Idle Inhibitor #[derive(Debug)] pub struct WaylandIdleInhibitor { compositor: WlCompositor, qhandle: QueueHandle, shm: WlShm, wlr_layer_shell: ZwlrLayerShellV1, idle_inhibit_manager: ZwpIdleInhibitManagerV1, outputs: HashMap, // The u32 key represents a proxy name, the ID used by Wayland is_idle_inhibited: bool, } /// Wayland [WlOutput] and it's [Surface] #[derive(Debug)] struct Output { wl_output: WlOutput, surface: Option, } /// Relevant surface objects that depend on each other, thus are represented in a single struct #[derive(Debug)] struct Surface { wl_surface: WlSurface, wlr_layer_surface: ZwlrLayerSurfaceV1, idle_inhibitor: Option, } /// Wrapper around the [ZwpIdleInhibitorV1] type for the implemenation of the [Drop] trait #[derive(Debug)] struct SurfaceIdleInhibitor(ZwpIdleInhibitorV1); // Struct implemenations impl WaylandIdleInhibitor { /// Creates an instance by going through the globals list and binding the relevant ones. Does /// not create a surface. pub fn new() -> Result<(Self, WaylandEventQueue), Box> { let connection = Connection::connect_to_env()?; let (global_list, mut event_queue) = registry_queue_init::(&connection)?; let qhandle = event_queue.handle(); let compositor: WlCompositor = global_list.bind(&qhandle, 1..=1, ())?; let shm: WlShm = global_list.bind(&qhandle, 1..=1, ())?; let wlr_layer_shell: ZwlrLayerShellV1 = global_list.bind(&qhandle, 1..=1, ())?; let idle_inhibit_manager: ZwpIdleInhibitManagerV1 = global_list.bind(&qhandle, 1..=1, ())?; let registry: &WlRegistry = global_list.registry(); let outputs: HashMap = global_list .contents() .clone_list() .iter() .filter_map(|global| { if global.interface == WlOutput::interface().name { Some(( global.name, Output::new(registry.bind(global.name, 3, &qhandle, ())), )) } else { None } }) .collect(); let mut obj = Self { compositor, qhandle, shm, wlr_layer_shell, idle_inhibit_manager, outputs, is_idle_inhibited: false, }; obj.init_missing_surfaces(); event_queue.roundtrip(&mut obj)?; Ok((obj, event_queue)) } /// Create surfaces for all outputs that do not already have one fn init_missing_surfaces(&mut self) { log::debug!(target: "WaylandIdleInhibitor::init_surfaces", "Initialising missing surfaces"); let missing_surface_outputs: Vec = self .outputs .iter() .filter_map(|(k, v)| if v.surface.is_none() { Some(*k) } else { None }) .collect(); if missing_surface_outputs.is_empty() { log::debug!(target: "WaylandIdleInhibitor::init_surfaces", "No new surfaces need to be created"); return; } for output_id in missing_surface_outputs { let Some(output) = self.outputs.get(&output_id) else { continue; }; let mut surface = Surface::new(self, &self.qhandle, &output.wl_output); surface.set_inhibit_idle( self.is_idle_inhibited, &self.idle_inhibit_manager, &self.qhandle, ); let Some(output) = self.outputs.get_mut(&output_id) else { continue; }; output.surface = Some(surface); log::debug!(target: "WaylandIdleInhibitor::init_surfaces", "Created surface for {}", output.wl_output.id()); } } /// Find an output proxy name (u32) from a related wlr_layer_surface id fn find_wlr_layer_surface_output(&self, id: &ObjectId) -> Option<&u32> { self.outputs.iter().find_map(|(k, v)| { if v.surface .as_ref() .is_some_and(|s| s.wlr_layer_surface.id() == *id) { Some(k) } else { None } }) } /// Enables or disables Idle inhibiting using the Wayland protocol, using a /// [ZwpIdleInhibitorV1] for each [Surface] pub fn set_inhibit_idle(&mut self, inhibit_idle: bool) -> Result<(), Box> { self.is_idle_inhibited = inhibit_idle; let surfaces: Vec<&mut Surface> = self .outputs .iter_mut() .filter_map(|(_, v)| v.surface.as_mut()) .collect(); if surfaces.is_empty() { log::debug!(target: "WaylandIdleInhibitor::set_inhibit_idle", "No surfaces loaded"); return Ok(()); } let mut changed_value = false; for surface in surfaces { changed_value = surface.set_inhibit_idle(inhibit_idle, &self.idle_inhibit_manager, &self.qhandle) || changed_value; } if changed_value { //self.roundtrip()?; log::info!(target: "WaylandIdleInhibitor::set_inhibit_idle", "Idle Inhibitor was {}", if inhibit_idle {"ENABLED"} else {"DISABLED"}); } Ok(()) } } impl IdleInhibitor for WaylandIdleInhibitor { fn inhibit(&mut self) -> Result<(), Box> { self.set_inhibit_idle(true) } fn uninhibit(&mut self) -> Result<(), Box> { self.set_inhibit_idle(false) } } impl Output { fn new(wl_output: WlOutput) -> Self { Self { wl_output, surface: None, } } } impl Surface { /// Creates an instance. It must receive a [zwlr_layer_surface_v1::Event::Configure] event /// before the buffer is created and attached fn new( state: &WaylandIdleInhibitor, qhandle: &QueueHandle, output: &WlOutput, ) -> Self { let wl_surface = state.compositor.create_surface(qhandle, ()); let wlr_layer_surface = state.wlr_layer_shell.get_layer_surface( &wl_surface, Some(output), zwlr_layer_shell_v1::Layer::Background, "wayland-pipewire-idle-inhibit".into(), qhandle, (), ); wlr_layer_surface.set_anchor(zwlr_layer_surface_v1::Anchor::all()); wl_surface.commit(); Self { wl_surface, wlr_layer_surface, idle_inhibitor: None, } } /// Creates and attaches a buffer for the surface. Must be called after the /// [zwlr_layer_surface_v1::Event::Configure] event. fn configure( &self, state: &WaylandIdleInhibitor, qhandle: &QueueHandle, ) -> Result<(), Box> { let width: i32 = 1; let height: i32 = 1; let stride: i32 = width * 4; let pool_size: i32 = height * stride * 2; let shm = Self::allocate_shm_file(pool_size as off_t)?; let pool = state.shm.create_pool(shm.as_fd(), pool_size, qhandle, ()); let buffer = pool.create_buffer(0, width, height, stride, Format::Argb8888, qhandle, ()); self.wl_surface.attach(Some(&buffer), 0, 0); self.wl_surface.commit(); pool.destroy(); // Destroys Pool when all buffers are gone Ok(()) } /// Creates a shm file, unlinks it (so that it gets removed when closed) and allocates the /// requested number of bytes. fn allocate_shm_file(size: off_t) -> Result> { let (shm, shm_name) = Self::create_shm_file()?; shm_unlink(shm_name.as_str())?; ftruncate(&shm, size)?; Ok(shm) } /// Creates a shm file with a random name. In case of name conflicts it retries the process /// multiple times. fn create_shm_file() -> Result<(OwnedFd, String), Box> { let mut rng = fastrand::Rng::new(); let mut retries: u32 = 100; loop { if retries == 0 { break Err(Box::new(Errno::EEXIST)); } retries = retries.saturating_sub(1); let shm_name_suffix: String = repeat_with(|| rng.alphanumeric()).take(10).collect(); let shm_name = format!("/wayland-pipewire-idle-inhibit-buffer-{shm_name_suffix}"); let shm = shm_open( shm_name.as_str(), OFlag::O_CREAT | OFlag::O_EXCL | OFlag::O_RDWR, Mode::S_IWUSR | Mode::S_IRUSR, ); match shm { Ok(shm) => break Ok((shm, shm_name)), Err(Errno::EEXIST) => continue, Err(err) => break Err(Box::new(err)), } } } /// Create or destroy the surface's [ZwpIdleInhibitorV1]. Returns true if state was changed, /// false otherwise. fn set_inhibit_idle( &mut self, inhibit_idle: bool, idle_inhibit_manager: &ZwpIdleInhibitManagerV1, qhandle: &QueueHandle, ) -> bool { if inhibit_idle { if self.idle_inhibitor.is_none() { self.idle_inhibitor = Some(SurfaceIdleInhibitor( idle_inhibit_manager.create_inhibitor(&self.wl_surface, qhandle, ()), )); log::debug!(target: "WaylandIdleInhibitor::Surface::set_inhibit_idle", "Idle Inhibitor was ENABLED for {}", self.wl_surface.id()); return true; } } else if self.idle_inhibitor.is_some() { self.idle_inhibitor = None; log::debug!(target: "WaylandIdleInhibitor::Surface::set_inhibit_idle", "Idle Inhibitor was DISABLED for {}", self.wl_surface.id()); return true; } false } } // Drop implementations to release Wayland resources. Objects are kepf even after the proxy goes // out of scope. Thus, we need to manually call the `destroy` destructor. impl Drop for WaylandIdleInhibitor { fn drop(&mut self) { self.idle_inhibit_manager.destroy(); self.shm.release(); self.wlr_layer_shell.destroy(); } } impl Drop for Output { fn drop(&mut self) { self.wl_output.release(); } } impl Drop for Surface { fn drop(&mut self) { self.wlr_layer_surface.destroy(); self.wl_surface.destroy(); } } impl Drop for SurfaceIdleInhibitor { fn drop(&mut self) { let SurfaceIdleInhibitor(idle_inhibitor) = self; idle_inhibitor.destroy(); } } // Event callback implementations /// Subscribes to the [ZwlrLayerSurfaceV1] events waiting for configure and closed events. impl Dispatch for WaylandIdleInhibitor { fn event( state: &mut Self, proxy: &ZwlrLayerSurfaceV1, event: ::Event, _data: &(), _conn: &Connection, qhandle: &QueueHandle, ) { match event { zwlr_layer_surface_v1::Event::Configure { serial, .. } => { log::trace!(target: "WaylandIdleInhibitor::ZwlrLayerSurfaceV1::Event::Configure", "Event received"); let Some(output_id) = state.find_wlr_layer_surface_output(&proxy.id()) else { log::debug!(target: "WaylandIdleInhibitor::ZwlrLayerSurfaceV1::Event::Configure", "Output not found"); return; }; if let Some(surface) = &state .outputs .get(output_id) .and_then(|o| o.surface.as_ref()) { surface.wlr_layer_surface.ack_configure(serial); if let Err(error) = surface.configure(state, qhandle) { log::error!(target: "WaylandIdleInhibitor::ZwlrLayerSurfaceV1::Event::Configure", "{error}"); return; } log::debug!(target: "WaylandIdleInhibitor::ZwlrLayerSurfaceV1::Event::Configure", "Configured"); }; } zwlr_layer_surface_v1::Event::Closed => { log::debug!(target: "WaylandIdleInhibitor::ZwlrLayerSurfaceV1::Event::Closed", "Surface {}", proxy.id()); let Some(output_id) = state.find_wlr_layer_surface_output(&proxy.id()) else { return; }; let Some(output) = &mut state.outputs.get_mut(&output_id.to_owned()) else { return; }; output.surface = None; } _ => {} } } } /// Subscribes to the [WlRegistry] events, mainly to treat added and removed objects impl Dispatch for WaylandIdleInhibitor { fn event( state: &mut Self, proxy: &WlRegistry, event: ::Event, _data: &GlobalListContents, _conn: &Connection, qhandle: &QueueHandle, ) { match event { wl_registry::Event::Global { name, interface, version, } => { log::trace!(target: "WaylandIdleInhibitor::WlRegistry::Event::Global", "New {interface} [{name}] v{version}"); if interface == WlOutput::interface().name { log::debug!(target: "WaylandIdleInhibitor::WlRegistry::Event::Global", "New output {name}"); let wl_output = proxy.bind(name, 3, qhandle, ()); state.outputs.insert(name, Output::new(wl_output)); state.init_missing_surfaces(); } } wl_registry::Event::GlobalRemove { name } => { log::trace!(target: "WaylandIdleInhibitor::WlRegistry::Event::Global", "Removed {name}"); if state.outputs.remove(&name).is_some() { log::debug!(target: "WaylandIdleInhibitor::WlRegistry::Event::GlobalRemove", "Removed output {name}"); } } _ => {} } } } /// Subscribes to the [WlBuffer] events, to destroy the buffer when it is time. impl Dispatch for WaylandIdleInhibitor { fn event( _state: &mut Self, proxy: &WlBuffer, event: ::Event, _data: &(), _conn: &Connection, _qhandle: &QueueHandle, ) { if let wl_buffer::Event::Release = event { proxy.destroy(); } } } // Ignore events from these object types. delegate_noop!(WaylandIdleInhibitor: ignore WlOutput); delegate_noop!(WaylandIdleInhibitor: ignore WlShm); delegate_noop!(WaylandIdleInhibitor: ignore WlSurface); delegate_noop!(WaylandIdleInhibitor: ignore WlCompositor); delegate_noop!(WaylandIdleInhibitor: ignore WlShmPool); delegate_noop!(WaylandIdleInhibitor: ignore ZwlrLayerShellV1); delegate_noop!(WaylandIdleInhibitor: ignore ZwpIdleInhibitManagerV1); delegate_noop!(WaylandIdleInhibitor: ignore ZwpIdleInhibitorV1); wayland-pipewire-idle-inhibit-0.7.1/src/inhibit_idle_state.rs000064400000000000000000000113031046102023000224270ustar 00000000000000// Copyright (C) 2023-2025 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // SPDX-License-Identifier: GPL-3.0-only //! Helper to manage the idle inhibiting state. This module is used to treat PipeWire events and //! send messages if and when idle should be inhibited, treating the minimum sound duration. use std::sync::{Arc, RwLock}; use chrono::Duration; use log::{debug, trace}; use timer::{Guard, Timer}; use crate::message_queue::MessageQueueSender; /// Module Event message type #[derive(Clone, Copy, Debug)] pub enum InhibitIdleStateEvent { InhibitIdle(bool), } /// Manager of the idle inhibit state pub struct InhibitIdleState + Clone> { inhibit_idle_timout_callback: Timer, inhibit_idle_timout_callback_guard: Option, inhibit_idle_timout: Option, is_idle_inhibited: Arc>, inhibit_idle_callback: MessageQueueSender, } impl + Clone + Send + 'static> InhibitIdleState { pub fn new( inhibit_idle_timout: Option, inhibit_idle_callback: MessageQueueSender, ) -> Self { Self { inhibit_idle_timout_callback: Timer::new(), inhibit_idle_timout_callback_guard: None, inhibit_idle_timout, is_idle_inhibited: Arc::new(RwLock::new(false)), inhibit_idle_callback, } } /// Wrapper function to update the inhibit idle state. It only updates the value if necessary, /// and manages the timer. When a call is made to change the state, it starts a timer with the /// set minimum duration that actually executes the update of the is_idle_inhibited field. pub fn set_is_idle_inhibited(&mut self, is_idle_inhibited: bool) { if let (Some(inhibit_idle_timout), true) = (self.inhibit_idle_timout, is_idle_inhibited) { if self.inhibit_idle_timout_callback_guard.is_some() { trace!(target: "InhibitIdleState::set_is_idle_inhibited", "Update Timer is already running"); return; } debug!(target: "InhibitIdleState::set_is_idle_inhibited", "Started Timer to inhibit idling"); self.inhibit_idle_timout_callback_guard = Some( self.inhibit_idle_timout_callback .schedule_with_delay(inhibit_idle_timout, { let is_idle_inhibited_ref = Arc::clone(&self.is_idle_inhibited); let inhibit_idle_callback = self.inhibit_idle_callback.clone(); move || { let is_idle_inhibited_ref = &is_idle_inhibited_ref; Self::update_is_idle_inhibited( Arc::clone(is_idle_inhibited_ref), inhibit_idle_callback.clone(), is_idle_inhibited, ); } }), ); } else { if self.inhibit_idle_timout_callback_guard.is_some() { self.inhibit_idle_timout_callback_guard = None } Self::update_is_idle_inhibited( self.is_idle_inhibited.clone(), self.inhibit_idle_callback.clone(), is_idle_inhibited, ); } } /// Private function that accesses the reference of the state and updates its value fn update_is_idle_inhibited( is_idle_inhibited_ref: Arc>, inhibit_idle_callback: MessageQueueSender, is_idle_inhibited: bool, ) { if *is_idle_inhibited_ref.read().unwrap() == is_idle_inhibited { trace!(target: "InhibitIdleState", "Tried to update 'is_idle_inhibited', but value is the same"); return; } *is_idle_inhibited_ref.write().unwrap() = is_idle_inhibited; inhibit_idle_callback .send(Msg::from(InhibitIdleStateEvent::InhibitIdle( is_idle_inhibited, ))) .unwrap(); debug!(target: "InhibitIdleState", "Idle inhibting was {}", if is_idle_inhibited { "ENABLED" } else { "DISABLED" }); } } wayland-pipewire-idle-inhibit-0.7.1/src/main.rs000064400000000000000000000220301046102023000175270ustar 00000000000000// Copyright (C) 2023-2025 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // SPDX-License-Identifier: GPL-3.0-only //! Inhibit idle in Wayland compositors when audio is being played through PipeWire, with highly //! customisable options use std::{ error::Error, panic, process::ExitCode, sync::{ Arc, atomic::{self, AtomicBool}, }, }; mod inhibit_idle_state; use inhibit_idle_state::{InhibitIdleState, InhibitIdleStateEvent}; mod pipewire_connection; use message_queue::MessageQueueReceiver; use pipewire_connection::{PWEvent, PWMsg, PWThread}; mod idle_inhibitor; use idle_inhibitor::{ IdleInhibitor, dbus::DbusIdleInhibitor, dry::DryRunIdleInhibitor, wayland::{WaylandEventQueue, WaylandIdleInhibitor}, }; mod settings; use settings::Settings; mod message_queue; use nix::{errno::Errno, sys::epoll::*}; #[repr(u64)] enum MessageQueueType { Unknown, Wayland, Main, } impl From for MessageQueueType { fn from(value: u64) -> Self { match value { value if value == Self::Wayland as u64 => Self::Wayland, value if value == Self::Main as u64 => Self::Main, _ => Self::Unknown, } } } #[derive(Clone, Debug)] enum Msg { PWEvent(PWEvent), InhibitIdleStateEvent(InhibitIdleStateEvent), } impl Msg { fn handle( &self, pw_thread: &PWThread, inhibit_idle_state_manager: &mut InhibitIdleState, idle_inhibitor: &mut dyn IdleInhibitor, ) -> Result<(), Box> { match self { Msg::PWEvent(pw_event) => match pw_event { PWEvent::GraphUpdated => { pw_thread.send(PWMsg::GraphUpdated)?; } PWEvent::InhibitIdleState(inhibit_idle_state) => { inhibit_idle_state_manager.set_is_idle_inhibited(*inhibit_idle_state); } PWEvent::ThreadPanic(err) => { if let Some(err) = err { Err(format!("Fatal PipeWire Error: {err}"))?; } else { Err("Fatal PipeWire Error!")?; } } }, Msg::InhibitIdleStateEvent(inhibit_idle_state_event) => { match inhibit_idle_state_event { InhibitIdleStateEvent::InhibitIdle(inhibit_idle_state) => { idle_inhibitor.set_inhibit_idle(*inhibit_idle_state)?; } } } } Ok(()) } } impl From for Msg { fn from(value: PWEvent) -> Self { Msg::PWEvent(value) } } impl From for Msg { fn from(value: InhibitIdleStateEvent) -> Self { Msg::InhibitIdleStateEvent(value) } } fn main() -> ExitCode { match run() { Ok(()) => ExitCode::SUCCESS, Err(error) => { log::error!("{error}"); ExitCode::FAILURE } } } fn run() -> Result<(), Box> { let settings = Settings::new()?; simplelog::TermLogger::init( settings.get_verbosity(), simplelog::Config::default(), simplelog::TerminalMode::Mixed, simplelog::ColorChoice::Auto, )?; let epoll = Epoll::new(EpollCreateFlags::empty())?; let (mq, mq_receiver) = message_queue::message_queue::(&epoll, MessageQueueType::Main as u64)?; panic::set_hook(Box::new({ let mq = mq.clone(); move |panic_info| { let err = panic_info .payload() .downcast_ref::<&str>() .map(|s| String::from(*s)) .or(panic_info .payload() .downcast_ref::() .map(|s| s.to_owned())); mq.send(Msg::PWEvent(PWEvent::ThreadPanic(err))).unwrap(); } })); let pw_thread = PWThread::new( mq.clone(), settings.get_sink_whitelist().to_vec(), settings.get_node_blacklist().to_vec(), ); let inhibit_idle_state_manager: InhibitIdleState = InhibitIdleState::new(settings.get_media_minimum_duration(), mq.clone()); let term = Arc::new(AtomicBool::new(false)); for sig in signal_hook::consts::TERM_SIGNALS { signal_hook::flag::register(*sig, Arc::clone(&term))?; } match settings.get_idle_inhibitor() { settings::IdleInhibitor::DBus => { let idle_inhibitor = Box::new(DbusIdleInhibitor::new()?); non_wayland_main_loop( idle_inhibitor, term, epoll, mq_receiver, &pw_thread, inhibit_idle_state_manager, )?; } settings::IdleInhibitor::DryRun => { let idle_inhibitor = Box::::default(); non_wayland_main_loop( idle_inhibitor, term, epoll, mq_receiver, &pw_thread, inhibit_idle_state_manager, )?; } settings::IdleInhibitor::Wayland => { let (idle_inhibitor, event_queue) = WaylandIdleInhibitor::new()?; wayland_main_loop( idle_inhibitor, event_queue, term, epoll, mq_receiver, &pw_thread, inhibit_idle_state_manager, )?; } }; pw_thread.send(PWMsg::Terminate)?; pw_thread.join()?; Ok(()) } fn wayland_main_loop( mut wayland_idle_inhibitor: WaylandIdleInhibitor, mut wayland_event_queue: WaylandEventQueue, term: Arc, epoll: Epoll, mq_receiver: MessageQueueReceiver, pw_thread: &PWThread, mut inhibit_idle_state_manager: InhibitIdleState, ) -> Result<(), Box> { while !term.load(atomic::Ordering::Relaxed) { wayland_event_queue.flush()?; let wayland_read_guard = if let Some(wayland_read_guard) = wayland_event_queue.prepare_read() { wayland_read_guard } else { wayland_event_queue.dispatch_pending(&mut wayland_idle_inhibitor)?; wayland_event_queue.prepare_read().ok_or( "Unknown error when trying to get a read lock on the Wayland Event Queue", )? }; epoll.add( wayland_read_guard.connection_fd(), EpollEvent::new(EpollFlags::EPOLLIN, MessageQueueType::Wayland as u64), )?; let mut events = [EpollEvent::empty()]; let ret = epoll.wait(&mut events, EpollTimeout::NONE); epoll.delete(wayland_read_guard.connection_fd())?; let event = match ret { Ok(_) => events[0], Err(Errno::EINTR) => continue, Err(err) => Err(err)?, }; match event.data().into() { MessageQueueType::Main => { std::mem::drop(wayland_read_guard); mq_receiver.recv()?.handle( pw_thread, &mut inhibit_idle_state_manager, &mut wayland_idle_inhibitor, )?; } MessageQueueType::Wayland => { if wayland_read_guard.read().is_ok() { wayland_event_queue.dispatch_pending(&mut wayland_idle_inhibitor)?; } } MessageQueueType::Unknown => log::error!(target: "main", "Unknown event queue"), } } Ok(()) } fn non_wayland_main_loop( mut idle_inhibitor: Box, term: Arc, epoll: Epoll, mq_receiver: MessageQueueReceiver, pw_thread: &PWThread, mut inhibit_idle_state_manager: InhibitIdleState, ) -> Result<(), Box> { while !term.load(atomic::Ordering::Relaxed) { let mut events = [EpollEvent::empty()]; let event = match epoll.wait(&mut events, EpollTimeout::NONE) { Ok(_) => events[0], Err(Errno::EINTR) => continue, Err(err) => Err(err)?, }; match event.data().into() { MessageQueueType::Main => mq_receiver.recv()?.handle( pw_thread, &mut inhibit_idle_state_manager, idle_inhibitor.as_mut(), )?, MessageQueueType::Unknown => log::error!(target: "main", "Unknown event queue"), MessageQueueType::Wayland => unreachable!(), } } Ok(()) } wayland-pipewire-idle-inhibit-0.7.1/src/message_queue.rs000064400000000000000000000042411046102023000214370ustar 00000000000000// Copyright (C) 2025 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // SPDX-License-Identifier: GPL-3.0-only use std::{ error::Error, sync::{Arc, mpsc}, }; use nix::sys::{ epoll::{Epoll, EpollEvent, EpollFlags}, eventfd::{self, EfdFlags, EventFd}, }; #[derive(Clone)] pub struct MessageQueueSender { sender: mpsc::Sender, eventfd: Arc, } pub struct MessageQueueReceiver { receiver: mpsc::Receiver, eventfd: Arc, } pub fn message_queue( epoll: &Epoll, queue_id: u64, ) -> Result<(MessageQueueSender, MessageQueueReceiver), Box> { let (sender, receiver) = mpsc::channel::(); let eventfd = EventFd::from_flags(EfdFlags::EFD_SEMAPHORE)?; epoll.add(&eventfd, EpollEvent::new(EpollFlags::EPOLLIN, queue_id))?; let eventfd = Arc::new(eventfd); let message_queue_sender = MessageQueueSender { sender, eventfd: eventfd.clone(), }; let message_queue_receiver = MessageQueueReceiver { receiver, eventfd: eventfd.clone(), }; log::debug!(target: "MessageQueue::new", "Created new message queue with ID {queue_id}"); Ok((message_queue_sender, message_queue_receiver)) } impl<'a, T: 'a + Clone> MessageQueueSender { pub fn send(&self, payload: T) -> Result<(), Box> { self.sender.send(payload)?; self.eventfd.write(1)?; Ok(()) } } impl MessageQueueReceiver { pub fn recv(&self) -> Result> { self.eventfd.read()?; Ok(self.receiver.recv()?) } } wayland-pipewire-idle-inhibit-0.7.1/src/pipewire_connection/graph/filter.rs000064400000000000000000000076061046102023000252500ustar 00000000000000// Copyright (C) 2024 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // SPDX-License-Identifier: GPL-3.0-only //! Tools used for filtering over [super::PWGraph] objects. use regex::Regex; use serde::{Deserialize, Serialize}; use super::NodeData; /// Represents a generic filter for a generic type. In the contexts of this application, it is used /// to filter objects of the [super::PWGraph], mainly [super::NodeData]s. pub trait Filter { /// Checks if the filter matches a given object. fn matches(&self, data: &T) -> bool; /// Checks if all filters of a slice matches a object. /// /// This function will return false on the first failed filter and true if all checks succed. /// /// When an empty slice of filters is passed, it returns true. #[allow(dead_code)] fn matches_all(filters: &[Self], data: &T) -> bool where Self: Sized, { filters.iter().all(|f| f.matches(data)) } /// Checks if any filters of a slice matches a object. /// /// This function will return true on the first succesful filter and false if all checks fail. /// /// When an empty slice of filters is passed, it returns false. fn matches_any(filters: &[Self], data: &T) -> bool where Self: Sized, { filters.iter().any(|f| f.matches(data)) } } /// Checks if a [Regex] filter matches a given [String] property. /// /// If the filter is [None] this means it should not be applied, and thus the result is always /// true. /// /// If the filter is [Some] but the property is [None], it means the filter must be applied but the /// property is missing, thus the result is always false. /// /// If the filter and property are [Some], the result will be the answer to if the property value /// matches the filter [Regex]. fn matches_property(filter: &Option, property: Option<&str>) -> bool { filter .as_ref() .is_none_or(|f| property.is_some_and(|p| f.is_match(p))) } /// Represents a [Filter] over a Sink. A Sink is a special case of a Node, and thus filters over /// [super::NodeData]s. #[derive(Serialize, Deserialize, Clone)] pub struct SinkFilter { #[serde(default, with = "serde_regex")] name: Option, } impl Filter for SinkFilter { fn matches(&self, node: &NodeData) -> bool { matches_property(&self.name, node.get_name()) } } /// Represents a [Filter] over a generic Node, and thus filters over [super::NodeData]s. #[derive(Serialize, Deserialize, Clone)] pub struct NodeFilter { #[serde(default, with = "serde_regex")] name: Option, #[serde(default, with = "serde_regex")] app_name: Option, #[serde(default, with = "serde_regex")] media_class: Option, #[serde(default, with = "serde_regex")] media_role: Option, #[serde(default, with = "serde_regex")] media_software: Option, } impl Filter for NodeFilter { fn matches(&self, node: &NodeData) -> bool { matches_property(&self.name, node.get_name()) && matches_property(&self.app_name, node.app_name.as_deref()) && matches_property(&self.media_class, node.media_class.as_deref()) && matches_property(&self.media_role, node.media_role.as_deref()) && matches_property(&self.media_software, node.media_software.as_deref()) } } wayland-pipewire-idle-inhibit-0.7.1/src/pipewire_connection/graph/mod.rs000064400000000000000000000472571046102023000245500ustar 00000000000000// Copyright (C) 2023-2024 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // SPDX-License-Identifier: GPL-3.0-only //! Module responsible to represent and treat the PipeWire Graph, in the context of this app, //! composed of [PWObject]s, that can be Nodes, Links or Ports. use std::collections::{HashMap, HashSet}; use log::{debug, trace, warn}; use pipewire::spa::utils::Direction; pub mod filter; use filter::{Filter, NodeFilter, SinkFilter}; pub mod object; use object::{Id, LinkData, NodeData, PWObject, PWObjectData, PortData}; /// Struct that represents the [pipewire] graph. /// /// Tracked objects are store in a [HashMap] with its id used as key /// /// Fast access to links attached to ports and the port's nodes are also kept in maps. pub struct PWGraph { objects: HashMap, sinks: HashSet, links_to_port: HashMap>, links_from_port: HashMap>, node_input_ports: HashMap>, node_output_ports: HashMap>, sink_whitelist: Vec, node_blacklist: Vec, } impl PWGraph { /// Builds a new [PWGraph] /// /// The vectors of [SinkFilter]s and [NodeFilter]s are defined by the user and, thus, are /// passed as arguments. pub fn new(sink_whitelist: Vec, node_blacklist: Vec) -> Self { Self { objects: HashMap::default(), sinks: HashSet::default(), links_to_port: HashMap::default(), links_from_port: HashMap::default(), node_input_ports: HashMap::default(), node_output_ports: HashMap::default(), sink_whitelist, node_blacklist, } } /// Inserts a new object into the Graph. /// /// Currently ID conflicts are not treated. pub fn insert(&mut self, id: Id, obj: PWObject) { match obj { PWObject::Node { ref data, .. } => { let NodeData { ref media_class, .. } = data; debug!(target: "PWGraph::insert", "Node ({id}) '{}'; {:?}", data.get_name().unwrap_or_default(), data); if let Some(media_class) = media_class { if media_class.contains("Sink") && (self.sink_whitelist.is_empty() || SinkFilter::matches_any(&self.sink_whitelist, data)) { self.sinks.insert(id); } }; } PWObject::Port { ref data, .. } => { let PortData { node_id, direction, .. } = data; debug!(target: "PWGraph::insert", "Port ({id})"); if let (Some(node_id), Some(direction)) = (node_id, direction) { match *direction { Direction::Input => { debug!(target: "PWGraph::insert", "Port ({id}) as Node {node_id} Input; {data:?}"); self.node_input_ports .entry(*node_id) .or_default() .insert(id); } Direction::Output => { debug!(target: "PWGraph::insert", "Port ({id}) as Node {node_id} Output; {data:?}"); self.node_output_ports .entry(*node_id) .or_default() .insert(id); } _ => {} }; }; } PWObject::Link { ref data, .. } => { let LinkData { input_port, output_port, .. } = data; debug!(target: "PWGraph::insert", "Link ({id}); {data:?}"); if let Some(output_port) = output_port { debug!(target: "PWGraph::insert", "Link ({id}) with output_port {output_port}"); self.links_from_port .entry(*output_port) .or_default() .insert(id); }; if let Some(input_port) = input_port { debug!(target: "PWGraph::insert", "Link ({id}) with input_port {input_port}"); self.links_to_port .entry(*input_port) .or_default() .insert(id); }; } } self.objects.insert(id, obj); } /// Updates an object data pub fn update(&mut self, id: Id, new_data: PWObjectData) -> bool { trace!(target: "PWGraph::update", "Called for object with ID {id}"); let Some(obj) = self.objects.get_mut(&id) else { warn!(target: "PWGraph::update", "Tried to update inexistent object with ID {id}"); return false; }; match new_data { PWObjectData::Node(new_data) => { let PWObject::Node { ref mut data, .. } = obj else { warn!(target: "PWGraph::update", "Tried to update Node, but object of ID {id} is not a Node"); return false; }; let NodeData { media_class: ref new_media_class, .. } = new_data; let NodeData { ref media_class, .. } = data; if media_class != new_media_class { if let Some(new_media_class) = new_media_class { if let Some(media_class) = media_class { if media_class.contains("Sink") { self.sinks.remove(&id); } } if new_media_class.contains("Sink") && (self.sink_whitelist.is_empty() || SinkFilter::matches_any(&self.sink_whitelist, &new_data)) { self.sinks.insert(id); } } } debug!(target: "PWGraph::update", "Updated Node ({id}) from {data:?}"); let was_updated = data.update(new_data); debug!(target: "PWGraph::update", "Updated Node ({id}) to {data:?}"); was_updated } PWObjectData::Port(new_data) => { let PWObject::Port { ref mut data, .. } = obj else { warn!(target: "PWGraph::update", "Tried to update Port, but object of ID {id} is not a Port"); return false; }; let PortData { node_id: ref new_node_id, direction: ref new_direction, .. } = new_data; let PortData { ref node_id, ref direction, .. } = data; if node_id != new_node_id || direction != new_direction { if let (Some(new_node_id), Some(new_direction)) = (new_node_id, new_direction) { if let (Some(node_id), Some(direction)) = (node_id, direction) { match *direction { Direction::Input => { self.node_input_ports .entry(*node_id) .or_default() .remove(&id); } Direction::Output => { self.node_output_ports .entry(*node_id) .or_default() .remove(&id); } _ => {} } } match *new_direction { Direction::Input => { self.node_input_ports .entry(*new_node_id) .or_default() .insert(id); } Direction::Output => { self.node_output_ports .entry(*new_node_id) .or_default() .insert(id); } _ => {} } } } debug!(target: "PWGraph::update", "Updated Port ({id}) from {data:?}"); let was_updated = data.update(new_data); debug!(target: "PWGraph::update", "Updated Port ({id}) to {data:?}"); was_updated } PWObjectData::Link(new_data) => { let PWObject::Link { ref mut data, .. } = obj else { warn!(target: "PWGraph::update", "Tried to update Link, but object of ID {id} is not a Link"); return false; }; let LinkData { input_port: ref new_input_port, output_port: ref new_output_port, .. } = new_data; let LinkData { ref input_port, ref output_port, .. } = data; if output_port != new_output_port { if let Some(new_output_port) = new_output_port { if let Some(output_port) = output_port { self.links_from_port .entry(*output_port) .or_default() .remove(&id); } self.links_from_port .entry(*new_output_port) .or_default() .insert(id); } } if input_port != new_input_port { if let Some(new_input_port) = new_input_port { if let Some(input_port) = input_port { self.links_to_port .entry(*input_port) .or_default() .remove(&id); } self.links_to_port .entry(*new_input_port) .or_default() .insert(id); } } debug!(target: "PWGraph::update", "Updated Link ({id}) from {data:?}"); let was_updated = data.update(new_data); debug!(target: "PWGraph::update", "Updated Link ({id}) to {data:?}"); was_updated } } } /// Remove an object from the graph and cleans up references to it. pub fn remove(&mut self, id: Id) -> Option { trace!(target: "PWGraph::remove", "Called for object with ID {id}"); let removed = self.objects.remove(&id); match removed { Some(PWObject::Node { ref data, .. }) => { let NodeData { media_class, .. } = data; if let Some(media_class) = media_class { if media_class.contains("Sink") { self.sinks.remove(&id); } } debug!(target: "PWGraph::remove", "Removed Node ({id})"); } Some(PWObject::Port { ref data, .. }) => { let PortData { node_id, direction, .. } = data; if let (Some(node_id), Some(direction)) = (node_id, direction) { match *direction { Direction::Input => { self.node_input_ports .entry(*node_id) .or_default() .remove(&id); } Direction::Output => { self.node_output_ports .entry(*node_id) .or_default() .remove(&id); } _ => {} }; } debug!(target: "PWGraph::remove", "Removed Port ({id})"); } Some(PWObject::Link { ref data, .. }) => { let LinkData { input_port, output_port, .. } = data; if let Some(output_port) = output_port { self.links_from_port .entry(*output_port) .or_default() .remove(&id); }; if let Some(input_port) = input_port { self.links_to_port .entry(*input_port) .or_default() .remove(&id); }; debug!(target: "PWGraph::remove", "Removed Link ({id})"); } None => { trace!(target: "PWGraph::remove", "Tried to remove inexistent object with ID {id}"); } }; removed } pub fn get(&self, id: &Id) -> Option<&PWObject> { self.objects.get(id) } /// Looks for sinks with active links to tracked nodes. /// /// If a sink_whitelist is passed to the graph, only sinks that match it will be treated. pub fn is_any_sink_active(&self) -> bool { if self.sinks.is_empty() { warn!(target: "PWGraph::is_any_sink_active", "List of sinks is empty"); } for sink in &self.sinks { trace!(target: "PWgraph::is_any_sink_active", "Starting transversal from Sink {sink}"); if self.does_sink_has_active_nodes(sink, &mut HashSet::new()) { return true; } } false } /// Transverses the Graphs in a manner similar to a DFS algorithm, looking for active /// connections from sinks to nodes. /// /// If a node_blacklist was passed, nodes that match it will be ignored. fn does_sink_has_active_nodes(&self, id: &Id, visited: &mut HashSet) -> bool { visited.insert(*id); trace!(target: "PWGraph::does_sink_has_active_nodes", "Node {id}"); match self.get(id) { Some(PWObject::Node { data, .. }) => { if NodeFilter::matches_any(&self.node_blacklist, data) { return false; } } None => { warn!(target: "PWGraph::does_sink_has_active_nodes", "While transversing graph, got invalid id {id}"); return false; } _ => { warn!(target: "PWGraph::does_sink_has_active_nodes", "While transversing graph expected Node, but got something else with id {id}"); return false; } }; let Some(node_input_ports) = self.node_input_ports.get(id) else { trace!(target: "PWGraph::does_sink_has_active_nodes", "Node ({id}) has no input ports, assuming it is a client"); return true; }; if node_input_ports.is_empty() { trace!(target: "PWGraph::does_sink_has_active_nodes", "Node ({id}) has no input ports, assuming it is a client"); return true; }; trace!( target: "PWGraph::does_sink_has_active_nodes", "Transversing Graph: Node {id}: Node Input Ports: {}", node_input_ports.len() ); let mut links_to_node: HashSet<(&Id, &Id)> = HashSet::new(); for port in node_input_ports { let Some(PWObject::Port { .. }) = self.get(port) else { warn!(target: "PWGraph::does_sink_has_active_nodes", "While transversing graph, expected Port, got something else with id {port}"); continue; }; trace!("Transversing Graph: Node {id}: Input Port {port}"); let Some(links) = self.links_to_port.get(port) else { trace!(target: "PWGraph::does_sink_has_active_nodes", "Transversing Graph: Node {id}: No links to Input Port {port}"); continue; }; if links.is_empty() { trace!(target: "PWGraph::does_sink_has_active_nodes", "Transversing Graph: Node {id}: No links to Input Port {port}"); continue; }; trace!( target: "PWGraph::does_sink_has_active_nodes", "Transversing Graph: Node {id}: links to Input Port {port}: {}", links.len() ); for link in links { let Some(PWObject::Link { data, .. }) = self.get(link) else { warn!(target: "PWGraph::does_sink_has_active_nodes", "While transversing graph, expected Link, got something else with id {link}"); continue; }; let LinkData { output_port, active, .. } = data; if let Some(active) = active { if !active { continue; } } else { continue; } let Some(output_port) = output_port else { warn!(target: "PWGraph::does_sink_has_active_nodes", "Link ({link}) is missing output_port"); continue; }; links_to_node.insert((link, output_port)); } } if links_to_node.is_empty() { trace!(target: "PWGraph::does_sink_has_active_nodes", "Transversing Graph: Node {id}: No Active Links to node"); return false; }; trace!(target: "PWGraph::does_sink_has_active_nodes", "Transversing Graph: Node {id}: Active Links to node: {}", links_to_node.len()); for (_, input_port) in links_to_node { let Some(PWObject::Port { data, .. }) = self.get(input_port) else { warn!(target: "PWGraph::does_sink_has_active_nodes", "While transversing graph, expected Port, got something else with id {input_port}"); continue; }; let PortData { node_id, .. } = data; let Some(node_id) = node_id else { warn!(target: "PWGraph::does_sink_has_active_nodes", "Port ({input_port}) is missing node_id"); continue; }; if !visited.contains(node_id) && self.does_sink_has_active_nodes(node_id, visited) { return true; } } false } } wayland-pipewire-idle-inhibit-0.7.1/src/pipewire_connection/graph/object.rs000064400000000000000000000160701046102023000252240ustar 00000000000000// Copyright (C) 2024 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // SPDX-License-Identifier: GPL-3.0-only //! Object types used to represent [super::PWGraph] elements. use pipewire::{ link::{Link, LinkListener}, node::{Node, NodeListener}, port::{Port, PortListener}, proxy::{Listener, ProxyT}, spa::utils::Direction, }; /// Type used by the [pipewire] crate API to represent object ids. pub type Id = u32; /// Generic struct that joins a [pipewire] [ProxyT], a reference to a global object, and its /// respective [Listener]. pub struct Proxy { pub _proxy: TProxy, pub _listener: TListener, } /// Struct representing relevant data of a [pipewire::node::Node] used by the app. /// /// When the global object is first registered, it comes without data, and its fields may be /// optionally filled by update events. Thus, all fields are [Option]s. #[derive(PartialEq, Debug, Clone)] pub struct NodeData { pub name: Option, pub app_name: Option, pub description: Option, pub nick: Option, pub media_class: Option, pub media_role: Option, pub media_software: Option, } impl NodeData { /// Gets a "pretty" node name. /// /// Based on the way [Helvum](https://gitlab.freedesktop.org/pipewire/helvum) does it. The /// compatibility with Helvum makes it easy to use it to make [super::filter::NodeFilter]s /// using the node name. pub fn get_name(&self) -> Option<&str> { self.description .as_deref() .or(self.nick.as_deref()) .or(self.name.as_deref()) } /// Updates fields if new data is give. /// /// Returns true if any field was updated, false otherwise. /// /// [pipewire] update events don't provide already existing data, only new one. Thus, only /// [Some] values should be used, as it represents data that should replace the current one. pub fn update(&mut self, new: Self) -> bool { let mut was_updated = false; if new.name.is_some() && self.name != new.name { self.name = new.name; was_updated = true; } if new.app_name.is_some() && self.app_name != new.app_name { self.app_name = new.app_name; was_updated = true; } if new.description.is_some() && self.description != new.description { self.description = new.description; was_updated = true; } if new.nick.is_some() && self.nick != new.nick { self.nick = new.nick; was_updated = true; } if new.media_class.is_some() && self.media_class != new.media_class { self.media_class = new.media_class; was_updated = true; } if new.media_role.is_some() && self.media_role != new.media_role { self.media_role = new.media_role; was_updated = true; } if new.media_software.is_some() && self.media_software != new.media_software { self.media_software = new.media_software; was_updated = true; } was_updated } } /// Struct representing relevant data of a [pipewire::port::Port] used by the app. /// /// When the global object is first registered, it comes without data, and its fields may be /// optionally filled by update events. Thus, all fields are [Option]s. #[derive(PartialEq, Debug, Clone)] pub struct PortData { pub name: Option, pub node_id: Option, pub direction: Option, pub is_terminal: Option, } impl PortData { /// Updates fields if new data is give. /// /// Returns true if any field was updated, false otherwise. /// /// [pipewire] update events don't provide already existing data, only new one. Thus, only /// [Some] values should be used, as it represents data that should replace the current one. pub fn update(&mut self, new: Self) -> bool { let mut was_updated = false; if new.name.is_some() && self.name != new.name { self.name = new.name; was_updated = true; } if new.node_id.is_some() && self.node_id != new.node_id { self.node_id = new.node_id; was_updated = true; } if new.direction.is_some() && self.direction != new.direction { self.direction = new.direction; was_updated = true; } if new.is_terminal.is_some() && self.is_terminal != new.is_terminal { self.is_terminal = new.is_terminal; was_updated = true; } was_updated } } /// Struct representing relevant data of a [pipewire::link::Link] used by the app. /// /// When the global object is first registered, it comes without data, and its fields may be /// optionally filled by update events. Thus, all fields are [Option]s. #[derive(PartialEq, Debug, Clone)] pub struct LinkData { pub input_port: Option, pub output_port: Option, pub active: Option, } impl LinkData { /// Updates fields if new data is give. /// /// Returns true if any field was updated, false otherwise. /// /// [pipewire] update events don't provide already existing data, only new one. Thus, only /// [Some] values should be used, as it represents data that should replace the current one. pub fn update(&mut self, new: Self) -> bool { let mut was_updated = false; if new.input_port.is_some() && self.input_port != new.input_port { self.input_port = new.input_port; was_updated = true; } if new.output_port.is_some() && self.output_port != new.output_port { self.output_port = new.output_port; was_updated = true; } if new.active.is_some() && self.active != new.active { self.active = new.active; was_updated = true; } was_updated } } /// Enum of all [PWObject] data variants. Used by polymorphic functions over only the object data. pub enum PWObjectData { Node(NodeData), Port(PortData), Link(LinkData), } /// Enum of all tracked types of [pipewire] graph elements. /// /// The variants are structs of the object data and its [Proxy]. pub enum PWObject { Node { data: NodeData, _proxy: Proxy, }, Port { data: PortData, _proxy: Proxy, }, Link { data: LinkData, _proxy: Proxy, }, } wayland-pipewire-idle-inhibit-0.7.1/src/pipewire_connection/mod.rs000064400000000000000000000375201046102023000234370ustar 00000000000000// Copyright (C) 2023-2026 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // SPDX-License-Identifier: GPL-3.0-only //! Manages the connection to the PipeWire server, listening to events and building a graph of //! nodes, ports and connections. //! //! The graph is used to detect if any connection to watched sinks is active. use std::{ cell::RefCell, marker::Send, rc::Rc, thread::{self, JoinHandle}, }; use pipewire::{ context::ContextRc, keys, link::{Link, LinkChangeMask, LinkInfoRef, LinkListener, LinkState}, main_loop::MainLoopRc, node::{Node, NodeInfoRef, NodeListener}, port::{Port, PortInfoRef, PortListener}, registry::{GlobalObject, RegistryRc}, spa::utils::{Direction, dict::DictRef}, types::ObjectType, }; use log::debug; pub mod graph; use graph::{ PWGraph, object::{Id, LinkData, NodeData, PWObject, PWObjectData, PortData, Proxy}, }; use graph::filter::{NodeFilter, SinkFilter}; use crate::message_queue::MessageQueueSender; /// Events that can be sent to the PipeWire thread #[derive(Debug)] pub enum PWMsg { Terminate, GraphUpdated, } /// Events that are fired by the PipeWire thread and must be treated by the caller #[derive(Clone, Debug)] pub enum PWEvent { GraphUpdated, InhibitIdleState(bool), ThreadPanic(Option), } /// Wrapper around the PipeWire thread and channel pub struct PWThread { pw_thread: JoinHandle<()>, pw_event_sender: pipewire::channel::Sender, } impl PWThread { /// Constructor that creates the channel used by the PipeWire [MainLoop] and launches it in /// another thread pub fn new + Clone + Send + 'static>( pw_event_listener: MessageQueueSender, sink_whitelist: Vec, node_blacklist: Vec, ) -> Self { let (pw_event_sender, pw_event_queue) = pipewire::channel::channel(); let pw_thread = thread::spawn(move || { pw_thread( pw_event_listener, pw_event_queue, sink_whitelist, node_blacklist, ) }); PWThread { pw_thread, pw_event_sender, } } /// Waits for PipeWire [MainLoop] to terminate /// /// As this function joins with the thread, it takes ownership of the [PWThread] value. pub fn join(self) -> Result<(), String> { self.pw_thread .join() .map_err(|_| "Error joining PipeWire thread".into()) } /// Sends message to PipeWire [MainLoop] pub fn send(&self, msg: PWMsg) -> Result<(), &str> { self.pw_event_sender .send(msg) .map_err(|_| "Error sending message to PipeWire channel") } } /// PipeWire thread function. Responsible to create PipeWire objects, subscribe to events and run /// the [MainLoop] fn pw_thread + Clone + 'static>( pw_event_listener: MessageQueueSender, pw_event_queue: pipewire::channel::Receiver, sink_whitelist: Vec, node_blacklist: Vec, ) { pipewire::init(); let mainloop = MainLoopRc::new(None).expect("Failed to create mainloop."); let context = ContextRc::new(&mainloop, None).expect("Failed to create context."); let core = context.connect_rc(None).expect("Failed to get core."); let registry = core.get_registry_rc().expect("Failed to get registry"); let graph = Rc::new(RefCell::new(PWGraph::new(sink_whitelist, node_blacklist))); // Listen to registry global events, that happen when objects when globals are created or // removed. let _listener = { registry .add_listener_local() .global({ // Object created let registry = registry.clone(); let graph = Rc::clone(&graph); let pw_event_listener = pw_event_listener.clone(); move |global| { let registry = registry.clone(); let graph = Rc::clone(&graph); // Stores only important objects to the algorithm match global.type_ { ObjectType::Node => { registry_global_node(global, registry, graph, pw_event_listener.clone()) } ObjectType::Port => { registry_global_port(global, registry, graph, pw_event_listener.clone()) } ObjectType::Link => { registry_global_link(global, registry, graph, pw_event_listener.clone()) } _ => {} } } }) .global_remove({ // Object Removed let graph = Rc::clone(&graph); let pw_event_listener = pw_event_listener.clone(); move |id| { registry_global_remove(id, Rc::clone(&graph), pw_event_listener.clone()); } }) .register() }; let _receiver = pw_event_queue.attach(mainloop.loop_(), { let mainloop = mainloop.clone(); // Treats events sent to the MainLoop thread by the caller move |signal: PWMsg| match signal { PWMsg::Terminate => mainloop.quit(), PWMsg::GraphUpdated => { let should_inhibit_idle = graph.borrow().is_any_sink_active(); pw_event_listener .send(Msg::from(PWEvent::InhibitIdleState(should_inhibit_idle))) .unwrap(); } } }); mainloop.run(); } /// Handles a new Node object sent by the PipeWire server. Its properties are read and stored in a /// [NodeData] object and the object reference is stored in a [Node] [Proxy]. Both are then /// inserted into the [PWGraph] shared object. /// /// The code also subscribes to updates to that Node. fn registry_global_node + Clone + 'static>( node: &GlobalObject<&DictRef>, registry: RegistryRc, graph: Rc>, pw_event_listener: MessageQueueSender, ) { let id = node.id; let props = node .props .as_ref() .expect("Node object is missing properties"); let name = props.get(&keys::NODE_NAME).map(|s| s.to_string()); let app_name = props.get(&keys::APP_NAME).map(|s| s.to_string()); let description = props.get(&keys::NODE_DESCRIPTION).map(|s| s.to_string()); let nick = props.get(&keys::NODE_NICK).map(|s| s.to_string()); let media_class = props.get(&keys::MEDIA_CLASS).map(|s| s.to_string()); let media_role = props.get(&keys::MEDIA_ROLE).map(|s| s.to_string()); let media_software = props.get(&keys::MEDIA_SOFTWARE).map(|s| s.to_string()); let proxy: Node = registry.bind(node).expect("Failed to bind Node Proxy"); let listener: NodeListener = proxy .add_listener_local() .info({ let graph = Rc::clone(&graph); let pw_event_listener = pw_event_listener.clone(); move |info| node_info(info, Rc::clone(&graph), pw_event_listener.clone()) }) .register(); let data = NodeData { name, app_name, description, nick, media_class, media_role, media_software, }; graph.borrow_mut().insert( id, PWObject::Node { data, _proxy: Proxy { _proxy: proxy, _listener: listener, }, }, ); pw_event_listener .send(Msg::from(PWEvent::GraphUpdated)) .unwrap(); } /// Handles updates to already existent [NodeData]. If necessary, the information is updated in the /// object in the [PWGraph]. fn node_info + Clone>( info: &NodeInfoRef, graph: Rc>, pw_event_listener: MessageQueueSender, ) { let id = info.id(); debug!("Event Node Info id:{id}"); let props = info.props().expect("NodeInfo object is missing properties"); let name = props.get(&keys::NODE_NAME).map(|s| s.to_string()); let app_name = props.get(&keys::APP_NAME).map(|s| s.to_string()); let description = props.get(&keys::NODE_DESCRIPTION).map(|s| s.to_string()); let nick = props.get(&keys::NODE_NICK).map(|s| s.to_string()); let media_class = props.get(&keys::MEDIA_CLASS).map(|s| s.to_string()); let media_role = props.get(&keys::MEDIA_ROLE).map(|s| s.to_string()); let media_software = props.get(&keys::MEDIA_SOFTWARE).map(|s| s.to_string()); let new_data = NodeData { name, app_name, description, nick, media_class, media_role, media_software, }; if graph.borrow_mut().update(id, PWObjectData::Node(new_data)) { pw_event_listener .send(Msg::from(PWEvent::GraphUpdated)) .unwrap(); } } /// Helper function that tries to decode a [Direction] from a string, received from the PipeWire /// server fn direction_from_string(direction: &str) -> Option { match direction { "out" => Some(Direction::Output), "in" => Some(Direction::Input), _ => None, } } /// Handles a new Port object sent by the PipeWire server. Its properties are read and stored in a /// [PortData] object and the object reference is stored in a [Port] [Proxy]. Both are then /// inserted into the [PWGraph] shared object. /// /// The code also subscribes to updates to that Port. fn registry_global_port + Clone + 'static>( port: &GlobalObject<&DictRef>, registry: RegistryRc, graph: Rc>, pw_event_listener: MessageQueueSender, ) { let id = port.id; let props = port .props .as_ref() .expect("Port object is missing properties"); let name = props.get(&keys::PORT_NAME).map(|s| s.to_string()); let node_id: Option = props.get(&keys::NODE_ID).and_then(|s| s.parse().ok()); let direction = props .get(&keys::PORT_DIRECTION) .and_then(direction_from_string); let is_terminal: Option = props.get(&keys::PORT_TERMINAL).and_then(|s| s.parse().ok()); let proxy: Port = registry.bind(port).expect("Failed to bind Port Proxy"); let listener: PortListener = proxy .add_listener_local() .info({ let graph = Rc::clone(&graph); let pw_event_listener = pw_event_listener.clone(); move |info| port_info(info, Rc::clone(&graph), pw_event_listener.clone()) }) .param(move |_, _param_id, _, _, _param| {}) // TODO .register(); let data = PortData { name, node_id, direction, is_terminal, }; graph.borrow_mut().insert( id, PWObject::Port { data, _proxy: Proxy { _proxy: proxy, _listener: listener, }, }, ); pw_event_listener .send(Msg::from(PWEvent::GraphUpdated)) .unwrap(); } /// Handles updates to already existent [PortData]. If necessary, the information is updated in the /// object in the [PWGraph]. fn port_info + Clone>( info: &PortInfoRef, graph: Rc>, pw_event_listener: MessageQueueSender, ) { let id = info.id(); debug!("Event Port Info id:{id}"); let props = info.props().expect("PortInfo object is missing properties"); let name = props.get(&keys::PORT_NAME).map(|s| s.to_string()); let node_id: Option = props.get(&keys::NODE_ID).and_then(|s| s.parse().ok()); let direction = props .get(&keys::PORT_DIRECTION) .and_then(direction_from_string); let is_terminal: Option = props.get(&keys::PORT_TERMINAL).and_then(|s| s.parse().ok()); let new_data = PortData { name, node_id, direction, is_terminal, }; if graph.borrow_mut().update(id, PWObjectData::Port(new_data)) { pw_event_listener .send(Msg::from(PWEvent::GraphUpdated)) .unwrap(); } } /// Handles a new Link object sent by the PipeWire server. Its properties are read and stored in a /// [LinkData] object and the object reference is stored in a [Link] [Proxy]. Both are then /// inserted into the [PWGraph] shared object. /// /// The code also subscribes to updates to that Port. fn registry_global_link + Clone + 'static>( link: &GlobalObject<&DictRef>, registry: RegistryRc, graph: Rc>, pw_event_listener: MessageQueueSender, ) { let id = link.id; let props = link .props .as_ref() .expect("Port object is missing properties"); let input_port: Option = props .get(&keys::LINK_INPUT_PORT) .and_then(|s| s.parse().ok()); let output_port: Option = props .get(&keys::LINK_OUTPUT_PORT) .and_then(|s| s.parse().ok()); let active = Some(false); let proxy: Link = registry.bind(link).expect("Failed to bind Link Proxy"); let listener: LinkListener = proxy .add_listener_local() .info({ let graph = Rc::clone(&graph); let pw_event_listener = pw_event_listener.clone(); move |info| link_info(info, Rc::clone(&graph), pw_event_listener.clone()) }) .register(); let data = LinkData { input_port, output_port, active, }; graph.borrow_mut().insert( id, PWObject::Link { data, _proxy: Proxy { _proxy: proxy, _listener: listener, }, }, ); pw_event_listener .send(Msg::from(PWEvent::GraphUpdated)) .unwrap(); } /// Handles updates to already existent [LinkData]. If necessary, the information is updated in the /// object in the [PWGraph]. /// /// This event is specially important, as the state of the links, stored in the [LinkData::active] /// field, is the main information used to search for active clients. fn link_info + Clone>( info: &LinkInfoRef, graph: Rc>, pw_event_listener: MessageQueueSender, ) { let id = info.id(); debug!("Event Link Info id:{id}"); let props = info.props().expect("LinkInfo object is missing properties"); let input_port: Option = props .get(&keys::LINK_INPUT_PORT) .and_then(|s| s.parse().ok()); let output_port: Option = props .get(&keys::LINK_OUTPUT_PORT) .and_then(|s| s.parse().ok()); let active = if info.change_mask().contains(LinkChangeMask::STATE) { Some(matches!(info.state(), LinkState::Active)) } else { None }; let new_data = LinkData { input_port, output_port, active, }; if graph.borrow_mut().update(id, PWObjectData::Link(new_data)) { pw_event_listener .send(Msg::from(PWEvent::GraphUpdated)) .unwrap(); } } /// Handles a removed object from the [PWGraph] fn registry_global_remove + Clone>( id: Id, graph: Rc>, pw_event_listener: MessageQueueSender, ) { debug!("Event Registry Global Remove Object id: {id}"); graph.borrow_mut().remove(id); pw_event_listener .send(Msg::from(PWEvent::GraphUpdated)) .unwrap(); } wayland-pipewire-idle-inhibit-0.7.1/src/settings/cli.rs000064400000000000000000000110711046102023000212150ustar 00000000000000// Copyright (C) 2024 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // SPDX-License-Identifier: GPL-3.0-only //! CLI Args parsing and processing use std::fmt::Display; use clap::{Parser, ValueEnum, builder::PossibleValue}; use log::LevelFilter; use serde::{Deserialize, Serialize}; use serde_with::{NoneAsEmptyString, serde_as}; use super::IdleInhibitor; /// Struct used to derive, parse and serialise CLI args. Some of the fields will not be used by the /// application and are only relevant in the context of CLI arguments, and thus have their /// serialisation skipped. #[serde_as] #[derive(Parser, Debug, Serialize, Deserialize)] #[command(author, version, about)] pub struct Args { #[arg( short = 'd', long, value_name = "SECONDS", allow_negative_numbers = false, help = format!("Minimum media duration to inhibit idle [default: {}]", super::default_media_minimum_duration()) )] #[serde(skip_serializing_if = "::std::option::Option::is_none")] media_minimum_duration: Option, #[arg( short, long, default_value_if("quiet", true.to_string(), LogLevel(LevelFilter::Off).to_string()), help = format!("Log verbosity [default: {}]", super::default_verbosity()) )] #[serde(skip_serializing_if = "::std::option::Option::is_none")] verbosity: Option, #[arg( short, long, conflicts_with = "verbosity", help = "Disables logging completely" )] #[serde(default, skip_serializing)] quiet: bool, #[arg( short = 'i', long = "idle-inhibitor", value_name = "IDLE INHIBITOR BACKEND", default_value_if("dbus", true.to_string(), IdleInhibitor::DBus.to_string()), default_value_if("wayland", true.to_string(), IdleInhibitor::Wayland.to_string()), default_value_if("dry_run", true.to_string(), IdleInhibitor::DryRun.to_string()), help = format!("Sets what idle inhibitor backend to use [default: {}]", super::default_idle_inhibitor()) )] #[serde(skip_serializing_if = "::std::option::Option::is_none")] #[serde_as(as = "NoneAsEmptyString")] idle_inhibitor: Option, #[arg( short = 'b', long = "d-bus", conflicts_with = "wayland", conflicts_with = "dry_run", conflicts_with = "idle_inhibitor", help = "Enable DBus (org.freedesktop.ScreenSaver) idle inhibitor" )] #[serde(default, skip_serializing)] dbus: bool, #[arg( short = 'w', long = "wayland", conflicts_with = "dbus", conflicts_with = "dry_run", conflicts_with = "idle_inhibitor", help = "Enable Wayland idle inhibitor" )] #[serde(default, skip_serializing)] wayland: bool, #[arg( short = 'n', long = "dry-run", conflicts_with = "dbus", conflicts_with = "wayland", conflicts_with = "idle_inhibitor", help = "Only logs (at INFO level) about idle inhibitor state changes" )] #[serde(default, skip_serializing)] dry_run: bool, #[arg(short, long, value_name = "PATH", help = "Path to config file")] #[serde(default, skip_serializing)] pub config: Option, } /// Wrapper type around [LevelFilter] to implement the trait [ValueEnum] for better CLI args /// integration #[derive(Debug, Clone, Serialize, Deserialize)] struct LogLevel(LevelFilter); impl Display for LogLevel { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } impl ValueEnum for LogLevel { fn value_variants<'a>() -> &'a [Self] { // TODO: Use macros to generate this array &[ Self(LevelFilter::Off), Self(LevelFilter::Error), Self(LevelFilter::Warn), Self(LevelFilter::Info), Self(LevelFilter::Debug), Self(LevelFilter::Trace), ] } fn to_possible_value(&self) -> Option { Some(PossibleValue::new(self.0.to_string())) } } wayland-pipewire-idle-inhibit-0.7.1/src/settings/mod.rs000064400000000000000000000115031046102023000212250ustar 00000000000000// Copyright (C) 2023-2026 Rafael Carvalho // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3 as published by // the Free Software Foundation. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // SPDX-License-Identifier: GPL-3.0-only //! Module responsible with the tool's configuration use std::{cmp::Ordering, error::Error, fmt::Display, path::PathBuf, str::FromStr}; use chrono::Duration; use clap::{Parser, ValueEnum}; use figment::{ Figment, providers::{Format, Serialized, Toml}, }; use log::{LevelFilter, warn}; use serde::{Deserialize, Serialize}; use serde_with::{DisplayFromStr, serde_as}; use crate::pipewire_connection::graph::filter::{NodeFilter, SinkFilter}; mod cli; use cli::Args; /// Struct that stores the settings that affect the tool behaviour #[serde_as] #[derive(Deserialize)] pub struct Settings { #[serde(default = "default_media_minimum_duration")] media_minimum_duration: i64, #[serde(default = "default_idle_inhibitor")] #[serde_as(as = "DisplayFromStr")] idle_inhibitor: IdleInhibitor, #[serde(default = "default_verbosity")] verbosity: LevelFilter, #[serde(default)] sink_whitelist: Vec, #[serde(default)] node_blacklist: Vec, } impl Settings { pub fn new() -> Result> { let cli = Args::parse(); let config_path = match cli.config { Some(ref p) => PathBuf::from(p), None => xdg::BaseDirectories::with_prefix(env!("CARGO_PKG_NAME")) .place_config_file("config.toml")?, }; let settings = Figment::new() .merge(Toml::file(config_path)) .merge(Serialized::defaults(cli)) .extract()?; Ok(settings) } /// Getter for the media minimum duration with the [chrono::Duration] type. If the set duration /// is 0, [None] is returned, to easily detect if this check is necessary pub fn get_media_minimum_duration(&self) -> Option { match self.media_minimum_duration.cmp(&0) { Ordering::Less => { warn!(target: "Settings::get_media_minimum_duration", "Tried to use a negative value as media minimum duration! Assuming as zero."); None } Ordering::Equal => None, Ordering::Greater => Some(Duration::seconds(self.media_minimum_duration)), } } /// Returns the current log verbosity pub fn get_verbosity(&self) -> LevelFilter { self.verbosity } /// Return sink filters pub fn get_sink_whitelist(&self) -> &Vec { &self.sink_whitelist } /// Return Node filters pub fn get_node_blacklist(&self) -> &Vec { &self.node_blacklist } pub fn get_idle_inhibitor(&self) -> &IdleInhibitor { &self.idle_inhibitor } } /// Default media minimum duration, set to 5 seconds const fn default_media_minimum_duration() -> i64 { 5 } /// Default log verbosity, set to [LevelFilter::Warn] const fn default_verbosity() -> LevelFilter { LevelFilter::Warn } /// Default IdleInhibitor backend, set to [IdleInhibitor::Wayland] const fn default_idle_inhibitor() -> IdleInhibitor { IdleInhibitor::Wayland } #[derive(Debug, Clone, Serialize, Deserialize, ValueEnum)] pub enum IdleInhibitor { DBus, DryRun, Wayland, } impl Display for IdleInhibitor { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { Self::DBus => f.write_str("d-bus"), Self::DryRun => f.write_str("dry-run"), Self::Wayland => f.write_str("wayland"), } } } impl FromStr for IdleInhibitor { type Err = ParseIdleInhibitorError; fn from_str(s: &str) -> Result { match s { "d-bus" => Ok(Self::DBus), "dbus" => Ok(Self::DBus), "dry-run" => Ok(Self::DryRun), "wayland" => Ok(Self::Wayland), _ => Err(ParseIdleInhibitorError(s.into())), } } } #[derive(Debug, Clone, PartialEq, Eq)] pub struct ParseIdleInhibitorError(String); impl Display for ParseIdleInhibitorError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { format!( "Provided value '{}' is not a valid IdleInhibitor variant", self.0 ) .fmt(f) } } impl Error for ParseIdleInhibitorError {} wayland-pipewire-idle-inhibit-0.7.1/wayland-pipewire-idle-inhibit.service000064400000000000000000000005351046102023000246560ustar 00000000000000[Install] WantedBy=graphical-session.target [Service] ExecStart=wayland-pipewire-idle-inhibit Restart=always RestartSec=10 [Unit] Description=Inhibit Wayland idling when media is played through pipewire Documentation=https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit After=pipewire.service graphical-session.target Wants=pipewire.service