diff --git a/Makefile b/Makefile index a9e7733..b1135cb 100644 --- a/Makefile +++ b/Makefile @@ -13,13 +13,13 @@ install_no_build: cp -rvf data/scripts $(DESTDIR)/usr/lib/fedora-kernel-manager/ chmod 755 $(DESTDIR)/usr/lib/fedora-kernel-manager/scripts/*.sh cp -rvf data/locales $(DESTDIR)/usr/lib/fedora-kernel-manager/ - cp -vf data/kernel_branches.json $(DESTDIR)/usr/lib/fedora-kernel-manager/ + cp -rvf data/kernel_branches $(DESTDIR)/usr/lib/fedora-kernel-manager/ cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/fedora-kernel-manager/ mkdir -p $(DESTDIR)/usr/share/applications mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps cp -vf data/com.github.cosmicfusion.fedora-kernel-manager.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/ cp -vf data/com.github.cosmicfusion.fedora-kernel-manager.desktop $(DESTDIR)/usr/share/applications/ - cp -vf data/polkit-1 $(DESTDIR)/usr/share/ + cp -rvf data/polkit-1 $(DESTDIR)/usr/share/ install: mkdir -p $(DESTDIR)/usr/bin/ @@ -30,10 +30,10 @@ install: mkdir -p $(DESTDIR)/usr/lib/fedora-kernel-manager/ cp -rvf data/scripts $(DESTDIR)/usr/lib/fedora-kernel-manager/ chmod 755 $(DESTDIR)/usr/lib/fedora-kernel-manager/scripts/*.sh - cp -vf data/kernel_branches.json $(DESTDIR)/usr/lib/fedora-kernel-manager/ + cp -rvf data/kernel_branches $(DESTDIR)/usr/lib/fedora-kernel-manager/ cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/fedora-kernel-manager/ mkdir -p $(DESTDIR)/usr/share/applications mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps cp -vf data/com.github.cosmicfusion.fedora-kernel-manager.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/ cp -vf data/com.github.cosmicfusion.fedora-kernel-manager.desktop $(DESTDIR)/usr/share/applications/ - cp -vf data/polkit-1 $(DESTDIR)/usr/share/ + cp -rvf data/polkit-1 $(DESTDIR)/usr/share/ diff --git a/core b/core index fe73b1d..0ca5050 100644 Binary files a/core and b/core differ diff --git a/data/kernel_branches.json b/data/kernel_branches.json deleted file mode 100644 index 2b8c193..0000000 --- a/data/kernel_branches.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "branches": [ - { - "name": "kernel-cachyos", - "db_url": "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db_kernel_cachy.json", - "init_script": "pkexec /usr/lib/fedora-kernel-manager/scripts/kernel-cachyos-init.sh" - } - ] -} \ No newline at end of file diff --git a/data/kernel_branches/kernel-cachyos.json b/data/kernel_branches/kernel-cachyos.json new file mode 100644 index 0000000..31875f1 --- /dev/null +++ b/data/kernel_branches/kernel-cachyos.json @@ -0,0 +1,5 @@ +{ + "name": "kernel-cachyos", + "db_url": "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db_kernel_cachy.json", + "init_script": "pkexec /usr/lib/fedora-kernel-manager/scripts/kernel-cachyos-init.sh" +} \ No newline at end of file diff --git a/src/content/mod.rs b/src/content/mod.rs index e243303..18f0b30 100644 --- a/src/content/mod.rs +++ b/src/content/mod.rs @@ -149,7 +149,7 @@ pub fn content( .height_request(50) .width_request(50) .tooltip_text(t!("config_kernel_button_tooltip_text")) - .sensitive(!is_scx_kernel()) + .sensitive(is_scx_kernel()) .hexpand(true) .build(); config_kernel_button.add_css_class("circular"); @@ -379,37 +379,36 @@ pub fn create_kernel_badge( fn get_kernel_branches() -> Result, reqwest::Error> { let mut kernel_branches_array: Vec = Vec::new(); - let data = fs::read_to_string("/usr/lib/fedora-kernel-manager/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_name = branch["name"].as_str().to_owned().unwrap().to_string(); - let branch_db_url = branch["db_url"].as_str().to_owned().unwrap().to_string(); - let branch_init_script = branch["init_script"] - .as_str() - .to_owned() - .unwrap() - .to_string(); - println!("{} {}.",t!("db_downloading"), &branch_name); - let branch_db = - reqwest::blocking::get(branch["db_url"].as_str().to_owned().unwrap().to_string())? - .text() - .unwrap(); - let branch = KernelBranch { - name: branch_name, - db_url: branch_db_url, - init_script: branch_init_script, - db: branch_db, - }; - println!("{}", t!("db_download_complete")); - println!("{} {} {}", t!("db_init_script_run_p1"), &branch.name, t!("db_init_script_run_p2")); - match cmd!("bash", "-c", &branch.init_script).run() { - Ok(_) => println!("{} {}", &branch.name, t!("db_init_script_successful")), - _ => println!("{} {}", &branch.name, t!("db_init_script_failed")), - }; - kernel_branches_array.push(branch) - } + let kernel_branch_files_dir = fs::read_dir("/usr/lib/fedora-kernel-manager/kernel_branches").expect("No Kernel json files found"); + for kernel_branch_file in kernel_branch_files_dir { + let kernel_branch_file_path = kernel_branch_file.expect("couldn't change dir entry to path").path(); + let kernel_branch_data = fs::read_to_string(kernel_branch_file_path).expect("some json is invalid"); + let branch: serde_json::Value = serde_json::from_str(&kernel_branch_data).expect("some json is invalid"); + let branch_name = branch["name"].as_str().to_owned().unwrap().to_string(); + let branch_db_url = branch["db_url"].as_str().to_owned().unwrap().to_string(); + let branch_init_script = branch["init_script"] + .as_str() + .to_owned() + .unwrap() + .to_string(); + println!("{} {}.",t!("db_downloading"), &branch_name); + let branch_db = + reqwest::blocking::get(branch["db_url"].as_str().to_owned().unwrap().to_string())? + .text() + .unwrap(); + let branch = KernelBranch { + name: branch_name, + db_url: branch_db_url, + init_script: branch_init_script, + db: branch_db, + }; + println!("{}", t!("db_download_complete")); + println!("{} {} {}", t!("db_init_script_run_p1"), &branch.name, t!("db_init_script_run_p2")); + match cmd!("bash", "-c", &branch.init_script).run() { + Ok(_) => println!("{} {}", &branch.name, t!("db_init_script_successful")), + _ => println!("{} {}", &branch.name, t!("db_init_script_failed")), + }; + kernel_branches_array.push(branch) }; Ok(kernel_branches_array)