add sched detect
This commit is contained in:
parent
bde1a5c792
commit
be39a2a6e5
40
Cargo.lock
generated
40
Cargo.lock
generated
@ -114,6 +114,18 @@ dependencies = [
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "duct"
|
||||
version = "0.13.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"once_cell",
|
||||
"os_pipe",
|
||||
"shared_child",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
@ -124,11 +136,13 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
name = "fedora-kernel-manager"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"duct",
|
||||
"glib-build-tools",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
"linux-version",
|
||||
"serde_json",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -600,6 +614,22 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "os_pipe"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29d73ba8daf8fac13b0501d1abeddcfe21ba7401ada61a819144b6c2a4f32209"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.19.5"
|
||||
@ -786,6 +816,16 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shared_child"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "0.1.1"
|
||||
|
@ -8,9 +8,11 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
adw = { version = "0.6.0", package = "libadwaita", features = ["v1_5"] }
|
||||
duct = "0.13.7"
|
||||
gtk = { version = "0.8.2", package = "gtk4", features = ["v4_14"] }
|
||||
linux-version = "0.1.1"
|
||||
serde_json = "1.0.117"
|
||||
version-compare = "0.2.0"
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.19.0"
|
||||
|
@ -4,6 +4,10 @@ use gtk::prelude::{BoxExt, WidgetExt};
|
||||
use std::process::{Command, Stdio};
|
||||
use crate::{KernelBranch, RunningKernelInfo};
|
||||
use Vec;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use duct::cmd;
|
||||
use version_compare::Version;
|
||||
|
||||
pub fn content() -> gtk::Box {
|
||||
|
||||
@ -126,20 +130,54 @@ fn get_running_kernel_info() -> RunningKernelInfo {
|
||||
};
|
||||
|
||||
let version = match linux_version::linux_kernel_version() {
|
||||
Ok(t) => format!("{}.{}.{}", t.major, t.minor, t.patch),
|
||||
Ok(t) => {
|
||||
if t.patch == 0 {
|
||||
format!("{}.{}", t.major, t.minor)
|
||||
} else {
|
||||
format!("{}.{}.{}", t.major, t.minor, t.patch)
|
||||
}
|
||||
}
|
||||
Err(_) => "Unknown".to_string()
|
||||
};
|
||||
|
||||
let info = RunningKernelInfo {
|
||||
kernel: kernel,
|
||||
version: version,
|
||||
version: version.clone(),
|
||||
// didn't find a way to accurately get this, outside of sched-ext (https://github.com/CachyOS/kernel-manager/blob/develop/src/schedext-window.cpp)
|
||||
sched: "TODO".to_owned()
|
||||
sched: get_current_scheduler(version)
|
||||
};
|
||||
|
||||
info
|
||||
}
|
||||
|
||||
fn get_current_scheduler(version: String) -> String {
|
||||
if Path::new("/sys/kernel/sched_ext/root/ops").exists() {
|
||||
println!("sched_ext is detected, getting scx scheduler");
|
||||
let scx_sched = "sched_ext: ".to_string() + fs::read_to_string("/sys/kernel/sched_ext/root/ops").unwrap().as_str();
|
||||
scx_sched
|
||||
} else if bore_check() {
|
||||
"BORE".to_string()
|
||||
} else if Version::from(&version) >= Version::from("6.6") {
|
||||
"EEVDF?".to_string()
|
||||
} else {
|
||||
"CFS?".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn bore_check() -> bool {
|
||||
let is_bore= match cmd!("sysctl", "-n", "kernel.sched_bore").read() {
|
||||
Ok(t) => {
|
||||
if t == "1" {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
Err(_) => false
|
||||
};
|
||||
is_bore
|
||||
}
|
||||
|
||||
fn create_kernel_badges(badge_box: >k::Box, running_kernel_info: &RunningKernelInfo) {
|
||||
let kernel_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||
let kernel_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||
|
Loading…
Reference in New Issue
Block a user