From 9c77a027d6af6f6ccf280aa8cc9af7605e5f84ea Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 23 Feb 2024 18:14:58 +0300 Subject: [PATCH] Update json with mesa --- Cargo.toml | 2 +- data/generate_package_info.sh | 35 ----------------------------- driver-db.json | 32 ++++++++++++++++++++------ src/build_ui/mod.rs | 42 ++++++++++++++++++----------------- 4 files changed, 48 insertions(+), 63 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c173a2..99c2305 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,4 @@ rust-i18n = "3.0.1" users = "0.11.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -reqwest = { version = "0.11", features = ["blocking", "json"] } +reqwest = { version = "0.11", features = ["blocking"] } diff --git a/data/generate_package_info.sh b/data/generate_package_info.sh index 91efdf3..438211e 100755 --- a/data/generate_package_info.sh +++ b/data/generate_package_info.sh @@ -10,42 +10,7 @@ then fi elif [[ $1 == "description" ]] then - if echo "$2" | grep mesa-git &> /dev/null - then - apt-cache show mesa-git | grep 'Description*' | cut -d":" -f2 | head -n1 - else apt-cache show $2 | grep 'Description*' | cut -d":" -f2 | head -n1 - fi -elif [[ $1 == "icon" ]] -then - if echo "$2" | grep "pika-rocm-meta"&> /dev/null; then - echo "amd" - elif echo "$2" | grep "vulkan-amdgpu-pro"&> /dev/null; then - echo "amd" - elif echo "$2" | grep "amf-amdgpu-pro"&> /dev/null; then - echo "amd" - elif echo "$2" | grep "amdvlk"&> /dev/null; then - echo "amd" - elif echo "$2" | grep "opencl-legacy-amdgpu-pro-icd"&> /dev/null; then - echo "amd" - elif echo "$2" | grep "amdgpu-pro-oglp"&> /dev/null; then - echo "amd" - elif echo "$2" | grep "xone-dkms"&> /dev/null; then - echo "input-gaming" - elif echo "$2" | grep "nvidia"&> /dev/null; then - echo "nvidia" - elif echo "$2" | grep "intel"&> /dev/null; then - echo "intel" - else - echo "pika-drivers" - fi -elif [[ $1 == "safe" ]] -then - if [[ "$2" == "mesa-git" ]]; then - echo "true" - else - echo "false" - fi elif [[ $1 == "device" ]] then if echo "$2" | grep -i -E 'pika-rocm-meta|vulkan-amdgpu-pro|amf-amdgpu-pro|amdvlk|opencl-legacy-amdgpu-pro-icd|amdgpu-pro-oglp' &> /dev/null diff --git a/driver-db.json b/driver-db.json index 066da25..59a67ce 100644 --- a/driver-db.json +++ b/driver-db.json @@ -1,40 +1,58 @@ { "drivers": [ + { + "driver": "mesa-stable", + "icon": "video-display", + "experimental": false, + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -vi nvidia" + }, + { + "driver": "mesa-hybrid", + "icon": "video-display", + "experimental": false, + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -vi nvidia" + }, + { + "driver": "mesa-git", + "icon": "video-display", + "experimental": true, + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -vi nvidia" + }, { "driver": "pika-rocm-meta", "icon": "amd", "experimental": false, - "detection": "inxi -G | grep driver | grep -i amdgpu" + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" }, { "driver": "vulkan-amdgpu-pro", "icon": "amd", "experimental": false, - "detection": "inxi -G | grep driver | grep -i amdgpu" + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" }, { "driver": "amf-amdgpu-pro", "icon": "amd", "experimental": false, - "detection": "inxi -G | grep driver | grep -i amdgpu" + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" }, { "driver": "amdvlk", "icon": "amd", "experimental": false, - "detection": "inxi -G | grep driver | grep -i amdgpu" + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" }, { "driver": "opencl-legacy-amdgpu-pro-icd", "icon": "amd", "experimental": false, - "detection": "inxi -G | grep driver | grep -i amdgpu" + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" }, { "driver": "amdgpu-pro-oglp", "icon": "amd", "experimental": false, - "detection": "inxi -G | grep driver | grep -i amdgpu" + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" }, { "driver": "nvidia-driver-525", @@ -94,7 +112,7 @@ "driver": "intel-gpu-compute", "icon": "intel", "experimental": false, - "detection": "inxi -G | grep driver | grep -i intel" + "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel" } ] } \ No newline at end of file diff --git a/src/build_ui/mod.rs b/src/build_ui/mod.rs index 3619515..f0fa6b7 100644 --- a/src/build_ui/mod.rs +++ b/src/build_ui/mod.rs @@ -120,12 +120,14 @@ pub fn build_ui(app: &adw::Application) { credits_button.connect_clicked(clone!(@weak credits_button => move |_| credits_window.present())); + println!("Downloading driver DB..."); + let data = reqwest::blocking::get("https://raw.githubusercontent.com/PikaOS-Linux/pkg-pika-drivers/main/driver-db.json").unwrap().text().unwrap(); + let (drive_hws_sender, drive_hws_receiver) = async_channel::unbounded(); let drive_hws_sender = drive_hws_sender.clone(); // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - println!("Downloading driver DB..."); - let data = reqwest::blocking::get("https://raw.githubusercontent.com/PikaOS-Linux/pkg-pika-drivers/main/driver-db.json").unwrap().text().unwrap(); + gio::spawn_blocking(clone!(@strong data => move || { + let mut drivers_found_array: Vec = Vec::new(); println!("Parsing Downloaded driver DB..."); let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse"); if let serde_json::Value::Array(drivers) = &res["drivers"] { @@ -137,14 +139,14 @@ pub fn build_ui(app: &adw::Application) { let _ = cmd!("chmod", "+x", "/tmp/run-pkdm-detect.sh").run(); let result = cmd!("/tmp/run-pkdm-detect.sh").run(); if result.is_ok() { - println!("{}", driver["driver"]) + drivers_found_array.push((driver["driver"].as_str().to_owned().unwrap()).to_string()) } } } - // drive_hws_sender - // .send_blocking(ubuntu_drivers_list_utf8) - // .expect("channel needs to be open.") - }); + drive_hws_sender + .send_blocking(drivers_found_array) + .expect("channel needs to be open.") + })); window.present(); @@ -152,7 +154,7 @@ pub fn build_ui(app: &adw::Application) { // The main loop executes the asynchronous block drive_hws_main_context.spawn_local(clone!(@weak content_box, @weak loading_box => async move { while let Ok(drive_hws_state) = drive_hws_receiver.recv().await { - get_drivers(&content_box, &loading_box, drive_hws_state, &window); + get_drivers(&content_box, &loading_box, &drive_hws_state, &window); } })); } @@ -184,7 +186,7 @@ fn driver_modify( fn get_drivers( main_window: >k::Box, loading_box: >k::Box, - ubuntu_drivers_list_utf8: String, + driver_found_array: &Vec, window: &adw::ApplicationWindow, ) { let main_box = gtk::Box::builder() @@ -210,31 +212,31 @@ fn get_drivers( let mut driver_array: Vec = Vec::new(); let mut device_groups: HashMap> = HashMap::new(); - for ubuntu_driver in ubuntu_drivers_list_utf8.lines() { - let ubuntu_driver_string = ubuntu_driver.to_string(); + for found_driver in driver_found_array.iter() { + let found_driver_string = found_driver.to_string(); let command_version_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh") - .args(["version", ubuntu_driver]) + .args(["version", found_driver]) .output() .unwrap(); let command_description_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh") - .args(["description", ubuntu_driver]) + .args(["description", found_driver]) .output() .unwrap(); let command_device_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh") - .args(["device", ubuntu_driver]) + .args(["device", found_driver]) .output() .unwrap(); let command_icon_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh") - .args(["icon", ubuntu_driver]) + .args(["icon", found_driver]) .output() .unwrap(); let command_safe_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh") - .args(["safe", ubuntu_driver]) + .args(["safe", found_driver]) .output() .unwrap(); - let ubuntu_driver_package = DriverPackage { - driver: ubuntu_driver_string, + let found_driver_package = DriverPackage { + driver: found_driver_string, version: String::from_utf8(command_version_label.stdout) .unwrap() .trim() @@ -257,7 +259,7 @@ fn get_drivers( .parse() .unwrap(), }; - driver_array.push(ubuntu_driver_package); + driver_array.push(found_driver_package); driver_array.sort_by(|a, b| b.cmp(a)) }