mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-26 11:56:25 -08:00
fix(desktop): bundle appindicator for CEF tray and guard when missing (#1139)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes # #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
This commit is contained in:
4 files changed
+57
-2
No files matched your search
+30
-2
@@ -38,6 +38,30 @@ stage_runtime() {
|
||||
bash scripts/cef-copy-libs.sh release "$dest"
|
||||
}
|
||||
|
||||
# Bundle the system-tray libraries (Tauri's linuxdeploy path normally does this,
|
||||
# which the CEF build bypasses). Bundle libayatana-appindicator3 plus its
|
||||
# ayatana/dbusmenu/indicator dependency closure; host libs (gtk, glib, X11, …)
|
||||
# are left to the system, matching linuxdeploy-plugin-appindicator.
|
||||
stage_appindicator() {
|
||||
local dest="$1" main dep
|
||||
mkdir -p "$dest"
|
||||
# awk reads to EOF (no early exit) so ldconfig never gets SIGPIPE under pipefail.
|
||||
main="$(ldconfig -p 2>/dev/null | awk '$1=="libayatana-appindicator3.so.1"{v=$NF} END{print v}')"
|
||||
[ -n "$main" ] || main="$(find /usr/lib /usr/lib64 /lib -name libayatana-appindicator3.so.1 2>/dev/null | sort | tail -n1)"
|
||||
if [ -z "$main" ] || [ ! -e "$main" ]; then
|
||||
echo "warning: libayatana-appindicator3.so.1 not found; tray disabled in the AppImage" >&2
|
||||
return 0
|
||||
fi
|
||||
{
|
||||
echo "$main"
|
||||
ldd "$main" 2>/dev/null | awk '/=>/ {print $3}' | grep -iE 'ayatana|dbusmenu|indicator|ido' || true
|
||||
} | sort -u | while read -r dep; do
|
||||
if [ -e "$dep" ]; then
|
||||
cp -Lf "$dep" "$dest/$(basename "$dep")"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
write_desktop() {
|
||||
cat > "$1" <<'EOF'
|
||||
[Desktop Entry]
|
||||
@@ -73,13 +97,15 @@ EOF
|
||||
# Stable-named deps only; version-suffixed names break install across releases.
|
||||
DEB_DEPS=(--depends libwebkit2gtk-4.1-0 --depends libgtk-3-0
|
||||
--depends libnss3 --depends libnspr4 --depends libgbm1
|
||||
--depends libdrm2 --depends libxkbcommon0 --depends xdg-utils)
|
||||
--depends libdrm2 --depends libxkbcommon0 --depends xdg-utils
|
||||
--depends libayatana-appindicator3-1)
|
||||
(cd "$OUT/deb" && fpm "${COMMON[@]}" -v "$DEB_VERSION" --iteration 1 \
|
||||
-t deb -a amd64 "${DEB_DEPS[@]}" -C "$PKGROOT" .)
|
||||
|
||||
RPM_DEPS=(--depends webkit2gtk4.1 --depends gtk3 --depends nss
|
||||
--depends nspr --depends mesa-libgbm --depends libdrm
|
||||
--depends libxkbcommon --depends xdg-utils)
|
||||
--depends libxkbcommon --depends xdg-utils
|
||||
--depends 'libayatana-appindicator3.so.1()(64bit)')
|
||||
(cd "$OUT/rpm" && fpm "${COMMON[@]}" -v "$RPM_VERSION" --iteration "$RPM_ITERATION" \
|
||||
-t rpm -a x86_64 "${RPM_DEPS[@]}" -C "$PKGROOT" .)
|
||||
else
|
||||
@@ -88,6 +114,7 @@ fi
|
||||
|
||||
APPDIR="$WORK/Sable.AppDir"
|
||||
stage_runtime "$APPDIR/usr/bin"
|
||||
stage_appindicator "$APPDIR/usr/bin"
|
||||
# nosuid AppImage mount: drop setuid chrome-sandbox, use the namespace sandbox.
|
||||
rm -f "$APPDIR/usr/bin/chrome-sandbox"
|
||||
write_desktop "$APPDIR/sable.desktop"
|
||||
@@ -95,6 +122,7 @@ cp src-tauri/icons/128x128.png "$APPDIR/sable.png"
|
||||
cat > "$APPDIR/AppRun" <<'EOF'
|
||||
#!/bin/sh
|
||||
HERE="$(dirname "$(readlink -f "$0")")"
|
||||
export LD_LIBRARY_PATH="$HERE/usr/bin${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
exec "$HERE/usr/bin/sable" "$@"
|
||||
EOF
|
||||
chmod 755 "$APPDIR/AppRun"
|
||||
|
||||
Generated
+1
@@ -5222,6 +5222,7 @@ dependencies = [
|
||||
"enigo",
|
||||
"gtk",
|
||||
"jni 0.21.1",
|
||||
"libloading 0.8.9",
|
||||
"log",
|
||||
"objc2",
|
||||
"percent-encoding",
|
||||
|
||||
@@ -85,6 +85,7 @@ gtk = "0.18"
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
tauri-runtime-cef = { git = "https://github.com/byeongsu-hong/tauri-runtime-cef", rev = "c215d6e52dd507956d9b8cc868906d690dc477c2", optional = true }
|
||||
cef = { version = "=148.0.0", optional = true }
|
||||
libloading = "0.8"
|
||||
|
||||
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
|
||||
tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugin-notifications.git", rev = "95c1574cf4c2be0f3e7c1d7b8102b2f7b59bcb68", features = [
|
||||
|
||||
@@ -246,7 +246,32 @@ fn configure_tray_icon_interactions(
|
||||
builder
|
||||
}
|
||||
|
||||
// libappindicator panics (rather than returning an error) when the appindicator
|
||||
// library is missing, which would crash the whole app. Probe for it first and
|
||||
// treat its absence as a recoverable tray failure.
|
||||
#[cfg(target_os = "linux")]
|
||||
fn appindicator_available() -> bool {
|
||||
const CANDIDATES: [&str; 4] = [
|
||||
"libayatana-appindicator3.so.1",
|
||||
"libappindicator3.so.1",
|
||||
"libayatana-appindicator3.so",
|
||||
"libappindicator3.so",
|
||||
];
|
||||
CANDIDATES
|
||||
.iter()
|
||||
.any(|name| unsafe { libloading::Library::new(name) }.is_ok())
|
||||
}
|
||||
|
||||
pub fn create_system_tray(app: &AppHandle<crate::BrowserEngine>) -> tauri::Result<()> {
|
||||
#[cfg(target_os = "linux")]
|
||||
if !appindicator_available() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
"appindicator library not found; skipping system tray",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
||||
let show_item = MenuItem::with_id(app, TRAY_MENU_SHOW_ID, "Show", true, None::<&str>)?;
|
||||
let quit_item = MenuItem::with_id(app, TRAY_MENU_QUIT_ID, "Quit", true, None::<&str>)?;
|
||||
let tray_menu = Menu::with_items(app, &[&show_item, &quit_item])?;
|
||||
|
||||
Reference in new issue
Block a user