This commit is contained in:
nnduc
2026-09-01 14:49:06 +07:00
parent e4591cd969
commit e4396ecdbd
Executable
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
set -euo pipefail
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="/opt/betterbird"
echo "Installing Betterbird from $SRC_DIR to $INSTALL_DIR ..."
sudo mkdir -p "$(dirname "$INSTALL_DIR")"
sudo cp -r "$SRC_DIR" "$INSTALL_DIR"
sudo ln -sf "$INSTALL_DIR/betterbird" /usr/local/bin/betterbird
sudo tee /usr/share/applications/betterbird.desktop > /dev/null <<EOF
[Desktop Entry]
Name=Betterbird
Comment=Betterbird Mail Client
Exec=$INSTALL_DIR/betterbird %u
Icon=$INSTALL_DIR/chrome/icons/default/default256.png
Terminal=false
Type=Application
Categories=Network;Email;
MimeType=x-scheme-handler/mailto;
EOF
sudo update-desktop-database /usr/share/applications 2>/dev/null || true
# --- i3 + polybar tray icon fix ---
#
# Betterbird gates its tray-icon feature behind mail.minimizeToTray.supportedDesktops,
# which defaults to "kde,gnome,pop:gnome,xfce,mate" and does not include i3. On top of
# that, within the whitelist it defaults to a StatusNotifierItem (SNI/AppIndicator) tray
# icon everywhere except "mate" -- but polybar's tray module only speaks the legacy
# XEmbed protocol, and this session has no StatusNotifierWatcher, so an SNI icon has
# nowhere to register.
#
# Fix: add "i3" to both prefs via user.js, which Betterbird force-applies at every
# startup (unlike prefs.js, which Betterbird overwrites from its own in-memory state
# and would silently drop a plain text edit).
THUNDERBIRD_CONFIG_DIR="$HOME/.config/thunderbird"
BB_PROFILE_DIR="$(find "$THUNDERBIRD_CONFIG_DIR" -maxdepth 1 -iname "*.default-default" -type d 2>/dev/null | head -1)"
if [ -z "$BB_PROFILE_DIR" ]; then
BB_PROFILE_DIR="$(find "$THUNDERBIRD_CONFIG_DIR" -maxdepth 1 -iname "*.default*" -type d 2>/dev/null | head -1)"
fi
if [ -n "$BB_PROFILE_DIR" ]; then
echo "Applying i3/polybar tray icon fix to profile: $BB_PROFILE_DIR"
USER_JS="$BB_PROFILE_DIR/user.js"
touch "$USER_JS"
if ! grep -q "mail.minimizeToTray.supportedDesktops" "$USER_JS" 2>/dev/null; then
cat >> "$USER_JS" <<'EOF'
// Betterbird gates its whole tray-icon feature behind a whitelist of
// XDG_CURRENT_DESKTOP values; add i3 so the feature isn't disabled outright.
user_pref("mail.minimizeToTray.supportedDesktops", "kde,gnome,pop:gnome,xfce,mate,i3");
// Within the whitelist, Betterbird still defaults to a StatusNotifierItem
// (SNI/AppIndicator) tray icon everywhere except "mate". polybar's tray
// module only speaks the legacy XEmbed protocol, so force the legacy icon
// for i3 too.
user_pref("mail.systemTrayNoSniSupport", "mate,i3");
EOF
else
echo "Tray icon fix already present in $USER_JS, skipping."
fi
else
echo "No Betterbird profile found yet -- launch Betterbird once, then re-run this script to apply the i3/polybar tray icon fix."
fi
echo "Done. Launch with 'betterbird' or from your application menu."