fix inputless terminal
This commit is contained in:
parent
be30228a8a
commit
45d1339950
@ -43,18 +43,18 @@ then
|
||||
then
|
||||
zenity --error --text "the following driver "$1" can not be removed only swapped"
|
||||
else
|
||||
echo "pikaos" | sudo -S bash -c "apt remove $pkg -y && sudo apt autoremove -y"
|
||||
echo "pikaos" | sudo -S bash -c "DEBIAN_FRONTEND=noninteractive apt remove $pkg -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
fi
|
||||
else
|
||||
if echo $pkg | grep -i nvidia
|
||||
then
|
||||
echo "pikaos" | sudo -S bash -c "apt update -y && apt purge nvidia-driver-* -y && apt install $pkg -y && sudo apt autoremove -y"
|
||||
echo "pikaos" | sudo -S bash -c "DEBIAN_FRONTEND=noninteractive apt update -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt purge nvidia-driver-* -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install $pkg -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
else
|
||||
if echo $pkg | grep -i mesa-hybrid
|
||||
then
|
||||
echo "pikaos" | sudo -S bash -c "apt update -y && apt install mesa-stable -y && apt install mesa-hybrid -y && sudo apt autoremove -y"
|
||||
echo "pikaos" | sudo -S bash -c "DEBIAN_FRONTEND=noninteractive apt update -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install mesa-stable -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install mesa-hybrid -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
else
|
||||
echo "pikaos" | sudo -S bash -c "apt update -y && apt install $pkg -y && sudo apt autoremove -y"
|
||||
echo "pikaos" | sudo -S bash -c "DEBIAN_FRONTEND=noninteractive apt update -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install $pkg -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@ -100,18 +100,18 @@ then
|
||||
then
|
||||
zenity --error --text "the following driver "$1" can not be removed only swapped"
|
||||
else
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "apt remove $pkg -y && sudo apt autoremove -y"
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "DEBIAN_FRONTEND=noninteractive apt remove $pkg -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
fi
|
||||
else
|
||||
if echo $pkg | grep -i nvidia
|
||||
then
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "apt update -y && apt purge nvidia-driver-* -y && apt install $pkg -y && sudo apt autoremove -y"
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "DEBIAN_FRONTEND=noninteractive apt update -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt purge nvidia-driver-* -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install $pkg -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
else
|
||||
if echo $pkg | grep -i mesa-hybrid
|
||||
then
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "apt update -y && apt install mesa-stable -y && apt install mesa-hybrid -y && sudo apt autoremove -y"
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "DEBIAN_FRONTEND=noninteractive apt update -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install mesa-stable -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install mesa-hybrid -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
else
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "apt update -y && apt install $pkg -y && sudo apt autoremove -y"
|
||||
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c "DEBIAN_FRONTEND=noninteractive apt update -y -o Dpkg::Options::='--force-confnew' && DEBIAN_FRONTEND=noninteractive apt install $pkg -y -o Dpkg::Options::='--force-confnew' && sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y -o Dpkg::Options::='--force-confnew'"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"app_name": "PikaOS Welcome",
|
||||
"app_name": "PikaOS Driver Manager",
|
||||
"app_dev": "Cosmo",
|
||||
"loading_label_label": "Downloading driver database...",
|
||||
"loading_no_internet_box_text_title": "Network Error!",
|
||||
|
@ -1,3 +1,4 @@
|
||||
use std::thread;
|
||||
use crate::config::*;
|
||||
use crate::save_window_size::save_window_size;
|
||||
use crate::DriverPackage;
|
||||
@ -6,7 +7,7 @@ use adw::prelude::*;
|
||||
use adw::{gio, glib};
|
||||
use duct::cmd;
|
||||
use gtk::prelude::{BoxExt, ButtonExt, GtkWindowExt, WidgetExt};
|
||||
use gtk::Orientation;
|
||||
use gtk::{Orientation, SizeGroupMode};
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
@ -14,6 +15,7 @@ use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::time::Duration;
|
||||
|
||||
use users::*;
|
||||
|
||||
@ -84,7 +86,6 @@ pub fn build_ui(app: &adw::Application) {
|
||||
.width_request(950)
|
||||
.height_request(500)
|
||||
.startup_id(APP_ID)
|
||||
.hide_on_close(true)
|
||||
.build();
|
||||
|
||||
if glib_settings.boolean("is-maximized") == true {
|
||||
@ -107,12 +108,20 @@ pub fn build_ui(app: &adw::Application) {
|
||||
.issue_url(APP_GITHUB.to_owned() + "/issues")
|
||||
.build();
|
||||
|
||||
let list_row_size_group = gtk::SizeGroup::new(SizeGroupMode::Horizontal);
|
||||
let rows_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||
|
||||
content_box.append(&window_title_bar);
|
||||
|
||||
window_title_bar.pack_end(&credits_button.clone());
|
||||
|
||||
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
|
||||
window.connect_hide(clone!(@weak window => move |_| window.destroy()));
|
||||
window.connect_close_request(move |window| {
|
||||
if let Some(application) = window.application() {
|
||||
save_window_size(&window, &glib_settings);
|
||||
application.remove_window(window);
|
||||
}
|
||||
glib::Propagation::Proceed
|
||||
});
|
||||
|
||||
credits_button
|
||||
.connect_clicked(clone!(@weak credits_button => move |_| credits_window.present()));
|
||||
@ -193,7 +202,7 @@ pub fn build_ui(app: &adw::Application) {
|
||||
drive_hws_main_context.spawn_local(
|
||||
clone!(@weak content_box, @weak loading_box, @strong data => 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, &list_row_size_group, &rows_size_group);
|
||||
}
|
||||
}),
|
||||
);
|
||||
@ -240,6 +249,8 @@ fn get_drivers(
|
||||
loading_box: >k::Box,
|
||||
driver_array: Vec<DriverPackage>,
|
||||
window: &adw::ApplicationWindow,
|
||||
list_row_size_group: >k::SizeGroup,
|
||||
rows_size_group: >k::SizeGroup,
|
||||
) {
|
||||
let main_box = gtk::Box::builder()
|
||||
.margin_top(20)
|
||||
@ -295,6 +306,8 @@ fn get_drivers(
|
||||
.build();
|
||||
drivers_list_row.add_css_class("boxed-list");
|
||||
|
||||
list_row_size_group.add_widget(&drivers_list_row);
|
||||
|
||||
main_box.append(&drivers_list_row);
|
||||
|
||||
for driver in group.iter() {
|
||||
@ -305,6 +318,26 @@ fn get_drivers(
|
||||
let log_status_loop_sender: async_channel::Sender<bool> =
|
||||
log_status_loop_sender.clone();
|
||||
|
||||
let (driver_status_loop_sender, driver_status_loop_receiver) = async_channel::unbounded();
|
||||
let driver_status_loop_sender: async_channel::Sender<bool> =
|
||||
driver_status_loop_sender.clone();
|
||||
|
||||
let driver_package_ind2 = driver.driver.to_owned();
|
||||
let driver_package_removeble = driver.removeble.to_owned();
|
||||
|
||||
gio::spawn_blocking(move || loop {
|
||||
thread::sleep(Duration::from_secs(5));
|
||||
let command_installed_status = Command::new("dpkg")
|
||||
.args(["-s", &driver_package_ind2])
|
||||
.output()
|
||||
.unwrap();
|
||||
if command_installed_status.status.success() {
|
||||
driver_status_loop_sender.send_blocking(true).expect("channel needs to be open")
|
||||
} else {
|
||||
driver_status_loop_sender.send_blocking(false).expect("channel needs to be open")
|
||||
}
|
||||
});
|
||||
|
||||
let driver_package_ind = driver.driver.to_owned();
|
||||
let driver_expander_row = adw::ExpanderRow::new();
|
||||
let driver_icon = gtk::Image::builder()
|
||||
@ -353,20 +386,23 @@ fn get_drivers(
|
||||
driver_action_box.append(&driver_install_button);
|
||||
driver_content_row.add_suffix(&driver_action_box);
|
||||
driver_expander_row.add_row(&driver_content_row);
|
||||
rows_size_group.add_widget(&driver_action_box);
|
||||
//
|
||||
let command_installed_status = Command::new("dpkg")
|
||||
.args(["-s", &driver.clone().driver])
|
||||
.output()
|
||||
.unwrap();
|
||||
if command_installed_status.status.success() {
|
||||
let driver_status_loop_context = MainContext::default();
|
||||
// The main loop executes the asynchronous block
|
||||
driver_status_loop_context.spawn_local(clone!(@weak driver_remove_button, @weak driver_install_button, @strong driver_status_loop_receiver => async move {
|
||||
while let Ok(driver_status_state) = driver_status_loop_receiver.recv().await {
|
||||
if driver_status_state == true {
|
||||
driver_install_button.set_sensitive(false);
|
||||
if driver.clone().removeble == true {
|
||||
if driver_package_removeble == true {
|
||||
driver_remove_button.set_sensitive(true);
|
||||
}
|
||||
} else {
|
||||
driver_remove_button.set_sensitive(false);
|
||||
driver_install_button.set_sensitive(true);
|
||||
}
|
||||
}
|
||||
}));
|
||||
//
|
||||
let driver_install_log_terminal_buffer = gtk::TextBuffer::builder().build();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user