[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
+11
View File
@@ -311,6 +311,16 @@ version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "libloading"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "linux-raw-sys"
version = "0.0.46"
@@ -832,6 +842,7 @@ dependencies = [
"colored",
"goblin",
"is_executable",
"libloading",
"promptly",
"rayon",
"reflink",
+1
View File
@@ -15,6 +15,7 @@ clap = { version = "3.0.6", features = ["cargo", "env", "wrap_help"] }
colored = "2.0.0"
is_executable = "1.0.1"
goblin = { version = "0.6", default_features = false, features = ["std", "pe32", "pe64"] }
libloading = "0.7.3"
promptly = "0.3.1"
# Version 0.1.3 from crates.io assumes a 64-bit toolchain
reflink = { git = "https://github.com/nicokoch/reflink", rev = "e8d93b465f5d9ad340cd052b64bbc77b8ee107e2" }
+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(),
))
);
}