make json versitile
This commit is contained in:
parent
9d33a1ea43
commit
9cd9f6dd8f
8
Makefile
8
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/
|
||||
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
5
data/kernel_branches/kernel-cachyos.json
Normal file
5
data/kernel_branches/kernel-cachyos.json
Normal file
@ -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"
|
||||
}
|
@ -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<Vec<KernelBranch>, reqwest::Error> {
|
||||
let mut kernel_branches_array: Vec<KernelBranch> = 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)
|
||||
|
Loading…
Reference in New Issue
Block a user