Removable check

This commit is contained in:
Ward from fusion-voyager-3 2024-02-23 21:57:36 +03:00
parent c888b2ebd7
commit e9a1168bec
4 changed files with 44 additions and 11 deletions

View File

@ -5,6 +5,7 @@
"driver": "mesa-stable", "driver": "mesa-stable",
"icon": "video-display", "icon": "video-display",
"experimental": false, "experimental": false,
"removable": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -12,6 +13,7 @@
"driver": "mesa-hybrid", "driver": "mesa-hybrid",
"icon": "video-display", "icon": "video-display",
"experimental": false, "experimental": false,
"removable": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -19,6 +21,7 @@
"driver": "mesa-git", "driver": "mesa-git",
"icon": "video-display", "icon": "video-display",
"experimental": true, "experimental": true,
"removable": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -26,6 +29,7 @@
"driver": "mesa-stable", "driver": "mesa-stable",
"icon": "video-display", "icon": "video-display",
"experimental": false, "experimental": false,
"removable": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel"
}, },
{ {
@ -33,6 +37,7 @@
"driver": "mesa-hybrid", "driver": "mesa-hybrid",
"icon": "video-display", "icon": "video-display",
"experimental": false, "experimental": false,
"removable": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel"
}, },
{ {
@ -40,6 +45,7 @@
"driver": "mesa-git", "driver": "mesa-git",
"icon": "video-display", "icon": "video-display",
"experimental": true, "experimental": true,
"removable": false,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel"
}, },
{ {
@ -47,6 +53,7 @@
"driver": "pika-rocm-meta", "driver": "pika-rocm-meta",
"icon": "amd", "icon": "amd",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -54,6 +61,7 @@
"driver": "vulkan-amdgpu-pro", "driver": "vulkan-amdgpu-pro",
"icon": "amd", "icon": "amd",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -61,6 +69,7 @@
"driver": "amf-amdgpu-pro", "driver": "amf-amdgpu-pro",
"icon": "amd", "icon": "amd",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -68,6 +77,7 @@
"driver": "amdvlk", "driver": "amdvlk",
"icon": "amd", "icon": "amd",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -75,6 +85,7 @@
"driver": "opencl-legacy-amdgpu-pro-icd", "driver": "opencl-legacy-amdgpu-pro-icd",
"icon": "amd", "icon": "amd",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -82,6 +93,7 @@
"driver": "amdgpu-pro-oglp", "driver": "amdgpu-pro-oglp",
"icon": "amd", "icon": "amd",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i amd"
}, },
{ {
@ -89,6 +101,7 @@
"driver": "nvidia-driver-525", "driver": "nvidia-driver-525",
"icon": "nvidia", "icon": "nvidia",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -96,6 +109,7 @@
"driver": "nvidia-driver-525-open", "driver": "nvidia-driver-525-open",
"icon": "nvidia", "icon": "nvidia",
"experimental": true, "experimental": true,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -103,6 +117,7 @@
"driver": "nvidia-driver-535", "driver": "nvidia-driver-535",
"icon": "nvidia", "icon": "nvidia",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -110,6 +125,7 @@
"driver": "nvidia-driver-535-open", "driver": "nvidia-driver-535-open",
"icon": "nvidia", "icon": "nvidia",
"experimental": true, "experimental": true,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -117,6 +133,7 @@
"driver": "nvidia-driver-545", "driver": "nvidia-driver-545",
"icon": "nvidia", "icon": "nvidia",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -124,6 +141,7 @@
"driver": "nvidia-driver-545-open", "driver": "nvidia-driver-545-open",
"icon": "nvidia", "icon": "nvidia",
"experimental": true, "experimental": true,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -131,6 +149,7 @@
"driver": "nvidia-driver-550", "driver": "nvidia-driver-550",
"icon": "nvidia", "icon": "nvidia",
"experimental": true, "experimental": true,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -138,6 +157,7 @@
"driver": "nvidia-driver-550-open", "driver": "nvidia-driver-550-open",
"icon": "nvidia", "icon": "nvidia",
"experimental": true, "experimental": true,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i nvidia | cut -d: -f 4"
}, },
{ {
@ -145,6 +165,7 @@
"driver": "xone-dkms", "driver": "xone-dkms",
"icon": "input-gaming", "icon": "input-gaming",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lsusb | grep -i xbox" "detection": "lsusb | grep -i xbox"
}, },
{ {
@ -152,6 +173,7 @@
"driver": "intel-gpu-compute", "driver": "intel-gpu-compute",
"icon": "intel", "icon": "intel",
"experimental": false, "experimental": false,
"removable": true,
"detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel" "detection": "lspci -D | grep -iE 'VGA|3D' | grep -i intel"
} }
] ]

View File

@ -1,5 +1,13 @@
{ {
"app_name": "PikaOS Driver Manager", "app_name": "PikaOS Driver Manager",
"app_dev": "Cosmo", "app_dev": "Cosmo",
"loading_label_label": "Scanning for drivers..." "loading_label_label": "Downloading driver database...",
"loading_no_internet_box_text_title": "Network Error!",
"loading_no_internet_box_text_description": "An Internet Connection is needed to download the driver database.",
"device_label_label_prefix": "Device: ",
"driver_install_button_label": "Install",
"driver_install_button_tooltip_text": "Install the driver package.",
"driver_remove_button_label": "Uninstall",
"driver_remove_button_tooltip_text": "Uninstall the driver package.",
"driver_expander_row_title_suffix": " (WARNING: THIS DRIVER IS EXPERMINTAL USE AT YOUR OWN RISK!)"
} }

View File

@ -142,7 +142,7 @@ pub fn build_ui(app: &adw::Application) {
if Path::new("/tmp/run-pkdm-detect.sh").exists() { 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::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"); fs::write("/tmp/run-pkdm-detect.sh", "#! /bin/bash\nset -e\nexport LANG=en_US.UTF-8\n".to_owned() + driver["detection"].as_str().to_owned().unwrap()).expect("Unable to write file");
let _ = cmd!("chmod", "+x", "/tmp/run-pkdm-detect.sh").read(); let _ = cmd!("chmod", "+x", "/tmp/run-pkdm-detect.sh").read();
let result = cmd!("/tmp/run-pkdm-detect.sh").stdout_capture().read(); let result = cmd!("/tmp/run-pkdm-detect.sh").stdout_capture().read();
if result.is_ok() { if result.is_ok() {
@ -150,6 +150,7 @@ pub fn build_ui(app: &adw::Application) {
let driver_device = result.unwrap(); let driver_device = result.unwrap();
let driver_icon = driver["icon"].as_str().to_owned().unwrap().to_string(); let driver_icon = driver["icon"].as_str().to_owned().unwrap().to_string();
let driver_experimental = driver["experimental"].as_bool().unwrap(); let driver_experimental = driver["experimental"].as_bool().unwrap();
let driver_removeble= driver["removable"].as_bool().unwrap();
let command_version_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh") let command_version_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh")
.args(["version", &driver_name]) .args(["version", &driver_name])
.output() .output()
@ -171,6 +172,7 @@ pub fn build_ui(app: &adw::Application) {
.to_string(), .to_string(),
icon: driver_icon, icon: driver_icon,
experimental: driver_experimental, experimental: driver_experimental,
removeble: driver_removeble,
}; };
driver_package_array.push(found_driver_package) driver_package_array.push(found_driver_package)
} }
@ -199,8 +201,8 @@ pub fn build_ui(app: &adw::Application) {
println!("Network Error!"); println!("Network Error!");
let loading_no_internet_box_text = adw::StatusPage::builder() let loading_no_internet_box_text = adw::StatusPage::builder()
.icon_name("network-cellular-offline") .icon_name("network-cellular-offline")
.title(t!("first_setup_gameutils_box_text_title")) .title(t!("loading_no_internet_box_text_title"))
.description(t!("first_setup_gameutils_box_text_description")) .description(t!("loading_no_internet_box_text_description"))
.build(); .build();
loading_no_internet_box_text.add_css_class("compact"); loading_no_internet_box_text.add_css_class("compact");
@ -275,7 +277,7 @@ fn get_drivers(
}); });
for (device, group) in device_groups { for (device, group) in device_groups {
let device_label = gtk::Label::builder() let device_label = gtk::Label::builder()
.label("Device: ".to_owned() + &device) .label(t!("device_label_label_prefix").to_owned().to_string() + &device)
.halign(gtk::Align::Center) .halign(gtk::Align::Center)
.valign(gtk::Align::Center) .valign(gtk::Align::Center)
.build(); .build();
@ -318,8 +320,8 @@ fn get_drivers(
.margin_top(5) .margin_top(5)
.margin_bottom(5) .margin_bottom(5)
.valign(gtk::Align::Center) .valign(gtk::Align::Center)
.label("Install") .label(t!("driver_install_button_label"))
.tooltip_text("Install the driver package.") .tooltip_text(t!("driver_install_button_tooltip_text"))
.sensitive(false) .sensitive(false)
.build(); .build();
driver_install_button.add_css_class("suggested-action"); driver_install_button.add_css_class("suggested-action");
@ -328,8 +330,8 @@ fn get_drivers(
.margin_top(5) .margin_top(5)
.margin_bottom(5) .margin_bottom(5)
.valign(gtk::Align::Center) .valign(gtk::Align::Center)
.label("Uninstall") .label(t!("driver_remove_button_label"))
.tooltip_text("Uninstall the driver package.") .tooltip_text(t!("driver_remove_button_tooltip_text"))
.sensitive(false) .sensitive(false)
.build(); .build();
let driver_action_box = gtk::Box::builder().homogeneous(true).build(); let driver_action_box = gtk::Box::builder().homogeneous(true).build();
@ -338,7 +340,7 @@ fn get_drivers(
if driver.clone().experimental == true { if driver.clone().experimental == true {
driver_expander_row.set_title( driver_expander_row.set_title(
&(driver.clone().driver &(driver.clone().driver
+ " (WARNING: THIS DRIVER IS EXPERMINTAL USE AT YOUR OWN RISK!)"), + &t!("driver_expander_row_title_suffix").to_string()),
); );
driver_expander_row.add_css_class("midLabelWARN"); driver_expander_row.add_css_class("midLabelWARN");
} else { } else {
@ -358,7 +360,7 @@ fn get_drivers(
.unwrap(); .unwrap();
if command_installed_status.status.success() { if command_installed_status.status.success() {
driver_install_button.set_sensitive(false); driver_install_button.set_sensitive(false);
if !driver.clone().driver.contains("mesa") { if driver.clone().removeble == false {
driver_remove_button.set_sensitive(true); driver_remove_button.set_sensitive(true);
} }
} else { } else {

View File

@ -17,6 +17,7 @@ pub struct DriverPackage {
description: String, description: String,
icon: String, icon: String,
experimental: bool, experimental: bool,
removeble: bool,
} }
use build_ui::build_ui; use build_ui::build_ui;