[yabridgectl] Check for libdbus-1.so

Instead of checking for notify-send.
This commit is contained in:
Robbert van der Helm
2022-10-28 19:44:19 +02:00
parent af0f38c00b
commit b9bf67754d
4 changed files with 24 additions and 10 deletions
+3 -2
View File
@@ -833,8 +833,9 @@ 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
// Yabridge uses D-Bus notifications to relay important information when something's very wrong,
// so we'll check whether `libdbus-1.so` is available (even though it would be very odd if it
// isn't)
verify_external_dependencies()?;
Ok(())
+9 -8
View File
@@ -29,7 +29,6 @@ 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};
@@ -465,18 +464,20 @@ 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.
/// Check whether yabridge's (optional) external dependencies are installed. Right now this only
/// checks for libdbus, 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() {
let libdbus_name = libloading::library_filename("dbus-1");
let libdbus_available = unsafe { libloading::Library::new(&libdbus_name) }.is_ok();
if !libdbus_available {
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(),
you will also not receive any notifcations when something is wrong. D-Bus should \
already be installed on the system, so if you're seeing this warning then \
something is probably very wrong.",
libdbus_name.to_str().unwrap().bright_white(),
))
);
}