1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-09-16 11:46:58 +02:00

feat(sysinfo): overhaul to add aggregate/unit/formatting support

This completely reworks the sysinfo module to add support for aggregate functions, better support for working with individual devices, the ability to specify units, and some string formatting support.

Several new tokens have also been added, and performance should be marginally improved.

BREAKING CHANGE: Use of the `sys_info` module in your config will need to be updated to use the new token format. See the wiki page for more info.
This commit is contained in:
Jake Stanger 2025-01-04 23:08:01 +00:00
commit 01de0ac6f5
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
14 changed files with 1633 additions and 589 deletions

View file

@ -0,0 +1,66 @@
use crate::clients::sysinfo::{Function, Prefix};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TokenType {
CpuFrequency,
CpuPercent,
MemoryFree,
MemoryAvailable,
MemoryTotal,
MemoryUsed,
MemoryPercent,
SwapFree,
SwapTotal,
SwapUsed,
SwapPercent,
TempC,
TempF,
DiskFree,
DiskTotal,
DiskUsed,
DiskPercent,
DiskRead,
DiskWrite,
NetDown,
NetUp,
LoadAverage1,
LoadAverage5,
LoadAverage15,
Uptime,
}
#[derive(Debug, Clone)]
pub struct Token {
pub token: TokenType,
pub function: Function,
pub prefix: Prefix,
pub formatting: Formatting,
}
#[derive(Debug, Clone)]
pub enum Part {
Static(String),
Token(Token),
}
#[derive(Debug, Clone, Copy)]
pub struct Formatting {
pub width: usize,
pub fill: char,
pub align: Alignment,
pub precision: usize,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum Alignment {
#[default]
Left,
Center,
Right,
}