[yabridgectl] Check notify-send install status

Since it's used for yabridge's desktop notifications.
This commit is contained in:
Robbert van der Helm
2022-05-24 13:40:58 +02:00
parent 480755f8f0
commit 78858b98f7
3 changed files with 31 additions and 1 deletions
+20
View File
@@ -29,6 +29,7 @@ use std::os::unix::process::CommandExt;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use textwrap::Wrapper;
use which::which;
use crate::config::{self, Config, KnownConfig, YABRIDGE_HOST_32_EXE_NAME, YABRIDGE_HOST_EXE_NAME};
use crate::files::{LibArchitecture, NativeFile};
@@ -463,6 +464,25 @@ pub fn verify_wine_setup(config: &mut Config) -> Result<()> {
Ok(())
}
/// Check whether `notify-send` is installed, as this is used to relay important information when
/// something's very wrong.
pub fn verify_external_dependencies() -> Result<()> {
if which("notify-send").is_err() {
eprintln!(
"\n{}",
wrap(&format!(
"Warning: Could not find '{}'. This will not prevent yabridge from working, but \
you will also not receive any notifcations when something is wrong. It is \
usually part of the libnotify package, but your distro might have moved it into a \
separate libnotify-tools package.",
"notify-send".bright_white(),
))
);
}
Ok(())
}
/// Wrap a long paragraph of text to terminal width, or 80 characters if the width of the terminal
/// can't be determined. Everything after the first line gets indented with four spaces.
pub fn wrap(text: &str) -> String {