From 3cc326e8dc721dda045d18a2ce67e9d573e5c2b4 Mon Sep 17 00:00:00 2001 From: Alexandr Bogomiakov Date: Thu, 24 Jul 2025 03:54:13 +0300 Subject: [PATCH] Fixed tray icon on linux --- .github/workflows/main.yml | 2 +- Cargo.lock | 28 ++++++++++++++++++++-------- Cargo.toml | 2 +- README.MD | 1 + src/gui/tray/app.rs | 31 +++++++++++++++++++++++-------- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5bab7f2..06d93be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,7 +76,7 @@ jobs: if: matrix.os == 'ubuntu-latest' && matrix.build_type == 'dynamic' && matrix.build_target == 'x86_64-unknown-linux-gnu' run: | sudo apt-get update - sudo apt-get install -y libssl-dev pkg-config libgtk-3-dev libglib2.0-dev libcairo2-dev libpango1.0-dev libatk1.0-dev libgdk-pixbuf2.0-dev libxdo-dev + sudo apt-get install -y libssl-dev pkg-config libgtk-3-dev libglib2.0-dev libcairo2-dev libpango1.0-dev libatk1.0-dev libgdk-pixbuf2.0-dev libxdo-dev libayatana-appindicator3-dev - name: Install Linux ARM64 cross-compilation dependencies if: matrix.os == 'ubuntu-latest' && matrix.build_type == 'dynamic' && matrix.build_target == 'aarch64-unknown-linux-gnu' diff --git a/Cargo.lock b/Cargo.lock index 8857cbc..5c4e136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2687,6 +2687,7 @@ dependencies = [ "log", "notify", "notify-debouncer-mini", + "openssl", "regex", "reqwest", "rust-embed", @@ -2993,21 +2994,22 @@ dependencies = [ [[package]] name = "muda" -version = "0.15.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdae9c00e61cc0579bcac625e8ad22104c60548a025bfc972dc83868a28e1484" +checksum = "58b89bf91c19bf036347f1ab85a81c560f08c0667c8601bece664d860a600988" dependencies = [ "crossbeam-channel", "dpi", "gtk", "keyboard-types", "libxdo", - "objc2 0.5.2", - "objc2-app-kit 0.2.2", - "objc2-foundation 0.2.2", + "objc2 0.6.1", + "objc2-app-kit 0.3.1", + "objc2-core-foundation", + "objc2-foundation 0.3.1", "once_cell", "png", - "thiserror 1.0.69", + "thiserror 2.0.12", "windows-sys 0.59.0", ] @@ -3512,6 +3514,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.5.1+3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735230c832b28c000e3bc117119e6466a663ec73506bc0a9907ea4187508e42a" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.102" @@ -3520,6 +3531,7 @@ checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -4895,9 +4907,9 @@ dependencies = [ [[package]] name = "tray-icon" -version = "0.19.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadd75f5002e2513eaa19b2365f533090cc3e93abd38788452d9ea85cff7b48a" +checksum = "2da75ec677957aa21f6e0b361df0daab972f13a5bee3606de0638fd4ee1c666a" dependencies = [ "crossbeam-channel", "dirs 6.0.0", diff --git a/Cargo.toml b/Cargo.toml index fb27ba1..0dee1fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ trust-dns-resolver = "0.23" futures = "0.3" hostname = "0.3" rust-embed = "8.0" -tray-icon = { version = "0.19", optional = true } +tray-icon = { version = "0.21", optional = true } notify = { version = "6.1", optional = true } notify-debouncer-mini = { version = "0.4", optional = true } dirs = "5.0" diff --git a/README.MD b/README.MD index 0571ff8..27c562e 100644 --- a/README.MD +++ b/README.MD @@ -98,6 +98,7 @@ Download the latest binary from the [Releases](https://github.com/house-of-vanit ### System Dependencies For GUI features on Linux: ```bash +# Build dependencies sudo apt-get install libgtk-3-dev libglib2.0-dev libcairo2-dev libpango1.0-dev libatk1.0-dev libgdk-pixbuf2.0-dev ``` diff --git a/src/gui/tray/app.rs b/src/gui/tray/app.rs index 72736fa..735528e 100644 --- a/src/gui/tray/app.rs +++ b/src/gui/tray/app.rs @@ -225,16 +225,31 @@ impl ApplicationHandler for TrayApplication { info!("Creating tray icon"); let settings = self.settings.lock().unwrap(); let sync_status = self.sync_status.lock().unwrap(); - let (tray_icon, menu_ids) = create_tray_icon(&settings, &sync_status); - drop(settings); - drop(sync_status); + + match std::panic::catch_unwind(|| create_tray_icon(&settings, &sync_status)) { + Ok((tray_icon, menu_ids)) => { + drop(settings); + drop(sync_status); - self.tray_icon = Some(tray_icon); - self.menu_ids = Some(menu_ids); + self.tray_icon = Some(tray_icon); + self.menu_ids = Some(menu_ids); - self.setup_file_watcher(); - self.start_auto_sync(); - info!("KHM tray application ready"); + self.setup_file_watcher(); + self.start_auto_sync(); + info!("KHM tray application ready"); + } + Err(_) => { + drop(settings); + drop(sync_status); + error!("Failed to create tray icon. This usually means the required system libraries are not installed."); + error!("On Ubuntu/Debian, try installing: sudo apt install libayatana-appindicator3-1"); + error!("Alternative: sudo apt install libappindicator3-1"); + error!("KHM will continue running but without system tray integration."); + error!("You can still use --settings-ui to access the settings window."); + + // Don't exit, just continue without tray icon + } + } } }