From 7ccf769887c0ef2c9a2a8e56b416d4d3fb6bc56b Mon Sep 17 00:00:00 2001 From: terrorwolf <78974581+Terrorwolf01@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:36:23 +0100 Subject: [PATCH 1/4] Added Support for GPU utilization --- Cargo.toml | 1 + assets/manifest.json | 10 +++++++++- src/main.rs | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d44c732..1eb6bd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,4 @@ tokio = { version = "1.47", features = ["rt-multi-thread", "macros", "time"] } log = "0.4" simplelog = "0.12" sysinfo = "0.37" +gfxinfo = { version = "0.1.2", features = ["default"] } diff --git a/assets/manifest.json b/assets/manifest.json index 9035adf..e316759 100644 --- a/assets/manifest.json +++ b/assets/manifest.json @@ -1,7 +1,7 @@ { "Name": "System Information", "Author": "nekename", - "Version": "1.0.0", + "Version": "1.0.1", "Category": "System Information", "Icon": "icon", "OS": [{ "Platform": "windows" }, { "Platform": "mac" }, { "Platform": "linux" }], @@ -32,6 +32,14 @@ "Controllers": ["Keypad", "Encoder"], "States": [{ "Title": "0GB", "FontSize": 14 }] }, + { + "UUID": "me.amankhanna.oasystem.gpu", + "Name": "GPU", + "Icon": "icon", + "Tooltip": "Displays GPU utilisation", + "Controllers": ["Keypad", "Encoder"], + "States": [{ "Title": "0%", "FontSize": 16 }] + }, { "UUID": "me.amankhanna.oasystem.uptime", "Name": "Uptime", diff --git a/src/main.rs b/src/main.rs index 4415d38..ec54827 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,8 @@ use openaction::*; use sysinfo::System; +use gfxinfo::active_gpu; + struct CPUAction; #[async_trait] impl Action for CPUAction { @@ -18,6 +20,13 @@ impl Action for RAMAction { type Settings = HashMap; } +struct GPUAction; +#[async_trait] +impl Action for GPUAction { + const UUID: ActionUuid = "me.amankhanna.oasystem.gpu"; + type Settings = HashMap; +} + struct UptimeAction; #[async_trait] impl Action for UptimeAction { @@ -97,6 +106,13 @@ async fn main() -> OpenActionResult<()> { .await; } } + + let gpu_usage = format!("{:.0}%", active_gpu().expect("REASON").info().load_pct()); + for instance in visible_instances(GPUAction::UUID).await { + let _ = instance.set_title(Some(gpu_usage.clone()), None).await; + } + + } }); @@ -104,6 +120,7 @@ async fn main() -> OpenActionResult<()> { register_action(RAMAction).await; register_action(UptimeAction).await; register_action(OSAction).await; + register_action(GPUAction).await; run(std::env::args().collect()).await } From 1dc08f0dfaa0ece90ff18690a6eca173c4d9407f Mon Sep 17 00:00:00 2001 From: Terrorwolf01 <78974581+Terrorwolf01@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:40:48 +0100 Subject: [PATCH 2/4] Add GPU to system requirements listEdit README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 901aab1..f83ae48 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,4 @@ An OpenAction ([OpenDeck](https://github.com/nekename/OpenDeck) / [Tacto](https: - RAM - Uptime - OS +- GPU From 46ad1bbf4f80373ac451cc0c593bf814267d0d5c Mon Sep 17 00:00:00 2001 From: Terrorwolf01 <78974581+terrorwolf01@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:40:48 +0100 Subject: [PATCH 3/4] Edit README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 901aab1..f83ae48 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,4 @@ An OpenAction ([OpenDeck](https://github.com/nekename/OpenDeck) / [Tacto](https: - RAM - Uptime - OS +- GPU From 93d9041d6fa1baa2f955bfc25f5e337da2c9c452 Mon Sep 17 00:00:00 2001 From: nekename <63245705+nekename@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:17:09 +0000 Subject: [PATCH 4/4] Review changes --- Cargo.toml | 2 +- README.md | 2 +- assets/manifest.json | 2 +- src/main.rs | 21 +++++++++++---------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1eb6bd7..a94fbcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,4 @@ tokio = { version = "1.47", features = ["rt-multi-thread", "macros", "time"] } log = "0.4" simplelog = "0.12" sysinfo = "0.37" -gfxinfo = { version = "0.1.2", features = ["default"] } +gfxinfo = { version = "0.1", features = ["default"] } diff --git a/README.md b/README.md index f83ae48..8524c83 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,6 @@ An OpenAction ([OpenDeck](https://github.com/nekename/OpenDeck) / [Tacto](https: - CPU - RAM +- GPU - Uptime - OS -- GPU diff --git a/assets/manifest.json b/assets/manifest.json index e316759..cd24104 100644 --- a/assets/manifest.json +++ b/assets/manifest.json @@ -1,7 +1,7 @@ { "Name": "System Information", "Author": "nekename", - "Version": "1.0.1", + "Version": "1.0.0", "Category": "System Information", "Icon": "icon", "OS": [{ "Platform": "windows" }, { "Platform": "mac" }, { "Platform": "linux" }], diff --git a/src/main.rs b/src/main.rs index ec54827..05fac67 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,8 @@ use std::collections::HashMap; use openaction::*; -use sysinfo::System; - use gfxinfo::active_gpu; +use sysinfo::System; struct CPUAction; #[async_trait] @@ -90,6 +89,15 @@ async fn main() -> OpenActionResult<()> { let _ = instance.set_title(Some(ram_usage.clone()), None).await; } + let gpu_usage = if let Ok(gpu) = active_gpu() { + format!("{:.0}%", gpu.info().load_pct()) + } else { + "No GPU found".to_owned() + }; + for instance in visible_instances(GPUAction::UUID).await { + let _ = instance.set_title(Some(gpu_usage.clone()), None).await; + } + { let total_secs = System::uptime(); let days = total_secs / 86_400; @@ -106,21 +114,14 @@ async fn main() -> OpenActionResult<()> { .await; } } - - let gpu_usage = format!("{:.0}%", active_gpu().expect("REASON").info().load_pct()); - for instance in visible_instances(GPUAction::UUID).await { - let _ = instance.set_title(Some(gpu_usage.clone()), None).await; - } - - } }); register_action(CPUAction).await; register_action(RAMAction).await; + register_action(GPUAction).await; register_action(UptimeAction).await; register_action(OSAction).await; - register_action(GPUAction).await; run(std::env::args().collect()).await }