Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c1d46a4be0 |
|||
|
ba96aa4d6b |
|||
|
3fa2163366 |
6 changed files with 317 additions and 306 deletions
574
Cargo.lock
generated
574
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -12,3 +12,7 @@ sysinfo = "0.39.6"
|
||||||
[dependencies.iced]
|
[dependencies.iced]
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
features = [ "canvas", "smol" ]
|
features = [ "canvas", "smol" ]
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
|
|
||||||
23
flake.lock
generated
23
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1785782307,
|
"lastModified": 1790899423,
|
||||||
"narHash": "sha256-MPaRdVkf6zZP5fCPxYCi8Dr4pZzgmXzg8T9nVEbp3Mw=",
|
"narHash": "sha256-THGtz65UGJU+sonZidRboyCMk+9DclpMF7pwL4uDV4M=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "2c71e194474d13de031d729b729c968ddbe3507f",
|
"rev": "47b6b27ed9a3a9181415e4367d0c30ab2a0e0250",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -35,18 +35,15 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1785747939,
|
"lastModified": 1791260994,
|
||||||
"narHash": "sha256-D740uKsMbgsfK2oaDenJLLPIZfq7W0/g4KN/Fls8eKs=",
|
"narHash": "sha256-MFBjw66d4h06MvpW6lIl7RwarLteD0sk859CncGwb1Q=",
|
||||||
"owner": "nixos",
|
"rev": "151fa4e8ddfdd8dd25d945ad94ed54a13de9f6e4",
|
||||||
"repo": "nixpkgs",
|
"type": "tarball",
|
||||||
"rev": "104240a772428cc2e20d8fd86c9ddbb886bbaff2",
|
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1086391.151fa4e8ddfd/nixexprs.tar.zst?lastModified=1791260994&rev=151fa4e8ddfdd8dd25d945ad94ed54a13de9f6e4"
|
||||||
"type": "github"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"type": "tarball",
|
||||||
"ref": "nixpkgs-unstable",
|
"url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst"
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst";
|
||||||
|
|
||||||
crane.url = "github:ipetkov/crane";
|
crane.url = "github:ipetkov/crane";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,21 @@ use crate::app;
|
||||||
const CYAN: Color = Color::from_rgb8(0, 255, 255);
|
const CYAN: Color = Color::from_rgb8(0, 255, 255);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct CpuGraph {
|
pub struct Graph {
|
||||||
pub cache: canvas::Cache,
|
pub cache: canvas::Cache,
|
||||||
timeline: VecDeque<f32>,
|
timeline: VecDeque<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CpuGraph {
|
impl Graph {
|
||||||
pub fn update(&mut self, usage: f32) {
|
pub fn update(&mut self, value: f32) {
|
||||||
self.timeline.push_back(usage);
|
self.timeline.push_back(value);
|
||||||
if self.timeline.len() > 1000 {
|
if self.timeline.len() > 1000 {
|
||||||
self.timeline.pop_front();
|
self.timeline.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl canvas::Program<app::Message, Theme, Renderer> for CpuGraph {
|
impl canvas::Program<app::Message, Theme, Renderer> for Graph {
|
||||||
type State = ();
|
type State = ();
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
use iced::{
|
use iced::{
|
||||||
Color, Element, Length, Renderer, Task, Theme, application, futures::SinkExt, stream::channel,
|
Color, Element, Length, Renderer, Task, Theme, application, futures::SinkExt, stream, theme,
|
||||||
theme, widget,
|
widget,
|
||||||
};
|
};
|
||||||
use smol::Timer;
|
use smol::Timer;
|
||||||
|
|
||||||
use crate::app::cpu_graph::CpuGraph;
|
use crate::app::graph::Graph;
|
||||||
|
|
||||||
mod cpu_graph;
|
mod graph;
|
||||||
|
|
||||||
enum Message {
|
enum Message {
|
||||||
Cpu(f32),
|
Cpu(f32),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
cpu_graph: CpuGraph,
|
cpu_graph: Graph,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
|
|
@ -23,7 +23,7 @@ impl State {
|
||||||
cpu_graph: Default::default(),
|
cpu_graph: Default::default(),
|
||||||
},
|
},
|
||||||
Task::run(
|
Task::run(
|
||||||
channel(1, async |mut sender| {
|
stream::channel(1, async |mut sender| {
|
||||||
let mut sys = sysinfo::System::new();
|
let mut sys = sysinfo::System::new();
|
||||||
let refreshes = sysinfo::RefreshKind::nothing()
|
let refreshes = sysinfo::RefreshKind::nothing()
|
||||||
.with_cpu(sysinfo::CpuRefreshKind::nothing().with_cpu_usage());
|
.with_cpu(sysinfo::CpuRefreshKind::nothing().with_cpu_usage());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue