[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
+5 -1
View File
@@ -28,7 +28,7 @@ use crate::config::{
};
use crate::files::{self, NativeFile, Plugin, Vst2Plugin};
use crate::util::{self, get_file_type};
use crate::util::{verify_path_setup, verify_wine_setup};
use crate::util::{verify_external_dependencies, verify_path_setup, verify_wine_setup};
use crate::vst3_moduleinfo::ModuleInfo;
pub mod blacklist;
@@ -682,6 +682,10 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
// This check is only performed once per combination of Wine and yabridge versions
verify_wine_setup(config)?;
// Yabridge uses notify-send to relay important information when something's very wrong, so
// we'll check whether this is installed
verify_external_dependencies()?;
Ok(())
}
+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 {