Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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", features = ["default"] }
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ An OpenAction ([OpenDeck](https://github.com/nekename/OpenDeck) / [Tacto](https:

- CPU
- RAM
- GPU
- Uptime
- OS
8 changes: 8 additions & 0 deletions assets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;

use openaction::*;

use gfxinfo::active_gpu;
use sysinfo::System;

struct CPUAction;
Expand All @@ -18,6 +19,13 @@ impl Action for RAMAction {
type Settings = HashMap<String, String>;
}

struct GPUAction;
#[async_trait]
impl Action for GPUAction {
const UUID: ActionUuid = "me.amankhanna.oasystem.gpu";
type Settings = HashMap<String, String>;
}

struct UptimeAction;
#[async_trait]
impl Action for UptimeAction {
Expand Down Expand Up @@ -81,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;
Expand All @@ -102,6 +119,7 @@ async fn main() -> OpenActionResult<()> {

register_action(CPUAction).await;
register_action(RAMAction).await;
register_action(GPUAction).await;
register_action(UptimeAction).await;
register_action(OSAction).await;

Expand Down