Update json

This commit is contained in:
Ward from fusion-voyager-3 2024-02-23 17:50:02 +03:00
parent 067cf28bef
commit 509746951c
3 changed files with 47 additions and 28 deletions

View File

@ -13,3 +13,6 @@ duct = "0.13.7"
os_pipe = "1.1.5"
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"] }

View File

@ -1,100 +1,100 @@
{
"drivers": {
"pika-rocm-meta": {
"drivers": [
{
"driver": "pika-rocm-meta",
"icon": "amd",
"experimental": false,
"detection": "inxi -G | grep driver | grep -i amdgpu"
},
"vulkan-amdgpu-pro": {
{
"driver": "vulkan-amdgpu-pro",
"icon": "amd",
"experimental": false,
"detection": "inxi -G | grep driver | grep -i amdgpu"
},
"amf-amdgpu-pro": {
{
"driver": "amf-amdgpu-pro",
"icon": "amd",
"experimental": false,
"detection": "inxi -G | grep driver | grep -i amdgpu"
},
"amdvlk": {
{
"driver": "amdvlk",
"icon": "amd",
"experimental": false,
"detection": "inxi -G | grep driver | grep -i amdgpu"
},
"opencl-legacy-amdgpu-pro-icd": {
{
"driver": "opencl-legacy-amdgpu-pro-icd",
"icon": "amd",
"experimental": false,
"detection": "inxi -G | grep driver | grep -i amdgpu"
},
"amdgpu-pro-oglp": {
{
"driver": "amdgpu-pro-oglp",
"icon": "amd",
"experimental": false,
"detection": "inxi -G | grep driver | grep -i amdgpu"
},
"nvidia-driver-525": {
{
"driver": "nvidia-driver-525",
"icon": "nvidia",
"experimental": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"nvidia-driver-525-open": {
{
"driver": "nvidia-driver-525-open",
"icon": "nvidia",
"experimental": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"nvidia-driver-535": {
{
"driver": "nvidia-driver-535",
"icon": "nvidia",
"experimental": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"nvidia-driver-535-open": {
{
"driver": "nvidia-driver-535-open",
"icon": "nvidia",
"experimental": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"nvidia-driver-545": {
{
"driver": "nvidia-driver-545",
"icon": "nvidia",
"experimental": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"nvidia-driver-545-open": {
{
"driver": "nvidia-driver-545-open",
"icon": "nvidia",
"experimental": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"nvidia-driver-550": {
{
"driver": "nvidia-driver-550",
"icon": "nvidia",
"experimental": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"nvidia-driver-550-open": {
{
"driver": "nvidia-driver-550-open",
"icon": "nvidia",
"experimental": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
},
"xone-dkms": {
{
"driver": "xone-dkms",
"icon": "input-gaming",
"experimental": false,
"detection": "lsusb | grep -i xbox"
},
"intel-gpu-compute": {
{
"driver": "intel-gpu-compute",
"icon": "intel",
"experimental": false,
"detection": "inxi -G | grep driver | grep -i intel"
}
}
]
}

View File

@ -1,3 +1,5 @@
use std::path::Path;
use std::fs;
use crate::config::*;
use crate::save_window_size::save_window_size;
use crate::DriverPackage;
@ -12,8 +14,12 @@ use std::error::Error;
use std::io::BufRead;
use std::io::BufReader;
use std::process::Command;
use users::*;
use serde_json::json;
use serde_json::Value;
pub fn build_ui(app: &adw::Application) {
gtk::glib::set_prgname(Some(APP_NAME));
glib::set_application_name(APP_NAME);
@ -118,16 +124,26 @@ pub fn build_ui(app: &adw::Application) {
let drive_hws_sender = drive_hws_sender.clone();
// The long running operation runs now in a separate thread
gio::spawn_blocking(move || {
println!("Checking HW paramter script for available drivers:\n");
let ubuntu_drivers_list_cli =
Command::new("/usr/lib/pika/drivers/generate_driver_definitions.sh")
.output()
.expect("failed to execute process");
let ubuntu_drivers_list_utf8 = String::from_utf8(ubuntu_drivers_list_cli.stdout).unwrap_or_default();
drive_hws_sender
.send_blocking(ubuntu_drivers_list_utf8)
.expect("channel needs to be open.")
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();
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"] {
for driver in drivers {
if Path::new("/tmp/run-pkdm-detect.sh").exists() {
fs::remove_file("/tmp/run-pkdm-detect.sh").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt");
}
fs::write("/tmp/run-pkdm-detect.sh", "#! /bin/bash\nset -e\n".to_owned() + driver["detection"].as_str().to_owned().unwrap()).expect("Unable to write file");
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"])
}
}
}
// drive_hws_sender
// .send_blocking(ubuntu_drivers_list_utf8)
// .expect("channel needs to be open.")
});
window.present();