x86 march check complete
This commit is contained in:
parent
62505286b2
commit
42d34c9c17
@ -1,11 +1,9 @@
|
|||||||
use std::{cell::RefCell, env, rc::Rc, sync::OnceLock};
|
use std::{cell::RefCell, env, rc::Rc, sync::OnceLock};
|
||||||
|
|
||||||
|
use adw::*;
|
||||||
use adw::{prelude::*, subclass::prelude::*, *};
|
use adw::{prelude::*, subclass::prelude::*, *};
|
||||||
use glib::{clone, subclass::Signal, Properties};
|
use glib::{clone, subclass::Signal, Properties};
|
||||||
use gtk::{glib, Orientation::Horizontal};
|
use gtk::{glib, Orientation::Horizontal};
|
||||||
use adw::*;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ANCHOR: custom_button
|
// ANCHOR: custom_button
|
||||||
// Object holding the state
|
// Object holding the state
|
||||||
@ -40,8 +38,7 @@ impl ObjectImpl for KernelPackageRow {
|
|||||||
// `SYNC_CREATE` ensures that the label will be immediately set
|
// `SYNC_CREATE` ensures that the label will be immediately set
|
||||||
let obj = self.obj();
|
let obj = self.obj();
|
||||||
|
|
||||||
let basic_expander_row_package_label = gtk::Label::builder()
|
let basic_expander_row_package_label = gtk::Label::builder().build();
|
||||||
.build();
|
|
||||||
|
|
||||||
obj.add_suffix(&basic_expander_row_package_label);
|
obj.add_suffix(&basic_expander_row_package_label);
|
||||||
|
|
||||||
@ -62,4 +59,4 @@ impl WidgetImpl for KernelPackageRow {}
|
|||||||
|
|
||||||
impl ListBoxRowImpl for KernelPackageRow {}
|
impl ListBoxRowImpl for KernelPackageRow {}
|
||||||
impl PreferencesRowImpl for KernelPackageRow {}
|
impl PreferencesRowImpl for KernelPackageRow {}
|
||||||
impl ExpanderRowImpl for KernelPackageRow {}
|
impl ExpanderRowImpl for KernelPackageRow {}
|
||||||
|
@ -20,4 +20,4 @@ impl Default for KernelPackageRow {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use std::process::Stdio;
|
|
||||||
use crate::content::get_running_kernel_info;
|
use crate::content::get_running_kernel_info;
|
||||||
use crate::{kernel_package_row, KernelBranch, RunningKernelInfo};
|
use crate::{kernel_package_row, KernelBranch, RunningKernelInfo};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
@ -13,6 +12,7 @@ use std::fs::*;
|
|||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::process::Stdio;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::*;
|
use std::time::*;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ pub fn kernel_pkg_page(
|
|||||||
&selected_kernel_branch_clone0.db,
|
&selected_kernel_branch_clone0.db,
|
||||||
&window,
|
&window,
|
||||||
&rows_size_group,
|
&rows_size_group,
|
||||||
&searchbar
|
&searchbar,
|
||||||
);
|
);
|
||||||
|
|
||||||
let packages_viewport = gtk::ScrolledWindow::builder()
|
let packages_viewport = gtk::ScrolledWindow::builder()
|
||||||
@ -136,13 +136,13 @@ fn add_package_rows(
|
|||||||
data: &str,
|
data: &str,
|
||||||
window: &adw::ApplicationWindow,
|
window: &adw::ApplicationWindow,
|
||||||
rows_size_group: >k::SizeGroup,
|
rows_size_group: >k::SizeGroup,
|
||||||
searchbar: >k::SearchEntry
|
searchbar: >k::SearchEntry,
|
||||||
) {
|
) {
|
||||||
let cpu_feature_level: u64 = match get_cpu_feature_level().as_str() {
|
let cpu_feature_level: u32 = match get_cpu_feature_level().as_str() {
|
||||||
"x86-64-v4" => 4,
|
"x86-64-v4" => 4,
|
||||||
"x86-64-v3" => 3,
|
"x86-64-v3" => 3,
|
||||||
"x86-64-v2" => 2,
|
"x86-64-v2" => 2,
|
||||||
_ => 1
|
_ => 1,
|
||||||
};
|
};
|
||||||
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
|
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
|
||||||
if let serde_json::Value::Array(kernels) = &res["kernels"] {
|
if let serde_json::Value::Array(kernels) = &res["kernels"] {
|
||||||
@ -155,15 +155,19 @@ fn add_package_rows(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
let kernel_min_x86_march = kernel["min_x86_march"]
|
let kernel_min_x86_march = kernel["min_x86_march"]
|
||||||
.as_u64()
|
.as_str()
|
||||||
.to_owned()
|
.to_owned()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
let kernel_package_version = match Command::new("/usr/lib/fedora-kernel-manager/scripts/get_version.sh")
|
.parse::<u32>()
|
||||||
.args([&kernel_package])
|
.unwrap();
|
||||||
.output() {
|
let kernel_package_version =
|
||||||
Ok(t) => String::from_utf8(t.stdout).unwrap(),
|
match Command::new("/usr/lib/fedora-kernel-manager/scripts/get_version.sh")
|
||||||
_ => "Error".to_owned()
|
.args([&kernel_package])
|
||||||
};
|
.output()
|
||||||
|
{
|
||||||
|
Ok(t) => String::from_utf8(t.stdout).unwrap(),
|
||||||
|
_ => "Error".to_owned(),
|
||||||
|
};
|
||||||
|
|
||||||
let (log_loop_sender, log_loop_receiver) = async_channel::unbounded();
|
let (log_loop_sender, log_loop_receiver) = async_channel::unbounded();
|
||||||
let log_loop_sender: async_channel::Sender<String> = log_loop_sender.clone();
|
let log_loop_sender: async_channel::Sender<String> = log_loop_sender.clone();
|
||||||
@ -185,9 +189,13 @@ fn add_package_rows(
|
|||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if command_installed_status.status.success() {
|
if command_installed_status.status.success() {
|
||||||
kernel_status_loop_sender.send_blocking(true).expect("channel needs to be open")
|
kernel_status_loop_sender
|
||||||
|
.send_blocking(true)
|
||||||
|
.expect("channel needs to be open")
|
||||||
} else {
|
} else {
|
||||||
kernel_status_loop_sender.send_blocking(false).expect("channel needs to be open")
|
kernel_status_loop_sender
|
||||||
|
.send_blocking(false)
|
||||||
|
.expect("channel needs to be open")
|
||||||
}
|
}
|
||||||
std::thread::sleep(Duration::from_secs(6));
|
std::thread::sleep(Duration::from_secs(6));
|
||||||
});
|
});
|
||||||
@ -381,9 +389,9 @@ fn add_package_rows(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
//
|
if cpu_feature_level >= kernel_min_x86_march {
|
||||||
//if kernel_needs_v3 = false || kernel_needs_v3 = true && cpu_feature_level = "x86-64-v3"
|
boxedlist.append(&kernel_expander_row);
|
||||||
boxedlist.append(&kernel_expander_row);
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -435,10 +443,10 @@ fn kernel_modify(
|
|||||||
|
|
||||||
fn get_cpu_feature_level() -> String {
|
fn get_cpu_feature_level() -> String {
|
||||||
let base_command = Command::new("/lib64/ld-linux-x86-64.so.2") // `ps` command...
|
let base_command = Command::new("/lib64/ld-linux-x86-64.so.2") // `ps` command...
|
||||||
.arg("--help") // with argument `axww`...
|
.arg("--help") // with argument `axww`...
|
||||||
.stdout(Stdio::piped()) // of which we will pipe the output.
|
.stdout(Stdio::piped()) // of which we will pipe the output.
|
||||||
.spawn() // Once configured, we actually spawn the command...
|
.spawn() // Once configured, we actually spawn the command...
|
||||||
.unwrap(); // and assert everything went right.
|
.unwrap(); // and assert everything went right.
|
||||||
let grep_command = Command::new("grep")
|
let grep_command = Command::new("grep")
|
||||||
.arg("(supported, searched)")
|
.arg("(supported, searched)")
|
||||||
.stdin(Stdio::from(base_command.stdout.unwrap()))
|
.stdin(Stdio::from(base_command.stdout.unwrap()))
|
||||||
@ -446,9 +454,16 @@ fn get_cpu_feature_level() -> String {
|
|||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let output = grep_command.wait_with_output().expect("Output failed");
|
let output = grep_command.wait_with_output().expect("Output failed");
|
||||||
let result = match String::from_utf8(output.stdout).expect("stringing failed").lines().next() {
|
let result = match String::from_utf8(output.stdout)
|
||||||
Some(t) => t.trim_end_matches("(supported, searched)").trim().to_string(),
|
.expect("stringing failed")
|
||||||
_ => "x86_64-v1".to_string()
|
.lines()
|
||||||
|
.next()
|
||||||
|
{
|
||||||
|
Some(t) => t
|
||||||
|
.trim_end_matches("(supported, searched)")
|
||||||
|
.trim()
|
||||||
|
.to_string(),
|
||||||
|
_ => "x86_64-v1".to_string(),
|
||||||
};
|
};
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
mod build_ui;
|
mod build_ui;
|
||||||
mod content;
|
mod content;
|
||||||
|
mod kernel_package_row;
|
||||||
mod kernel_pkg;
|
mod kernel_pkg;
|
||||||
mod sched_ext;
|
mod sched_ext;
|
||||||
mod kernel_package_row;
|
|
||||||
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use gtk::*;
|
use gtk::*;
|
||||||
|
@ -193,7 +193,7 @@ fn scx_sched_expandable(expander_row: &adw::ExpanderRow) -> gtk::ListBox {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if format!("scx_{}",get_current_scx_scheduler()).as_str() == sched_clone0 {
|
if format!("scx_{}", get_current_scx_scheduler()).as_str() == sched_clone0 {
|
||||||
sched_checkbutton.set_active(true)
|
sched_checkbutton.set_active(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,4 +240,4 @@ fn get_current_scx_scheduler() -> String {
|
|||||||
};
|
};
|
||||||
|
|
||||||
scx_sched
|
scx_sched
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user