👷 use msg dialog to inform user; use Exec::cmd
This commit is contained in:
parent
73d16a5f7b
commit
0c5f63eb3a
23
src/pages.rs
23
src/pages.rs
|
@ -66,16 +66,25 @@ fn create_fixes_section() -> gtk::Box {
|
||||||
// Spawn child process in separate thread.
|
// Spawn child process in separate thread.
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
// check if you have orphans packages.
|
// check if you have orphans packages.
|
||||||
let status = std::process::Command::new("pacman")
|
let mut orphan_pkgs = Exec::cmd("/sbin/pacman")
|
||||||
.arg("-Qtdq")
|
.arg("-Qtdq")
|
||||||
.status()
|
.stdout(Redirection::Pipe)
|
||||||
.expect("Found orphans packages");
|
.capture()
|
||||||
|
.unwrap()
|
||||||
|
.stdout_str();
|
||||||
|
|
||||||
if status.success() {
|
// get list of packages separated by space,
|
||||||
let _ = utils::run_cmd_terminal(String::from("pacman -Rns $(pacman -Qtdq)"), true);
|
// and check if it's empty or not.
|
||||||
} else {
|
orphan_pkgs = orphan_pkgs.replace('\n', " ");
|
||||||
let _ = utils::run_cmd_terminal(String::from("echo 'Not orphans packages'"), false);
|
if orphan_pkgs.is_empty() {
|
||||||
|
let dialog = gtk::MessageDialog::builder()
|
||||||
|
.message_type(gtk::MessageType::Info)
|
||||||
|
.text("No orphan packages found!")
|
||||||
|
.build();
|
||||||
|
dialog.show();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
let _ = utils::run_cmd_terminal(format!("pacman -Rns {orphan_pkgs}"), true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
clear_pkgcache_btn.connect_clicked(on_clear_pkgcache_btn_clicked);
|
clear_pkgcache_btn.connect_clicked(on_clear_pkgcache_btn_clicked);
|
||||||
|
|
Loading…
Reference in New Issue