feat: add statsDaemon.interval setting, pass --interval to nova-stats
This commit is contained in:
parent
c8d71bd871
commit
937ae5af2e
4 changed files with 35 additions and 3 deletions
|
|
@ -89,6 +89,9 @@ QtObject {
|
|||
property var overviewBackdrop: ({
|
||||
enable: true
|
||||
})
|
||||
property var statsDaemon: ({
|
||||
interval: -1
|
||||
})
|
||||
|
||||
property FileView _file: FileView {
|
||||
path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/modules.json"
|
||||
|
|
|
|||
|
|
@ -29,7 +29,10 @@ QtObject {
|
|||
// nova-stats stream (cpu + mem)
|
||||
property var _statsProc: Process {
|
||||
running: true
|
||||
command: ["nova-stats"]
|
||||
command: {
|
||||
const ms = M.Modules.statsDaemon.interval;
|
||||
return ms > 0 ? ["nova-stats", "--interval", ms.toString()] : ["nova-stats"];
|
||||
}
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\n"
|
||||
onRead: line => {
|
||||
|
|
|
|||
|
|
@ -169,6 +169,17 @@ in
|
|||
};
|
||||
}
|
||||
);
|
||||
statsDaemon = lib.mkOption {
|
||||
default = { };
|
||||
description = "Configuration for the nova-stats daemon.";
|
||||
type = lib.types.submodule {
|
||||
options.interval = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = -1;
|
||||
description = "nova-stats polling interval in milliseconds (-1 = use binary default of 1s).";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
theme = lib.mkOption {
|
||||
|
|
|
|||
|
|
@ -159,7 +159,22 @@ fn emit_mem(out: &mut impl Write) {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_interval_ms() -> u64 {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
let mut i = 1;
|
||||
while i < args.len() {
|
||||
if args[i] == "--interval" {
|
||||
if let Some(ms) = args.get(i + 1).and_then(|s| s.parse().ok()) {
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
1000
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let interval = Duration::from_millis(parse_interval_ms());
|
||||
let stdout = io::stdout();
|
||||
let mut out = io::BufWriter::new(stdout.lock());
|
||||
let mut prev: Vec<Sample> = vec![];
|
||||
|
|
@ -181,8 +196,8 @@ fn main() {
|
|||
tick += 1;
|
||||
|
||||
let elapsed = t0.elapsed();
|
||||
if elapsed < Duration::from_secs(1) {
|
||||
thread::sleep(Duration::from_secs(1) - elapsed);
|
||||
if elapsed < interval {
|
||||
thread::sleep(interval - elapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue