🚧 don't launch pamac with terminal
This commit is contained in:
parent
a7abc62247
commit
75b89db706
|
@ -1,5 +1,7 @@
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
use crate::utils::PacmanWrapper;
|
use crate::utils::PacmanWrapper;
|
||||||
|
use std::path::Path;
|
||||||
|
use subprocess::Exec;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -78,25 +80,32 @@ impl AlpmHelper {
|
||||||
if pkg_list.is_empty() {
|
if pkg_list.is_empty() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let (cmd, escalate) = match install {
|
|
||||||
true => match utils::get_pacman_wrapper_gui() {
|
|
||||||
PacmanWrapper::Pamac => ("pamac-installer", false),
|
|
||||||
PacmanWrapper::Pak => ("pak -Sy", false),
|
|
||||||
PacmanWrapper::Yay => ("yay -Sy", false),
|
|
||||||
PacmanWrapper::Paru => ("paru -Sy", false),
|
|
||||||
_ => ("pacman -Sy", true),
|
|
||||||
},
|
|
||||||
false => match utils::get_pacman_wrapper_gui() {
|
|
||||||
PacmanWrapper::Pamac => ("pamac-installer --remove", false),
|
|
||||||
PacmanWrapper::Pak => ("pak -R", false),
|
|
||||||
PacmanWrapper::Yay => ("yay -R", false),
|
|
||||||
PacmanWrapper::Paru => ("paru -R", false),
|
|
||||||
_ => ("pacman -R", true),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
let packages_do = pkg_list.iter().map(|s| s.to_string() + " ").collect::<String>();
|
let packages_do = pkg_list.iter().map(|s| s.to_string() + " ").collect::<String>();
|
||||||
let _ = utils::run_cmd_terminal(format!("{} {}", cmd, packages_do), escalate);
|
if Path::new("/sbin/pamac-installer").exists() {
|
||||||
|
let arg = match install {
|
||||||
|
false => "--remove",
|
||||||
|
_ => "",
|
||||||
|
};
|
||||||
|
Exec::shell(format!("pamac-installer {} {}", arg, packages_do)).join().unwrap();
|
||||||
|
} else {
|
||||||
|
let (cmd, escalate) = match install {
|
||||||
|
true => match utils::get_pacman_wrapper() {
|
||||||
|
PacmanWrapper::Pak => ("pak -Sy", false),
|
||||||
|
PacmanWrapper::Yay => ("yay -Sy", false),
|
||||||
|
PacmanWrapper::Paru => ("paru -Sy", false),
|
||||||
|
_ => ("pacman -Sy", true),
|
||||||
|
},
|
||||||
|
false => match utils::get_pacman_wrapper() {
|
||||||
|
PacmanWrapper::Pak => ("pak -R", false),
|
||||||
|
PacmanWrapper::Yay => ("yay -R", false),
|
||||||
|
PacmanWrapper::Paru => ("paru -R", false),
|
||||||
|
_ => ("pacman -R", true),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let _ = utils::run_cmd_terminal(format!("{} {}", cmd, packages_do), escalate);
|
||||||
|
}
|
||||||
|
|
||||||
match install {
|
match install {
|
||||||
true => self.app_installed(&pkg_list[0]),
|
true => self.app_installed(&pkg_list[0]),
|
||||||
false => !self.app_installed(&pkg_list[0]),
|
false => !self.app_installed(&pkg_list[0]),
|
||||||
|
|
16
src/utils.rs
16
src/utils.rs
|
@ -10,7 +10,6 @@ pub enum PacmanWrapper {
|
||||||
Pak,
|
Pak,
|
||||||
Yay,
|
Yay,
|
||||||
Paru,
|
Paru,
|
||||||
Pamac,
|
|
||||||
Pacman,
|
Pacman,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,21 +105,6 @@ pub fn get_pacman_wrapper() -> PacmanWrapper {
|
||||||
PacmanWrapper::Pacman
|
PacmanWrapper::Pacman
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_pacman_wrapper_gui() -> PacmanWrapper {
|
|
||||||
if Path::new("/sbin/pamac-installer").exists() {
|
|
||||||
return PacmanWrapper::Pamac;
|
|
||||||
} else if Path::new("/sbin/pak").exists() {
|
|
||||||
return PacmanWrapper::Pak;
|
|
||||||
} else if Path::new("/sbin/yay").exists() {
|
|
||||||
return PacmanWrapper::Yay;
|
|
||||||
} else if Path::new("/sbin/paru").exists() {
|
|
||||||
return PacmanWrapper::Paru;
|
|
||||||
}
|
|
||||||
|
|
||||||
PacmanWrapper::Pacman
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in New Issue