diff --git a/Cargo.lock b/Cargo.lock index aa1162e..e82e03c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -612,7 +612,7 @@ dependencies = [ [[package]] name = "rwpspread" -version = "0.2.2-1" +version = "0.2.3-1" dependencies = [ "clap", "clap_complete", diff --git a/Cargo.toml b/Cargo.toml index e7a9bc4..081831a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rwpspread" -version = "0.2.2-1" +version = "0.2.3-1" edition = "2021" authors = ["0xk1f0"] description = "Multi-Monitor Wallpaper Utility" diff --git a/man/rwpspread.1 b/man/rwpspread.1 index ed0d009..f2cb5b5 100644 --- a/man/rwpspread.1 +++ b/man/rwpspread.1 @@ -1,6 +1,6 @@ .ie \n(.g .ds Aq \(aq .el .ds Aq ' -.TH rwpspread 1 "rwpspread 0.2.2-1" +.TH rwpspread 1 "rwpspread 0.2.3-1" .SH NAME rwpspread \- Multi\-Monitor Wallpaper Utility .SH SYNOPSIS @@ -50,4 +50,4 @@ Print help \fB\-V\fR, \fB\-\-version\fR Print version .SH VERSION -v0.2.2\-1 +v0.2.3\-1 diff --git a/src/integrations/helpers.rs b/src/integrations/helpers.rs index 2606b55..8d47062 100644 --- a/src/integrations/helpers.rs +++ b/src/integrations/helpers.rs @@ -1,4 +1,4 @@ -use std::process; +use std::{process,env}; // force restart a program pub fn force_restart(program: &str, arguments: Vec<&str>) -> Result<(), String> { @@ -52,15 +52,15 @@ pub fn soft_restart(program: &str, arguments: Vec<&str>) -> Result<(), String> { Ok(()) } -// check if a program is available using which +// check if a program is available pub fn is_installed(program: &str) -> bool { - match process::Command::new("which") - .arg(program) - .stdout(process::Stdio::null()) - .stderr(process::Stdio::null()) - .status() - { - Ok(status) => status.success(), - Err(_) => false, + if let Some(path) = env::var_os("PATH") { + for path in env::split_paths(&path) { + let full_path = path.join(program); + if full_path.exists() { + return true; + } + } } + false }