Skip to content

Commit

Permalink
check if backends are installed using pure rust
Browse files Browse the repository at this point in the history
  • Loading branch information
0xk1f0 committed Mar 7, 2024
1 parent 434f28f commit 0bd233a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions man/rwpspread.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -50,4 +50,4 @@ Print help
\fB\-V\fR, \fB\-\-version\fR
Print version
.SH VERSION
v0.2.2\-1
v0.2.3\-1
20 changes: 10 additions & 10 deletions src/integrations/helpers.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down Expand Up @@ -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
}

0 comments on commit 0bd233a

Please sign in to comment.