diff --git a/CHANGELOG.md b/CHANGELOG.md index 65d082b1..94d203c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Rename and recreate the default Anime config if cache setup fails +### Fixed + +- Nuke the issue of GUI taking 100% of a CPU core + ## [v6.0.8] ### Added diff --git a/Cargo.lock b/Cargo.lock index db71eb3c..4000d794 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,6 +103,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27a4bd113ab6da4cd0f521068a6e2ee1065eab54107266a11835d02c8ec86a37" + [[package]] name = "arrayref" version = "0.3.7" @@ -392,6 +398,28 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.63", +] + [[package]] name = "async-task" version = "4.7.1" @@ -433,6 +461,51 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.71" @@ -842,6 +915,43 @@ dependencies = [ "serde", ] +[[package]] +name = "console-api" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" +dependencies = [ + "futures-core", + "prost", + "prost-types", + "tonic", + "tracing-core", +] + +[[package]] +name = "console-subscriber" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e" +dependencies = [ + "console-api", + "crossbeam-channel", + "crossbeam-utils", + "futures-task", + "hdrhistogram", + "humantime", + "prost-types", + "serde", + "serde_json", + "thread_local", + "tokio", + "tokio-stream", + "tonic", + "tracing", + "tracing-core", + "tracing-subscriber", +] + [[package]] name = "const-field-offset" version = "0.1.5" @@ -967,6 +1077,15 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" +[[package]] +name = "crossbeam-channel" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -1481,7 +1600,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9099a2f86b8e674b75d03ff154b3fe4c5208ed249ced8d69cc313a9fa40bb488" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", "ttf-parser 0.20.0", ] @@ -1521,6 +1640,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + [[package]] name = "futures-core" version = "0.3.30" @@ -1823,6 +1951,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.4.1" @@ -1833,6 +1980,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.14.5" @@ -1843,6 +1996,19 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hdrhistogram" +version = "7.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "765c9198f173dd59ce26ff9f95ef0aafd0a0fe01fb9d72841bc5066a4c06511d" +dependencies = [ + "base64 0.21.7", + "byteorder", + "flate2", + "nom", + "num-traits", +] + [[package]] name = "heck" version = "0.4.1" @@ -1870,12 +2036,82 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.7", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "i-slint-backend-linuxkms" version = "1.6.0" @@ -2178,6 +2414,16 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" +[[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", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -2185,7 +2431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -2604,6 +2850,21 @@ dependencies = [ "libc", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.7.2" @@ -2661,6 +2922,12 @@ dependencies = [ "paste", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3177,6 +3444,38 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.63", +] + +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost", +] + [[package]] name = "qoi" version = "0.4.1" @@ -3321,8 +3620,17 @@ checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -3333,9 +3641,15 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.3", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.3" @@ -3374,6 +3688,7 @@ dependencies = [ "cargo-husky", "concat-idents", "config-traits", + "console-subscriber", "dirs", "dmi_id", "env_logger", @@ -3512,7 +3827,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49" dependencies = [ "countme", - "hashbrown", + "hashbrown 0.14.5", "memoffset 0.9.1", "rustc-hash", "text-size", @@ -3741,6 +4056,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -4088,6 +4412,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "tar" version = "0.4.40" @@ -4162,6 +4492,16 @@ dependencies = [ "syn 2.0.63", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "tiff" version = "0.9.1" @@ -4252,15 +4592,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", + "bytes", "libc", "mio", "num_cpus", "pin-project-lite", "socket2 0.5.7", "tokio-macros", + "tracing", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-macros" version = "2.2.0" @@ -4272,6 +4624,30 @@ dependencies = [ "syn 2.0.63", ] +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.8.12" @@ -4299,7 +4675,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap", + "indexmap 2.2.6", "toml_datetime", "winnow 0.5.40", ] @@ -4310,13 +4686,72 @@ version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ - "indexmap", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", "winnow 0.6.8", ] +[[package]] +name = "tonic" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.40" @@ -4346,8 +4781,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", ] +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "once_cell", + "regex", + "sharded-slab", + "thread_local", + "tracing", + "tracing-core", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "ttf-parser" version = "0.20.0" @@ -4544,6 +5001,12 @@ dependencies = [ "xmlwriter", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -4609,6 +5072,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/rog-control-center/Cargo.toml b/rog-control-center/Cargo.toml index 2c69f676..8142ad04 100644 --- a/rog-control-center/Cargo.toml +++ b/rog-control-center/Cargo.toml @@ -12,8 +12,12 @@ edition.workspace = true default = [] mocking = [] x11 = ["slint/backend-winit-x11"] +# Requires RUSTFLAGS="--cfg tokio_unstable" +tokio-debug = ["console-subscriber"] [dependencies] +console-subscriber = { version = "0.2.0", optional = true } + nix = { version = "^0.28.0", features = ["fs"] } tempfile = "3.3.0" betrayer = { version = "0.2.0" } diff --git a/rog-control-center/src/main.rs b/rog-control-center/src/main.rs index c9076f46..357bb1c3 100644 --- a/rog-control-center/src/main.rs +++ b/rog-control-center/src/main.rs @@ -25,6 +25,9 @@ use tokio::runtime::Runtime; #[tokio::main] async fn main() -> Result<()> { + #[cfg(feature = "tokio-debug")] + console_subscriber::init(); + let self_version = env!("CARGO_PKG_VERSION"); let conn = zbus::blocking::Connection::system()?; let proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&conn)?; diff --git a/rog-control-center/src/notify.rs b/rog-control-center/src/notify.rs index addfd18c..f194b459 100644 --- a/rog-control-center/src/notify.rs +++ b/rog-control-center/src/notify.rs @@ -45,6 +45,44 @@ impl Default for EnabledNotifications { } } +fn start_dpu_status_mon(config: Arc>) { + use supergfxctl::pci_device::Device; + let dev = Device::find().unwrap_or_default(); + let mut found_dgpu = false; // just for logging + for dev in dev { + if dev.is_dgpu() { + let enabled_notifications_copy = config.clone(); + // Plain old thread is perfectly fine since most of this is potentially blocking + std::thread::spawn(move || { + let mut last_status = GfxPower::Unknown; + loop { + std::thread::sleep(Duration::from_millis(1000)); + if let Ok(status) = dev.get_runtime_status() { + if status != GfxPower::Unknown && status != last_status { + if let Ok(config) = enabled_notifications_copy.lock() { + if !config.notifications.receive_notify_gfx_status + || !config.notifications.enabled + { + continue; + } + } + // Required check because status cycles through + // active/unknown/suspended + do_gpu_status_notif("dGPU status changed:", &status).ok(); + } + last_status = status; + } + } + }); + found_dgpu = true; + break; + } + } + if !found_dgpu { + warn!("Did not find a dGPU on this system, dGPU status won't be avilable"); + } +} + pub fn start_notifications( config: Arc>, rt: &Runtime, @@ -103,20 +141,14 @@ pub fn start_notifications( // GPU MUX Mode notif let enabled_notifications_copy = config.clone(); tokio::spawn(async move { - let conn = zbus::Connection::system() - .await - .map_err(|e| { - error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); - e - }) - .unwrap(); - let proxy = PlatformProxy::new(&conn) - .await - .map_err(|e| { - error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); - e - }) - .unwrap(); + let conn = zbus::Connection::system().await.map_err(|e| { + error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); + e + })?; + let proxy = PlatformProxy::new(&conn).await.map_err(|e| { + error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); + e + })?; let mut actual_mux_mode = GpuMode::Error; if let Ok(mode) = proxy.gpu_mux_mode().await { @@ -138,87 +170,75 @@ pub fn start_notifications( do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &mode).ok(); } } + Ok::<(), zbus::Error>(()) }); - use supergfxctl::pci_device::Device; - let dev = Device::find().unwrap_or_default(); - let mut found_dgpu = false; // just for logging - for dev in dev { - if dev.is_dgpu() { - let enabled_notifications_copy = config.clone(); - // Plain old thread is perfectly fine since most of this is potentially blocking - rt.spawn_blocking(move || { - let mut last_status = GfxPower::Unknown; - loop { - if let Ok(status) = dev.get_runtime_status() { - if status != GfxPower::Unknown && status != last_status { - if let Ok(config) = enabled_notifications_copy.lock() { - if !config.notifications.receive_notify_gfx_status - || !config.notifications.enabled - { - continue; - } - } - // Required check because status cycles through - // active/unknown/suspended - do_gpu_status_notif("dGPU status changed:", &status).ok(); - } - last_status = status; - } - std::thread::sleep(Duration::from_millis(500)); - } - }); - found_dgpu = true; - break; - } - } - if !found_dgpu { - warn!("Did not find a dGPU on this system, dGPU status won't be avilable"); - } - + let enabled_notifications_copy = config.clone(); // GPU Mode change/action notif tokio::spawn(async move { - let conn = zbus::Connection::system() - .await - .map_err(|e| { - error!("zbus signal: receive_notify_action: {e}"); - e - }) - .unwrap(); - let proxy = SuperProxy::builder(&conn) - .build() - .await - .map_err(|e| { - error!("zbus signal: receive_notify_action: {e}"); - e - }) - .unwrap(); + if let Err(e) = { + let conn = zbus::Connection::system().await?; + let proxy = SuperProxy::builder(&conn).build().await?; + let _ = proxy.mode().await?; - if proxy.mode().await.is_err() { - info!("supergfxd not running or not responding"); - return; - } - - if let Ok(mut p) = proxy.receive_notify_action().await { - info!("Started zbus signal thread: receive_notify_action"); - while let Some(e) = p.next().await { - if let Ok(out) = e.args() { - let action = out.action(); - let mode = convert_gfx_mode(proxy.mode().await.unwrap_or_default()); - match action { - supergfxctl::actions::UserActionRequired::Reboot => { - do_mux_notification("Graphics mode change requires reboot", &mode) + let proxy_copy = proxy.clone(); + if let Ok(mut p) = proxy.receive_notify_action().await { + tokio::spawn(async move { + info!("Started zbus signal thread: receive_notify_action"); + while let Some(e) = p.next().await { + if let Ok(out) = e.args() { + let action = out.action(); + let mode = convert_gfx_mode(proxy.mode().await.unwrap_or_default()); + match action { + supergfxctl::actions::UserActionRequired::Reboot => { + do_mux_notification( + "Graphics mode change requires reboot", + &mode, + ) + } + _ => do_gfx_action_notif(<&str>::from(action), *action, mode), + } + .map_err(|e| { + error!("zbus signal: do_gfx_action_notif: {e}"); + e + }) + .ok(); } - _ => do_gfx_action_notif(<&str>::from(action), *action, mode), } - .map_err(|e| { - error!("zbus signal: do_gfx_action_notif: {e}"); - e - }) - .ok(); - } - } - }; + }); + }; + + if let Ok(mut p) = proxy_copy.receive_notify_gfx_status().await { + tokio::spawn(async move { + info!("Started zbus signal thread: receive_notify_gfx_status"); + let mut last_status = GfxPower::Unknown; + while let Some(e) = p.next().await { + if let Ok(out) = e.args() { + let status = out.status; + if status != GfxPower::Unknown && status != last_status { + if let Ok(config) = enabled_notifications_copy.lock() { + if !config.notifications.receive_notify_gfx_status + || !config.notifications.enabled + { + continue; + } + } + // Required check because status cycles through + // active/unknown/suspended + do_gpu_status_notif("dGPU status changed:", &status).ok(); + } + last_status = status; + } + } + }); + }; + Ok::<(), zbus::Error>(()) + } { + error!("zbus signal: receive_notify_gfx_status: {e}"); + info!("Attempting to start plain dgpu status monitor"); + start_dpu_status_mon(config.clone()); + } + Ok::<(), zbus::Error>(()) }); Ok(vec![blocking]) diff --git a/rog-control-center/src/ui/setup_aura.rs b/rog-control-center/src/ui/setup_aura.rs index 7f300156..4565d791 100644 --- a/rog-control-center/src/ui/setup_aura.rs +++ b/rog-control-center/src/ui/setup_aura.rs @@ -1,6 +1,6 @@ use std::sync::{Arc, Mutex}; -use log::{error, info}; +use log::{debug, error, info}; use rog_aura::keyboard::LaptopAuraPower; use rog_aura::{AuraDeviceType, PowerZones}; use rog_dbus::zbus_aura::AuraProxy; @@ -76,7 +76,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc>) { tokio::spawn(async move { let Ok(aura) = find_aura_iface().await else { info!("This device appears to have no aura interfaces"); - return; + return Ok::<(), zbus::Error>(()); }; set_ui_props_async!(handle, aura, AuraPageData, brightness); @@ -226,5 +226,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc>) { } } }); + debug!("Aura setup tasks complete"); + Ok(()) }); } diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index f5472ebe..a3657882 100644 --- a/rog-control-center/translations/en/rog-control-center.po +++ b/rog-control-center/translations/en/rog-control-center.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-05-17 10:14+0000\n" +"POT-Creation-Date: 2024-05-17 23:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n"