diff --git a/data/db-kernel-cachy.json b/data/db_kernel_cachy.json similarity index 100% rename from data/db-kernel-cachy.json rename to data/db_kernel_cachy.json diff --git a/data/kernel_branches.json b/data/kernel_branches.json new file mode 100644 index 0000000..db9ded2 --- /dev/null +++ b/data/kernel_branches.json @@ -0,0 +1,8 @@ +{ + "branches": [ + { + "name": "kernel-cachyos", + "db": "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db_kernel_cachy.json" + } + ] +} \ No newline at end of file diff --git a/src/content/mod.rs b/src/content/mod.rs index 5628743..d7b1092 100644 --- a/src/content/mod.rs +++ b/src/content/mod.rs @@ -116,28 +116,6 @@ pub fn content(content_stack: >k::Stack, selected_kernel_branch: &Rc Vec { - let test_branch = KernelBranch { - name: "kernel-cachy".to_string(), - db: "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db-kernel-cachy.json".to_string() - }; + let mut kernel_branches_array: Vec = Vec::new(); + let data = fs::read_to_string( + "/home/ward/RustroverProjects/fedora-kernel-manager/data/kernel_branches.json", + ) + .expect("Unable to read file"); + let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse"); + if let serde_json::Value::Array(branches) = &res["branches"] { + for branch in branches { + let branch = KernelBranch{ + name: branch["name"].as_str().to_owned().unwrap().to_string(), + db: branch["db"].as_str().to_owned().unwrap().to_string(), + }; + kernel_branches_array.push(branch) + }}; - let test_branch2 = KernelBranch { - name: "kernel-tkg".to_string(), - db: "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db-kernel-cachy.json".to_string() - }; - - vec![test_branch, test_branch2] + kernel_branches_array } pub fn get_running_kernel_info() -> RunningKernelInfo { let kernel = match Command::new("uname")