fix: libappindicator crashing and bundling on linux (#893)
This commit is contained in:
parent
06fa7739b3
commit
9b6f872a8d
4 changed files with 22 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -4949,6 +4949,7 @@ dependencies = [
|
|||
"freya-testing",
|
||||
"futures-util",
|
||||
"image",
|
||||
"libloading 0.8.9",
|
||||
"mimalloc",
|
||||
"notify",
|
||||
"oneclient_auth",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ freya-testing.workspace = true
|
|||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
mimalloc = "=0.1.52"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
libloading = "=0.8.9"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows = { version = "=0.62.2", features = [
|
||||
"Win32_Foundation",
|
||||
|
|
@ -153,6 +156,7 @@ desktop-template = "distribution/linux/org.polyfrost.oneclient.template"
|
|||
|
||||
[package.metadata.packager.appimage]
|
||||
# desktop entry generated from the deb template above via the linux config
|
||||
libs = ["libayatana-appindicator3.so.1"]
|
||||
|
||||
[package.metadata.generate-rpm]
|
||||
auto-req = "builtin"
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ fn main() {
|
|||
.with_plugin(freya::metrics::MetricsPlugin::default())
|
||||
.with_default_font(theme::DEFAULT_FONT);
|
||||
|
||||
if show_tray_icon {
|
||||
if show_tray_icon && platform::tray::available() {
|
||||
launch_config = launch_config.with_tray(platform::tray::build, platform::tray::handle);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,6 +181,22 @@ pub mod tray {
|
|||
});
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn available() -> bool {
|
||||
let loaded = ["libayatana-appindicator3.so.1", "libappindicator3.so.1"]
|
||||
.into_iter()
|
||||
.any(|name| unsafe { libloading::Library::new(name) }.is_ok());
|
||||
if !loaded {
|
||||
tracing::warn!("tray icon disabled, appindicator failed to load");
|
||||
}
|
||||
loaded
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
pub fn available() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn build() -> TrayIcon {
|
||||
let live_on_linux = cfg!(target_os = "linux");
|
||||
let stop = MenuItem::with_id(STOP_ID, "Stop game", live_on_linux, None);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue