add branch init script

This commit is contained in:
Ward from fusion-voyager-3 2024-06-20 01:37:27 +03:00
parent a87d458001
commit 7c3dbff13e
6 changed files with 9 additions and 4 deletions

View File

@ -3,7 +3,7 @@
{ {
"name": "kernel-cachyos", "name": "kernel-cachyos",
"db_url": "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db_kernel_cachy.json", "db_url": "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db_kernel_cachy.json",
"init_script": "" "init_script": "pkexec /usr/lib/fedora-kernel-manager/scripts/kernel-cachyos-init.sh"
} }
] ]
} }

Binary file not shown.

View File

@ -20,6 +20,7 @@ pub fn build_ui(app: &adw::Application) {
name: "?".to_owned(), name: "?".to_owned(),
db_url: "?".to_owned(), db_url: "?".to_owned(),
db: "?".to_owned(), db: "?".to_owned(),
init_script: "?".to_owned(),
})); }));
let db_load_complete = Rc::new(RefCell::new(false)); let db_load_complete = Rc::new(RefCell::new(false));

View File

@ -359,7 +359,7 @@ pub fn create_kernel_badge(
fn get_kernel_branches() -> Vec<KernelBranch> { fn get_kernel_branches() -> Vec<KernelBranch> {
let mut kernel_branches_array: Vec<KernelBranch> = Vec::new(); let mut kernel_branches_array: Vec<KernelBranch> = Vec::new();
let data = fs::read_to_string( let data = fs::read_to_string(
"/home/ward/RustroverProjects/fedora-kernel-manager/data/kernel_branches.json", "/usr/lib/fedora-kernel-manager/kernel_branches.json",
) )
.expect("Unable to read file"); .expect("Unable to read file");
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");
@ -372,6 +372,7 @@ fn get_kernel_branches() -> Vec<KernelBranch> {
let branch = KernelBranch { let branch = KernelBranch {
name: branch["name"].as_str().to_owned().unwrap().to_string(), name: branch["name"].as_str().to_owned().unwrap().to_string(),
db_url: branch["db_url"].as_str().to_owned().unwrap().to_string(), db_url: branch["db_url"].as_str().to_owned().unwrap().to_string(),
init_script: branch["init_script"].as_str().to_owned().unwrap().to_string(),
db: reqwest::blocking::get( db: reqwest::blocking::get(
branch["db_url"].as_str().to_owned().unwrap().to_string(), branch["db_url"].as_str().to_owned().unwrap().to_string(),
) )
@ -380,6 +381,8 @@ fn get_kernel_branches() -> Vec<KernelBranch> {
.unwrap(), .unwrap(),
}; };
println!("Download Complete!"); println!("Download Complete!");
println!("Running {} init script.", &branch.name);
let _ = cmd!(&branch.init_script).run();
kernel_branches_array.push(branch) kernel_branches_array.push(branch)
} }
}; };

View File

@ -26,6 +26,7 @@ struct KernelBranch {
name: String, name: String,
db_url: String, db_url: String,
db: String, db: String,
init_script: String
} }
fn main() -> glib::ExitCode { fn main() -> glib::ExitCode {

View File

@ -226,7 +226,7 @@ fn scx_sched_expandable(expander_row: &adw::ExpanderRow,
.build(); .build();
let data = fs::read_to_string( let data = fs::read_to_string(
"/home/ward/RustroverProjects/fedora-kernel-manager/data/scx_scheds.json", "/usr/lib/fedora-kernel-manager/scx_scheds.json",
) )
.expect("Unable to read file"); .expect("Unable to read file");
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");
@ -307,7 +307,7 @@ fn change_scx_scheduler(scx_sched: &str,
kernel_badges_size_group: &gtk::SizeGroup, kernel_badges_size_group: &gtk::SizeGroup,
kernel_badges_size_group0: &gtk::SizeGroup, kernel_badges_size_group0: &gtk::SizeGroup,
kernel_badges_size_group1: &gtk::SizeGroup,) -> Result<(), io::Error> { kernel_badges_size_group1: &gtk::SizeGroup,) -> Result<(), io::Error> {
cmd!("pkexec", "bash", "-c", format!("/home/ward/RustroverProjects/fedora-kernel-manager/data/scripts/change_scx.sh {}", scx_sched)).run()?; cmd!("pkexec", "bash", "-c", format!("/usr/lib/fedora-kernel-manager/scripts/scripts/change_scx.sh {}", scx_sched)).run()?;
create_current_sched_badge( create_current_sched_badge(
&badge_box, &badge_box,
&get_running_kernel_info(), &get_running_kernel_info(),